def initComponents(self): self.setLayout(GridBagLayout()) gc = GridBagConstraints() gc.weightx = 1 gc.weighty = 1 # First Row gc.gridy = 0 gc.weightx = 1 gc.weighty = 0.1 gc.gridx = 0 gc.fill = GridBagConstraints.NONE gc.anchor = GridBagConstraints.LINE_END gc.insets = Insets(0, 0, 0, 5) self.add(self.usernameLabel, gc) gc.gridx = 1 gc.anchor = GridBagConstraints.LINE_START gc.insets = Insets(0, 0, 0, 0) self.add(self.usernameField, gc) # Second Row gc.gridy += 1 gc.weightx = 1 gc.weighty = 0.1 gc.gridx = 0 gc.anchor = GridBagConstraints.LINE_END gc.insets = Insets(0, 0, 0, 5) self.add(self.superPassLabel, gc) gc.gridx = 1 gc.anchor = GridBagConstraints.LINE_START gc.insets = Insets(0, 0, 0, 0) self.add(self.superPassField, gc) #Next Row gc.gridy += 1 gc.weightx = 1 gc.weighty = 2.0 gc.gridx = 1 gc.anchor = GridBagConstraints.FIRST_LINE_START self.add(self.deleteAdminBtn, gc) innerBorder = BorderFactory.createTitledBorder('Delete Admin') outerBorder = BorderFactory.createEmptyBorder(5, 5, 5, 5) self.setBorder( BorderFactory.createCompoundBorder(outerBorder, innerBorder))
def create_button(self, table_name, opt, panel, mode=''): ContentData.file_path = '/' button = swing.JButton(table_name) button.setMargin(Insets(0, 0, 0, 0)) button.addActionListener( AddAction(self, opt['type'], opt['funcopt'], mode)) return button
def actionPerformed(self, e): bugs_tab = self.tabbed_panes[self.key].getComponentAt(1) tab_count = str(bugs_tab.getTabCount()) request_tab = self.view.set_request_tab_pane(self.request_response) response_tab = self.view.set_response_tab_pane(self.request_response) bugs_tabbed_pane = self.view.set_bugs_tabbed_pane(request_tab, response_tab) bugs_tab.add(tab_count, bugs_tabbed_pane) index = bugs_tab.indexOfTab(tab_count) panel_tab = JPanel(GridBagLayout()) panel_tab.setOpaque(False) label_title = JLabel(tab_count) # Create a button to close tab button_close = JButton("x") button_close.setToolTipText("Close tab") button_close.setOpaque(False); button_close.setContentAreaFilled(False); button_close.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)) button_close.setPreferredSize(Dimension(18, 18)) button_close.setMargin(Insets(0, 0, 0, 0)) button_close.setForeground(Color.gray) panel_tab.add(label_title) panel_tab.add(button_close) bugs_tab.setTabComponentAt(index, panel_tab) button_close.addMouseListener(CloseTab(button_close, bugs_tab))
def createEditorComponent(self, properties): p = JPanel(GridBagLayout()) p.setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3)) gbc = GridBagConstraints() gbc.gridx = 0 gbc.gridy = 0 gbc.weightx = 0.0 gbc.weighty = 0.0 gbc.fill = GridBagConstraints.HORIZONTAL gbc.insets = Insets(3, 3, 3, 3) p.add(JLabel("Prompt:"), gbc) gbc.gridx = 1 editor = NodePropertiesDialog.createTextArea(properties, self.PROMPT) p.add(editor, gbc) gbc.gridx, gbc.gridy = 1, 0 p.add( NodePropertiesDialog.createCheckBox(properties, self.WAIT, "Wait until done"), gbc) jtp = JTabbedPane() jtp.addTab("Output", p) return jtp
def tag_1_2(self, c): # 创建 检查框 self.url_repeated_box = JCheckBox( u'是否启动url重复验证', ForwardRequestsConfig.URL_REPEATED_VERIFY) self.setFontBold(self.url_repeated_box) self.url_repeated_box.setForeground(Color(0, 0, 153)) c.insets = Insets(5, 5, 5, 5) c.gridx = 0 c.gridy = 3 self.settings.add(self.url_repeated_box, c) # 在窗口添加一句话 url_repeated_box_lbl = JLabel(u'打勾-开启验证, 不打勾-关闭验证') self.setFontItalic(url_repeated_box_lbl) c.insets = Insets(5, 5, 5, 5) c.gridx = 0 c.gridy = 4 self.settings.add(url_repeated_box_lbl, c)
def tag_2(self, c): # 创建 检查框 self.is_scan_post_start_box = JCheckBox(u'是否扫描POST类型的参数(推荐打勾)', XssConfig.IS_SCAN_POST_START) self.setFontBold(self.is_scan_post_start_box) self.is_scan_post_start_box.setForeground(Color(0, 0, 153)) c.insets = Insets(5, 5, 5, 5) c.gridx = 0 c.gridy = 3 self.scan_type_settings.add(self.is_scan_post_start_box, c) # 在窗口添加一句话 is_scan_post_start_box_lbl = JLabel(u'打勾-启动, 不打勾-关闭') self.setFontItalic(is_scan_post_start_box_lbl) c.insets = Insets(5, 5, 5, 5) c.gridx = 0 c.gridy = 4 self.scan_type_settings.add(is_scan_post_start_box_lbl, c)
def tag_1_1(self, c): # 创建 检查框 self.is_start_box = JCheckBox(u'是否启动插件', ForwardRequestsConfig.IS_START) self.setFontBold(self.is_start_box) self.is_start_box.setForeground(Color(0, 0, 153)) c.insets = Insets(5, 5, 5, 5) c.gridx = 0 c.gridy = 1 self.settings.add(self.is_start_box, c) # 在窗口添加一句话 is_start_box_lbl = JLabel(u'打勾-启动, 不打勾-关闭') self.setFontItalic(is_start_box_lbl) c.insets = Insets(5, 5, 5, 5) c.gridx = 0 c.gridy = 2 self.settings.add(is_start_box_lbl, c)
def tag_2(self, c): # 创建 检查框 self.is_scan_post_start_box = JCheckBox(u'是否扫描POST类型的参数(推荐打勾)', XssConfig.IS_SCAN_POST_START) self.setFontBold(self.is_scan_post_start_box) self.is_scan_post_start_box.setForeground(Color(0, 0, 153)) c.insets = Insets(5, 5, 5, 5) c.gridx = 0 c.gridy = 2 self.scan_type_settings.add(self.is_scan_post_start_box, c)
def tag_3(self, c): # 创建 检查框 self.is_scan_url_path_folders_box = JCheckBox( u'扫描URL路径作为参数', XssConfig.IS_SCAN_URL_PATH_FOLDERS) self.setFontBold(self.is_scan_url_path_folders_box) self.is_scan_url_path_folders_box.setForeground(Color(0, 0, 153)) c.insets = Insets(5, 5, 5, 5) c.gridx = 0 c.gridy = 3 self.scan_type_settings.add(self.is_scan_url_path_folders_box, c)
def __init__(self, spy, parentCrate=None): JButton.__init__(self) self.spy = spy self.parentCrate = parentCrate self.text = "0" self.icon = self.redLED self.addActionListener(self) self.margin = Insets(1, 1, 1, 1) self.focusPainted = 0 self.borderPainted = 0
def tag_4_8(self, c): # 创建 检查框 self.is_options_forward_requests_box = JCheckBox( u'转发OPTIONS请求', ForwardRequestsConfig.IS_OPTIONS_FORWARD_REQUESTS) self.setFontBold(self.is_options_forward_requests_box) self.is_options_forward_requests_box.setForeground(Color(0, 0, 153)) c.insets = Insets(5, 5, 5, 5) c.gridx = 0 c.gridy = 8 self.white_list_http_method_settings.add( self.is_options_forward_requests_box, c)
def tag_4_15(self, c): # 创建 检查框 self.is_view_forward_requests_box = JCheckBox( u'转发VIEW请求', ForwardRequestsConfig.IS_VIEW_FORWARD_REQUESTS) self.setFontBold(self.is_view_forward_requests_box) self.is_view_forward_requests_box.setForeground(Color(0, 0, 153)) c.insets = Insets(5, 5, 5, 5) c.gridx = 0 c.gridy = 15 self.white_list_http_method_settings.add( self.is_view_forward_requests_box, c)
def __init__(self, view, handler): JButton.__init__(self) self.view = view self.icon = GUIUtilities.loadIcon("Find.png") self.margin = Insets(0, 0, 0, 0) self.handler = handler self.alignY = 1 self.actionPerformed = self.action self.cursor = Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR) self.toolTipText = u"Jump to error file %s:%s" % (unicode( handler[0]), unicode(handler[1]))
def _new_grid_bag(gridx, gridy, gridwidth=1): """Creates a new GridBagConstraints""" g = GridBagConstraints() g.gridx = gridx g.gridy = gridy g.gridwidth = gridwidth g.fill = GridBagConstraints.BOTH g.insets = Insets(2, 2, 5, 5) return g
def tag_4_14(self, c): # 创建 检查框 self.is_propfind_forward_requests_box = JCheckBox( u'转发PROPFIND请求', ForwardRequestsConfig.IS_PROPFIND_FORWARD_REQUESTS) self.setFontBold(self.is_propfind_forward_requests_box) self.is_propfind_forward_requests_box.setForeground(Color(0, 0, 153)) c.insets = Insets(5, 5, 5, 5) c.gridx = 0 c.gridy = 14 self.white_list_http_method_settings.add( self.is_propfind_forward_requests_box, c)
def tag_2_2(self, c): # 创建 检查框 self.is_repeater_forward_requests_box = JCheckBox( u'是否启动Repeater模块请求转发', ForwardRequestsConfig.IS_START_REPEATER_FORWARD_REQUESTS) self.setFontBold(self.is_repeater_forward_requests_box) self.is_repeater_forward_requests_box.setForeground(Color(0, 0, 153)) c.insets = Insets(5, 5, 5, 5) c.gridx = 0 c.gridy = 3 self.forward_requests_settings.add( self.is_repeater_forward_requests_box, c) # 在窗口添加一句话 is_repeater_forward_requests_box_lbl = JLabel(u'打勾-启动, 不打勾-关闭') self.setFontItalic(is_repeater_forward_requests_box_lbl) c.insets = Insets(5, 5, 5, 5) c.gridx = 0 c.gridy = 4 self.forward_requests_settings.add( is_repeater_forward_requests_box_lbl, c)
def tag_2_1(self, c): # 创建 检查框 self.is_proxy_forward_requests_box = JCheckBox( u'是否启动Proxy模块请求转发(推荐打勾)', ForwardRequestsConfig.IS_START_PROXY_FORWARD_REQUESTS) self.setFontBold(self.is_proxy_forward_requests_box) self.is_proxy_forward_requests_box.setForeground(Color(0, 0, 153)) c.insets = Insets(5, 5, 5, 5) c.gridx = 0 c.gridy = 1 self.forward_requests_settings.add(self.is_proxy_forward_requests_box, c) # 在窗口添加一句话 is_proxy_forward_requests_box_lbl = JLabel(u'打勾-启动, 不打勾-关闭') self.setFontItalic(is_proxy_forward_requests_box_lbl) c.insets = Insets(5, 5, 5, 5) c.gridx = 0 c.gridy = 2 self.forward_requests_settings.add(is_proxy_forward_requests_box_lbl, c)
def build_general_panel(self): ''' Create the panel that'll go in the General tab. This should contain options for choosing which server to use for validation as well as default working dir. ''' panel = JPanel(GridBagLayout()) constraints = GridBagConstraints() constraints.insets = Insets(10, 10, 10, 10) panel = self.build_working_dir_panel(constraints, panel) panel = self.build_servers_panel(constraints, panel) return panel
def build_working_dir_panel(self, constraints, panel): ''' Working directory row: label + field + button This is for users to browse for their preferred default directory when opening/creating a new file. ''' working_dir_label = JLabel("Working directory:") constraints = self.add_constraints(constraints, weightx=0.30, gridx=0, gridy=0, anchor=GridBagConstraints.EAST) panel.add(working_dir_label, constraints) self.wd_field = JTextField() self.wd_field.setEditable(False) # Can't find an elegant way to default to something that would be # crossplatform, and I can't leave the default field empty. if self.working_dir['default'] != "None": self.wd_field.setText(self.working_dir['default']) else: self.wd_field.setText(os.getcwd()) constraints = self.add_constraints(constraints, weightx=0.60, gridx=1, gridy=0, fill=GridBagConstraints.HORIZONTAL, insets=Insets(10, 10, 10, 5)) panel.add(self.wd_field, constraints) constraints.fill = 0 button = JButton("Browse", actionPerformed=self.browse) constraints = self.add_constraints(constraints, weightx=0.10, gridx=2, gridy=0, insets=Insets(10, 0, 10, 10)) panel.add(button, constraints)
def initComponents(self): self.setLayout(GridBagLayout()) gc = GridBagConstraints() gc.weightx = 1 gc.weighty = 1 # First Row gc.gridy = 0 gc.weightx = 1 gc.weighty = 0.1 gc.gridx = 0 gc.fill = GridBagConstraints.NONE gc.anchor = GridBagConstraints.LINE_END gc.insets = Insets(0, 0, 0, 5) self.add(self.vehicleLabel, gc) gc.gridx = 1 gc.anchor = GridBagConstraints.LINE_START gc.insets = Insets(0, 0, 0, 0) self.add(self.vehicleField, gc) #Next Row gc.gridy += 1 gc.weightx = 1 gc.weighty = 2.0 gc.gridx = 1 gc.anchor = GridBagConstraints.FIRST_LINE_START self.add(self.bypassBtn, gc) innerBorder = BorderFactory.createTitledBorder('Emergency Bypass') outerBorder = BorderFactory.createEmptyBorder(5, 5, 5, 5) self.setBorder( BorderFactory.createCompoundBorder(outerBorder, innerBorder))
def compose_ui(self, components): panel = JPanel() panel.setLayout(GridBagLayout()) constraints= GridBagConstraints() constraints.fill = GridBagConstraints.HORIZONTAL constraints.insets = Insets(2, 1, 2, 1) for i in components: for j in components[i]: constraints.gridy, constraints.gridx = i, j constraints.gridwidth = components[i][j]['width'] if type(components[i][j]) == dict and 'width' in components[i][j] else 1 constraints.gridheight = components[i][j]['height'] if type(components[i][j]) == dict and 'height' in components[i][j] else 1 item = components[i][j]['item'] if type(components[i][j]) == dict and 'item' in components[i][j] else components[i][j] panel.add(item, constraints) return panel
def build_appearance_panel(self): ''' Create the panel that'll go in the General tab. This should contain options for choosing which server to use for validation as well as default working dir. ''' panel = JPanel(GridBagLayout()) constraints = self.add_constraints(GridBagConstraints(), insets=Insets(10, 10, 10, 10)) self.build_console_font_panel(constraints, panel) self.build_console_font_color_panel(constraints, panel) self.build_console_background_color_panel(constraints, panel) self.build_edit_area_font_panel(constraints, panel) return panel
def tag_2_3(self, c): self.url_forward_xray = JCheckBox( u'是否将请求转发到xray', ForwardRequestsConfig.URL_FORWARD_XRAY) self.setFontBold(self.url_forward_xray) self.url_forward_xray.setForeground(Color(0, 0, 153)) c.insets = Insets(5, 5, 5, 5) c.gridx = 0 c.gridy = 5 self.forward_requests_settings.add(self.url_forward_xray, c) self.xray_listen_text_field = JTextField(u"127.0.0.1:7777") c.fill = GridBagConstraints.BOTH c.gridx = 0 c.gridy = 6 self.forward_requests_settings.add(self.xray_listen_text_field, c)
def constrain(self, component, grid_x, grid_y, grid_width, grid_height, fill, anchor, weight_x, weight_y, top, left, bottom, right): container = self c = self.gbc c.gridx = grid_x c.gridy = grid_y c.gridwidth = grid_width c.gridheight = grid_height c.fill = fill c.anchor = anchor c.weightx = weight_x c.weighty = weight_y if (top + bottom + left + right > 0): c.insets = Insets(top, left, bottom, right) container.getLayout().setConstraints(component, c) container.add(component)
def __init__(self, ui, tabName): self._ui = ui self.jStatusBtn = JButton() #self.jStatusBtn.setMargin(Insets(2,0,2,0)) self.jStatusBtn = JCheckBox() self.jStatusBtn.setToolTipText(Strings.jStatusBtn_tooltip) self.jStatusBtn.setMargin(Insets(1, 5, 1, 5)) #enlarged clickable zone self.jStatusBtn.setBackground(Color.RED) #transparent background self.add(self.jStatusBtn) self.jStatusBtn.addActionListener(self) self.jLabel = JDoubleClickTextField(self, tabName) self.add(self.jLabel) self.setOpaque(False)
def add_field(self, field, anchor=GridBagConstraints.WEST): if field.label: label = JLabel("{} :".format(field.label), JLabel.LEFT) self.add( label, make_constraints( gridy=len(self._fields), gridx=0, anchor=GridBagConstraints.WEST ), ) insets = Insets(3, 3, 3, 3) self.add( field.element, make_constraints( gridy=len(self._fields), gridx=1, anchor=anchor, insets=insets ), ) self._update_size() self._fields[field.name] = field
def __init__(self, interpreter, debugger, debugPanel): self.interpreter = interpreter self.debugger = debugger self.debugPanel = debugPanel # Build our slider! self.slider = JSlider(JSlider.HORIZONTAL, debugger.MIN_SPEED, debugger.MAX_SPEED, debugger.speed, stateChanged=self._sliderSpeedChanged) # Label the slider! self.sliderLabels = labels = Hashtable() labels.put(debugger.MIN_SPEED, JLabel("Slow")) labels.put(debugger.MAX_SPEED, JLabel("Fast")) self.slider.labelTable = labels self.slider.paintLabels = True # Build some buttons! self.buttonInsets = Insets(0, 0, 0, 0) self.watchButton = self.makeDebuggerButton( self.debugPanel.watchVariable, 'images/plus.jpg') self.unwatchButton = self.makeDebuggerButton( self.debugPanel.unwatchVariable, 'images/minus.jpg') self.fullspeedButton = self.makeDebuggerButton( self.debugPanel.fullSpeed, 'images/fullspeed.jpg') self.stopButton = self.makeDebuggerButton(self.interpreter.stopAction, 'images/stop.jpg') # Display them all! self.setLayout(BoxLayout(self, BoxLayout.X_AXIS)) self.add(self.slider) self.add(self.watchButton) self.add(self.unwatchButton) self.add(self.fullspeedButton) self.add(self.stopButton) # Connect the slider to the debugger! self.debugger.onSpeedSet.connect(self._showSpeedSetting) self.debugger.onStart.connect(self._lockControls) self.debugger.onStop.connect(self._unlockControls)
def registerExtenderCallbacks(self, callbacks): callbacks.registerContextMenuFactory(self) self._callbacks = callbacks self._helpers = callbacks.getHelpers() callbacks.setExtensionName(EXTENSION_NAME) # Construct UI insets = Insets(3, 3, 3, 3) self._messageEditor = callbacks.createMessageEditor(self, True) attackPanel = self._constructAttackPanel( insets, self._messageEditor.getComponent()) resultsPanel = self._constructResultsPanel(insets) aboutPanel = self._constructAboutPanel(insets) self._tabbedPane = JTabbedPane() self._tabbedPane.addTab("Attack", attackPanel) self._tabbedPane.addTab("Results", resultsPanel) self._tabbedPane.addTab("About", aboutPanel) callbacks.addSuiteTab(self)
def build_servers_panel(self, constraints, panel): ''' Server location row: label + dropdown Contains a drop down with the servers to choose from. ''' constraints.insets = Insets(10, 10, 80, 10) server_label = JLabel("ORACC server location:") constraints.weightx = 0.30 constraints.gridx = 0 constraints.gridy = 1 panel.add(server_label, constraints) self.combo = self.build_servers_combobox() constraints.weightx = 0.70 constraints.gridx = 1 constraints.gridy = 1 constraints.gridwidth = 2 constraints.fill = GridBagConstraints.HORIZONTAL panel.add(self.combo, constraints) return panel
def build_servers_panel(self, constraints, panel): ''' Server location row: label + dropdown Contains a drop down with the servers to choose from. ''' server_label = JLabel("ORACC server location:") constraints = self.add_constraints(constraints, weightx=0.30, gridx=0, gridy=1, insets=Insets(10, 10, 80, 10)) panel.add(server_label, constraints) self.combo = self.build_servers_combobox() constraints = self.add_constraints(constraints, weightx=0.70, gridx=1, gridy=1, gridwidth=2, fill=GridBagConstraints.HORIZONTAL) panel.add(self.combo, constraints)