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 getTestingPane(self):
        def openTesting(event):
            file = JFileChooser()
            file.showOpenDialog(self)
            val = file.showOpenDialog(self)
            if (val == JFileChooser.APPROVE_OPTION):
                f = file.getSelectedFile()
                #print f.getName()
                tb.append(f.getName() + ' selected \n')

        def runTest(event):
            print "test running"

        t = TitledBorder('Testing')
        p = JPanel(GridBagLayout())
        c = GridBagConstraints(anchor=WEST)
        p.add(JLabel('Choose file for testing:      '), c)
        c = GridBagConstraints(gridx=1, gridy=0, anchor=EAST)
        b = JButton('Open file', actionPerformed=openTesting)
        p.add(b, c)
        c = GridBagConstraints(gridx=0, gridy=2, gridwidth=2, anchor=WEST)
        test = JButton('Test', actionPerformed=runTest)
        p.add(test, c)
        c = GridBagConstraints(gridx=0, gridy=3, anchor=WEST)
        p.add(JLabel('Display'), c)
        c = GridBagConstraints(gridx=0,
                               gridy=4,
                               gridwidth=2,
                               fill=GridBagConstraints.HORIZONTAL)
        tb = JTextArea(rows=9)
        scroll = JScrollPane(tb)
        p.add(scroll, c)
        p.setBorder(t)
        return p
Example #3
0
    def p_build_ui(self, event):
        """
        Adds a list of checkboxes, one for each loaded plugin
        to the Selct plugins window
        """
        if not self.loaded_p_list:
            self.update_scroll("[!!] No plugins loaded!")
            return

        scroll_pane = JScrollPane()
        scroll_pane.setPreferredSize(Dimension(200, 250))
        check_frame = JPanel(GridBagLayout())
        constraints = GridBagConstraints()
        constraints.fill = GridBagConstraints.HORIZONTAL
        constraints.gridy = 0
        constraints.anchor = GridBagConstraints.FIRST_LINE_START

        for plug in self.loaded_p_list:
            check_frame.add(JCheckBox(plug.get_name(), plug.enabled,
                                      actionPerformed=self.update_box),
                            constraints)
            constraints.gridy += 1

        vport = JViewport()
        vport.setView(check_frame)
        scroll_pane.setViewport(vport)
        self.window.contentPane.add(scroll_pane)
        self.window.pack()
        self.window.setVisible(True)
Example #4
0
    def p_build_ui(self, event):
        """
        Adds a list of checkboxes, one for each loaded plugin
        to the Selct plugins window
        """
        if not self.loaded_p_list:
            self.update_scroll("[!!] No plugins loaded!")
            return

        scroll_pane = JScrollPane()
        scroll_pane.setPreferredSize(Dimension(200, 250))
        check_frame = JPanel(GridBagLayout())
        constraints = GridBagConstraints()
        constraints.fill = GridBagConstraints.HORIZONTAL
        constraints.gridy = 0
        constraints.anchor = GridBagConstraints.FIRST_LINE_START

        for plug in self.loaded_p_list:
            check_frame.add(JCheckBox(plug.get_name(), plug.enabled,
                                      actionPerformed=self.update_box),
                            constraints)
            constraints.gridy += 1

        vport = JViewport()
        vport.setView(check_frame)
        scroll_pane.setViewport(vport)
        self.window.contentPane.add(scroll_pane)
        self.window.pack()
        self.window.setVisible(True)
Example #5
0
 def addStatusLabel(self, msg):
     gbc = GridBagConstraints()
     gbc.anchor = GridBagConstraints.NORTHWEST
     gbc.gridx = 0
     gbc.gridy = 7
     lab = JLabel(msg)
     self.add(lab, gbc)
Example #6
0
    def __init__(self, callbacks):
        self._callbacks = callbacks
        self.tab = JPanel(GridBagLayout())

        about_constraints = GridBagConstraints()

        about_author = (("<html><center><h2>SpyDir</h2><b>Version:</b> "
                         "%s<br/>Created by: <em>Ryan Reid</em>"
                         " (@_aur3lius)<br/>https://github.com/aur3lius-dev/"
                         "SpyDir</center><br/>")
                        % VERSION)
        about_spydir = """<em><center>
        SpyDir is an extension that assists in the enumeration of
        application<br/>
        endpoints via an input directory containing the application's<br/>
        source code. It provides an option to process files as endpoints,<br/>
        think: ASP, PHP, HTML, or parse files to attempt to enumerate<br/>
        endpoints via plugins, think: MVC. Users may opt to send the<br/>
        discovered endpoints directly to the Burp Spider.
        </center></em><br/>
        This tool is in <b>Alpha</b>! <b>Please</b> provide feedback on the
        GitHub page!<br/><br/>"""
        getting_started = """<b>Getting started:</b><br/>
         <ul>
            <li>Add a local source repository</li>
            <li>Add the target URL</li>
            <li>Use the String delimiter to construct the appropriate
             directory path (if necessary)</li>
            <li>Alternatively, parse each file by selecting plugins
             and checking the checkbox</li>
            <li>Explicitly define the file extensions to process</li>
            <li>Parse the directory</li>
            <li>Verify output is correct <b>before</b> sending to spider</li>
            <li>Send requests to the Burp Spider</li>
        </ul>
        """
        advanced_info = r"""<html><b>String Delimiter</b><br/>
        String Delimiter allows us to append the necessary section
        of the folder structure.<br/>
        Suppose the target application is hosted at the following URL:
        https://localhost:8080. <br/>The target code base is stored in:
        'C:\Source\TestApp'. <br/>Within the TestApp folder there is a
        subfolder, 'views', with static .html files.<br/>
        In this case the String Delimiter will need to equal 'TestApp'.
        <br/>With the expectation that the tool will produce an example URL
        will such as:<br/>https://localhost:8080/views/view1.html.<br/>
        <b>Note:</b> String Delimiter is ignored if parsing files using
        plugins!
        </html>"""
        about_constraints.anchor = GridBagConstraints.FIRST_LINE_START
        about_constraints.weightx = 1.0
        about_constraints.weighty = 1.0
        self.tab.add(JLabel("%s\n%s\n%s\n%s" % (about_author, about_spydir,
                                                getting_started,
                                                advanced_info)),
                     about_constraints)
Example #7
0
 def addSigningKeyTextArea(self):
     self._signingKeyTextArea = JTextArea()
     self._signingKeyTextArea.setColumns(50)
     self._signingKeyTextArea.setRows(10)
     self._signingKeyScrollPane = JScrollPane(self._signingKeyTextArea)
     c = GridBagConstraints()
     c.gridx = 1
     c.gridy = 6
     c.anchor = GridBagConstraints.LINE_START
     self._configurationPanel.add(self._signingKeyScrollPane,c)
Example #8
0
 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
Example #9
0
def cachedBPROM(genome, fileName, frame):
  """
  genome: Genome as a string.
  fileName: File to save the BPROM results in.
  swing: A JFrame or None.  If this is None then messages will be printed, if it isn't then
         they will also be put in a dialog box.

  return: Results of the BPROM prediction stored in a list of Promoter objects.

  If the file Specified by fileName already exists then this function simply parses the file
  already there.  Also, if a request is made to BPROM and nothing is returned, no file is
  created, the user is warned, and an empty list is returned.
  """
  offset = 25 if ".forward.bprom" in fileName else 50
  direction = "forward" if offset == 50 else "reverse"
    
  def getPromoters():
    input = open(fileName, "r")
    results = parseBPROM(input.read())
    input.close()
    return results

  if not os.path.isfile(fileName):
    results = urllib.urlopen("http://linux1.softberry.com/cgi-bin/programs/gfindb/bprom.pl",
                             urllib.urlencode({"DATA" : genome}))
    resultString = results.read()
    results.close()
    resultString = resultString[resultString.find("<pre>"):resultString.find("</pre>")]
    resultString = re.sub("<+.+>+", "", resultString).strip()
    if resultString:
      output = open(fileName, "w")
      output.write(resultString)
      output.close()
      return getPromoters()
    else:
      if frame:
        messageFrame = JFrame("BPROM Error",
                              defaultCloseOperation = WindowConstants.DISPOSE_ON_CLOSE)
        messageFrame.setLocation(frame.location().x + offset, frame.location().y + offset)
        messageFrame.contentPane.layout = GridBagLayout()
        constraints = GridBagConstraints()
        constraints.gridx, constraints.gridy = 0, 0
        constraints.gridwidth, constraints.gridheight = 1, 1
        constraints.fill = GridBagConstraints.BOTH
        constraints.weightx, constraints.weighty = 1, 1
        messageFrame.contentPane.add(JLabel("<html>The pipeline will continue to run but BPROM<br/>did not process the request for promoters on the<br/>" + direction + " strand.  Try again tomorrow.</html>"), constraints)
        constraints.gridx, constraints.gridy = 0, 1
        constraints.fill = GridBagConstraints.NONE
        constraints.weightx, constraints.weighty = 1, 1
        constraints.anchor = GridBagConstraints.LINE_END
        messageFrame.contentPane.add(JButton("Ok", actionPerformed = lambda e: messageFrame.dispose()), constraints)
        messageFrame.pack()
        messageFrame.visible = True
      print "BPROM Error:", "The pipeline will continue to run but BPROM did not process the request for promoters on the " + direction + " strand.  Try again tomorrow"
      return []
  else:
    return getPromoters()
Example #10
0
def add(parent,
        child,
        gridx=0,
        gridy=0,
        anchor=GC.NORTHWEST,
        fill=GC.NONE,
        weightx=0.0,
        weighty=0.0,
        gridwidth=1):
    c = GC()
    c.gridx = gridx
    c.gridy = gridy
    c.anchor = anchor
    c.fill = fill
    c.weightx = weightx
    c.weighty = weighty
    c.gridwidth = gridwidth
    """
  # Same, more flexible, less verbose: BUT FAILS at parent, child args
  kv = locals() # dict of local variables including the function arguments
  c = GC()
  for key, value in kv.iteritems():
    setattr(c, key, value)
  """
    #
    parent.getLayout().setConstraints(child, c)
    parent.add(child)
