def __init__(self): # set up the layout self.__component = JPanel(GridBagLayout()) self.__image = JLabel() self.__album = JLabel() self.__artist = JLabel() self.__application = None self.__image.setVerticalAlignment(SwingConstants.TOP) self.__album.setVerticalAlignment(SwingConstants.TOP) self.__artist.setVerticalAlignment(SwingConstants.TOP) gbc = GridBagConstraints() gbc.fill = GridBagConstraints.VERTICAL gbc.anchor = GridBagConstraints.NORTHWEST gbc.gridx = 0 gbc.gridy = 0 gbc.weighty = 2 gbc.gridheight = 2 self.__component.add(self.__image, gbc) gbc.fill = GridBagConstraints.HORIZONTAL gbc.anchor = GridBagConstraints.NORTHWEST gbc.gridx = 1 gbc.gridy = 0 gbc.gridheight = 1 gbc.weighty = 0 gbc.insets = Insets(0, 10, 0, 10) self.__component.add(self.__album, gbc) gbc.fill = GridBagConstraints.BOTH gbc.anchor = GridBagConstraints.NORTHWEST gbc.gridx = 1 gbc.gridy = 1 gbc.weightx = 2 gbc.weighty = 2 gbc.gridheight = 1 self.__component.add(self.__artist, gbc)
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 createAndShowGUI(): # Create the GUI and show it. As with all GUI code, this must run # on the event-dispatching thread. frame = JFrame("MAE ") frame.setSize(1024, 768) panel= JPanel() panel.setLayout(GridBagLayout()) #Create and set up the content pane. psimures= SimoutPanel() psimures.setOpaque(True) c = GridBagConstraints() c.fill = GridBagConstraints.HORIZONTAL c.weightx = 1 c.gridx = 0 c.gridy = 0 panel.add(psimures, c); pmeasure= MeasPanel() pmeasure.setOpaque(True) c = GridBagConstraints() c.fill = GridBagConstraints.HORIZONTAL c.weightx = 1 c.gridx = 0 c.gridy = 1 panel.add(pmeasure, c); preport = ReportPanel() preport.setOpaque(True) c = GridBagConstraints() c.fill = GridBagConstraints.VERTICAL c.weighty = 1 c.gridx = 1 c.gridy = 0 c.gridheight= 2 panel.add(preport,c) # show the GUI frame.add(panel) # frame.add(pmeasure) # frame.add(preport) frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE) frame.setVisible(True)
def getGridBagConstraints(game,node): c = GridBagConstraints() for str in node.getAttribute("constraints").split(","): a = str.split(":") if a[0]=="fill": c.fill = int(a[1]) elif a[0]=="gridwidth": c.gridwidth = int(a[1]) elif a[0]=="gridheight": c.gridheight = int(a[1]) elif a[0]=="gridx": c.gridx = int(a[1]) elif a[0]=="gridy": c.gridy = int(a[1]) elif a[0]=="weightx": c.weightx = int(a[1]) elif a[0]=="weighty": c.weighty = int(a[1]) else: print a[0]+"was not found" return c
def registerExtenderCallbacks(self, callbacks): self.callbacks = callbacks self.helpers = callbacks.getHelpers() callbacks.setExtensionName("Session Authentication Tool") self.out = callbacks.getStdout() # definition of suite tab self.tab = JPanel(GridBagLayout()) self.tabledata = MappingTableModel(callbacks) self.table = JTable(self.tabledata) #self.table.getColumnModel().getColumn(0).setPreferredWidth(50); #self.table.getColumnModel().getColumn(1).setPreferredWidth(100); self.tablecont = JScrollPane(self.table) c = GridBagConstraints() c.fill = GridBagConstraints.HORIZONTAL c.anchor = GridBagConstraints.FIRST_LINE_START c.gridx = 0 c.gridy = 0 c.gridheight = 6 c.weightx = 0.3 c.weighty = 0.5 self.tab.add(self.tablecont, c) c = GridBagConstraints() c.weightx = 0.1 c.anchor = GridBagConstraints.FIRST_LINE_START c.gridx = 1 c.gridy = 0 label_id = JLabel("Identifier:") self.tab.add(label_id, c) self.input_id = JTextField(20) self.input_id.setToolTipText( "Enter the identifier which is used by the application to identifiy a particular test user account, e.g. a numerical user id or a user name." ) c.gridy = 1 self.tab.add(self.input_id, c) c.gridy = 2 label_content = JLabel("Content:") self.tab.add(label_content, c) self.input_content = JTextField(20, actionPerformed=self.btn_add_id) self.input_content.setToolTipText( "Enter some content which is displayed in responses of the application and shows that the current session belongs to a particular user, e.g. the full name of the user." ) c.gridy = 3 self.tab.add(self.input_content, c) self.btn_add = JButton("Add/Edit Identity", actionPerformed=self.btn_add_id) c.gridy = 4 self.tab.add(self.btn_add, c) self.btn_del = JButton("Delete Identity", actionPerformed=self.btn_del_id) c.gridy = 5 self.tab.add(self.btn_del, c) callbacks.customizeUiComponent(self.tab) callbacks.customizeUiComponent(self.table) callbacks.customizeUiComponent(self.tablecont) callbacks.customizeUiComponent(self.btn_add) callbacks.customizeUiComponent(self.btn_del) callbacks.customizeUiComponent(label_id) callbacks.customizeUiComponent(self.input_id) callbacks.addSuiteTab(self) callbacks.registerScannerCheck(self) callbacks.registerIntruderPayloadGeneratorFactory(self) callbacks.registerContextMenuFactory(self)
def create(self): # Estilo general para todas las sub-tab. gBC = GridBagConstraints() gBC.fill = GridBagConstraints.BOTH gBC.ipadx = 5 gBC.ipady = 5 gBC.insets = Insets(0, 5, 5, 5) gBC.weightx = 0.5 #gBC.weighty = 0.7 ####################################### ### Creamos la primera sub-tab. (MASHUP) ####################################### tab_1 = JPanel(GridBagLayout()) tab_1_jlabelAyuda = JLabel( '<html><i>•Tip: This Mashup receive one or more keywords in order to generate a list of possible passwords</i></html>' ) tab_1_jlabelAyuda.setFont(Font("Serif", 0, 12)) gBC.gridx = 0 gBC.gridy = 0 tab_1.add( JLabel('<html><font color=green><i>Income:</i></font></html>'), gBC) gBC.gridy = 1 tab_1.add(JLabel('<html><b>• Name:</b></html>'), gBC) gBC.gridy = 2 tab_1.add(self._tab1_nombre, gBC) gBC.gridy = 3 tab_1.add(JLabel('<html><b>• Surname:</b></html>'), gBC) gBC.gridy = 4 tab_1.add(self._tab1_apellido, gBC) gBC.gridy = 5 tab_1.add(JLabel('<html><b>• Birthdate: (DDMMYYYY)</b></html>'), gBC) gBC.gridy = 6 tab_1.add(self._tab1_FNacimiento, gBC) gBC.gridy = 7 tab_1.add(JLabel('<html><b>• Pet:</b></html>'), gBC) gBC.gridy = 8 tab_1.add(self._tab1_mascota, gBC) gBC.gridy = 9 tab_1.add(JLabel('<html><b>• Anyother:</b></html>'), gBC) gBC.gridy = 10 tab_1.add(self._tab1_otro, gBC) gBC.gridy = 11 tab_1.add(JLabel('<html><b>• Passwd Min Size:</b></html>'), gBC) gBC.gridy = 12 tab_1.add(self._tab1_minsize, gBC) gBC.gridy = 13 tab_1.add(JLabel('<html><b>• Passwd Max Size:</b></html>'), gBC) gBC.gridy = 14 tab_1.add(self._tab1_maxsize, gBC) gBC.gridy = 15 tab_1.add( JLabel( '<html><b>• Especial Chars: (comma separated)</b></html>' ), gBC) gBC.gridy = 16 tab_1.add(self._tab1_specialchars, gBC) gBC.gridy = 17 tab_1.add(self._tab1_transformations, gBC) gBC.gridy = 18 tab_1.add(self._tab1_firstcapital, gBC) gBC.gridy = 19 tab_1.add(JButton('Mashup!', actionPerformed=self.mashup), gBC) gBC.gridy = 20 gBC.gridwidth = 3 tab_1.add(JSeparator(), gBC) gBC.gridwidth = 1 gBC.gridy = 21 gBC.gridwidth = 3 tab_1.add(tab_1_jlabelAyuda, gBC) gBC.gridwidth = 1 gBC.gridx = 1 gBC.gridy = 0 gBC.gridheight = 20 gBC.weightx = 0 tab_1.add(JSeparator(SwingConstants.VERTICAL), gBC) gBC.gridheight = 1 gBC.weightx = 0.5 gBC.gridx = 2 gBC.gridy = 0 tab_1.add( JLabel('<html><font color=green><i>Outcome:</i></font></html>'), gBC) gBC.gridy = 1 gBC.gridwidth = 2 gBC.gridheight = 18 tab_1.add(self._tab1_feedback_sp, gBC) gBC.gridwidth = 1 gBC.gridheight = 1 gBC.gridy = 19 tab_1.add( JButton('Copy to clipboard!', actionPerformed=self.cpy_clipboard), gBC) ####################################### ### Creamos la segunda sub-tab. (REDIRECT) ####################################### tab_2 = JPanel(GridBagLayout()) tab_2_jlabelAyuda = JLabel( '<html><i>•Tip: This Redirect receive a pair of hosts x,y in order to redirect from x to y.</i></html>' ) tab_2_jlabelAyuda.setFont(Font("Serif", 0, 12)) gBC.gridx = 0 gBC.gridy = 0 tab_2.add( JLabel('<html><b>• From: (i.e. www.facebook.com)</b></html>'), gBC) gBC.gridx = 1 gBC.gridy = 0 tab_2.add(self._tab2_JTFa, gBC) gBC.gridx = 2 gBC.gridy = 0 tab_2.add( JLabel('<html><b>• To: (i.e. www.myhomepage.es)</b></html>'), gBC) gBC.gridx = 3 gBC.gridy = 0 tab_2.add(self._tab2_JTFaa, gBC) gBC.gridx = 0 gBC.gridy = 1 gBC.gridwidth = 4 tab_2.add(JSeparator(), gBC) gBC.gridwidth = 1 gBC.gridx = 0 gBC.gridy = 2 tab_2.add(JLabel('<html><b>• From:</b></html>'), gBC) gBC.gridx = 1 gBC.gridy = 2 tab_2.add(self._tab2_JTFb, gBC) gBC.gridx = 2 gBC.gridy = 2 tab_2.add(JLabel('<html><b>• To:</b></html>'), gBC) gBC.gridx = 3 gBC.gridy = 2 tab_2.add(self._tab2_JTFbb, gBC) gBC.gridx = 0 gBC.gridy = 3 gBC.gridwidth = 4 tab_2.add(self._tab2_boton, gBC) gBC.gridwidth = 1 gBC.gridx = 0 gBC.gridy = 4 gBC.gridwidth = 4 gBC.insets = Insets(100, 10, 5, 10) tab_2.add(JSeparator(), gBC) gBC.gridwidth = 1 gBC.insets = Insets(5, 10, 5, 10) gBC.gridx = 0 gBC.gridy = 5 gBC.gridwidth = 4 tab_2.add(tab_2_jlabelAyuda, gBC) gBC.gridwidth = 1 ####################################### ### Creamos la tercera sub-tab. (LOADER) ####################################### tab_3 = JPanel(GridBagLayout()) tab_3_jlabelAyuda = JLabel( '<html><i>•Tip: This Loader receive a list of Hosts or IPs that will be added to the Burp Scope.</i></html>' ) tab_3_jlabelAyuda.setFont(Font("Serif", 0, 12)) gBC.gridx = 0 gBC.gridy = 0 tab_3.add( JLabel( '<html><font color=green><i>List of targets: (i.e. http://www.mytargetweb.com)</i></font></html>' ), gBC) gBC.gridy = 1 gBC.gridheight = 10 gBC.weighty = 0.5 tab_3.add(self._tab3_urls_sp, gBC) gBC.gridheight = 1 gBC.weighty = 0 gBC.gridy = 11 tab_3.add( JButton('Load Into Target => Scope!', actionPerformed=self.loader), gBC) gBC.gridy = 12 gBC.gridwidth = 5 gBC.insets = Insets(100, 10, 5, 10) tab_3.add(JSeparator(), gBC) gBC.gridwidth = 1 gBC.insets = Insets(5, 10, 5, 10) gBC.gridy = 13 tab_3.add(tab_3_jlabelAyuda, gBC) ####################################### ### Creamos la cuarta sub-tab. (HEADERS) ####################################### tab_4_jlabelAyuda = JLabel( "<html><i>•Tip: This Headers records all unique headers that appear in every host, check out the security headers.</i></html>" ) tab_4_jlabelAyuda.setFont(Font("Serif", 0, 12)) tab_4_jLabelRecomendacion = JLabel( "<html>•<b>Server</b>: Don't give away much information.<br> •<b>Content-Security-Policy</b>: Protect your site from XSS attacks by whitelisting sources of approved content.<br> •<b>Strict-Transport-Security</b>: Enforce the browser to use HTTPS.<br> •<b>Public-Key-Pins</b>: Protect your site from MITM attacks.<br> •<b>X-Content-Type-Options</b>: the valid value is -> nosniff .<br> •<b>X-Frame-Options</b>: tells the browser whether you want to allow your site to be framed or not.<br> •<b>X-XSS-Protection</b>: the best value is -> 1; mode=block .</html>" ) tab_4_jLabelRecomendacion.setFont(Font("Dialog", 0, 13)) tab_4 = JPanel(GridBagLayout()) splitpane = JSplitPane(JSplitPane.VERTICAL_SPLIT) tab_4_top = JPanel(GridBagLayout()) tab_4_bottom = JPanel(GridBagLayout()) gBC_table = GridBagConstraints() gBC_table.fill = GridBagConstraints.BOTH gBC_table.ipadx = 5 gBC_table.ipady = 5 gBC_table.insets = Insets(5, 10, 5, 10) gBC_table.weightx = 1 gBC_table.weighty = 1 tabla_datos = [] tabla_headers = ('Severity', 'Header', 'Value', 'Host') self._tab4_tabla_model = DefaultTableModel(tabla_datos, tabla_headers) tabla_ej = JTable(self._tab4_tabla_model) tabla_example = JScrollPane(tabla_ej, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED) gBC_table.gridx = 0 gBC_table.gridy = 0 gBC_table.gridheight = 5 tab_4_top.add(tabla_example, gBC_table) gBC_table.gridheight = 1 gBC_table.weightx = 0.5 gBC_table.weighty = 0 gBC_table.gridwidth = 2 gBC_table.gridx = 0 gBC_table.gridy = 0 tab_4_bottom.add(JSeparator(), gBC_table) gBC_table.gridy = 1 tab_4_bottom.add(tab_4_jlabelAyuda, gBC_table) gBC_table.gridy = 2 tab_4_bottom.add(tab_4_jLabelRecomendacion, gBC_table) splitpane.setTopComponent(tab_4_top) splitpane.setBottomComponent(tab_4_bottom) gBC_table.weightx = 1 gBC_table.weighty = 1 gBC_table.gridx = 0 gBC_table.gridy = 0 tab_4.add(splitpane, gBC_table) ####################################### ### Creamos la quinta sub-tab. (ACTIVE SCAN) ####################################### tab_5 = JPanel(GridBagLayout()) tab_5_jlabelAyuda = JLabel( '<html><i>•Tip: This Quick Scan receive a list of targets and launch an active scan.</i></html>' ) tab_5_jlabelAyuda.setFont(Font("Serif", 0, 12)) tab_5_jlabelWarning = JLabel( '<html><font color=red><i>•Warning: Active scanning generates large numbers of requests which are malicious in form and which may result in compromise of the application. You should use this scanning mode with caution, only with the explicit permission of the application owner. For more information, read the documentation of active scan, Burp Suite.</font></i></html>' ) tab_5_jlabelWarning.setFont(Font("Dialog", 0, 13)) gBC.gridx = 0 gBC.gridy = 0 tab_5.add( JLabel( '<html><font color=green><i>List of targets: (i.e. http://192.168.1.1/index.html)</i></font></html>' ), gBC) gBC.gridy = 1 gBC.gridheight = 8 gBC.weighty = 0.5 tab_5.add(self._tab5_target_sp, gBC) gBC.gridheight = 1 gBC.weighty = 0 gBC.gridy = 9 tab_5.add(JButton('Launch Scan!', actionPerformed=self.do_active_scan), gBC) gBC.gridy = 10 gBC.gridwidth = 5 gBC.insets = Insets(100, 10, 5, 10) tab_5.add(JSeparator(), gBC) gBC.gridwidth = 1 gBC.insets = Insets(5, 10, 5, 10) gBC.gridy = 11 tab_5.add(tab_5_jlabelAyuda, gBC) gBC.gridy = 12 tab_5.add(tab_5_jlabelWarning, gBC) ####################################### ### Creamos la ultima sub-tab. ####################################### tab_about = JPanel(GridBagLayout()) gBC_about = GridBagConstraints() gBC_about.fill = GridBagConstraints.HORIZONTAL gBC_about.ipadx = 5 gBC_about.ipady = 5 gBC_about.insets = Insets(5, 10, 5, 10) gBC_about.weightx = 1 gBC_about.weighty = 1 Jlabel1 = JLabel('<html><b>Plug-in L-Tools</b></html>') Jlabel1.setFont(Font("Dialog", 1, 18)) jlabel2 = JLabel( '<html>This Plug-in provides utilities for pentesters, researchers and developers, in order to support their work.</html>' ) jlabel3 = JLabel('<html><b>CC-BY 4.0, 2017. Gino Angles</b></html>') jlabel3.setFont(Font("Dialog", 1, 14)) jlabel4 = JLabel('<html><b>License</b></html>') jlabel4.setFont(Font("Dialog", 1, 14)) jlabel5 = JLabel( '<html><img alt="Licensed under a Creative Commons BY" style="border-width:0" src="https://licensebuttons.net/l/by/4.0/88x31.png"></html>' ) jlabel6 = JLabel( '<html>This work is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by/4.0/">Creative Commons Attribution 4.0 International License</a>.</html>' ) jlabel7 = JLabel('<html><b>Dependencies</b></html>') jlabel7.setFont(Font("Dialog", 1, 14)) jlabel8 = JLabel('Jython +2.7') jlabel9 = JLabel('http://www.jython.org') gBC_about.gridx = 0 gBC_about.gridy = 0 tab_about.add(Jlabel1, gBC_about) gBC_about.gridy = 1 tab_about.add(jlabel2, gBC_about) gBC_about.gridy = 2 tab_about.add(jlabel3, gBC_about) gBC_about.gridy = 3 gBC_about.gridwidth = 5 tab_about.add(JSeparator(), gBC_about) gBC_about.gridwidth = 1 gBC_about.gridy = 4 tab_about.add(jlabel4, gBC_about) gBC_about.gridy = 5 tab_about.add(jlabel5, gBC_about) gBC_about.gridy = 6 tab_about.add(jlabel6, gBC_about) gBC_about.gridy = 7 gBC_about.gridwidth = 5 tab_about.add(JSeparator(), gBC_about) gBC_about.gridwidth = 1 gBC_about.gridy = 8 tab_about.add(jlabel7, gBC_about) gBC_about.gridy = 9 tab_about.add(jlabel8, gBC_about) gBC_about.gridy = 10 tab_about.add(jlabel9, gBC_about) # Añadimos los sub-tab al contenedor y lo devolvemos. self.contenedor.addTab('Mashup', tab_1) self.contenedor.addTab('Redirect', tab_2) self.contenedor.addTab('Loader', tab_3) self.contenedor.addTab('Headers', tab_4) self.contenedor.addTab('Quick Scan', tab_5) self.contenedor.addTab('About', tab_about) return self.contenedor
def __init__(self, extender=None, *rows): self.extender = extender self.table = table = JTable(ParameterProcessingRulesTableModel(*rows)) table.setPreferredScrollableViewportSize(Dimension(500, 70)) table.setRowSorter(TableRowSorter(table.getModel())) table.setFillsViewportHeight(True) gridBagLayout = GridBagLayout() gridBagLayout.columnWidths = [0, 0, 25, 0 ] gridBagLayout.rowHeights = [0, 0, 0, 0] gridBagLayout.columnWeights = [0.0, 1.0, 1.0, Double.MIN_VALUE] gridBagLayout.rowWeights = [0.0, 0.0, 0.0, Double.MIN_VALUE] self.setLayout(gridBagLayout) addButton = JButton("Add") addButton.addActionListener(AddRemoveParameterListener(table)) addButtonConstraints = GridBagConstraints() addButtonConstraints.fill = GridBagConstraints.HORIZONTAL addButtonConstraints.insets = Insets(0, 0, 5, 5) addButtonConstraints.gridx = 0 addButtonConstraints.gridy = 0 self.add(addButton, addButtonConstraints) removeButton = JButton("Remove") removeButton.addActionListener(AddRemoveParameterListener(table)) removeButtonConstraints = GridBagConstraints() removeButtonConstraints.fill = GridBagConstraints.HORIZONTAL removeButtonConstraints.insets = Insets(0, 0, 5, 5) removeButtonConstraints.gridx = 0 removeButtonConstraints.gridy = 1 self.add(removeButton, removeButtonConstraints) upButton = JButton("Up") upButton.addActionListener(AddRemoveParameterListener(table)) upButtonConstraints = GridBagConstraints() upButtonConstraints.fill = GridBagConstraints.HORIZONTAL upButtonConstraints.insets = Insets(0, 0, 5, 5) upButtonConstraints.gridx = 0 upButtonConstraints.gridy = 2 self.add(upButton, upButtonConstraints) downButton = JButton("Down") downButton.addActionListener(AddRemoveParameterListener(table)) downButtonConstraints = GridBagConstraints() downButtonConstraints.fill = GridBagConstraints.HORIZONTAL downButtonConstraints.anchor = GridBagConstraints.NORTH downButtonConstraints.insets = Insets(0, 0, 5, 5) downButtonConstraints.gridx = 0 downButtonConstraints.gridy = 3 self.add(downButton, downButtonConstraints) scrollPane = JScrollPane(table) scrollPaneConstraints = GridBagConstraints() scrollPaneConstraints.gridwidth = 2 scrollPaneConstraints.gridheight = 5 scrollPaneConstraints.insets = Insets(0, 0, 5, 5) scrollPaneConstraints.anchor = GridBagConstraints.NORTHWEST scrollPaneConstraints.gridx = 1 scrollPaneConstraints.gridy = 0 self.add(scrollPane, scrollPaneConstraints) self.initParameterColumn(table) self.initColumnSizes(table)
def initComponents(self): self.setLayout(GridBagLayout()) gbc = GridBagConstraints() gbc.anchor = GridBagConstraints.NORTHWEST gbc.gridx = 0 gbc.gridy = 0 descriptionLabel = JLabel("FEA - Forensics Email Analysis") self.add(descriptionLabel, gbc) gbc.gridy = 1 self.cbNSLookup = JCheckBox( "Perform DNS Lookup on email domains", actionPerformed=self.cbNSLookupActionPerformed) self.cbNSLookup.setSelected(True) self.add(self.cbNSLookup, gbc) # TODO: include option to browse for text file with list of emails to exclude from analysis numberThreadsLabel = JLabel( "Maximum number of threads for DNS Lookup task: ") gbc.gridy = 2 self.add(numberThreadsLabel, gbc) self.numberThreadsSlider = JSlider( JSlider.HORIZONTAL, 1, 16, 8, stateChanged=self.sliderActionPerformed) self.numberThreadsSlider.setMajorTickSpacing(1) self.numberThreadsSlider.setPaintLabels(True) self.numberThreadsSlider.setPaintTicks(True) self.numberThreadsSlider.setSnapToTicks(True) self.numberThreadsSlider.setToolTipText( "set maximum number of concurrent threads when performing DNS lookup on email domains" ) gbc.gridy = 5 gbc.gridwidth = 15 gbc.gridheight = 1 gbc.fill = GridBagConstraints.BOTH gbc.weightx = 0 gbc.weighty = 0 gbc.anchor = GridBagConstraints.NORTHWEST gbc.gridy = 3 self.add(self.numberThreadsSlider, gbc) self.cbGenerateExcel = JCheckBox( "Generate Excel format report (more detailed)", actionPerformed=self.cbGenerateExcelActionPerformed) self.cbGenerateExcel.setSelected(True) gbc.gridy = 4 self.add(self.cbGenerateExcel, gbc) self.cbGenerateCSV = JCheckBox( "Generate CSV format report (plaintext)", actionPerformed=self.cbGenerateCSVActionPerformed) self.cbGenerateCSV.setSelected(True) gbc.gridy = 5 self.add(self.cbGenerateCSV, gbc) gbc.gridy = 6 self.cbWayback = JCheckBox( "Perform Wayback Machine Lookup on email domains (WARNING: can be a slow process!)", actionPerformed=self.cbWaybackActionPerformed) self.cbWayback.setSelected(True) self.add(self.cbWayback, gbc)
def _constructAttackPanel(self, insets, messageEditorComponent): attackPanel = JPanel(GridBagLayout()) targetHeadingLabel = JLabel("<html><b>Target</b></html>") targetHeadingLabelConstraints = GridBagConstraints() targetHeadingLabelConstraints.gridx = 0 targetHeadingLabelConstraints.gridy = 0 targetHeadingLabelConstraints.gridwidth = 4 targetHeadingLabelConstraints.anchor = GridBagConstraints.LINE_START targetHeadingLabelConstraints.insets = insets attackPanel.add(targetHeadingLabel, targetHeadingLabelConstraints) startAttackButton = JButton("<html><b>Start Attack</b></html>", actionPerformed=self._startAttack) startAttackButtonConstraints = GridBagConstraints() startAttackButtonConstraints.gridx = 4 startAttackButtonConstraints.gridy = 0 startAttackButtonConstraints.insets = insets attackPanel.add(startAttackButton, startAttackButtonConstraints) hostLabel = JLabel("Host:") hostLabelConstraints = GridBagConstraints() hostLabelConstraints.gridx = 0 hostLabelConstraints.gridy = 1 hostLabelConstraints.anchor = GridBagConstraints.LINE_START hostLabelConstraints.insets = insets attackPanel.add(hostLabel, hostLabelConstraints) self._hostTextField = JTextField(25) self._hostTextField.setMinimumSize( self._hostTextField.getPreferredSize()) hostTextFieldConstraints = GridBagConstraints() hostTextFieldConstraints.gridx = 1 hostTextFieldConstraints.gridy = 1 hostTextFieldConstraints.weightx = 1 hostTextFieldConstraints.gridwidth = 2 hostTextFieldConstraints.anchor = GridBagConstraints.LINE_START hostTextFieldConstraints.insets = insets attackPanel.add(self._hostTextField, hostTextFieldConstraints) portLabel = JLabel("Port:") portLabelConstraints = GridBagConstraints() portLabelConstraints.gridx = 0 portLabelConstraints.gridy = 2 portLabelConstraints.anchor = GridBagConstraints.LINE_START portLabelConstraints.insets = insets attackPanel.add(portLabel, portLabelConstraints) self._portTextField = JTextField(5) self._portTextField.setMinimumSize( self._portTextField.getPreferredSize()) portTextFieldConstraints = GridBagConstraints() portTextFieldConstraints.gridx = 1 portTextFieldConstraints.gridy = 2 portTextFieldConstraints.gridwidth = 2 portTextFieldConstraints.anchor = GridBagConstraints.LINE_START portTextFieldConstraints.insets = insets attackPanel.add(self._portTextField, portTextFieldConstraints) self._protocolCheckBox = JCheckBox("Use HTTPS") protocolCheckBoxConstraints = GridBagConstraints() protocolCheckBoxConstraints.gridx = 0 protocolCheckBoxConstraints.gridy = 3 protocolCheckBoxConstraints.gridwidth = 3 protocolCheckBoxConstraints.anchor = GridBagConstraints.LINE_START protocolCheckBoxConstraints.insets = insets attackPanel.add(self._protocolCheckBox, protocolCheckBoxConstraints) requestHeadingLabel = JLabel("<html><b>Request</b></html>") requestHeadingLabelConstraints = GridBagConstraints() requestHeadingLabelConstraints.gridx = 0 requestHeadingLabelConstraints.gridy = 4 requestHeadingLabelConstraints.gridwidth = 4 requestHeadingLabelConstraints.anchor = GridBagConstraints.LINE_START requestHeadingLabelConstraints.insets = insets attackPanel.add(requestHeadingLabel, requestHeadingLabelConstraints) messageEditorComponentConstraints = GridBagConstraints() messageEditorComponentConstraints.gridx = 0 messageEditorComponentConstraints.gridy = 5 messageEditorComponentConstraints.weightx = 1 messageEditorComponentConstraints.weighty = .75 messageEditorComponentConstraints.gridwidth = 4 messageEditorComponentConstraints.gridheight = 2 messageEditorComponentConstraints.fill = GridBagConstraints.BOTH messageEditorComponentConstraints.insets = insets attackPanel.add( messageEditorComponent, messageEditorComponentConstraints) addPayloadButton = JButton( "Add \xa7", actionPerformed=self._addPayload) addPayloadButtonConstraints = GridBagConstraints() addPayloadButtonConstraints.gridx = 4 addPayloadButtonConstraints.gridy = 5 addPayloadButtonConstraints.fill = GridBagConstraints.HORIZONTAL addPayloadButtonConstraints.insets = insets attackPanel.add(addPayloadButton, addPayloadButtonConstraints) clearPayloadButton = JButton( "Clear \xa7", actionPerformed=self._clearPayloads) clearPayloadButtonConstraints = GridBagConstraints() clearPayloadButtonConstraints.gridx = 4 clearPayloadButtonConstraints.gridy = 6 clearPayloadButtonConstraints.anchor = GridBagConstraints.PAGE_START clearPayloadButtonConstraints.fill = GridBagConstraints.HORIZONTAL clearPayloadButtonConstraints.insets = insets attackPanel.add(clearPayloadButton, clearPayloadButtonConstraints) payloadHeadingLabel = JLabel("<html><b>Payloads<b></html>") payloadHeadingLabelConstraints = GridBagConstraints() payloadHeadingLabelConstraints.gridx = 0 payloadHeadingLabelConstraints.gridy = 7 payloadHeadingLabelConstraints.gridwidth = 4 payloadHeadingLabelConstraints.anchor = GridBagConstraints.LINE_START payloadHeadingLabelConstraints.insets = insets attackPanel.add(payloadHeadingLabel, payloadHeadingLabelConstraints) self._payloadTextArea = JTextArea() payloadScrollPane = JScrollPane(self._payloadTextArea) payloadScrollPaneConstraints = GridBagConstraints() payloadScrollPaneConstraints.gridx = 0 payloadScrollPaneConstraints.gridy = 8 payloadScrollPaneConstraints.weighty = .25 payloadScrollPaneConstraints.gridwidth = 3 payloadScrollPaneConstraints.fill = GridBagConstraints.BOTH payloadScrollPaneConstraints.insets = insets attackPanel.add(payloadScrollPane, payloadScrollPaneConstraints) requestsNumLabel = JLabel("Number of requests for each payload:") requestsNumLabelConstraints = GridBagConstraints() requestsNumLabelConstraints.gridx = 0 requestsNumLabelConstraints.gridy = 9 requestsNumLabelConstraints.gridwidth = 2 requestsNumLabelConstraints.anchor = GridBagConstraints.LINE_START requestsNumLabelConstraints.insets = insets attackPanel.add(requestsNumLabel, requestsNumLabelConstraints) self._requestsNumTextField = JTextField("100", 4) self._requestsNumTextField.setMinimumSize( self._requestsNumTextField.getPreferredSize()) requestsNumTextFieldConstraints = GridBagConstraints() requestsNumTextFieldConstraints.gridx = 2 requestsNumTextFieldConstraints.gridy = 9 requestsNumTextFieldConstraints.anchor = GridBagConstraints.LINE_START requestsNumTextFieldConstraints.insets = insets attackPanel.add( self._requestsNumTextField, requestsNumTextFieldConstraints) return attackPanel
def getArguments(self): """ This function brings up a window to retreive any required arguments. It uses a window with fields for each argument, filled with any arguments already given. While this window is visible the program will wait, once it is no longer visible all the arguments will be filled with the entries in the fields. """ class LocationAction(AbstractAction): """ Action to set the text of a text field to a folder or directory. """ def __init__(self, field): AbstractAction.__init__(self, "...") self.field = field def actionPerformed(self, event): fileChooser = JFileChooser() fileChooser.fileSelectionMode = JFileChooser.FILES_AND_DIRECTORIES if fileChooser.showOpenDialog(None) == JFileChooser.APPROVE_OPTION: self.field.text = fileChooser.selectedFile.absolutePath class HelpAction(AbstractAction): """ Displays a help page in a web browser. """ def __init__(self): AbstractAction.__init__(self, "Help") def actionPerformed(self, event): browsers = ["google-chrome", "firefox", "opera", "epiphany", "konqueror", "conkeror", "midori", "kazehakase", "mozilla"] osName = System.getProperty("os.name") helpHTML = ClassLoader.getSystemResource("help.html").toString() if osName.find("Mac OS") == 0: Class.forName("com.apple.eio.FileManager").getDeclaredMethod( "openURL", [String().getClass()]).invoke(None, [helpHTML]) elif osName.find("Windows") == 0: Runtime.getRuntime().exec( "rundll32 url.dll,FileProtocolHandler " + helpHTML) else: browser = None for b in browsers: if browser == None and Runtime.getRuntime().exec(["which", b]).getInputStream().read() != -1: browser = b Runtime.getRuntime().exec([browser, helpHTML]) class OKAction(AbstractAction): """ Action for starting the pipeline. This action will simply make the window invisible. """ def __init__(self): AbstractAction.__init__(self, "Ok") def actionPerformed(self, event): frame.setVisible(False) class CancelAction(AbstractAction): """ Action for canceling the pipeline. Exits the program. """ def __init__(self): AbstractAction.__init__(self, "Cancel") def actionPerformed(self, event): sys.exit(0) frame = JFrame("Neofelis") frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE) constraints = GridBagConstraints() contentPane = JPanel(GridBagLayout()) frame.setContentPane(contentPane) blastField = JTextField(self.blastLocation) genemarkField = JTextField(self.genemarkLocation) transtermField = JTextField(self.transtermLocation) tRNAscanField = JTextField(self.tRNAscanLocation) databaseLocationField = JTextField(os.path.split(self.database)[0]) databaseField = JTextField(os.path.split(self.database)[1]) matrixField = JTextField(str(self.matrix)) eValueField = JTextField(str(self.eValue)) minLengthField = JTextField(str(self.minLength)) scaffoldingDistanceField = JTextField(str(self.scaffoldingDistance)) promoterScoreField = JTextField(str(self.promoterScoreCutoff)) queryField = JTextField(self.sources[0]) constraints.gridx = 0 constraints.gridy = 0 constraints.gridwidth = 1 constraints.gridheight = 1 constraints.fill = GridBagConstraints.HORIZONTAL constraints.weightx = 0 constraints.weighty = 0 contentPane.add(JLabel("Blast Location"), constraints) constraints.gridy = 1 contentPane.add(JLabel("Genemark Location"), constraints) constraints.gridy = 2 contentPane.add(JLabel("Transterm Location"), constraints) constraints.gridy = 3 contentPane.add(JLabel("tRNAscan Location"), constraints) constraints.gridy = 4 contentPane.add(JLabel("Databases Location"), constraints) constraints.gridy = 5 contentPane.add(JLabel("Database"), constraints) constraints.gridy = 6 contentPane.add(JLabel("Matrix(Leave blank to use heuristic matrix)"), constraints) constraints.gridy = 7 contentPane.add(JLabel("E Value"), constraints) constraints.gridy = 8 contentPane.add(JLabel("Minimum Intergenic Length"), constraints) constraints.gridy = 9 contentPane.add(JLabel("Scaffold Distance"), constraints) constraints.gridy = 10 contentPane.add(JLabel("Promoter Score Cutoff"), constraints) constraints.gridy = 11 contentPane.add(JLabel("Query"), constraints) constraints.gridx = 1 constraints.gridy = 0 constraints.weightx = 1 contentPane.add(blastField, constraints) constraints.gridy = 1 contentPane.add(genemarkField, constraints) constraints.gridy = 2 contentPane.add(transtermField, constraints) constraints.gridy = 3 contentPane.add(tRNAscanField, constraints) constraints.gridy = 4 contentPane.add(databaseLocationField, constraints) constraints.gridy = 5 contentPane.add(databaseField, constraints) constraints.gridy = 6 contentPane.add(matrixField, constraints) constraints.gridy = 7 contentPane.add(eValueField, constraints) constraints.gridy = 8 contentPane.add(minLengthField, constraints) constraints.gridy = 9 contentPane.add(scaffoldingDistanceField, constraints) constraints.gridy = 10 contentPane.add(promoterScoreField, constraints) constraints.gridy = 11 contentPane.add(queryField, constraints) constraints.gridx = 2 constraints.gridy = 0 constraints.weightx = 0 constraints.fill = GridBagConstraints.NONE constraints.anchor = GridBagConstraints.LINE_END contentPane.add(JButton(LocationAction(blastField)), constraints) constraints.gridy = 1 contentPane.add(JButton(LocationAction(genemarkField)), constraints) constraints.gridy = 2 contentPane.add(JButton(LocationAction(transtermField)), constraints) constraints.gridy = 3 contentPane.add(JButton(LocationAction(tRNAscanField)), constraints) constraints.gridy = 4 contentPane.add(JButton(LocationAction(databaseLocationField)), constraints) constraints.gridy = 11 contentPane.add(JButton(LocationAction(queryField)), constraints) constraints.gridx = 0 constraints.gridy = 12 constraints.anchor = GridBagConstraints.LINE_START contentPane.add(JButton(HelpAction()), constraints) constraints.gridx = 1 constraints.anchor = GridBagConstraints.LINE_END contentPane.add(JButton(OKAction()), constraints) constraints.gridx = 2 contentPane.add(JButton(CancelAction()), constraints) frame.pack() frame.setLocationRelativeTo(None) frame.setVisible(True) while frame.isVisible(): pass self.blastLocation = blastField.getText() self.genemarkLocation = genemarkField.getText() self.transtermLocation = transtermField.getText() self.database = databaseLocationField.getText() + "/" + databaseField.getText() self.matrix = matrixField.getText() self.eValue = float(eValueField.getText()) self.minLength = int(minLengthField.getText()) self.scaffoldingDistance = int(scaffoldingDistanceField.getText()) self.promoterScoreCutoff = float(promoterScoreField.getText()) self.sources = [queryField.getText()]
def __init__(self, extender): super(BeautifierOptionsPanel, self).__init__() self._extender = extender self.contentWrapper = JPanel(GridBagLayout()) self.setViewportView(self.contentWrapper) self.getVerticalScrollBar().setUnitIncrement(16) self.addMouseListener(self.RequestFocusListener( self)) # Let textArea lose focus when click empty area innerContainer = JPanel(GridBagLayout()) innerContainer.setFocusable( True ) # make sure the maxSizeText TextField is not focused when BeautifierOptionsPanel display # generalOptionPanel and it's inner component maxSizeLabel = JLabel("Max Size: ") self.maxSizeText = JTextField(5) self.maxSizeText.setHorizontalAlignment(SwingConstants.RIGHT) self.maxSizeText.addFocusListener(self.MaxSizeTextListener(self)) sizeUnitLabel = JLabel("KB") generalOptionPanel = JPanel(GridBagLayout()) generalOptionPanel.setBorder( BorderFactory.createTitledBorder("General Options")) gbc = GridBagConstraints() gbc.anchor = GridBagConstraints.WEST gbc.gridx = 0 gbc.gridy = 0 generalOptionPanel.add(maxSizeLabel, gbc) gbc.fill = GridBagConstraints.HORIZONTAL gbc.gridx = 1 gbc.gridy = 0 generalOptionPanel.add(self.maxSizeText, gbc) gbc.fill = GridBagConstraints.NONE gbc.gridx = 2 gbc.gridy = 0 gbc.weightx = 1.0 generalOptionPanel.add(sizeUnitLabel, gbc) gbc = GridBagConstraints() gbc.fill = GridBagConstraints.BOTH gbc.gridx = 1 gbc.gridy = 0 gbc.gridheight = 2 innerContainer.add(generalOptionPanel, gbc) # messageTabOptionPanel and it's inner component self.messageTabFormatCheckBoxs = [] for f in supportedFormats: ckb = JCheckBox(f) ckb.addItemListener(self.messageTabFormatListener) self.messageTabFormatCheckBoxs.append(ckb) messageTabOptionPanel = JPanel() messageTabOptionPanel.setLayout( BoxLayout(messageTabOptionPanel, BoxLayout.Y_AXIS)) messageTabOptionPanel.setBorder( BorderFactory.createTitledBorder("Enable in MessageEditorTab")) for b in self.messageTabFormatCheckBoxs: messageTabOptionPanel.add(b) gbc.gridx = 1 gbc.gridy = 2 gbc.gridheight = 9 innerContainer.add(messageTabOptionPanel, gbc) # replaceResponsePanel and it's inner component self.chkEnableReplace = JCheckBox("Enable") self.chkEnableReplace.addItemListener(self.repalceResponseBoxListener) replaceResponseFormatLabel = JLabel("Format") self.replaceResponseFormatCheckBoxs = [] for f in supportedFormats: ckb = JCheckBox(f) ckb.addItemListener(self.replaceResponseFormatListener) self.replaceResponseFormatCheckBoxs.append(ckb) replaceResponseIncludeLabel = JLabel( "Include URL that matches below(one item one line)") self.URLIncludeTextArea = JTextArea(6, 32) self.URLIncludeTextArea.addFocusListener( self.URLIncludeFocusListener(self)) URLIncludeScrollPane = JScrollPane(self.URLIncludeTextArea) URLIncludeScrollPane.setAlignmentX(Component.LEFT_ALIGNMENT) replaceResponseExcludeLabel = JLabel( "Exclude URL that matches below(one item one line)") self.URLExcludeTextArea = JTextArea(5, 32) self.URLExcludeTextArea.addFocusListener( self.URLExcludeFocusListener(self)) URLExcludeScrollPane = JScrollPane(self.URLExcludeTextArea) URLExcludeScrollPane.setAlignmentX(Component.LEFT_ALIGNMENT) replaceResponsePanel = JPanel() replaceResponsePanel.setLayout( BoxLayout(replaceResponsePanel, BoxLayout.Y_AXIS)) replaceResponsePanel.setBorder( BorderFactory.createTitledBorder("Replace PROXY Response")) replaceResponsePanel.add(self.chkEnableReplace) replaceResponsePanel.add(Box.createVerticalStrut(10)) replaceResponsePanel.add(replaceResponseFormatLabel) for b in self.replaceResponseFormatCheckBoxs: replaceResponsePanel.add(b) replaceResponsePanel.add(Box.createVerticalStrut(10)) replaceResponsePanel.add(replaceResponseIncludeLabel) replaceResponsePanel.add(URLIncludeScrollPane) replaceResponsePanel.add(Box.createVerticalStrut(10)) replaceResponsePanel.add(replaceResponseExcludeLabel) replaceResponsePanel.add(URLExcludeScrollPane) gbc.gridy = 11 innerContainer.add(replaceResponsePanel, gbc) # let innerContainer keep away from left and up gbc = GridBagConstraints() gbc.gridx = 1 gbc.gridy = 1 self.contentWrapper.add(Box.createHorizontalStrut(15), gbc) # gbc.ipadx = gbc.ipady = 25 gbc.gridx = 2 self.contentWrapper.add(innerContainer, gbc) # let innerContainer stay left side gbc = GridBagConstraints() gbc.gridx = 3 gbc.gridy = 2 gbc.gridwidth = 1 gbc.weightx = gbc.weighty = 1 paddingPanel = JPanel() self.contentWrapper.add(paddingPanel, gbc) self.setDefaultOptionDisplay()
def createAndShowGUI(self): ''' Create and display the gui. ''' layout = GridBagLayout() c = GridBagConstraints() self.setLayout(layout) projectLabel = Label("Project: ") c.gridx = 0 c.gridy = 0 c.ipady = 5 c.ipadx = 5 c.anchor = GridBagConstraints.EAST layout.setConstraints(projectLabel, c) self.projectChoice = Choice() for name in self.projectNames: self.projectChoice.add(name) c.gridx = 1 c.gridy = 0 c.fill = GridBagConstraints.HORIZONTAL layout.setConstraints(self.projectChoice, c) storageLabel = Label("Storage: ") c.gridx = 0 c.gridy = 1 c.fill = GridBagConstraints.NONE c.anchor = GridBagConstraints.EAST layout.setConstraints(storageLabel, c) self.storageChoice = Choice() for name in self.storageNames: self.storageChoice.add(name) c.gridx = 1 c.gridy = 1 c.fill = GridBagConstraints.HORIZONTAL layout.setConstraints(self.storageChoice, c) self.convertToOMETIFCheckBox = Checkbox("convert to OME-TIF", True) c.gridx = 1 c.gridy = 2 layout.setConstraints(self.convertToOMETIFCheckBox, c) self.uploadAsGroundTruthCheckBox = Checkbox("upload as ground-truth images") c.gridx = 1 c.gridy = 3 layout.setConstraints(self.uploadAsGroundTruthCheckBox, c) self.folderTextField = TextField("", 15) self.folderTextField.setText("<Image-Folder>") c.gridx = 0 c.gridy = 4 layout.setConstraints(self.folderTextField, c) self.folderTextField.setEditable(False) browseButton = Button('Browse...') browseButton.addActionListener(self) c.gridx = 1 c.gridy = 4 layout.setConstraints(browseButton, c) statusLabel = Label("Status:") c.gridy = 5 c.gridx = 0 c.fill = GridBagConstraints.NONE c.anchor = GridBagConstraints.EAST layout.setConstraints(statusLabel, c) self.statusTextField = TextField("Select a folder!", 20) c.gridy = 5 c.gridx = 1 c.fill = GridBagConstraints.HORIZONTAL layout.setConstraints(self.statusTextField, c) self.statusTextField.setEditable(False) self.uploadButton = Button("Upload Images") self.uploadButton.addActionListener(self) c.gridwidth = 2 c.gridheight = 2 c.gridy = 6 c.gridx = 0 c.weighty = 1.0 layout.setConstraints(self.uploadButton, c) self.add(projectLabel) self.add(self.projectChoice) self.add(storageLabel) self.add(self.storageChoice) self.add(self.convertToOMETIFCheckBox) self.add(self.uploadAsGroundTruthCheckBox) self.add(self.folderTextField) self.add(browseButton) self.add(statusLabel) self.add(self.statusTextField) self.add(self.uploadButton) self.setSize(400,300) self.setVisible(True)
def registerExtenderCallbacks(self, callbacks): self._callbacks = callbacks self._helpers = callbacks.getHelpers() callbacks.setExtensionName("Module Importer") self.out = callbacks.getStdout() self.tab = JPanel(GridBagLayout()) self.tableData = [] colNames = ('Enabled', 'Module') self.dataModel = MyTableModel(self.tableData, colNames) self.table = JTable(self.dataModel) self.tablecont = JScrollPane(self.table) c = GridBagConstraints() c.anchor = GridBagConstraints.FIRST_LINE_START c.gridx = 0 c.gridy = 4 c.gridheight = 6 c.gridwidth = 6 c.weightx = 0.6 c.weighty = 0.5 self.tab.add(self.tablecont, c) self.fc = JFileChooser() self.fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY) label_for_openDirectory = JLabel("Module Importer") c = GridBagConstraints() c.anchor = GridBagConstraints.FIRST_LINE_START c.gridx = 0 c.gridy = 0 self.tab.add(label_for_openDirectory, c) label_plugin_desc = JLabel( "This module makes your development of Burp Suite Plugin easier.") label_plugin_desc.setPreferredSize(Dimension(400, 50)) c = GridBagConstraints() c.gridx = 0 c.gridy = 1 self.tab.add(label_plugin_desc, c) label_for_openDirectory = JLabel("Module Path:") c = GridBagConstraints() c.anchor = GridBagConstraints.FIRST_LINE_START c.gridx = 0 c.gridy = 2 self.tab.add(label_for_openDirectory, c) c = GridBagConstraints() c.anchor = GridBagConstraints.FIRST_LINE_START c.gridx = 0 c.gridy = 3 self.input_id = JTextField(40) self.input_id.setEditable(java.lang.Boolean.FALSE) self.tab.add(self.input_id, c) c = GridBagConstraints() c.anchor = GridBagConstraints.FIRST_LINE_START c.gridx = 1 c.gridy = 3 self.openButton = JButton("Open Directory", actionPerformed=self.openDialog) self.tab.add(self.openButton, c) if M_PATH: self.set_fixed_module_path() #callbacks.customizeUiComponent(self.tab) #callbacks.customizeUiComponent(self.table) #callbacks.customizeUiComponent(self.tablecont) callbacks.addSuiteTab(self) callbacks.registerProxyListener(self) return
def __init__(self, extender=None, *rows): self.extender = extender self.table = table = JTable(ParameterProcessingRulesTableModel(*rows)) table.setPreferredScrollableViewportSize(Dimension(500, 70)) table.setRowSorter(TableRowSorter(table.getModel())) table.setFillsViewportHeight(True) gridBagLayout = GridBagLayout() gridBagLayout.columnWidths = [0, 0, 25, 0] gridBagLayout.rowHeights = [0, 0, 0, 0] gridBagLayout.columnWeights = [0.0, 1.0, 1.0, Double.MIN_VALUE] gridBagLayout.rowWeights = [0.0, 0.0, 0.0, Double.MIN_VALUE] self.setLayout(gridBagLayout) addButton = JButton("Add") addButton.addActionListener(AddRemoveParameterListener(table)) addButtonConstraints = GridBagConstraints() addButtonConstraints.fill = GridBagConstraints.HORIZONTAL addButtonConstraints.insets = Insets(0, 0, 5, 5) addButtonConstraints.gridx = 0 addButtonConstraints.gridy = 0 self.add(addButton, addButtonConstraints) removeButton = JButton("Remove") removeButton.addActionListener(AddRemoveParameterListener(table)) removeButtonConstraints = GridBagConstraints() removeButtonConstraints.fill = GridBagConstraints.HORIZONTAL removeButtonConstraints.insets = Insets(0, 0, 5, 5) removeButtonConstraints.gridx = 0 removeButtonConstraints.gridy = 1 self.add(removeButton, removeButtonConstraints) upButton = JButton("Up") upButton.addActionListener(AddRemoveParameterListener(table)) upButtonConstraints = GridBagConstraints() upButtonConstraints.fill = GridBagConstraints.HORIZONTAL upButtonConstraints.insets = Insets(0, 0, 5, 5) upButtonConstraints.gridx = 0 upButtonConstraints.gridy = 2 self.add(upButton, upButtonConstraints) downButton = JButton("Down") downButton.addActionListener(AddRemoveParameterListener(table)) downButtonConstraints = GridBagConstraints() downButtonConstraints.fill = GridBagConstraints.HORIZONTAL downButtonConstraints.anchor = GridBagConstraints.NORTH downButtonConstraints.insets = Insets(0, 0, 5, 5) downButtonConstraints.gridx = 0 downButtonConstraints.gridy = 3 self.add(downButton, downButtonConstraints) scrollPane = JScrollPane(table) scrollPaneConstraints = GridBagConstraints() scrollPaneConstraints.gridwidth = 2 scrollPaneConstraints.gridheight = 5 scrollPaneConstraints.insets = Insets(0, 0, 5, 5) scrollPaneConstraints.anchor = GridBagConstraints.NORTHWEST scrollPaneConstraints.gridx = 1 scrollPaneConstraints.gridy = 0 self.add(scrollPane, scrollPaneConstraints) self.initParameterColumn(table) self.initColumnSizes(table)
def __init__(self, scannerInstance): self.scannerInstance = scannerInstance JSplitPane.__init__(self, JSplitPane.VERTICAL_SPLIT) # super(MyPanel, self).__init__(self, JSplitPane.VERTICAL_SPLIT) # self.setSize(640, 460) self.setBorder(EmptyBorder(20, 20, 20, 20)) self.topPanel = JPanel(BorderLayout(10, 10)) self.topPanel.setBorder(EmptyBorder(0, 0, 10, 0)) # self.topPanel.setBackground(Color.blue) self.bottomPanel = JPanel() self.bottomPanel.setBorder(EmptyBorder(10, 0, 0, 0)) # self.bottomPanel.setBackground(Color.yellow) self.bottomPanel.setPreferredSize(Dimension(580, 40)) # plain self.plainPanel = JPanel(BorderLayout(10, 10)) self.plainTextPane = JTextArea() self.plainTextPane.setLineWrap(True) self.plainTextPane.setEditable(True) self.plainScrollPane = JScrollPane(self.plainTextPane) self.plainScrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER) self.plainPanel.add(JLabel("PLAIN:", SwingConstants.CENTER), BorderLayout.PAGE_START) self.plainPanel.add(self.plainScrollPane, BorderLayout.CENTER) self.topPanel.add(self.plainPanel, BorderLayout.LINE_START) # button self.btnsPanel = JPanel(GridBagLayout()) gbc = GridBagConstraints() gbc.fill = GridBagConstraints.HORIZONTAL gbc.gridx = 0 gbc.gridy = 0 self.btnsPanel.add(JButton("=Encrypt=>", actionPerformed=self.encrypt), gbc) gbc.fill = GridBagConstraints.HORIZONTAL gbc.gridx = 0 gbc.gridy = 1 self.btnsPanel.add(JButton("<=Decrypt=", actionPerformed=self.decrypt), gbc) gbc.fill = GridBagConstraints.HORIZONTAL gbc.gridx = 0 gbc.gridy = 2 gbc.gridheight = 2 gbc.ipadx = 10 self.btnsPanel.add(JButton("SIGN", actionPerformed=self.sign), gbc) # b_enc.setPreferredSize(Dimension(30, 20)) # b_dec.setPreferredSize(Dimension(30, 20)) self.topPanel.add(self.btnsPanel, BorderLayout.CENTER) # cipher self.cipherPanel = JPanel(BorderLayout(10, 10)) self.cipherTextPane = JTextArea() self.cipherTextPane.setLineWrap(True) self.cipherTextPane.setEditable(True) self.cipherScrollPane = JScrollPane(self.cipherTextPane) self.cipherScrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER) self.cipherPanel.add(JLabel("CIPHER:", SwingConstants.CENTER), BorderLayout.PAGE_START) self.cipherPanel.add(self.cipherScrollPane, BorderLayout.CENTER) self.topPanel.add(self.cipherPanel, BorderLayout.LINE_END) self.signPanel = JPanel(FlowLayout(FlowLayout.LEADING, 10, 10)) self.signPanel.add(JLabel("SIGN:", SwingConstants.LEFT), BorderLayout.LINE_START) self.signField = JTextField(50) self.signPanel.add(self.signField) self.bottomPanel.add(self.signPanel) self.plainPanel.setPreferredSize(Dimension(260, 400)) self.btnsPanel.setPreferredSize(Dimension(80, 400)) self.cipherPanel.setPreferredSize(Dimension(260, 400)) self.setTopComponent(self.topPanel) self.setBottomComponent(self.bottomPanel)
def generateDeconvolutionScriptUI(srcDir, tgtDir, calibration, preCropAffines, ROI, postCropAffines): """ Open an UI to automatically generate a script to: 1. Register the views of each time point TM folder, and deconvolve them. 2. Register deconvolved time points to each other, for a range of consecutive time points. Will ask for the file path to the kernel file, and also for the range of time points to process, and for the deconvolution iterations for CM00-CM01, and CM02-CM03. """ template = """ # AUTOMATICALLY GENERATED - %s import sys, os sys.path.append("%s") from lib.isoview import deconvolveTimePoints from mpicbg.models import RigidModel3D, TranslationModel3D from net.imglib2.img.display.imagej import ImageJFunctions as IL # The folder with the sequence of TM\d+ folders, one per time point in the 4D series. # Each folder should contain 4 KLB files, one per camera view of the IsoView microscope. srcDir = "%s" # A folder to save deconvolved images in, and CSV files describing features, point matches and transformations targetDir = "%s" # Path to the volume describing the point spread function (PSF) kernelPath = "%s" calibration = [%s] # An array with 3 floats (identity--all 1.0--because the coarse affines, that is, # the camera transformations, already include the scaling to isotropy computed using the original calibration. # The transformations of each timepoint onto the camera at index zero. def cameraTransformations(dims0, dims1, dims2, dims3, calibration): return { 0: [%s], 1: [%s], 2: [%s], 3: [%s] } # Deconvolution parameters paramsDeconvolution = { "blockSizes": None, # None means the image size + kernel size. Otherwise specify like e.g. [[128, 128, 128]] for img in images] "CM_0_1_n_iterations": %i, "CM_2_3_n_iterations": %i, } # Joint dictionary of parameters params = {} params.update(paramsDeconvolution) # A region of interest for each camera view, for cropping after registration but prior to deconvolution roi = ([%s], # array of 3 integers, top-left coordinates [%s]) # array of 3 integers, bottom-right coordinates # All 4 cameras relative to CM00 fineTransformsPostROICrop = \ [[1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0], [%s], [%s], [%s]] deconvolveTimePoints(srcDir, targetDir, kernelPath, calibration, cameraTransformations, fineTransformsPostROICrop, params, roi, fine_fwd=True, subrange=range(%i, %i)) """ od = OpenDialog("Choose kernel file", srcDir) kernel_path = od.getPath() if not kernel_path: JOptionPane.showMessageDialog(None, "Can't proceed without a filepath to the kernel", "Alert", JOptionPane.ERROR_MESSAGE) return panel = JPanel() panel.setBorder(BorderFactory.createEmptyBorder(10,10,10,10)) gb = GridBagLayout() panel.setLayout(gb) gc = GBC() msg = ["Edit parameters, then push the button", "to generate a script that, when run,", "will execute the deconvolution for each time point", "saving two 3D stacks per time point as ZIP files", "in the target directory under subfolder 'deconvolved'.", "Find the script in a new Script Editor window.", " "] gc.gridy = -1 # init for line in msg: label = JLabel(line) gc.anchor = GBC.WEST gc.gridx = 0 gc.gridy += 1 gc.gridwidth = 2 gc.gridheight = 1 gb.setConstraints(label, gc) panel.add(label) strings = [["Deconvolution iterations", "CM_0_1_n_iterations", "CM_2_3_n_iterations"], ["Range", "First time point", "Last time point"]] params = {"CM_0_1_n_iterations": 5, "CM_2_3_n_iterations": 7, "First time point": 0, "Last time point": -1} # -1 means last insertFloatFields(panel, gb, gc, params, strings) def asString(affine): matrix = zeros(12, 'd') affine.toArray(matrix) return ",".join(imap(str, matrix)) def generateScript(event): script = template % (str(datetime.now()), filter(lambda path: path.endswith("IsoView-GCaMP"), sys.path)[-1], srcDir, tgtDir, kernel_path, ", ".join(imap(str, calibration)), asString(preCropAffines[0]), asString(preCropAffines[1]), asString(preCropAffines[2]), asString(preCropAffines[3]), params["CM_0_1_n_iterations"], params["CM_2_3_n_iterations"], ", ".join(imap(str, ROI[0])), ", ".join(imap(str, ROI[1])), asString(postCropAffines[1]), asString(postCropAffines[2]), asString(postCropAffines[3]), params["First time point"], params["Last time point"]) tab = None for frame in JFrame.getFrames(): if str(frame).startswith("org.scijava.ui.swing.script.TextEditor["): try: tab = frame.newTab(script, "python") break except: print sys.exc_info() if not tab: try: now = datetime.now() with open(os.path.join(System.getProperty("java.io.tmpdir"), "script-%i-%i-%i_%i:%i.py" % (now.year, now.month, now.day, now.hour, now.minute)), 'w') as f: f.write(script) except: print sys.exc_info() print script gen = JButton("Generate script") gen.addActionListener(generateScript) gc.anchor = GBC.CENTER gc.gridx = 0 gc.gridy += 1 gc.gridwidth = 2 gb.setConstraints(gen, gc) panel.add(gen) frame = JFrame("Generate deconvolution script") frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE) frame.getContentPane().add(panel) frame.pack() frame.setLocationRelativeTo(None) # center in the screen frame.setVisible(True)
search_field = JTextField("", keyPressed=typingInSearchField) gb.setConstraints(search_field, c) all.add(search_field) # Bottom left element: the table, wrapped in a scrollable component table = JTable(TableModel()) table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION) #table.setCellSelectionEnabled(True) table.setAutoCreateRowSorter( True) # to sort the view only, not the data in the underlying TableModel c.gridx = 0 c.gridy = 1 c.anchor = GridBagConstraints.NORTHWEST c.fill = GridBagConstraints.BOTH # resize with the frame c.weightx = 1.0 c.gridheight = 2 jsp = JScrollPane(table) jsp.setMinimumSize(Dimension(400, 500)) gb.setConstraints(jsp, c) all.add(jsp) # Convert from row index in the view (could e.g. be sorted) # to the index in the underlying table model def getSelectedRowIndex(): viewIndex = table.getSelectionModel().getLeadSelectionIndex() modelIndex = table.convertRowIndexToModel(viewIndex) return modelIndex # Top component: a text area showing the full file path to the image in the selected table row
def show_detectable_objects_dialog(self, e): parentComponent = SwingUtilities.windowForComponent(self.panel0) self.detectable_obejcts_dialog = JDialog( parentComponent, "List of Objects to Detect", ModalityType.APPLICATION_MODAL) panel = JPanel() self.detectable_obejcts_dialog.add(panel) gbPanel = GridBagLayout() gbcPanel = GridBagConstraints() panel.setLayout(gbPanel) y = 0 x = 0 for line in self.local_settings.getClassesOfInterest(): if y > 15: y = 0 x = x + 1 class_check_box = JCheckBox(line['name']) self.classes_of_interest_checkboxes.append(class_check_box) class_check_box.setEnabled(True) class_check_box.setSelected(line['enabled']) class_check_box.addItemListener(self.on_class_checkbox_clicked) gbcPanel.gridx = x gbcPanel.gridy = y gbcPanel.gridwidth = 1 gbcPanel.gridheight = 1 gbcPanel.fill = GridBagConstraints.BOTH gbcPanel.weightx = 1 gbcPanel.weighty = 1 gbcPanel.anchor = GridBagConstraints.NORTH gbPanel.setConstraints(class_check_box, gbcPanel) panel.add(class_check_box) y = y + 1 blank_1_L = JLabel(" ") blank_1_L.setEnabled(True) gbcPanel.gridx = 0 gbcPanel.gridy = y + 1 gbcPanel.gridwidth = 1 gbcPanel.gridheight = 1 gbcPanel.fill = GridBagConstraints.BOTH gbcPanel.weightx = 1 gbcPanel.weighty = 0 gbcPanel.anchor = GridBagConstraints.NORTH gbPanel.setConstraints(blank_1_L, gbcPanel) panel.add(blank_1_L) deselect_all_button = JButton("Deselect all") deselect_all_button.setEnabled(True) deselect_all_button.addActionListener(self.on_deselect_all_clicked) gbcPanel.gridx = 1 gbcPanel.gridy = y + 2 gbcPanel.gridwidth = 1 gbcPanel.gridheight = 1 gbcPanel.fill = GridBagConstraints.BOTH gbcPanel.weightx = 2 gbcPanel.weighty = 1 gbcPanel.anchor = GridBagConstraints.NORTH gbPanel.setConstraints(deselect_all_button, gbcPanel) panel.add(deselect_all_button) select_all_button = JButton("Select all") select_all_button.setEnabled(True) select_all_button.addActionListener(self.on_select_all_clicked) gbcPanel.gridx = 3 gbcPanel.gridy = y + 2 gbcPanel.gridwidth = 1 gbcPanel.gridheight = 1 gbcPanel.fill = GridBagConstraints.BOTH gbcPanel.weightx = 2 gbcPanel.weighty = 1 gbcPanel.anchor = GridBagConstraints.NORTH gbPanel.setConstraints(select_all_button, gbcPanel) panel.add(select_all_button) blank_2_L = JLabel(" ") blank_2_L.setEnabled(True) gbcPanel.gridx = 0 gbcPanel.gridy = y + 3 gbcPanel.gridwidth = 1 gbcPanel.gridheight = 1 gbcPanel.fill = GridBagConstraints.BOTH gbcPanel.weightx = 1 gbcPanel.weighty = 0 gbcPanel.anchor = GridBagConstraints.NORTH gbPanel.setConstraints(blank_2_L, gbcPanel) panel.add(blank_2_L) cancel_button = JButton("Cancel") cancel_button.setEnabled(True) cancel_button.addActionListener( self.on_cancel_classes_of_interest_click) gbcPanel.gridx = 1 gbcPanel.gridy = y + 4 gbcPanel.gridwidth = 1 gbcPanel.gridheight = 1 gbcPanel.fill = GridBagConstraints.BOTH gbcPanel.weightx = 2 gbcPanel.weighty = 1 gbcPanel.anchor = GridBagConstraints.NORTH gbPanel.setConstraints(cancel_button, gbcPanel) panel.add(cancel_button) save_button = JButton("Save") save_button.setEnabled(True) save_button.addActionListener(self.on_save_classes_of_interest_click) gbcPanel.gridx = 3 gbcPanel.gridy = y + 4 gbcPanel.gridwidth = 1 gbcPanel.gridheight = 1 gbcPanel.fill = GridBagConstraints.BOTH gbcPanel.weightx = 2 gbcPanel.weighty = 1 gbcPanel.anchor = GridBagConstraints.NORTH gbPanel.setConstraints(save_button, gbcPanel) panel.add(save_button) blank_3_L = JLabel(" ") blank_3_L.setEnabled(True) gbcPanel.gridx = 0 gbcPanel.gridy = y + 5 gbcPanel.gridwidth = 1 gbcPanel.gridheight = 1 gbcPanel.fill = GridBagConstraints.BOTH gbcPanel.weightx = 1 gbcPanel.weighty = 0 gbcPanel.anchor = GridBagConstraints.NORTH gbPanel.setConstraints(blank_3_L, gbcPanel) panel.add(blank_3_L) self.detectable_obejcts_dialog.pack() screenSize = Toolkit.getDefaultToolkit().getScreenSize() self.detectable_obejcts_dialog.setLocation( int((screenSize.getWidth() / 2) - (self.detectable_obejcts_dialog.getWidth() / 2)), int((screenSize.getHeight() / 2) - (self.detectable_obejcts_dialog.getHeight() / 2))) self.detectable_obejcts_dialog.setVisible(True)
def registerExtenderCallbacks(self, callbacks): self.callbacks = callbacks self.helpers = callbacks.getHelpers() callbacks.setExtensionName("Session Authentication Tool") self.out = callbacks.getStdout() # definition of suite tab self.tab = JPanel(GridBagLayout()) self.tabledata = MappingTableModel(callbacks) self.table = JTable(self.tabledata) #self.table.getColumnModel().getColumn(0).setPreferredWidth(50); #self.table.getColumnModel().getColumn(1).setPreferredWidth(100); self.tablecont = JScrollPane(self.table) c = GridBagConstraints() c.fill = GridBagConstraints.HORIZONTAL c.anchor = GridBagConstraints.FIRST_LINE_START c.gridx = 0 c.gridy = 0 c.gridheight = 6 c.weightx = 0.3 c.weighty = 0.5 self.tab.add(self.tablecont, c) c = GridBagConstraints() c.weightx = 0.1 c.anchor = GridBagConstraints.FIRST_LINE_START c.gridx = 1 c.gridy = 0 label_id = JLabel("Identifier:") self.tab.add(label_id, c) self.input_id = JTextField(20) self.input_id.setToolTipText("Enter the identifier which is used by the application to identifiy a particular test user account, e.g. a numerical user id or a user name.") c.gridy = 1 self.tab.add(self.input_id, c) c.gridy = 2 label_content = JLabel("Content:") self.tab.add(label_content, c) self.input_content = JTextField(20, actionPerformed=self.btn_add_id) self.input_content.setToolTipText("Enter some content which is displayed in responses of the application and shows that the current session belongs to a particular user, e.g. the full name of the user.") c.gridy = 3 self.tab.add(self.input_content, c) self.btn_add = JButton("Add/Edit Identity", actionPerformed=self.btn_add_id) c.gridy = 4 self.tab.add(self.btn_add, c) self.btn_del = JButton("Delete Identity", actionPerformed=self.btn_del_id) c.gridy = 5 self.tab.add(self.btn_del, c) callbacks.customizeUiComponent(self.tab) callbacks.customizeUiComponent(self.table) callbacks.customizeUiComponent(self.tablecont) callbacks.customizeUiComponent(self.btn_add) callbacks.customizeUiComponent(self.btn_del) callbacks.customizeUiComponent(label_id) callbacks.customizeUiComponent(self.input_id) callbacks.addSuiteTab(self) callbacks.registerScannerCheck(self) callbacks.registerIntruderPayloadGeneratorFactory(self) callbacks.registerContextMenuFactory(self)
def specifyRoiUI(roi=Roi(0, 0, 0, 0)): # A panel in which to place UI elements panel = JPanel() panel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)) gb = GridBagLayout() panel.setLayout(gb) gc = GBC() bounds = roi.getBounds() if roi else Rectangle() textfields = [] roimakers = [] # Basic properties of most UI elements, will edit when needed gc.gridx = 0 # can be any natural number gc.gridy = 0 # idem. gc.gridwidth = 1 # when e.g. 2, the UI element will occupy two horizontally adjacent grid cells gc.gridheight = 1 # same but vertically gc.fill = GBC.NONE # can also be BOTH, VERTICAL and HORIZONTAL for title in ["x", "y", "width", "height"]: # label gc.gridx = 0 gc.anchor = GBC.EAST label = JLabel(title + ": ") gb.setConstraints(label, gc) # copies the given constraints 'gc', # so we can modify and reuse gc later. panel.add(label) # text field, below the title gc.gridx = 1 gc.anchor = GBC.WEST text = str(getattr(bounds, title)) # same as e.g. bounds.x, bounds.width, ... textfield = JTextField(text, 10) # 10 is the size of the field, in digits gb.setConstraints(textfield, gc) panel.add(textfield) textfields.append( textfield) # collect all 4 created textfields for the listeners # setup ROI and text field listeners listener = RoiMaker(textfields, len(textfields) - 1) # second argument is the index of textfield # in the list of textfields. roimakers.append(listener) textfield.addKeyListener(listener) textfield.addMouseWheelListener(listener) # Position next ROI property in a new row by increasing the Y coordinate of the layout grid gc.gridy += 1 # User documentation (uses HTML to define line breaks) doc = JLabel( "<html><body><br />Click on a field to activate it, then:<br />" + "Type in integer numbers<br />" + "or use arrow keys to increase by 1<br />" + "or use the scroll wheel on a field.</body></html>") gc.gridx = 0 # start at the first column gc.gridwidth = 2 # Spans both columns gb.setConstraints(doc, gc) panel.add(doc) # Listen to changes in the ROI of imp roilistener = TextFieldUpdater(textfields) Roi.addRoiListener(roilistener) # Show window frame = JFrame("Specify rectangular ROI") frame.getContentPane().add(panel) frame.pack() frame.setLocationRelativeTo(None) # center in the screen frame.setDefaultCloseOperation( JFrame.DO_NOTHING_ON_CLOSE) # prevent closing the window frame.addWindowListener( CloseControl(roilistener)) # handles closing the window frame.setVisible(True)