Example #11
0
    def initComponents(self):
        self.setLayout(GridBagLayout())

        gbc = GridBagConstraints()
        gbc.anchor = GridBagConstraints.NORTHWEST
        gbc.gridx = 0
        gbc.gridy = 0

        descriptionLabel = JLabel("FEA - Credit Card module")
        self.add(descriptionLabel, gbc)

        self.cbGenerateExcel = JCheckBox("Generate Excel format report (more detailed)", actionPerformed=self.cbGenerateExcelActionPerformed)
        self.cbGenerateExcel.setSelected(True)
        gbc.gridy = 2
        self.add(self.cbGenerateExcel, gbc)

        self.cbGenerateCSV = JCheckBox("Generate CSV format report (plaintext)", actionPerformed=self.cbGenerateCSVActionPerformed)
        self.cbGenerateCSV.setSelected(True)
        gbc.gridy = 3
        self.add(self.cbGenerateCSV, gbc)

        self.cbRemoveFalsePositives = JCheckBox("Remove False Positives from Autopsy", actionPerformed=self.cbRemoveFalsePositivesActionPerformed)
        self.cbRemoveFalsePositives.setSelected(True)
        gbc.gridy = 4
        self.cbRemoveFalsePositives.setEnabled(False)
        self.add(self.cbRemoveFalsePositives, gbc)
Example #12
0
    def addComponents( self, container ) :
        container.setLayout( GridBagLayout() )

        names = '1,2,3 being the third number'.split( ',' )
        for col in range( len( names ) ) :
            c = GridBagConstraints()
            container.add( JButton( names[ col ] ), c )
Example #13
0
    def tagLoad(self):
        # 创建窗口 开始
        self.tabs = JTabbedPane()

        self.settings = JPanel(GridBagLayout())
        self.forward_requests_settings = JPanel(GridBagLayout())
        self.white_list_domain_settings = JPanel(GridBagLayout())

        c = GridBagConstraints()

        # 界面选项卡1-标签加载
        self.tag_1(c)
        self.tag_2(c)

        # 界面选项卡2-标签加载
        self.tag_3(c)
        self.tag_4(c)

        # 界面选项卡3-标签加载
        self.tag_5(c)

        # 添加选项卡
        self.tabs.addTab(u'基本设置', self.settings)
        self.tabs.addTab(u'http请求转发设置', self.forward_requests_settings)
        self.tabs.addTab(u'白名单域名设置', self.white_list_domain_settings)

        self._callbacks.customizeUiComponent(self.tabs)
        self._callbacks.addSuiteTab(self)
Example #14
0
 def __createTableConstraints(self):
     constr = GridBagConstraints()
     constr.fill = GridBagConstraints.BOTH
     constr.weighty = 1000
     constr.weightx = 2
     constr.gridwidth = 4
     constr.gridx = 0
     constr.gridy = 2
     return constr
Example #15
0
    def addComponents(self, container):
        container.setLayout(GridBagLayout())

        names = '1,2,3 being the third number'.split(',')
        for col in range(len(names)):
            c = GridBagConstraints()
            c.gridx = col  # gridx is the grid column
            c.gridy = col  # gridy is the grid row #
            container.add(JButton(names[col]), c)

        c = GridBagConstraints()
        c.gridx = 1
        c.gridy = 3  # put this one on the next row
        c.ipady = 32  # make this one taller
        container.add(JButton('Four shalt thou not count'), c)
Example #16
0
 def __createDropDownConstraints(self):
     constr = GridBagConstraints()
     constr.fill = GridBagConstraints.HORIZONTAL
     constr.weighty = 1
     constr.gridwidth = 4
     constr.gridx = 0
     constr.gridy = 0
     return constr
Example #17
0
 def __createRadioConstraints(self, mode):
     constr = GridBagConstraints()
     constr.fill = GridBagConstraints.HORIZONTAL
     constr.weighty = 1
     constr.weightx = 1
     if   mode == 'cases':    constr.gridx = 2
     elif mode == 'commands': constr.gridx = 3
     constr.gridy = 1
     return constr
Example #18
0
 def __setupLayout(self):
     self.setLayout(GridBagLayout())
     constr = GridBagConstraints()
     constr.weighty = 1
     constr.weightx = 1
     constr.gridx = 0
     constr.gridy = 1
     constr.fill = GridBagConstraints.BOTH
     return constr
Example #19
0
 def __init__(self, view, sys):
     JDialog.__init__(self, view,
                      jEdit.getProperty("jython.pathhandler.title"))
     self.sys = sys
     content = self.contentPane
     content.layout = BorderLayout()
     upperPanel = JPanel(BorderLayout())
     leftPanel = JPanel(BorderLayout(), border = \
      BorderFactory.createTitledBorder(jEdit.getProperty("jython.pathhandler.pathborder")))
     self.model = DefaultListModel()
     for s in sys.path:
         self.model.addElement(s)
     self.pathlist = JList(
         self.model, selectionMode=ListSelectionModel.SINGLE_SELECTION)
     leftPanel.add(JScrollPane(self.pathlist))
     rightPanel = JPanel(GridBagLayout())
     constraints = GridBagConstraints()
     constraints.insets = Insets(5, 5, 5, 5)
     constraints.gridy = GridBagConstraints.RELATIVE
     constraints.gridx = 0
     buttons = [("Plus.png", "New...", self.new), \
      ("ButtonProperties.png", "Edit...", self.edit),
      ("Minus.png", "Remove", self.remove), \
      ("ArrowU.png", "Move Up", self.up), \
      ("ArrowD.png", "Move down", self.down)]
     for (i, t, a) in buttons:
         rightPanel.add(JButton(icon = GUIUtilities.loadIcon(i), \
          toolTipText=t, actionPerformed=a), constraints)
     upperPanel.add(leftPanel, BorderLayout.CENTER)
     upperPanel.add(rightPanel, BorderLayout.EAST)
     content.add(upperPanel, BorderLayout.CENTER)
     lowerPanel = JPanel(FlowLayout(FlowLayout.RIGHT))
     self.saveAsk = JCheckBox(jEdit.getProperty("options.jython.saveJythonPathTitle"), \
      selected = jEdit.getBooleanProperty("options.jython.saveJythonPath"), actionPerformed = self.saveAsk)
     ok = JButton("Ok", actionPerformed=self.__ok)
     lowerPanel.add(self.saveAsk)
     lowerPanel.add(ok)
     self.rootPane.defaultButton = ok
     lowerPanel.add(JButton("Cancel", actionPerformed=self.__cancel))
     content.add(lowerPanel, BorderLayout.SOUTH)
Example #20
0
 def __initTable(self):
     ''' construct the test case table '''
     self.model = TestCaseModel(self.testcases)
     self.table = TestCaseTable(self.model, self.testcases)
     self.scrollpane = JScrollPane(self.table)
     self.setLayout(GridBagLayout())
     self.constr = GridBagConstraints()
     self.constr.weighty = 1
     self.constr.weightx = 1
     self.constr.gridx = 0
     self.constr.gridy = 1
     self.constr.fill = GridBagConstraints.BOTH
     self.add(self.scrollpane,self.constr)
Example #21
0
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 __init__(self):
        # Make the frame and set its properties
        self.frame = JFrame(
            "File Translator",
            defaultCloseOperation=WindowConstants.EXIT_ON_CLOSE,
            layout=GridBagLayout())
        self.frame.setSize(1200, 800)

        # Make a GridBagLayout for this frame
        gridbag = GridBagLayout()
        constraints = GridBagConstraints()
        constraints.fill = GridBagConstraints.CENTER

        # Make sure to have a panel to hold everything
        self.loginPanel = JPanel(GridLayout(0, 2))
        self.frame.add(self.loginPanel)
        gridbag.setConstraints(self.loginPanel, constraints)
        self.loginPanel.setLayout(gridbag)

        # Entry for the path
        self.usernameField = JTextField('', 30)
        self.loginPanel.add(JLabel("username:"******"password:"))
        self.loginPanel.add(self.textField)

        # Make a button to enter the information
        self.loginButton = JButton('Enter', actionPerformed=enter_button)
        self.loginPanel.add(self.loginButton)
        self.frame.add(self.loginPanel)

        # Make everything visible and make sure it starts at centre of screen
        self.frame.pack()
        self.frame.setLocationRelativeTo(None)
        self.frame.setVisible(True)
Example #23
0
def arrange_plots(regplot, plotm, plotd):
    """
    arranges the plots in a certain order, 
    regplot and plotm in first row next to each other
    plotd in second row 
    """
    from javax.swing import JPanel, JFrame
    from java.awt import GridBagLayout, GridBagConstraints
    mainPanel = JPanel()
    mainPanel.setLayout(GridBagLayout())
    c = GridBagConstraints()
    c.fill = c.BOTH
    c.weightx, c.weighty = 0.5, 1
    c.gridx, c.gridy, c.gridwidth, c.gridheight = 0, 0, 10, 4
    c.weightx, c.weighty = 0.5, 1
    c.gridx, c.gridy, c.gridwidth, c.gridheight = 0, 0, 10, 4
    mainPanel.add(regplot)
    c.gridx, c.gridy, c.gridwidth, c.gridheight = 0, 0, 10, 4
    c.weightx, c.weighty = 1, 1
    mainPanel.add(plotm, c)
    c.gridx, c.gridy, c.gridwidth, c.gridheight = 0, 4, 10, 6
    mainPanel.add(plotd, c)
    return mainPanel
Example #24
0
 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 initComponents(self):
        self.panel0 = JPanel()

        self.rbgPanel0 = ButtonGroup()
        self.gbPanel0 = GridBagLayout()
        self.gbcPanel0 = GridBagConstraints()
        self.panel0.setLayout(self.gbPanel0)

        self.Label_2 = JLabel(
            "List of File Extensions to Export, Comma Seperated no dots (.)")
        self.Label_2.setEnabled(True)
        self.gbcPanel0.gridx = 2
        self.gbcPanel0.gridy = 5
        self.gbcPanel0.gridwidth = 1
        self.gbcPanel0.gridheight = 1
        self.gbcPanel0.fill = GridBagConstraints.BOTH
        self.gbcPanel0.weightx = 1
        self.gbcPanel0.weighty = 0
        self.gbcPanel0.anchor = GridBagConstraints.NORTH
        self.gbPanel0.setConstraints(self.Label_2, self.gbcPanel0)
        self.panel0.add(self.Label_2)

        self.fileExtension_TF = JTextField(30, focusLost=self.setFileExtension)
        self.fileExtension_TF.setEnabled(True)
        self.gbcPanel0.gridx = 2
        self.gbcPanel0.gridy = 7
        self.gbcPanel0.gridwidth = 1
        self.gbcPanel0.gridheight = 1
        self.gbcPanel0.fill = GridBagConstraints.BOTH
        self.gbcPanel0.weightx = 1
        self.gbcPanel0.weighty = 0
        self.gbcPanel0.anchor = GridBagConstraints.NORTH
        self.gbPanel0.setConstraints(self.fileExtension_TF, self.gbcPanel0)
        self.panel0.add(self.fileExtension_TF)

        self.Blank_2 = JLabel(" ")
        self.Blank_2.setEnabled(True)
        self.gbcPanel0.gridx = 2
        self.gbcPanel0.gridy = 9
        self.gbcPanel0.gridwidth = 1
        self.gbcPanel0.gridheight = 1
        self.gbcPanel0.fill = GridBagConstraints.BOTH
        self.gbcPanel0.weightx = 1
        self.gbcPanel0.weighty = 0
        self.gbcPanel0.anchor = GridBagConstraints.NORTH
        self.gbPanel0.setConstraints(self.Blank_2, self.gbcPanel0)
        self.panel0.add(self.Blank_2)

        self.add(self.panel0)
Example #26
0
 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    
Example #27
0
    def _constructAboutPanel(self, insets):
        aboutPanel = JPanel(GridBagLayout())
        with open("about.html") as file:
            aboutBody = file.read()
        aboutLabel = JLabel(aboutBody.format(extension_name=EXTENSION_NAME))
        aboutLabelConstraints = GridBagConstraints()
        aboutLabelConstraints.weightx = 1
        aboutLabelConstraints.weighty = 1
        aboutLabelConstraints.insets = insets
        aboutLabelConstraints.fill = GridBagConstraints.HORIZONTAL
        aboutLabelConstraints.anchor = GridBagConstraints.PAGE_START
        aboutPanel.add(aboutLabel, aboutLabelConstraints)

        return aboutPanel
Example #28
0
 def __initTable(self):
     ''' Construct the smell information table and add it '''
     self.model = SmellIdentiKitModel()
     self.table = SmellIdentiKitTable(self.model, self.metricDict)
     self.listener = SelectionListener(self.table)
     self.table.getSelectionModel().addListSelectionListener(self.listener)
     self.table.getColumnModel().getSelectionModel().addListSelectionListener(self.listener)
     self.scrollpane = JScrollPane(self.table)
     self.setLayout(GridBagLayout())
     self.constr = GridBagConstraints()
     self.constr.fill = GridBagConstraints.BOTH
     self.constr.weighty = 1
     self.constr.weightx = 1
     self.constr.gridx = 0
     self.constr.gridy = 1
     self.add(self.scrollpane,self.constr)
Example #29
0
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
Example #30
0
    def tagLoad(self):
        # 创建窗口 开始
        self.tabs = JTabbedPane()

        self.scan_type_settings = JPanel(GridBagLayout())

        c = GridBagConstraints()

        # 界面选项卡加载
        self.tag_1(c)
        self.tag_2(c)

        # 添加选项卡
        self.tabs.addTab(u'扫描类型设置', self.scan_type_settings)

        self._callbacks.customizeUiComponent(self.tabs)
        self._callbacks.addSuiteTab(self)
def arrange_plots(regplot, plotm, plotd):
    """
    arranges the plots in a certain order, 
    regplot and plotm in first row next to each other
    plotd in second row 
    """
    from javax.swing import JPanel,JFrame
    from java.awt import GridBagLayout, GridBagConstraints
    mainPanel = JPanel()
    mainPanel.setLayout(GridBagLayout())
    c=GridBagConstraints()
    c.fill=c.BOTH
    c.weightx,c.weighty=0.5,1
    c.gridx,c.gridy,c.gridwidth,c.gridheight=0,0,10,4
    c.weightx,c.weighty=0.5,1
    c.gridx,c.gridy,c.gridwidth,c.gridheight=0,0,10,4
    mainPanel.add(regplot)
    c.gridx,c.gridy,c.gridwidth,c.gridheight=0,0,10,4
    c.weightx,c.weighty=1,1
    mainPanel.add(plotm,c)
    c.gridx,c.gridy,c.gridwidth,c.gridheight=0,4,10,6
    mainPanel.add(plotd,c)
    return mainPanel
Example #32
0
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
Example #33
0
    def addComponents( self, container ) :
        container.setLayout( GridBagLayout() )
        c = GridBagConstraints()       # Start with the default constraints

        print '\n default constraints:'
        print '     gridx:', c.gridx
        print '     gridy:', c.gridx
        print ' gridwidth:', c.gridwidth
        print 'gridheight:', c.gridheight
        print '   weightx:', c.weightx
        print '   weighty:', c.weighty
        print '    anchor:', c.anchor
        print '      fill:', c.fill
        print '    insets:', c.insets
        print '     ipadx:', c.ipadx
        print '     ipady:', c.ipady

        for name in '1,2,3 being the third number'.split( ',' ) :
            container.add( JButton( name ) )
Example #34
0
 def __fillQuestions(self):
   panel = JPanel()
   panel.setLayout(GridBagLayout())
   panel.setBorder(None)
   c = GridBagConstraints()
   c.gridx = 0
   c.gridy = 0
   c.weightx = 1.0
   c.fill = GridBagConstraints.HORIZONTAL
   c.anchor = GridBagConstraints.PAGE_START
   line = 0
   for question in self.test.getQuestions():
     c.gridy = line
     panel.add(question.getPanel().asJComponent(),c)
     line += 1
   scrollPanel = JScrollPane(panel)
   scrollPanel.setBorder(None)
   self.questionsContainer.setLayout(BorderLayout())
   self.questionsContainer.add(scrollPanel, BorderLayout.CENTER)
Example #35
0
    def __init__(self, frame, name):
        self.frame = frame
        self.exception = None
        self.name = name
        self.searchTerm = None
        self.searchIndex = -1

        self.searchField = JTextField("")
        self.searchField.addActionListener(SearchListener(self))

        self.newGeneFrom = JTextField("")
        self.newGeneTo = JTextField("")
        self.newGeneButton = JButton("New Gene")
        newGeneActionListener = NewGeneActionListener(self)
        self.newGeneFrom.addActionListener(newGeneActionListener)
        self.newGeneTo.addActionListener(newGeneActionListener)
        self.newGeneButton.addActionListener(newGeneActionListener)

        self.markForRemovalButton = JButton("Mark For Removal")
        self.markForRemovalButton.addActionListener(MarkForRemovalListener(self))
        
        self.inGenes = JList(DefaultListModel())
        self.inGenes.selectionMode = ListSelectionModel.SINGLE_SELECTION
        self.inGenes.cellRenderer = ProfelisCellRenderer()
        self.markButtonLabelerTimer = Timer(100, MarkButtonLabeler(self))
        self.markButtonLabelerTimer.start()
        self.loadFile()

        self.outGenes = JList(DefaultListModel())
        self.outGenes.selectionMode = ListSelectionModel.SINGLE_SELECTION
        self.outGenes.cellRenderer = ProfelisCellRenderer()
                
        constraints = GridBagConstraints()
        self.layout = GridBagLayout()
        
        constraints.gridx, constraints.gridy = 0, 0
        constraints.gridwidth, constraints.gridheight = 1, 1
        constraints.fill = GridBagConstraints.NONE
        constraints.weightx, constraints.weighty = 0, 0
        self.add(JLabel("Genes In Artemis File"), constraints)
        constraints.gridx, constraints.gridy = 0, 1
        self.add(JButton(RemoveAction(self)), constraints)
        constraints.gridx, constraints.gridy = 1, 1
        self.add(self.markForRemovalButton, constraints)
        constraints.gridx, constraints.gridy = 2, 1
        self.add(JLabel("Search"), constraints)
        constraints.gridx, constraints.gridy = 3, 1
        constraints.fill = GridBagConstraints.HORIZONTAL
        self.add(self.searchField, constraints)
        constraints.gridx, constraints.gridy = 0, 2
        constraints.gridwidth, constraints.gridheight = 4, 2
        constraints.fill = GridBagConstraints.BOTH
        constraints.weightx, constraints.weighty = 1, 1
        self.add(JScrollPane(self.inGenes), constraints)

        constraints.gridx, constraints.gridy = 4, 0
        constraints.gridwidth, constraints.gridheight = 1, 1
        constraints.fill = GridBagConstraints.NONE
        constraints.weightx, constraints.weighty = 0, 0
        self.add(JLabel("Genes To Add To Artemis File"), constraints)
        constraints.gridx, constraints.gridy = 4, 1
        self.add(self.newGeneButton, constraints)
        constraints.weightx = 1
        constraints.fill = GridBagConstraints.BOTH
        constraints.gridx, constraints.gridy = 5, 1
        self.add(self.newGeneFrom, constraints)
        constraints.weightx = 0
        constraints.fill = GridBagConstraints.NONE
        constraints.gridx, constraints.gridy = 6, 1
        self.add(JLabel("To"), constraints)
        constraints.weightx = 1
        constraints.fill = GridBagConstraints.BOTH
        constraints.gridx, constraints.gridy = 7, 1
        self.add(self.newGeneTo, constraints)

        constraints.weightx = 0
        constraints.fill = GridBagConstraints.NONE
        constraints.gridx, constraints.gridy = 4, 2
        self.add(JButton(AddGenesAction(self)), constraints)
        constraints.gridx, constraints.gridy = 4, 3
        constraints.gridwidth, constraints.gridheight = 4, 1
        constraints.fill = GridBagConstraints.BOTH
        constraints.weightx, constraints.weighty = 1, 1
        self.add(JScrollPane(self.outGenes), constraints)
Example #36
0
  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()]
Example #37
0
 def addSigningKeyFromCmdTextField(self):
     c = GridBagConstraints()
     c.gridx = 1
     c.gridy = 6
     self._configurationPanel.add(self._fromCmdTextField, c)
Example #38
0
    def __init__(self):
        ''' Configuration Panel '''
#         pconfig = JPanel(GridBagLayout())
#         pconfig.setSize(Dimension(500,300))
        self.setLayout(GridBagLayout())
#         super(self,GridBagLayout())
        self.setSize(Dimension(500,300))
        ''' fila 1 '''
        label = JLabel('Configuration panel')
        c1 = GridBagConstraints()
        c1.fill = GridBagConstraints.HORIZONTAL
        c1.weightx = 0.5
        c1.gridwidth = 4
        c1.gridx = 0
        c1.gridy = 0
        self.add(label, c1)
        ''' fila 2 '''
        self.radioBtnOMC = JRadioButton('OpenModelica')
        c2 = GridBagConstraints()
        c2.fill = GridBagConstraints.HORIZONTAL
        c2.weightx = 0.5
        c2.gridx = 0
        c2.gridy = 1
        self.add(self.radioBtnOMC, c2)
        self.radioBtnJM = JRadioButton('JModelica')
        c3 = GridBagConstraints()
        c3.fill = GridBagConstraints.HORIZONTAL
        c3.weightx = 0.5
        c3.gridx = 1
        c3.gridy = 1
        self.add(self.radioBtnJM, c3)
        self.radioBtnDY = JRadioButton('Dymola')
        c4 = GridBagConstraints()
        c4.fill = GridBagConstraints.HORIZONTAL
        c4.weightx = 0.5
        c4.gridx = 2
        c4.gridy = 1
        self.add(self.radioBtnDY, c4)
        rbBtnGroup = ButtonGroup()
        rbBtnGroup.add(self.radioBtnOMC)
        rbBtnGroup.add(self.radioBtnJM)
        rbBtnGroup.add(self.radioBtnDY)
        ''' fila 2 '''
        label = JLabel('Start time')
        c = GridBagConstraints()
        c.fill = GridBagConstraints.HORIZONTAL
        c.weightx = 0.5
        c.gridx = 0
        c.gridy = 2
        self.add(label, c)
        self.txtstart= JTextField('0')
        c = GridBagConstraints()
        c.fill = GridBagConstraints.HORIZONTAL
        c.weightx = 0.5
        c.gridx = 1
        c.gridy = 2
        self.add(self.txtstart, c)
        label = JLabel('Stop time')
        c = GridBagConstraints()
        c.fill = GridBagConstraints.HORIZONTAL
        c.weightx = 0.5
        c.gridx = 2
        c.gridy = 2
        self.add(label, c)
        self.txtstop= JTextField('0')
        c = GridBagConstraints()
        c.fill = GridBagConstraints.HORIZONTAL
        c.weightx = 0.5
        c.gridx = 3
        c.gridy = 2
        self.add(self.txtstop, c)
        ''' fila 3 '''
        label = JLabel('Solver')
        c = GridBagConstraints()
        c.fill = GridBagConstraints.HORIZONTAL
        c.weightx = 0.5
        c.gridx = 0
        c.gridy = 3
        self.add(label, c)
        self.cbsolver= JComboBox(['dassl','rkfix2'])
        c = GridBagConstraints()
        c.fill = GridBagConstraints.HORIZONTAL
        c.weightx = 0.5
        c.gridx = 1
        c.gridy = 3
        self.add(self.cbsolver, c)
        label = JLabel('Algorithm (JM)')
        c = GridBagConstraints()
        c.fill = GridBagConstraints.HORIZONTAL
        c.weightx = 0.5
        c.gridx = 2
        c.gridy = 3
        self.add(label, c)
        self.cbalgorithm= JComboBox(['AssimuloAlg'])
        c = GridBagConstraints()
        c.fill = GridBagConstraints.HORIZONTAL
        c.weightx = 0.5
        c.gridx = 3
        c.gridy = 3
        self.add(self.cbalgorithm, c)
        ''' fila 4 '''
        label = JLabel('Interval')
        c = GridBagConstraints()
        c.fill = GridBagConstraints.HORIZONTAL
        c.weightx = 0.5
        c.gridx = 0
        c.gridy = 4
        self.add(label, c)
        self.txtinterval= JTextField('0')
        c = GridBagConstraints()
        c.fill = GridBagConstraints.HORIZONTAL
        c.weightx = 0.5
        c.gridx = 1
        c.gridy = 4
        self.add(self.txtinterval, c)
        ''' fila 5 '''
        label = JLabel('Tolerance')
        c = GridBagConstraints()
        c.fill = GridBagConstraints.HORIZONTAL
        c.weightx = 0.5
        c.gridx = 0
        c.gridy = 5
        self.add(label, c)
        self.txttolerance= JTextField('0')
        c = GridBagConstraints()
        c.fill = GridBagConstraints.HORIZONTAL
        c.weightx = 0.5
        c.gridx = 1
        c.gridy = 5
        self.add(self.txttolerance, c)
        ''' fila 6 '''
        label = JLabel('Output format')
        c = GridBagConstraints()
        c.fill = GridBagConstraints.HORIZONTAL
        c.weightx = 0.5
        c.gridx = 0
        c.gridy = 6
        self.add(label, c)
        self.cboutformat= JComboBox(['.mat','.h5','.csv'])
        c = GridBagConstraints()
        c.fill = GridBagConstraints.HORIZONTAL
        c.weightx = 0.5
        c.gridx = 1
        c.gridy = 6
        self.add(self.cboutformat, c)
        label = JLabel('Initialize (JM)')
        c = GridBagConstraints()
        c.fill = GridBagConstraints.HORIZONTAL
        c.weightx = 0.5
        c.gridx = 2
        c.gridy = 6
        self.add(label, c)
        self.cbinitialize= JComboBox(['True','False'])
        c = GridBagConstraints()
        c.fill = GridBagConstraints.HORIZONTAL
        c.weightx = 0.5
        c.gridx = 3
        c.gridy = 6
        self.add(self.cbinitialize, c)
        ''' fila 7 '''
        bSaveCfg= JButton('Save Configuration', actionPerformed= self.saveConfiguration)
        c = GridBagConstraints()
        c.fill = GridBagConstraints.HORIZONTAL
        c.weightx = 0.5
        c.gridwidth = 2
        c.gridx = 0
        c.gridy = 7
        self.add(bSaveCfg, c)
        self.bSimulation= JButton('Load Configuration', actionPerformed= self.loadConfiguration)
        c = GridBagConstraints()
        c.fill = GridBagConstraints.HORIZONTAL
        c.weightx = 0.5
        c.gridwidth = 2
        c.gridx = 2
        c.gridy = 7
        self.add(self.bSimulation, c)
        ''' fila 8 '''
        self.bSimulation= JButton('Simulate', actionPerformed= self.startSimlation)
        self.bSimulation.enabled= 0
        c = GridBagConstraints()
        c.fill = GridBagConstraints.HORIZONTAL
        c.weightx = 1
        c.gridwidth = 4
        c.gridx = 0
        c.gridy = 8
        self.add(self.bSimulation, c)
        ''' file 9 '''
        simProgress= JProgressBar(0, self.getWidth(), value=0, stringPainted=True)
        c = GridBagConstraints()
        c.fill = GridBagConstraints.HORIZONTAL
        c.weightx = 1
        c.gridwidth = 4
        c.gridx = 0
        c.gridy = 9
        self.add(simProgress, c)
        ''' fila 10 '''
        self.lblResult= JLabel('Simulation information')
        c = GridBagConstraints()
        c.fill = GridBagConstraints.HORIZONTAL
        c.weightx = 1
        c.gridwidth = 4
        c.gridx = 0
        c.gridy = 10
        self.add(self.lblResult, c) 
Example #39
0
    def build_welcome_panel(self):
        '''
        Construct the welcome panel here.
        '''
        panel = JPanel(GridBagLayout())
        constraints = GridBagConstraints()
        constraints.insets = Insets(10, 10, 10, 10)

        message = ('<html><body>'
                   '<h1>Welcome to Nammu</h1>'
                   '<h2>An editor for the ORACC project<h2>'
                   '<p>'
                   '<a href=\'oracc\'>Click here</a> for help with ORACC.'
                   '</p>'
                   '<p>Learn more about Nammu <a href=\'nammu\'>here</a>.</p>'
                   '</body></html>')

        # Configure a JEditorPane to display HTML for our welcome message
        msg_pane = JEditorPane()
        msg_pane.setEditable(False)
        kit = HTMLEditorKit()
        msg_pane.setEditorKit(kit)
        scrollPane = JScrollPane(msg_pane)

        # This handles the stylesheet applied to the welcome message
        styleSheet = kit.getStyleSheet()
        styleSheet.addRule('body {color:black; font-size: 16 pt; }')
        styleSheet.addRule('h1 {text-align:center; }')
        styleSheet.addRule('h2 {text-align:center; }')

        # Set the JEditorPane background to match the rest of the window
        msg_pane.border = BorderFactory.createEmptyBorder(4, 4, 4, 4)
        msg_pane.background = Color(238, 238, 238)

        # Add the message and the css and to the JEditorPane
        doc = kit.createDefaultDocument()
        msg_pane.setDocument(doc)
        msg_pane.setText(message)

        # Set up a hyperlink listener
        listener = addEventListener(msg_pane, HyperlinkListener,
                                    'hyperlinkUpdate', self.handleEvent)

        # Configure the placement of the JEditorPane
        constraints.gridx = 1
        constraints.gridy = 1
        constraints.fill = GridBagConstraints.BOTH
        constraints.anchor = GridBagConstraints.CENTER

        panel.add(msg_pane, constraints)

        # Build and place the checkbox
        self.checkbox = JCheckBox('Don\'t show this message again.',
                                  selected=False)
        constraints.gridx = 1
        constraints.gridy = 2
        panel.add(self.checkbox, constraints)

        # Build and place the close button
        close_button = JButton('Close', actionPerformed=self.close_action)

        constraints.gridx = 2
        constraints.gridy = 2
        panel.add(close_button, constraints)

        return panel
Example #40
0
    def __init__(self, callbacks):
        self._callbacks = callbacks
        self.tab = JPanel(GridBagLayout())

        about_constraints = GridBagConstraints()

        about_author = (("<html><center><h2>SpyDir</h2><b>Version:</b> "
                         "%s<br/>Created by: <em>Ryan Reid</em>"
                         " (@_aur3lius)<br/>https://github.com/aur3lius-dev/"
                         "SpyDir</center><br/>")
                        % VERSION)
        about_spydir = """<em><center>
        SpyDir is an extension that assists in the enumeration of
        application<br/>
        endpoints via an input directory containing the application's<br/>
        source code. It provides an option to process files as endpoints,<br/>
        think: ASP, PHP, HTML, or parse files to attempt to enumerate<br/>
        endpoints via plugins, think: MVC. Users may opt to send the<br/>
        discovered endpoints directly to the Burp Spider.
        </center></em><br/>
        This tool is in <b>Alpha</b>! <b>Please</b> provide feedback on the
        GitHub page!<br/><br/>"""
        getting_started = """<b>Getting started:</b><br/>
         <ul>
            <li>Add a local source repository</li>
            <li>Add the target URL</li>
            <li>Use the String delimiter to construct the appropriate
             directory path (if necessary)</li>
            <li>Alternatively, parse each file by selecting plugins
             and checking the checkbox</li>
            <li>Explicitly define the file extensions to process</li>
            <li>Parse the directory</li>
            <li>Verify output is correct <b>before</b> sending to spider</li>
            <li>Send requests to the Burp Spider</li>
        </ul>
        """
        advanced_info = r"""<html><b>String Delimiter</b><br/>
        String Delimiter allows us to append the necessary section
        of the folder structure.<br/>
        Suppose the target application is hosted at the following URL:
        https://localhost:8080. <br/>The target code base is stored in:
        'C:\Source\TestApp'. <br/>Within the TestApp folder there is a
        subfolder, 'views', with static .html files.<br/>
        In this case the String Delimiter will need to equal 'TestApp'.
        <br/>With the expectation that the tool will produce an example URL
        will such as:<br/>https://localhost:8080/views/view1.html.<br/><br/>
        <b>Path Vars</b><br/>Use this option to swap values for dynamically
        enumerated query string parameters. This needs to be a JSON object.
        <br/><b>Example:</b>{"{userID}": "aur3lius", "admin_status=": 
        "admin_status=True"}<br/><br/>


        <b>Note:</b> String Delimiter is ignored if parsing files using
        plugins!
        </html>"""
        about_constraints.anchor = GridBagConstraints.FIRST_LINE_START
        about_constraints.weightx = 1.0
        about_constraints.weighty = 1.0
        self.tab.add(JLabel("%s\n%s\n%s\n%s" % (about_author, about_spydir,
                                                getting_started,
                                                advanced_info)),
                     about_constraints)
Example #41
0
    def registerExtenderCallbacks(self, callbacks):
        # Initialize the global stdout stream
        global stdout

        # Keep a reference to our callbacks object
        self._callbacks = callbacks

        # Obtain an extension helpers object
        self._helpers = callbacks.getHelpers()

        # set our extension name
        callbacks.setExtensionName("Burpsuite Yara Scanner")

        # Create the log and a lock on which to synchronize when adding log entries
        self._log = ArrayList()
        self._lock = Lock()

        # main split pane
        splitpane = JSplitPane(JSplitPane.VERTICAL_SPLIT)

        # table of log entries
        logTable = Table(self)
        scrollPane = JScrollPane(logTable)
        splitpane.setLeftComponent(scrollPane)

        # Options panel
        optionsPanel = JPanel()
        optionsPanel.setLayout(GridBagLayout())
        constraints = GridBagConstraints()

        yara_exe_label = JLabel("Yara Executable Location:")
        constraints.fill = GridBagConstraints.HORIZONTAL
        constraints.gridx = 0
        constraints.gridy = 0
        optionsPanel.add(yara_exe_label, constraints)

        self._yara_exe_txtField = JTextField(25)
        constraints.fill = GridBagConstraints.HORIZONTAL
        constraints.gridx = 1
        constraints.gridy = 0
        optionsPanel.add(self._yara_exe_txtField, constraints)

        yara_rules_label = JLabel("Yara Rules File:")
        constraints.fill = GridBagConstraints.HORIZONTAL
        constraints.gridx = 0
        constraints.gridy = 1
        optionsPanel.add(yara_rules_label, constraints)
		
        self._yara_rules_files = Vector()
        self._yara_rules_files.add("< None >")
        self._yara_rules_fileList = JList(self._yara_rules_files)
        constraints.fill = GridBagConstraints.HORIZONTAL
        constraints.gridx = 1
        constraints.gridy = 1
        optionsPanel.add(self._yara_rules_fileList, constraints)
        
        self._yara_rules_select_files_button = JButton("Select Files")
        self._yara_rules_select_files_button.addActionListener(self)
        constraints.fill = GridBagConstraints.HORIZONTAL
        constraints.gridx = 1
        constraints.gridy = 2
        optionsPanel.add(self._yara_rules_select_files_button, constraints)

        self._yara_clear_button = JButton("Clear Yara Results Table")
        self._yara_clear_button.addActionListener(self)
        constraints.fill = GridBagConstraints.HORIZONTAL
        constraints.gridx = 1
        constraints.gridy = 3
        optionsPanel.add(self._yara_clear_button, constraints)

        # Tabs with request/response viewers
        viewerTabs = JTabbedPane()
        self._requestViewer = callbacks.createMessageEditor(self, False)
        self._responseViewer = callbacks.createMessageEditor(self, False)
        viewerTabs.addTab("Request", self._requestViewer.getComponent())
        viewerTabs.addTab("Response", self._responseViewer.getComponent())
        splitpane.setRightComponent(viewerTabs)

        # Tabs for the Yara output and the Options
        self._mainTabs = JTabbedPane()
        self._mainTabs.addTab("Yara Output", splitpane)
        self._mainTabs.addTab("Options", optionsPanel)

        # customize our UI components
        callbacks.customizeUiComponent(splitpane)
        callbacks.customizeUiComponent(logTable)
        callbacks.customizeUiComponent(scrollPane)
        callbacks.customizeUiComponent(viewerTabs)
        callbacks.customizeUiComponent(self._mainTabs)

        # add the custom tab to Burp's UI
        callbacks.addSuiteTab(self)

        # add ourselves as a context menu factory
        callbacks.registerContextMenuFactory(self)

        # Custom Menu Item
        self.menuItem = JMenuItem("Scan with Yara")
        self.menuItem.addActionListener(self)

        # obtain our output stream
        stdout = PrintWriter(callbacks.getStdout(), True)

        # Print a startup notification
        stdout.println("Burpsuite Yara scanner initialized.")
Example #42
0
    def __init__(self):
        self.frame = JFrame('Hello, Jython!',
                            defaultCloseOperation=JFrame.EXIT_ON_CLOSE,
                            size=(400, 600))
        bag_layout = GridBagLayout()
        self.frame.layout = bag_layout
        grid_constraints = GridBagConstraints()

        format_1_string_label = JLabel("Format 1 string:")
        grid_constraints.weightx = 0.1
        grid_constraints.weighty = 0.1
        grid_constraints.gridy = 0
        grid_constraints.fill = GridBagConstraints.NONE
        self._add_component(format_1_string_label, bag_layout, grid_constraints)

        self.input_textbox = JTextArea()
        grid_constraints.weightx = 1
        grid_constraints.weighty = 1
        grid_constraints.gridy = 1
        grid_constraints.fill = GridBagConstraints.BOTH
        input_scroll_pane = JScrollPane(self.input_textbox)
        input_scroll_pane.verticalScrollBarPolicy = ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS
        self._add_component(input_scroll_pane, bag_layout, grid_constraints)

        output_string_label = JLabel("Output:")
        grid_constraints.weightx = 0.1
        grid_constraints.weighty = 0.1
        grid_constraints.gridy = 2
        grid_constraints.fill = GridBagConstraints.NONE
        self._add_component(output_string_label, bag_layout, grid_constraints)

        self.output_textbox = JTextArea()
        grid_constraints.weightx = 1
        grid_constraints.weighty = 1
        grid_constraints.gridy = 3
        grid_constraints.fill = GridBagConstraints.BOTH
        self.output_textbox.editable = False
        output_scroll_pane = JScrollPane(self.output_textbox)
        output_scroll_pane.verticalScrollBarPolicy = ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS
        self._add_component(output_scroll_pane, bag_layout, grid_constraints)
Example #43
0
    def __init__(self):
        self.setLayout(GridBagLayout())

        shrinkX = JButton("shrinkX")
        shrinkX.actionPerformed = lambda event : rescaleLayout(0.5, 1)
        constr = GridBagConstraints()
        constr.gridx = 0
        constr.gridy = 0
        self.add(shrinkX, constr)

        growX = JButton("growX")
        growX.actionPerformed = lambda event : rescaleLayout(1.5, 1)
        constr = GridBagConstraints()
        constr.gridx = 2
        constr.gridy = 0
        self.add(growX, constr)

        shrinkY = JButton("shrinkY")
        shrinkY.actionPerformed = lambda event : rescaleLayout(1, 0.5)
        constr = GridBagConstraints()
        constr.gridx = 0
        constr.gridy = 2
        self.add(shrinkY, constr)

        growY = JButton("growY")
        growY.actionPerformed = lambda event : rescaleLayout(1, 1.5)
        constr = GridBagConstraints()
        constr.gridx = 2
        constr.gridy = 2
        self.add(growY, constr)

        centerB = JButton("center")
        centerB.actionPerformed = lambda event : center()
        constr = GridBagConstraints()
        constr.gridx = 1
        constr.gridy = 1
        self.add(centerB, constr)

        ui.dock(self)
Example #44
0
def get_gbc():
    gbc = GridBagConstraints()
    gbc.weightx = 1.0
    gbc.anchor = GridBagConstraints.NORTHWEST
    gbc.ipady = 2
    return gbc
Example #45
0
    def __init__(self):
        self.running = True
        menuBar = JMenuBar()
        
        menu = JMenu("File")
        menu.add(OpenAction(self))
        menu.add(CloseAction(self))
        menu.addSeparator()
        menu.add(QuitAction(self))
        self.addWindowListener(ProfelisWindowAdapter(self))
        menuBar.add(menu)

        self.setJMenuBar(menuBar)

        self.contentPane = JPanel()
        self.contentPane.layout = GridBagLayout()
        constraints = GridBagConstraints()

        self.blastLocation = JTextField(System.getProperty("user.home") + "/blast")
        self.databaseLocation = JTextField(System.getProperty("user.home") + "/blast/db")
        self.projects = JTabbedPane()
        
        constraints.gridx, constraints.gridy = 0, 0
        constraints.gridwidth, constraints.gridheight = 1, 1
        constraints.fill = GridBagConstraints.NONE
        constraints.weightx, constraints.weighty = 0, 0
        self.contentPane.add(JLabel("Blast Location"), constraints)
        constraints.gridx, constraints.gridy = 1, 0
        constraints.fill = GridBagConstraints.HORIZONTAL
        constraints.weightx, constraints.weighty = 1, 0
        self.contentPane.add(self.blastLocation, constraints)
        constraints.gridx, constraints.gridy = 2, 0
        constraints.fill = GridBagConstraints.NONE
        constraints.weightx, constraints.weighty = 0, 0
        self.contentPane.add(JButton(BlastAction(self)), constraints)
        constraints.gridx, constraints.gridy = 3, 0
        constraints.fill = GridBagConstraints.NONE
        constraints.weightx, constraints.weighty = 0, 0
        self.contentPane.add(JLabel("Database Location"), constraints)
        constraints.gridx, constraints.gridy = 4, 0
        constraints.fill = GridBagConstraints.HORIZONTAL
        constraints.weightx, constraints.weighty = 1, 0
        self.contentPane.add(self.databaseLocation, constraints)
        constraints.gridx, constraints.gridy = 5, 0
        constraints.fill = GridBagConstraints.NONE
        constraints.weightx, constraints.weighty = 0, 0
        self.contentPane.add(JButton(DatabaseAction(self)), constraints)
        constraints.gridx, constraints.gridy = 0, 1
        constraints.gridwidth, constraints.gridheight = 6, 1
        constraints.fill = GridBagConstraints.BOTH
        constraints.weightx, constraints.weighty = 1, 1
        self.contentPane.add(self.projects, constraints)
Example #46
0
    def __init__(self):
        ''' Resources Panel '''
#         psimures= JPanel(GridBagLayout())
#         psimures.setSize(Dimension(500,300))
        self.setLayout(GridBagLayout())
#         super(self,GridBagLayout())
        self.setSize(Dimension(500,300))
        ''' fila 1 '''
        label = JLabel('Resources panel')
        c = GridBagConstraints()
        c.fill = GridBagConstraints.HORIZONTAL
        c.weightx = 1
        c.gridwidth = 4
        c.gridx = 0
        c.gridy = 0
        self.add(label, c)
        ''' fila 2 '''
        self.dModelFile = []
        self.cbMoFile = JComboBox(self.dModelFile)
        c = GridBagConstraints()
        c.fill = GridBagConstraints.HORIZONTAL
        c.weightx = 0.75
        c.gridwidth = 3
        c.gridx = 0
        c.gridy = 1
        self.add(self.cbMoFile, c)
        bloadmodel= JButton('Load Model',actionPerformed=self.onOpenFile)
        c = GridBagConstraints()
        c.fill = GridBagConstraints.HORIZONTAL
        c.weightx = 0.25
#         c.gridwidth = 1
        c.gridx = 3
        c.gridy = 1
        self.add(bloadmodel, c)
        ''' fila 3 '''
        self.dLibFile = []
        self.cbMoLib = JComboBox(self.dLibFile)
        c = GridBagConstraints()
        c.fill = GridBagConstraints.HORIZONTAL
        c.weightx = 0.75
        c.gridwidth = 3
        c.gridx = 0
        c.gridy = 2
        self.add(self.cbMoLib, c)
        bloadlib= JButton('Load Library',actionPerformed=self.onOpenFile)
        c = GridBagConstraints()
        c.fill = GridBagConstraints.HORIZONTAL
        c.weightx = 0.25
#         c.gridwidth = 1
        c.gridx = 3
        c.gridy = 2
        self.add(bloadlib, c)
        ''' fila 4 '''
        self.dModel = []
        self.cbModel = JComboBox(self.dModel)
        c = GridBagConstraints()
        c.fill = GridBagConstraints.HORIZONTAL
        c.weightx = 0.75
        c.gridwidth = 3
        c.gridx = 0
        c.gridy = 3
        self.add(self.cbModel, c)
        bselectmodel= JButton('Select Model',actionPerformed=self.onOpenModel)
        c = GridBagConstraints()
        c.fill = GridBagConstraints.HORIZONTAL
        c.weightx = 0.25
#         c.gridwidth = 1
        c.gridx = 3
        c.gridy = 3
        self.add(bselectmodel, c)
        ''' fila 5 '''
        self.dOutPath = []
        self.cbOutDir = JComboBox(self.dOutPath)
        c = GridBagConstraints()
        c.fill = GridBagConstraints.HORIZONTAL
        c.weightx = 0.75
        c.gridwidth = 3
        c.gridx = 0
        c.gridy = 4
        self.add(self.cbOutDir, c)
        bloadoutpath= JButton('Output Path',actionPerformed=self.onOpenFolder)
        c = GridBagConstraints()
        c.fill = GridBagConstraints.HORIZONTAL
        c.weightx = 0.25
#         c.gridwidth = 1
        c.gridx = 3
        c.gridy = 4
        self.add(bloadoutpath, c)
        ''' fila 6 '''
        bsaveSource= JButton('Save Resources',actionPerformed=self.saveResources)
        c = GridBagConstraints()
        c.fill = GridBagConstraints.HORIZONTAL
        c.weightx = 0.5
        c.gridwidth = 2
        c.gridx = 0
        c.gridy = 5
        self.add(bsaveSource, c)
        bloadSource= JButton('Load Resources',actionPerformed=self.loadResources)
        c = GridBagConstraints()
        c.fill = GridBagConstraints.HORIZONTAL
        c.weightx = 0.5
        c.gridwidth = 2
        c.gridx = 2
        c.gridy = 5
        self.add(bloadSource, c)
Example #47
0
    def __init__(self, callbacks, parent):
        # Initialze self stuff
        self._callbacks = callbacks
        self.config = {}
        self.ext_stats = {}
        self.url_reqs = []
        self.parse_files = False
        self.tab = JPanel(GridBagLayout())
        self.view_port_text = JTextArea("===SpyDir===")
        self.delim = JTextField(30)
        self.ext_white_list = JTextField(30)
        # I'm not sure if these fields are necessary still
        # why not just use Burp func to handle this?
        # leaving them in case I need it for the HTTP handler later
        # self.cookies = JTextField(30)
        # self.headers = JTextField(30)
        self.url = JTextField(30)
        self.parent_window = parent
        self.plugins = {}
        self.loaded_p_list = set()
        self.loaded_plugins = False
        self.config['Plugin Folder'] = None
        self.double_click = False
        self.source_input = ""
        self.print_stats = True
        self.curr_conf = JLabel()
        self.window = JFrame("Select plugins",
                             preferredSize=(200, 250),
                             windowClosing=self.p_close)
        self.window.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE)
        self.window.setVisible(False)
        self.path_vars = JTextField(30)


        # Initialize local stuff
        tab_constraints = GridBagConstraints()
        status_field = JScrollPane(self.view_port_text)

        # Configure view port
        self.view_port_text.setEditable(False)

        labels = self.build_ui()

        # Add things to rows
        tab_constraints.anchor = GridBagConstraints.FIRST_LINE_END
        tab_constraints.gridx = 1
        tab_constraints.gridy = 0
        tab_constraints.fill = GridBagConstraints.HORIZONTAL
        self.tab.add(JButton(
            "Resize screen", actionPerformed=self.resize),
                     tab_constraints)
        tab_constraints.gridx = 0
        tab_constraints.gridy = 1
        tab_constraints.anchor = GridBagConstraints.FIRST_LINE_START
        self.tab.add(labels, tab_constraints)

        tab_constraints.gridx = 1
        tab_constraints.gridy = 1
        tab_constraints.fill = GridBagConstraints.BOTH
        tab_constraints.weightx = 1.0
        tab_constraints.weighty = 1.0

        tab_constraints.anchor = GridBagConstraints.FIRST_LINE_END
        self.tab.add(status_field, tab_constraints)
        try:
            self._callbacks.customizeUiComponent(self.tab)
        except Exception:
            pass
Example #48
0
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)
Example #49
0
    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)
Example #50
0
  def initializeDisplay(self, queries, swing):
    """
    queries: A list of the fasts files to be processed.
    swing:   If true then updates about progress will be displayed in a swing window, otherwise they will be written to stdout.
    
    Initializes the interface for telling the user about progress in the pipeline.  Queries is used to count the
    number of queries the pipeline will process and to size the swing display(if it is used) so that text
    isn't cutoff at the edge of the window.  The swing display is setup if swing is true.
    """
  
    self.numJobs = len(queries)
    if swing:
      self.frame = JFrame("Neofelis")
      self.frame.addWindowListener(PipelineWindowAdapter(self))
      contentPane = JPanel(GridBagLayout())
      self.frame.setContentPane(contentPane)
      self.globalLabel = JLabel(max(queries, key = len))
      self.globalProgress = JProgressBar(0, self.numJobs)
      self.currentLabel = JLabel(max(self.messages, key = len))
      self.currentProgress = JProgressBar(0, len(self.messages))
      self.doneButton = JButton(DoneAction(self.frame))
      self.doneButton.setEnabled(False)

      constraints = GridBagConstraints()
      
      constraints.gridx, constraints.gridy = 0, 0
      constraints.gridwidth, constraints.gridheight = 1, 1
      constraints.weightx = 1
      constraints.fill = GridBagConstraints.HORIZONTAL
      contentPane.add(self.globalLabel, constraints)
      constraints.gridy = 1
      contentPane.add(self.globalProgress, constraints)
      constraints.gridy = 2
      contentPane.add(self.currentLabel, constraints)
      constraints.gridy = 3
      contentPane.add(self.currentProgress, constraints)
      constraints.gridy = 4
      constraints.weightx = 0
      constraints.fill = GridBagConstraints.NONE
      constraints.anchor = GridBagConstraints.LINE_END
      contentPane.add(self.doneButton, constraints)
    
      self.frame.pack()
      self.frame.setResizable(False)
      self.globalLabel.setText(" ")
      self.currentLabel.setText(" ")
      self.frame.setLocationRelativeTo(None)
      self.frame.setVisible(True)
def doall(locations, fileobs,filerun1,filerun2,stime,etime,imageDir='d:/temp',weights=None,filter_type="AVE",normalize=False):
    obs=HecDss.open(fileobs,True)
    obs.setTimeWindow(stime,etime)
    run1=HecDss.open(filerun1,True)
    run1.setTimeWindow(stime,etime)
    if filerun2 != None:
        run2=HecDss.open(filerun2,True)
        run2.setTimeWindow(stime,etime)
    else:
        run2=None
    rms1=0
    rms1_min,rms1_max=0,0
    rms2=0
    rms2_min,rms2_max=0,0
    rmsmap={}
    #run2=None
    sumwts=0
    average_interval=None;
    for l in locations:
        data1=get_matching(obs,'A=%s C=%s E=15MIN'%(l,type))
        if data1 == None:
            data1=get_matching(obs,'A=%s C=%s E=1DAY'%(l,type))
        if data1 == None:
            data1=get_matching(obs,'A=%s C=%s E=IR-DAY'%(l,type))
        if data1 == None:
            data1=get_matching(obs,'A=%s C=%s E=1HOUR'%(l,type))
        drun1=get_matching(run1,'B=%s C=%s'%(l,type))
        if run2 != None:
            drun2=get_matching(run2, 'B=%s C=%s'%(l,type))
        else:
            drun2=None
        avg_intvl="1DAY"
        if data1 != None:
            if average_interval != None:
                dobsd=TimeSeriesMath(data1).transformTimeSeries(average_interval, None, filter_type, 0)
            else:
                dobsd=TimeSeriesMath(data1)
            if normalize:
                dobsd=dobsd.divide(TimeSeriesMath(data1).mean())
            dobsm=TimeSeriesMath(data1).transformTimeSeries(avg_intvl, None, filter_type, 0)
            dobsm_max=TimeSeriesMath(data1).transformTimeSeries(avg_intvl, None, "MAX", 0)
            dobsm_max.data.fullName=dobsm_max.data.fullName+"MAX"
            dobsm_min=TimeSeriesMath(data1).transformTimeSeries(avg_intvl, None, "MIN", 0)
            dobsm_min.data.fullName=dobsm_min.data.fullName+"MIN"
            if normalize:
                dobsm=dobsm.divide(TimeSeriesMath(data1).mean())
        if drun1==None:
            continue;
        else:
            if average_interval != None:
                drun1d=TimeSeriesMath(drun1).transformTimeSeries(average_interval, None, filter_type, 0)
            else:
                drun1d=TimeSeriesMath(drun1)
            if normalize:
                drun1d=drun1d.divide(TimeSeriesMath(drun1).mean())
            if drun2 != None:
                if average_interval != None:
                    drun2d=TimeSeriesMath(drun2).transformTimeSeries(average_interval, None, filter_type, 0)
                else:
                    drun2d=TimeSeriesMath(drun2)
                if normalize:
                    drun2d=drun2d.divide(TimeSeriesMath(drun2).mean())
            drun1m=TimeSeriesMath(drun1).transformTimeSeries(avg_intvl, None, filter_type, 0)
            drun1m_max=TimeSeriesMath(drun1).transformTimeSeries(avg_intvl, None, "MAX", 0)
            drun1m_min=TimeSeriesMath(drun1).transformTimeSeries(avg_intvl, None, "MIN", 0)
            if normalize:
                drun1m=drun1m.divide(TimeSeriesMath(drun1).mean())
            if drun2 != None:
                drun2m=TimeSeriesMath(drun2).transformTimeSeries(avg_intvl, None, filter_type, 0)
                drun2m_max=TimeSeriesMath(drun2).transformTimeSeries(avg_intvl, None, "MAX", 0)
                drun2m_min=TimeSeriesMath(drun2).transformTimeSeries(avg_intvl, None, "MIN", 0)
                if normalize:
                    drun2m=drun2m.divide(TimeSeriesMath(drun2).mean())
            else:
                drun2m=None
        if weights != None:
            sumwts=sumwts+weights[l]
            lrms1 = calculate_rms(drun1m.data, dobsm.data)*weights[l]
            lrms1_min=calculate_rms(drun1m_min.data,dobsm_min.data)*weights[l]
            lrms1_max=calculate_rms(drun1m_max.data,dobsm_max.data)*weights[l]
            rms1=rms1+lrms1
            rms1_min=rms1_min+lrms1_min
            rms1_max=rms1_max+lrms1_max
            lrms2 = calculate_rms(drun2m.data,dobsm.data)*weights[l]
            lrms2_min=calculate_rms(drun2m_min.data,dobsm_min.data)*weights[l]
            lrms2_max=calculate_rms(drun2m_max.data,dobsm_max.data)*weights[l]
            rmsmap[l] = lrms1,lrms2,lrms1_min,lrms2_min,lrms1_max,lrms2_max
            rms2=rms2+lrms2
            rms2_min=rms2_min+lrms2_min
            rms2_max=rms2_max+lrms2_max
        plotd = newPlot("Hist vs New Geom [%s]"%l)
        if data1 != None:
            plotd.addData(dobsd.data)
        plotd.addData(drun1d.data)
        if drun2 != None:
            plotd.addData(drun2d.data)
        plotd.showPlot()
        legend_label = plotd.getLegendLabel(drun1d.data)
        legend_label.setText(legend_label.getText()+" ["+str(int(lrms1*100)/100.)+","+str(int(lrms1_min*100)/100.)+","+str(int(lrms1_max*100)/100.)+"]")
        legend_label = plotd.getLegendLabel(drun2d.data)
        legend_label.setText(legend_label.getText()+" ["+str(int(lrms2*100)/100.)+","+str(int(lrms2_min*100)/100.)+","+str(int(lrms2_max*100)/100.)+"]")
        plotd.setVisible(False)
        xaxis=plotd.getViewport(0).getAxis("x1")
        vmin =xaxis.getViewMin()+261500. # hardwired to around july 1, 2008
        xaxis.setViewLimits(vmin,vmin+10000.)
        if data1 != None:
            pline = plotd.getCurve(dobsd.data)
            pline.setLineVisible(1)
            pline.setLineColor("blue")
            pline.setSymbolType(Symbol.SYMBOL_CIRCLE)
            pline.setSymbolsVisible(0)
            pline.setSymbolSize(3)
            pline.setSymbolSkipCount(0)
            pline.setSymbolFillColor(pline.getLineColorString())
            pline.setSymbolLineColor(pline.getLineColorString())
            g2dPanel = plotd.getPlotpanel()
            g2dPanel.revalidate();
            g2dPanel.paintGfx();
        plotm = newPlot("Hist vs New Geom Monthly [%s]"%l)
        plotm.setSize(1800,1200)
        if data1 != None:
            plotm.addData(dobsm.data)
           #plotm.addData(dobsm_max.data)
            #plotm.addData(dobsm_min.data)
        plotm.addData(drun1m.data)
        #plotm.addData(drun1m_max.data)
        #plotm.addData(drun1m_min.data)
        if drun2 != None:
            plotm.addData(drun2m.data)
            #plotm.addData(drun2m_max.data)
            #plotm.addData(drun2m_min.data)
        plotm.showPlot()
        if data1 != None:
            pline = plotm.getCurve(dobsm.data)
            pline.setLineVisible(1)
            pline.setLineColor("blue")
            pline.setSymbolType(Symbol.SYMBOL_CIRCLE)
            pline.setSymbolsVisible(0)
            pline.setSymbolSize(3)
            pline.setSymbolSkipCount(0)
            pline.setSymbolFillColor(pline.getLineColorString())
            pline.setSymbolLineColor(pline.getLineColorString())
        plotm.setVisible(False)
        if data1 != None:
            plots=do_regression_plots(dobsm,drun1m,drun2m)
            if plots != None:
                spanel = plots.getPlotpanel()
                removeToolbar(spanel)
        mpanel = plotm.getPlotpanel()
        removeToolbar(mpanel)
        dpanel = plotd.getPlotpanel()
        removeToolbar(dpanel)
        from javax.swing import JPanel,JFrame
        from java.awt import GridBagLayout, GridBagConstraints
        mainPanel = JPanel()
        mainPanel.setLayout(GridBagLayout())
        c=GridBagConstraints()
        c.fill=c.BOTH
        c.weightx,c.weighty=0.5,1
        c.gridx,c.gridy,c.gridwidth,c.gridheight=0,0,10,4
        if data1 != None:
            if plots != None:
                pass
                #mainPanel.add(spanel,c)
        c.gridx,c.gridy,c.gridwidth,c.gridheight=0,0,10,4
        c.weightx,c.weighty=1,1
        mainPanel.add(mpanel,c)
        c.gridx,c.gridy,c.gridwidth,c.gridheight=0,4,10,6
        mainPanel.add(dpanel,c)
        fr=JFrame()
        fr.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE)
        fr.getContentPane().add(mainPanel)
        fr.setSize(1100,850);
        fr.show();
        mainPanel.setSize(1100,850);
        mainPanel.setBackground(Color.WHITE);
        #import time; time.sleep(5)
        saveToPNG(mainPanel,imageDir+l+".png")
    if weights != None:
        rms1=(rms1+rms1_min+rms1_max)/sumwts
        rms2=(rms2+rms2_min+rms2_max)/sumwts
        print 'RMS Run 1: %f'%rms1
        print 'RMS Run 2: %f'%rms2
        for loc in rmsmap.keys():
            print loc, rmsmap[loc] 
Example #52
0
    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)
Example #53
0
    def registerExtenderCallbacks( self, callbacks):
        self._helpers = callbacks.getHelpers()
        callbacks.setExtensionName("JWT FuzzHelper")
        callbacks.registerIntruderPayloadProcessor(self)
        callbacks.registerExtensionStateListener(self)
        
        self._stdout = PrintWriter(callbacks.getStdout(), True)
        self._stderr = PrintWriter(callbacks.getStderr(), True)

        # Holds values passed by user from Configuration panel
        self._fuzzoptions = { 
                                "target" : "Header", 
                                "selector" : None, 
                                "signature" : False,
                                "algorithm" : "HS256",
                                "key" : "",
                                "key_cmd" : ""
                            }

        self._isNone = lambda val: isinstance(val, type(None))

        # Configuration panel Layout
        self._configurationPanel = JPanel()
        gridBagLayout = GridBagLayout()
        gridBagLayout.columnWidths = [ 0, 0, 0]
        gridBagLayout.rowHeights = [ 10, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
        gridBagLayout.columnWeights = [ 0.0, 0.0, 0.0 ]
        gridBagLayout.rowWeights = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0]
        self._configurationPanel.setLayout(gridBagLayout)

        # Setup tabs
        self._tabs = JTabbedPane()
        self._tabs.addTab('Configuration',self._configurationPanel)
        #self._tabs.addTab('Help',self._helpPanel)

        # Target Options
        targetLabel = JLabel("Target Selection (Required): ")
        targetLabel.setFont(Font("Tahoma",Font.BOLD, 12))
        c = GridBagConstraints()
        c.gridx = 0
        c.gridy = 1
        c.insets = Insets(0,10,0,0)
        c.anchor = GridBagConstraints.LINE_END
        self._configurationPanel.add(targetLabel,c)

        options = [ 'Header', 'Payload' ]
        self._targetComboBox = JComboBox(options)
        c = GridBagConstraints()
        c.gridx = 1
        c.gridy = 1
        c.anchor = GridBagConstraints.LINE_START
        self._configurationPanel.add(self._targetComboBox,c)

        # Help Button
        self._helpButton = JButton("Help", actionPerformed=self.helpMenu)
        c = GridBagConstraints()
        c.gridx = 2
        c.gridy = 1
        c.anchor = GridBagConstraints.FIRST_LINE_START
        self._configurationPanel.add(self._helpButton,c)

        # Selector Options
        self._selectorLabel = JLabel("JSON Selector [Object Identifier-Index Syntax] (Required): ")
        self._selectorLabel.setFont(Font("Tahoma",Font.BOLD, 12))
        c = GridBagConstraints()
        c.gridx = 0
        c.gridy = 2
        c.insets = Insets(0,10,0,0)
        c.anchor = GridBagConstraints.LINE_END
        self._configurationPanel.add(self._selectorLabel, c)

        self._selectorTextField = JTextField('',50)
        c = GridBagConstraints()
        c.gridx = 1
        c.gridy = 2
        self._configurationPanel.add(self._selectorTextField, c)

        # Regex option

        self._regexLabel = JLabel("Use regex as JSON Selector? (Optional): ")
        self._regexLabel.setFont(Font("Tahoma",Font.BOLD, 12))
        c = GridBagConstraints()
        c.gridx = 0
        c.gridy = 3
        c.insets = Insets(0,0,0,0)
        c.anchor = GridBagConstraints.LINE_END
        self._configurationPanel.add(self._regexLabel,c)

        self._regexCheckBox = JCheckBox("", actionPerformed=self.regexSelector)
        c = GridBagConstraints()
        c.gridx = 1
        c.gridy = 3
        c.anchor = GridBagConstraints.FIRST_LINE_START
        self._configurationPanel.add(self._regexCheckBox,c)

        # Signature Options
        generateSignatureLabel = JLabel("Generate signature? (Required): ")
        generateSignatureLabel.setFont(Font("Tahoma",Font.BOLD, 12))
        c = GridBagConstraints()
        c.gridx = 0
        c.gridy = 4
        c.insets = Insets(0,10,0,0)
        c.anchor = GridBagConstraints.LINE_END
        self._configurationPanel.add(generateSignatureLabel,c)

        options = ["False", "True"]
        self._generateSignatureComboBox = JComboBox(options)
        c = GridBagConstraints()
        c.gridx = 1
        c.gridy = 4
        c.anchor = GridBagConstraints.LINE_START
        self._configurationPanel.add(self._generateSignatureComboBox,c)

        signatureAlgorithmLabel = JLabel("Signature Algorithm (Optional): ")
        signatureAlgorithmLabel.setFont(Font("Tahoma",Font.BOLD, 12))
        c = GridBagConstraints()
        c.gridx = 0
        c.gridy = 5
        c.insets = Insets(0,10,0,0)
        c.anchor = GridBagConstraints.LINE_END
        self._configurationPanel.add(signatureAlgorithmLabel,c)

        options = ["None", "HS256","HS384","HS512","ES256","ES384","ES512","RS256","RS384","RS512","PS256","PS256","PS384","PS512"]
        self._algorithmSelectionComboBox = JComboBox(options)
        c = GridBagConstraints()
        c.gridx = 1
        c.gridy = 5
        c.anchor = GridBagConstraints.LINE_START
        self._configurationPanel.add(self._algorithmSelectionComboBox,c)

        # Signing key options
        self._signingKeyLabel = JLabel("Signing Key (Optional): ")
        self._signingKeyLabel.setFont(Font("Tahoma",Font.BOLD, 12))
        c = GridBagConstraints()
        c.gridx = 0
        c.gridy = 6
        c.insets = Insets(0,10,0,0)
        c.anchor = GridBagConstraints.LINE_END
        self._configurationPanel.add(self._signingKeyLabel,c)

        self.addSigningKeyTextArea()
        self._fromFileTextField = JTextField('',50) 

        fromFileLabel = JLabel("Signing key from file? (Optional): ")
        fromFileLabel.setFont(Font("Tahoma",Font.BOLD, 12))
        c = GridBagConstraints()
        c.gridx = 0
        c.gridy = 7
        c.insets = Insets(0,0,0,0)
        c.anchor = GridBagConstraints.LINE_END
        self._configurationPanel.add(fromFileLabel,c)

        self._fromFileCheckBox = JCheckBox("", actionPerformed=self.fromFile)
        c = GridBagConstraints()
        c.gridx = 1
        c.gridy = 7
        c.anchor = GridBagConstraints.FIRST_LINE_START
        self._configurationPanel.add(self._fromFileCheckBox,c)

        self._fromCmdTextField = JTextField('',50)

        fromCmdLabel = JLabel("Signing key from command? (Optional): ")
        fromCmdLabel.setFont(Font("Tahoma",Font.BOLD, 12))
        c = GridBagConstraints()
        c.gridx = 0
        c.gridy = 8
        c.insets = Insets(0,0,0,0)
        c.anchor = GridBagConstraints.LINE_END
        self._configurationPanel.add(fromCmdLabel,c)

        self._fromCmdCheckBox = JCheckBox("", actionPerformed=self.fromCmd)
        c = GridBagConstraints()
        c.gridx = 1
        c.gridy = 8
        c.anchor = GridBagConstraints.FIRST_LINE_START
        self._configurationPanel.add(self._fromCmdCheckBox,c)

        self._saveButton = JButton("Save Configuration", actionPerformed=self.saveOptions)
        self._saveButton.setText("Save Configuration")
        c = GridBagConstraints()
        c.gridx = 1
        c.gridy = 9
        c.anchor = GridBagConstraints.FIRST_LINE_START
        self._configurationPanel.add(self._saveButton,c)

        
        callbacks.customizeUiComponent(self._configurationPanel)
        callbacks.customizeUiComponent(self._tabs)
        callbacks.addSuiteTab(self)

        self._stdout.println("[JWT FuzzHelper] Loaded successfully")
        return
Example #54
0
 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)