Пример #1
0
 def __init__(self, controller):
     '''
     Creates default empty console-looking panel.
     It should be separated from the rest of the GUI so that users can choose
     to show or hide the console. Or should it be a split panel?
     This panel will display log and validation/lemmatization messages.
     It might need its own toolbar for searching, etc.
     It will also accept commands in later stages of development, if need be.
     '''
     
     #Give reference to controller to delegate action response
     self.controller = controller
     
     #Make text area occupy all available space and resize with parent window
     self.setLayout(BorderLayout())
     
     #Create console-looking area
     self.editArea = JTextArea()
     self.editArea.border = BorderFactory.createEmptyBorder(4,4,4,4)
     self.editArea.font = Font("Courier New", Font.BOLD, 14)
     self.editArea.background = Color.BLACK
     self.editArea.foreground = Color.WHITE
     self.editArea.text = "Console started. Nammu's log will appear here.\n\n"
     
     #Will need scrolling controls
     scrollingText = JScrollPane(self.editArea)
     scrollingText.setPreferredSize(Dimension(1,150))
     
     #Make text area auto scroll down to last printed line
     caret = self.editArea.getCaret();
     caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE);
     
     #Add to parent panel
     self.add(scrollingText, BorderLayout.CENTER)
    def initComponents(self):
        self.setLayout(BoxLayout(self, BoxLayout.Y_AXIS))
        #self.setLayout(GridLayout(0,1))
        self.setAlignmentX(JComponent.LEFT_ALIGNMENT)
        self.panel1 = JPanel()
        self.panel1.setLayout(BoxLayout(self.panel1, BoxLayout.Y_AXIS))
        self.panel1.setAlignmentY(JComponent.LEFT_ALIGNMENT)
        self.checkbox = JCheckBox("Create Content View of Unique Event Id's", actionPerformed=self.checkBoxEvent)
        self.checkbox4 = JCheckBox("Other - Input in text area below then check this box", actionPerformed=self.checkBoxEvent)
        self.text1 = JLabel("*** Only run this once otherwise it adds it to the data again.")
        self.text2 = JLabel(" ")
        self.text3 = JLabel("*** Format is a comma delimited text ie:  8001, 8002")
        self.panel1.add(self.checkbox)
        self.panel1.add(self.text1)
        self.panel1.add(self.text2)
        self.panel1.add(self.checkbox4)
        self.panel1.add(self.text3)
        self.add(self.panel1)
		
        self.area = JTextArea(5,25)
        #self.area.addKeyListener(self)
        self.area.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0))
        self.pane = JScrollPane()
        self.pane.getViewport().add(self.area)
        #self.pane.addKeyListener(self)
        #self.add(self.area)
        self.add(self.pane)
Пример #3
0
    def __init__(self):
        """
        Line numbers need to be displayed in a separate panel with different
        styling.
        """
        # Align right
        para_attribs = SimpleAttributeSet()
        StyleConstants.setAlignment(para_attribs, StyleConstants.ALIGN_RIGHT)
        self.setParagraphAttributes(para_attribs, True)

        # Use default font style
        default_attribs = SimpleAttributeSet()
        StyleConstants.setFontFamily(default_attribs, "Monaco")
        StyleConstants.setFontSize(default_attribs, 14)
        StyleConstants.setForeground(default_attribs, Color.gray)
        self.setCharacterAttributes(default_attribs, True)

        # Initialize content
        border = BorderFactory.createEmptyBorder(4, 4, 4, 4)
        self.border = border
        self.setText("1: \n")
        self.setEditable(False)

        # Prevent auto scroll down when line numbers are repainted
        caret = self.getCaret()
        caret.setUpdatePolicy(DefaultCaret.NEVER_UPDATE)
Пример #4
0
    def initComponents(self):
        self.setLayout(BoxLayout(self, BoxLayout.Y_AXIS))
        #self.setLayout(GridLayout(0,1))
        self.setAlignmentX(JComponent.LEFT_ALIGNMENT)
        self.panel1 = JPanel()
        self.panel1.setLayout(BoxLayout(self.panel1, BoxLayout.Y_AXIS))
        self.panel1.setAlignmentY(JComponent.LEFT_ALIGNMENT)
        self.checkbox = JCheckBox("All Logs",
                                  actionPerformed=self.checkBoxEvent)
        self.checkbox1 = JCheckBox("Application.Evtx",
                                   actionPerformed=self.checkBoxEvent)
        self.checkbox2 = JCheckBox("Security.EVTX",
                                   actionPerformed=self.checkBoxEvent)
        self.checkbox3 = JCheckBox("System.EVTX",
                                   actionPerformed=self.checkBoxEvent)
        self.checkbox4 = JCheckBox(
            "Other - Input in text area below then check this box",
            actionPerformed=self.checkBoxEvent)
        self.panel1.add(self.checkbox)
        self.panel1.add(self.checkbox1)
        self.panel1.add(self.checkbox2)
        self.panel1.add(self.checkbox3)
        self.panel1.add(self.checkbox4)
        self.add(self.panel1)

        self.area = JTextArea(5, 25)
        #self.area.addKeyListener(self)
        self.area.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0))
        self.pane = JScrollPane()
        self.pane.getViewport().add(self.area)
        #self.pane.addKeyListener(self)
        #self.add(self.area)
        self.add(self.pane)
Пример #5
0
    def initComponents(self):
        self.setLayout(BoxLayout(self, BoxLayout.Y_AXIS))
        #self.setLayout(GridLayout(0,1))
        self.setAlignmentX(JComponent.LEFT_ALIGNMENT)
        self.panel1 = JPanel()
        self.panel1.setLayout(BoxLayout(self.panel1, BoxLayout.Y_AXIS))
        self.panel1.setAlignmentY(JComponent.LEFT_ALIGNMENT)
        self.checkbox = JCheckBox("All Logs", actionPerformed=self.checkBoxEvent)
        self.checkbox1 = JCheckBox("Application.Evtx", actionPerformed=self.checkBoxEvent)
        self.checkbox2 = JCheckBox("Security.EVTX", actionPerformed=self.checkBoxEvent)
        self.checkbox3 = JCheckBox("System.EVTX", actionPerformed=self.checkBoxEvent)
        self.checkbox4 = JCheckBox("Other - Input in text area below then check this box", actionPerformed=self.checkBoxEvent)
        self.panel1.add(self.checkbox)
        self.panel1.add(self.checkbox1)
        self.panel1.add(self.checkbox2)
        self.panel1.add(self.checkbox3)
        self.panel1.add(self.checkbox4)
        self.add(self.panel1)
		
        self.area = JTextArea(5,25)
        #self.area.addKeyListener(self)
        self.area.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0))
        self.pane = JScrollPane()
        self.pane.getViewport().add(self.area)
        #self.pane.addKeyListener(self)
        #self.add(self.area)
        self.add(self.pane)
Пример #6
0
    def initComponents(self):
        self.setLayout(BoxLayout(self, BoxLayout.Y_AXIS))
        self.setAlignmentX(JComponent.LEFT_ALIGNMENT)
        self.panel1 = JPanel()
        self.panel1.setLayout(BoxLayout(self.panel1, BoxLayout.Y_AXIS))
        self.panel1.setAlignmentY(JComponent.LEFT_ALIGNMENT)
        self.checkbox = JCheckBox("Искать таблицы?".decode('UTF-8'),
                                  actionPerformed=self.checkBoxEvent)
        self.label0 = JLabel(" ")
        self.label1 = JLabel(
            "Введите названия интересуемых таблиц".decode('UTF-8'))
        self.label2 = JLabel(
            "через запятую, после чего установите флажок".decode('UTF-8'))
        self.label3 = JLabel(" ")
        self.panel1.add(self.checkbox)
        self.panel1.add(self.label0)
        self.panel1.add(self.label1)
        self.panel1.add(self.label2)
        self.panel1.add(self.label3)
        self.add(self.panel1)
        self.local_settings.setSetting('Flag', 'false')

        self.area = JTextArea(5, 25)
        self.area.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0))
        self.pane = JScrollPane()
        self.pane.getViewport().add(self.area)
        self.add(self.pane)
Пример #7
0
    def __init__(self, parent, title, modal, app):
        JDialog.__init__(self, parent, title, modal)

        #Download and Read Dialog
        border = BorderFactory.createEmptyBorder(5, 7, 5, 7)
        self.getContentPane().setBorder(border)
        self.setLayout(BoxLayout(self.getContentPane(), BoxLayout.Y_AXIS))

        panel = JPanel()
        panel.setAlignmentX(0.5)
        panel.setLayout(BoxLayout(panel, BoxLayout.Y_AXIS))
        panel.add(Box.createRigidArea(Dimension(0, 10)))

        self.progressLbl = JLabel(app.strings.getString("downloading_and_reading_errors"))
        panel.add(self.progressLbl)

        panel.add(Box.createRigidArea(Dimension(0, 10)))

        self.progressBar = JProgressBar(0, 100, value=0)
        panel.add(self.progressBar)
        self.add(panel)

        self.add(Box.createRigidArea(Dimension(0, 20)))

        cancelBtn = JButton(app.strings.getString("cancel"),
                            ImageProvider.get("cancel"),
                            actionPerformed=app.on_cancelBtn_clicked)
        cancelBtn.setAlignmentX(0.5)
        self.add(cancelBtn)

        self.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE)
        self.pack()
Пример #8
0
 def __init__(self, controller):
     '''
     Creates default empty text area in a panel.
     It will contain the ATF file content, and allow text edition.
     It should highlight reserved words and suggest autocompletion or 
     possible typos, a la IDEs like Eclipse.
     It might need refactoring so that there is a parent panel with two modes
     or contexts, depending on user choice: text view or model view.
     '''
     #Give reference to controller to delegate action response
     self.controller = controller
     
     #Make text area occupy all available space and resize with parent window
     self.setLayout(BorderLayout())
     
     #Create text edition area
     self.editArea = JTextArea()
     self.editArea.border = BorderFactory.createEmptyBorder(4,4,4,4)
     self.editArea.font = Font("Monaco", Font.PLAIN, 14)
     
     #Will need scrolling controls
     scrollingText = JScrollPane(self.editArea)
     scrollingText.setPreferredSize(Dimension(1,500))
     
     #Add to parent panel
     self.add(scrollingText, BorderLayout.CENTER)
 
     
Пример #9
0
    def __init__(self):
        """
        Line numbers need to be displayed in a separate panel with different
        styling.
        """
        # Align right
        para_attribs = SimpleAttributeSet()
        StyleConstants.setAlignment(para_attribs, StyleConstants.ALIGN_RIGHT)
        self.setParagraphAttributes(para_attribs, True)

        # Use default font style
        default_attribs = SimpleAttributeSet()
        self.font = set_font()
        StyleConstants.setFontFamily(default_attribs, self.font.getFamily())
        StyleConstants.setFontSize(default_attribs, self.font.getSize())
        StyleConstants.setForeground(default_attribs, Color.gray)
        self.setCharacterAttributes(default_attribs, True)

        # Initialize content
        border = BorderFactory.createEmptyBorder(4, 4, 4, 4)
        self.border = border
        self.setText("1: \n")
        self.setEditable(False)

        # Prevent auto scroll down when line numbers are repainted
        caret = self.getCaret()
        caret.setUpdatePolicy(DefaultCaret.NEVER_UPDATE)
    def initComponents(self):
        self.setLayout(BoxLayout(self, BoxLayout.Y_AXIS))
        #self.setLayout(GridLayout(0,1))
        self.setAlignmentX(JComponent.LEFT_ALIGNMENT)
        self.panel1 = JPanel()
        self.panel1.setLayout(BoxLayout(self.panel1, BoxLayout.Y_AXIS))
        self.panel1.setAlignmentY(JComponent.LEFT_ALIGNMENT)
        self.checkbox = JCheckBox("Check to activate/deactivate TextArea",
                                  actionPerformed=self.checkBoxEvent)
        self.label0 = JLabel(" ")
        self.label1 = JLabel("Input in SQLite DB's in area below,")
        self.label2 = JLabel("seperate values by commas.")
        self.label3 = JLabel("then check the box above.")
        self.label4 = JLabel(" ")
        self.panel1.add(self.checkbox)
        self.panel1.add(self.label0)
        self.panel1.add(self.label1)
        self.panel1.add(self.label2)
        self.panel1.add(self.label3)
        self.panel1.add(self.label4)
        self.add(self.panel1)

        self.area = JTextArea(5, 25)
        #self.area.getDocument().addDocumentListener(self.area)
        #self.area.addKeyListener(listener)
        self.area.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0))
        self.pane = JScrollPane()
        self.pane.getViewport().add(self.area)
        #self.pane.addKeyListener(self.area)
        #self.add(self.area)
        self.add(self.pane)
Пример #11
0
    def __init__(self, parent, title, modal, app):
        self.app = app
        self.setSize(400, 450)
        border = BorderFactory.createEmptyBorder(5, 7, 5, 7)
        self.getContentPane().setBorder(border)
        self.setLayout(BorderLayout(5, 5))

        #Intro
        introLbl = JLabel("<html>%s</html>" % self.app.strings.getString("error_info_intro"))

        #Panel for displaying error info
        self.infoPanel = HtmlPanel()
        self.infoPanel.getEditorPane().addHyperlinkListener(self)
        self.scrollPane = JScrollPane(self.infoPanel)

        #OK button
        btnPanel = JPanel(FlowLayout(FlowLayout.CENTER))
        okBtn = JButton(self.app.strings.getString("OK"),
                        ImageProvider.get("ok"),
                        actionPerformed=self.on_okBtn_clicked)
        btnPanel.add(okBtn)

        #Layout
        self.add(introLbl, BorderLayout.PAGE_START)
        self.add(self.scrollPane, BorderLayout.CENTER)
        self.add(btnPanel, BorderLayout.PAGE_END)

        self.setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE)
Пример #12
0
 def __init__(self):
     self.frame = JFrame("Python Window")
     self.historyList = JList(DefaultListModel())
     self.historyList.cellRenderer = MyListCellRenderer()
     #self.historyPanel.layout = BoxLayout(
     #    self.historyPanel,
     #    BoxLayout.Y_AXIS
     #)
     scrollpane = JScrollPane()
     #    JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
     #    JScrollPane.HORIZONTAL_SCROLLBAR_NEVER
     #)
     # scrollpane.preferredSize = 400, 800
     inputPanel = JPanel()
     inputPanel.layout = GridLayout(1, 1)
     self.input = JTextArea("")
     self.input.border = BorderFactory.createEmptyBorder(5, 5, 5, 5)
     self.input.tabSize = 4
     self.input.font = Font("Monospaced", Font.PLAIN, 12)
     #self.input.preferredSize = 500, 200 
     self.input.addKeyListener(self)
     #self.button = JButton('Run', actionPerformed=self.run)
     inputPanel.add(self.input)
     #inputPanel.add(self.button)
     scrollpane.viewport.view = self.historyList
     self.frame.add(scrollpane, BorderLayout.CENTER)
     self.frame.add(inputPanel, BorderLayout.PAGE_END)
     self.frame.size = 500, 600
     self.frame.visible = False
Пример #13
0
    def initComponents(self):
        self.setLayout(BoxLayout(self, BoxLayout.Y_AXIS))
        #self.setLayout(GridLayout(0,1))
        self.setAlignmentX(JComponent.LEFT_ALIGNMENT)
        self.panel1 = JPanel()
        self.panel1.setLayout(BoxLayout(self.panel1, BoxLayout.Y_AXIS))
        self.panel1.setAlignmentY(JComponent.LEFT_ALIGNMENT)
        self.checkbox = JCheckBox("Check to activate/deactivate TextArea", actionPerformed=self.checkBoxEvent)
        self.label0 = JLabel(" ")
        self.label1 = JLabel("Input in SQLite DB's in area below,")
        self.label2 = JLabel("seperate values by commas.")
        self.label3 = JLabel("then check the box above.")
        self.label4 = JLabel(" ")
        self.panel1.add(self.checkbox)
        self.panel1.add(self.label0)
        self.panel1.add(self.label1)
        self.panel1.add(self.label2)
        self.panel1.add(self.label3)
        self.panel1.add(self.label4)
        self.add(self.panel1)
 
        self.area = JTextArea(5,25)
        #self.area.getDocument().addDocumentListener(self.area)
        #self.area.addKeyListener(listener)
        self.area.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0))
        self.pane = JScrollPane()
        self.pane.getViewport().add(self.area)
        #self.pane.addKeyListener(self.area)
        #self.add(self.area)
        self.add(self.pane)
Пример #14
0
    def __init__(self, parent, title, modal, app):
        JDialog.__init__(self, parent, title, modal)

        #Download and Read Dialog
        border = BorderFactory.createEmptyBorder(5, 7, 5, 7)
        self.getContentPane().setBorder(border)
        self.setLayout(BoxLayout(self.getContentPane(), BoxLayout.Y_AXIS))

        panel = JPanel()
        panel.setAlignmentX(0.5)
        panel.setLayout(BoxLayout(panel, BoxLayout.Y_AXIS))
        panel.add(Box.createRigidArea(Dimension(0, 10)))

        self.progressLbl = JLabel(
            app.strings.getString("downloading_and_reading_errors"))
        panel.add(self.progressLbl)

        panel.add(Box.createRigidArea(Dimension(0, 10)))

        self.progressBar = JProgressBar(0, 100, value=0)
        panel.add(self.progressBar)
        self.add(panel)

        self.add(Box.createRigidArea(Dimension(0, 20)))

        cancelBtn = JButton(app.strings.getString("cancel"),
                            ImageProvider.get("cancel"),
                            actionPerformed=app.on_cancelBtn_clicked)
        cancelBtn.setAlignmentX(0.5)
        self.add(cancelBtn)

        self.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE)
        self.pack()
Пример #15
0
    def initComponents(self):
        self.setLayout(BoxLayout(self, BoxLayout.Y_AXIS))
        #self.setLayout(GridLayout(0,1))
        self.setAlignmentX(JComponent.LEFT_ALIGNMENT)
        self.panel1 = JPanel()
        self.panel1.setLayout(BoxLayout(self.panel1, BoxLayout.Y_AXIS))
        self.panel1.setAlignmentY(JComponent.LEFT_ALIGNMENT)
        self.checkbox = JCheckBox("Create Content View of Unique Event Id's",
                                  actionPerformed=self.checkBoxEvent)
        self.checkbox4 = JCheckBox(
            "Other - Input in text area below then check this box",
            actionPerformed=self.checkBoxEvent)
        self.text1 = JLabel(
            "*** Only run this once otherwise it adds it to the data again.")
        self.text2 = JLabel(" ")
        self.text3 = JLabel(
            "*** Format is a comma delimited text ie:  8001, 8002")
        self.panel1.add(self.checkbox)
        self.panel1.add(self.text1)
        self.panel1.add(self.text2)
        self.panel1.add(self.checkbox4)
        self.panel1.add(self.text3)
        self.add(self.panel1)

        self.area = JTextArea(5, 25)
        #self.area.addKeyListener(self)
        self.area.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0))
        self.pane = JScrollPane()
        self.pane.getViewport().add(self.area)
        #self.pane.addKeyListener(self)
        #self.add(self.area)
        self.add(self.pane)
Пример #16
0
    def add_template(self,name,constructor,image):
        icon = ImageIcon(image)
        if icon.iconWidth>self.max_icon_width:
            icon = ImageIcon(icon.image.getScaledInstance(self.max_icon_width,icon.iconHeight*self.max_icon_width/icon.iconWidth,Image.SCALE_SMOOTH))


        panel = JPanel(layout = BorderLayout(),opaque = False)

        button = JButton(icon = icon,toolTipText = name.replace('\n',' '),
                       borderPainted = False,focusPainted = False,contentAreaFilled = False,margin = java.awt.Insets(0,0,0,0),
                       verticalTextPosition = AbstractButton.BOTTOM,horizontalTextPosition = AbstractButton.CENTER,
                       mousePressed = lambda e: e.source.transferHandler.exportAsDrag(e.source,e,TransferHandler.COPY))
        button.transferHandler = self
        panel.add(button)

        text = '<html><center>%s</center></html>'%name.replace('\n','<br/>')
        label = JLabel(text,horizontalAlignment = SwingConstants.CENTER,foreground = Color.WHITE)
        self.labels.append(label)
        panel.add(label,BorderLayout.SOUTH)
        self.panels.append(panel)

        panel.alignmentY = Component.CENTER_ALIGNMENT
        panel.border = BorderFactory.createEmptyBorder(2,1,2,1)
        panel.maximumSize = panel.preferredSize
        self.panel.add(panel)
        self.templates[button] = constructor
    def actionPerformed(self, e):
        bugs_tab = self.tabbed_panes[self.key].getComponentAt(1)
        tab_count = str(bugs_tab.getTabCount())

        request_tab = self.view.set_request_tab_pane(self.request_response)
        response_tab = self.view.set_response_tab_pane(self.request_response)
        bugs_tabbed_pane = self.view.set_bugs_tabbed_pane(request_tab, response_tab)

        bugs_tab.add(tab_count, bugs_tabbed_pane)
        index = bugs_tab.indexOfTab(tab_count)
        panel_tab = JPanel(GridBagLayout())
        panel_tab.setOpaque(False)
        label_title = JLabel(tab_count)

        # Create a button to close tab
        button_close = JButton("x")
        button_close.setToolTipText("Close tab")
        button_close.setOpaque(False);
        button_close.setContentAreaFilled(False);
        button_close.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0))
        button_close.setPreferredSize(Dimension(18, 18))
        button_close.setMargin(Insets(0, 0, 0, 0))
        button_close.setForeground(Color.gray)

        panel_tab.add(label_title)
        panel_tab.add(button_close)

        bugs_tab.setTabComponentAt(index, panel_tab)

        button_close.addMouseListener(CloseTab(button_close, bugs_tab))
Пример #18
0
 def __init__(self):
     FormPanel.__init__(
         self, gvsig.getResource(__file__, "sentinelSearchPanel.xml"))
     #self.setPreferredSize(300,700)
     self.params = None
     self.mapControl = None
     self.start = 0
     self.rows = 10
     self.sortby = "ingestiondate%20asc"
     # Init components
     self.lblPreview.setBorder(BorderFactory.createEmptyBorder())
     platformOptions = ["---", "Sentinel-1", "Sentinel-2", "Sentinel-3"]
     for k in platformOptions:
         self.cmbPlatform.addItem(k)
     polarisation = ["---", "HH", "VV", "HV", "VH", "HH HV", "VV VH"]
     for k in polarisation:
         self.cmbPolarisation.addItem(k)
     sensors = ["---", "SM", "IW", "EW", "WV"]
     for k in sensors:
         self.cmbSensor.addItem(k)
     model1 = SpinnerNumberModel(5.0, 0.0, 100.0, 1.0)
     #spin1 = JSpinner(model1)
     self.spnCloud.setModel(model1)
     self.txtInfo.setCaretPosition(0)
     ## Download manager
     self.downloadManager = SentinelDownloadManager(self)
    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
Пример #20
0
    def initComponents(self):
        dataModel = DefaultTableModel(self.regTableData, self.regCols)
        self.regTable = JTable(dataModel)
        scrollPaneReg = JScrollPane()
        scrollPaneReg.getViewport().setView((self.regTable))
        self.regTab.add(scrollPaneReg)
        # self.logTabbedPane.addTab('Registred',self.regTab)
        self.logTabbedPane.insertTab("Registred", None, self.regTab, None, 0)

        dataModel = DefaultTableModel(self.parkTableData, self.parkCols)
        self.parkTable = JTable(dataModel)
        scrollPanePark = JScrollPane()
        scrollPanePark.getViewport().setView((self.parkTable))
        self.parkedTab.add(scrollPanePark)
        # self.logTabbedPane.addTab('Parked',self.parkedTab)
        self.logTabbedPane.insertTab("Parked", None, self.parkedTab, None, 1)

        dataModel = DefaultTableModel(self.bypassTableData, self.bypassCol)
        self.bypassTable = JTable(dataModel)
        scrollPaneBypass = JScrollPane()
        scrollPaneBypass.getViewport().setView((self.bypassTable))
        self.bypassTab.add(scrollPaneBypass)
        # self.logTabbedPane.addTab('Bypassed',self.bypassTab)
        self.logTabbedPane.insertTab("Bypassed", None, self.bypassTab, None, 2)

        self.add(self.logTabbedPane, BorderLayout.CENTER)

        innerBorder = BorderFactory.createTitledBorder('View Logs ')
        outerBorder = BorderFactory.createEmptyBorder(5, 5, 5, 5)
        self.setBorder(
            BorderFactory.createCompoundBorder(outerBorder, innerBorder))
Пример #21
0
 def __init__(self, controller):
     self.controller = controller
     self.border = BorderFactory.createEmptyBorder(4, 4, 4, 4)
     self.font = set_font()
     # If this is not done, no tooltips appear
     self.setToolTipText("")
     # Consume mouse events when over this JTextPane
     listener = CustomMouseListener(self)
     self.addMouseListener(listener)
Пример #22
0
 def __init__(self):
     self.setLayout(
             BoxLayout(
                 self,
                 BoxLayout.X_AXIS
             )
         )
     self.setBorder(
             BorderFactory.createEmptyBorder(5, 5, 5, 5)
         )
Пример #23
0
 def __init__(self, controller):
     # This custom StyledEditorKit fixes broken line wrapping.
     self.setEditorKit(MyStyledEditorKit())
     self.controller = controller
     self.border = BorderFactory.createEmptyBorder(4, 4, 4, 4)
     # If this is not done, no tooltips appear
     self.setToolTipText("")
     # Consume mouse events when over this JTextPane
     listener = CustomMouseListener(self)
     self.addMouseListener(listener)
Пример #24
0
 def __init__(self, controller):
     # This custom StyledEditorKit fixes broken line wrapping.
     self.setEditorKit(MyStyledEditorKit())
     self.controller = controller
     self.border = BorderFactory.createEmptyBorder(4, 4, 4, 4)
     # If this is not done, no tooltips appear
     self.setToolTipText("")
     # Consume mouse events when over this JTextPane
     listener = CustomMouseListener(self)
     self.addMouseListener(listener)
Пример #25
0
   def initUI(self):

       global outputTextField
       self.panel = JPanel()
       self.panel.setLayout(BorderLayout())

       toolbar = JToolBar()
       openb = JButton("Choose input file", actionPerformed=self.onClick)
       outputLabel = JLabel("   Enter output file name:  ")
       outputTextField = JTextField("hl7OutputReport.txt", 5)
       print outputTextField.getText()


     


       toolbar.add(openb)
       toolbar.add(outputLabel)
       toolbar.add(outputTextField)
      

       self.area = JTextArea()
       self.area.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10))
       self.area.setText("Select your HL7 ORU messages text file to be converted to tab-delimited flat \nfile with select HL7 fields.\n")
       self.area.append("You can enter the path + file name for your output file or it will default to the current \nfile name in the text field above in your current working directory.")

       pane = JScrollPane()
       pane.getViewport().add(self.area)

       self.panel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10))
       self.panel.add(pane)
       self.add(self.panel)

       self.add(toolbar, BorderLayout.NORTH)


       self.setTitle("HL7 ORU Results Reporter")
       self.setSize(600, 300)
       self.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE)
       self.setLocationRelativeTo(None)
       self.setVisible(True)
       return outputTextField.getText()
Пример #26
0
    def initComponents(self):
        self.panel = JPanel()
        self.panel.setLayout(BorderLayout())

        toolbar = JToolBar()
        openb = JButton("Select", actionPerformed=self.onClick)

        toolbar.add(openb)

        self.area = JTextArea()
        self.area.setBorder(BorderFactory.createEmptyBorder(10, 100, 10, 100))

        pane = JScrollPane()
        pane.getViewport().add(self.area)

        self.panel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10))
        self.panel.add(pane)
        self.add(self.panel)

        self.add(toolbar)
    def initComponents(self):
        self.panel = JPanel()
        self.panel.setLayout(BorderLayout())

        toolbar = JToolBar()
        openb = JButton("Select", actionPerformed=self.onClick)

        toolbar.add(openb)

        self.area = JTextArea()
        self.area.setBorder(BorderFactory.createEmptyBorder(10, 100, 10, 100))

        pane = JScrollPane()
        pane.getViewport().add(self.area)

        self.panel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10))
        self.panel.add(pane)
        self.add(self.panel)

        self.add(toolbar)
Пример #28
0
    def initComponents(self):
        self.setLayout(GridBagLayout())

        gc = GridBagConstraints()

        gc.weightx = 1
        gc.weighty = 1

        # First Row
        gc.gridy = 0

        gc.weightx = 1
        gc.weighty = 0.1
        gc.gridx = 0

        gc.fill = GridBagConstraints.NONE
        gc.anchor = GridBagConstraints.LINE_END
        gc.insets = Insets(0, 0, 0, 5)
        self.add(self.usernameLabel, gc)

        gc.gridx = 1
        gc.anchor = GridBagConstraints.LINE_START
        gc.insets = Insets(0, 0, 0, 0)
        self.add(self.usernameField, gc)

        # Second Row
        gc.gridy += 1
        gc.weightx = 1
        gc.weighty = 0.1
        gc.gridx = 0

        gc.anchor = GridBagConstraints.LINE_END
        gc.insets = Insets(0, 0, 0, 5)
        self.add(self.superPassLabel, gc)

        gc.gridx = 1

        gc.anchor = GridBagConstraints.LINE_START
        gc.insets = Insets(0, 0, 0, 0)
        self.add(self.superPassField, gc)

        #Next Row
        gc.gridy += 1
        gc.weightx = 1
        gc.weighty = 2.0
        gc.gridx = 1
        gc.anchor = GridBagConstraints.FIRST_LINE_START
        self.add(self.deleteAdminBtn, gc)

        innerBorder = BorderFactory.createTitledBorder('Delete Admin')
        outerBorder = BorderFactory.createEmptyBorder(5, 5, 5, 5)
        self.setBorder(
            BorderFactory.createCompoundBorder(outerBorder, innerBorder))
Пример #29
0
    def run(self):
        self.frame = frame = JFrame('ProgressMonitor',
                                    size=(280, 125),
                                    locationRelativeTo=None,
                                    defaultCloseOperation=JFrame.EXIT_ON_CLOSE)
        frame.getContentPane().setBorder(
            BorderFactory.createEmptyBorder(20, 20, 20, 20))

        panel = JPanel()
        self.button = panel.add(JButton('Start', actionPerformed=self.start))
        frame.add(panel, BorderLayout.NORTH)
        frame.setVisible(1)
Пример #30
0
    def __init__(self):
        self.dir_path = ''

        self.panel = JPanel()
        box_layout = BoxLayout(self.panel, BoxLayout.Y_AXIS)
        self.panel.setLayout(box_layout)
        self.panel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10))

        self.choose_dir_label = JLabel('Experiment Folder:')
        self.choose_dir_textField = JTextField(30)
        self.choose_dir_textField.addActionListener(
            ActionListenerFactory(self, self.textField_al))
        self.choose_dir_button = JButton('open')
        self.choose_dir_button.addActionListener(
            ActionListenerFactory(self, self.choose_dir_al))

        self.choose_dir_panel = JPanel()
        self.choose_dir_panel.add(self.choose_dir_label)
        self.choose_dir_panel.add(self.choose_dir_textField)
        self.choose_dir_panel.add(self.choose_dir_button)

        self.panel.add(self.choose_dir_panel)

        # root = DefaultMutableTreeNode()

        # self.meta_data_mode_label = JLabel('Autogenerated meta_data file mode')
        # self.raw_stack_mode = JRadioButton('raw stack mode')
        # self.projection_mode = JRadioButton('projection files mode')
        #
        # self.meta_data_mode = ButtonGroup()
        # self.meta_data_mode.add(self.raw_stack_mode)
        # self.meta_data_mode.add(self.projection_mode)
        #
        # self.meta_data_mode_panel = JPanel(GridLayout(0, 1))
        # self.meta_data_mode_panel.add(self.meta_data_mode_label)
        # self.meta_data_mode_panel.add(self.raw_stack_mode)
        # self.meta_data_mode_panel.add(self.projection_mode)
        #
        # self.panel.add(self.meta_data_mode_panel)

        self.run_button = JButton('Run')
        self.run_button.addActionListener(
            ActionListenerFactory(self, self.run_button_al))
        self.panel.add(self.run_button)

        super(BobGui, self).__init__("BobPy")
        self.getContentPane().add(self.panel)
        self.pack()
        self.setLocationRelativeTo(None)
        self.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE)
        self.setVisible(True)
Пример #31
0
    def __init__(self):
        self.panel_update_cookies = Panel_Fetch_Update_Cookies()
        self.panel_remove_cookies = Panel_Remove_Cookies()
        self.panel_extension = Panel_Extension()

        self.setLayout(BoxLayout(self, BoxLayout.Y_AXIS))
        self.setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20))

        self.add(self.panel_extension)
        self.add(SHA.sha_panel)
        self.add(self.panel_update_cookies)
        self.add(self.panel_remove_cookies)

        self.panel_extension.load_profiles()
Пример #32
0
    def __init__(self, controller):
        '''
        Creates default empty console-looking panel.
        It should be separated from the rest of the GUI so that users can
        choose to show or hide the console. Or should it be a split panel?
        This panel will display log and validation/lemmatization messages.
        It might need its own toolbar for searching, etc.
        It will also accept commands in later stages of development, if need
        be.
        '''
        # Give reference to controller to delegate action response
        self.controller = controller

        # Make text area occupy all available space and resize with parent
        # window
        self.setLayout(BorderLayout())

        # Create console-looking area
        self.edit_area = JEditorPane()

        # Although most of the styling is done using css, we need to set these
        # properties to ensure the html is rendered properly in the console
        self.edit_area.border = BorderFactory.createEmptyBorder(6, 6, 6, 6)
        self.edit_area.setContentType("text/html")

        # Disable writing in the console - required to render hyperlinks
        self.edit_area.setEditable(False)

        # Map CSS color strings to Java Color objects
        self.colors = {'Gray': Color(238, 238, 238),
                       'Black': Color(0, 0, 0),
                       'Yellow': Color(255, 255, 0)}

        # Initial call to refresh console to set the console style properties
        self.refreshConsole()

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

        # Will need scrolling controls
        scrollingText = JScrollPane(self.edit_area)
        scrollingText.setPreferredSize(Dimension(1, 150))

        # Make text area auto scroll down to last printed line
        caret = self.edit_area.getCaret()
        caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE)

        # Add to parent panel
        self.add(scrollingText, BorderLayout.CENTER)
Пример #33
0
    def registerExtenderCallbacks(self, callbacks):
        print '------------------------------Welcome to the Burp Suite Wordlist Creator----------------------------------'
        print 'Right click HTML or JSON responses in the Target tab to gather all unique words gathered from the response'
        # print '##########################################################################################################'
        self._callbacks = callbacks
        self._helpers = callbacks.getHelpers()
        self.context = None
        self.hosts = set()

        #Define extension properties
        callbacks.setExtensionName("Custom Wordlist")
        callbacks.registerContextMenuFactory(self)

        #wordlist file
        self.wordlist = []

        #Setup space for save dialogue to sit in.
        self.panel = JPanel()
        self.panel.setLayout(BorderLayout())

        self.area = JTextArea()
        self.area.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10))

        pane = JScrollPane()
        pane.getViewport().add(self.area)

        self.panel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10))
        self.panel.add(pane)
        self.add(self.panel)

        self.setTitle("File chooser")
        self.setSize(300, 250)
        self.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE)
        self.setLocationRelativeTo(None)
        #this is just providing a place where the save box can sit in, no need for it to be visible on start
        self.setVisible(False)
        return
Пример #34
0
    def __init__(self, parent, title, modal, app):
        border = BorderFactory.createEmptyBorder(5, 7, 5, 7)
        self.getContentPane().setBorder(border)
        self.setLayout(BoxLayout(self.getContentPane(), BoxLayout.Y_AXIS))

        #Intro
        falsePositivePng = File.separator.join(
            [app.SCRIPTDIR, "images", "icons", "not_error36.png"])
        introLbl = JMultilineLabel(
            app.strings.getString("manual_false_positives_info"))
        introLbl.setMaxWidth(600)

        #Table
        table = JTable()
        columns = [
            app.strings.getString("Tool"),
            app.strings.getString("Check"),
            app.strings.getString("Error_id"),
            app.strings.getString("OSM_id")
        ]
        self.tableModel = MyTableModel([], columns)
        table.setModel(self.tableModel)
        scrollPane = JScrollPane(table)
        scrollPane.setAlignmentX(0.0)

        #OK button
        btnPanel = JPanel(FlowLayout(FlowLayout.CENTER))
        okBtn = JButton("OK",
                        ImageProvider.get("ok"),
                        actionPerformed=self.on_okBtn_clicked)
        btnPanel.add(okBtn)
        btnPanel.setAlignmentX(0.0)

        #Layout
        headerPnl = JPanel()
        headerPnl.setLayout(BoxLayout(headerPnl, BoxLayout.X_AXIS))
        headerPnl.add(JLabel(ImageIcon(falsePositivePng)))
        headerPnl.add(Box.createRigidArea(Dimension(10, 0)))
        headerPnl.add(introLbl)
        headerPnl.setAlignmentX(0.0)
        self.add(headerPnl)
        self.add(Box.createRigidArea(Dimension(0, 10)))
        self.add(scrollPane)
        self.add(Box.createRigidArea(Dimension(0, 10)))
        self.add(btnPanel)

        self.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE)
        self.pack()
Пример #35
0
    def createAuxPanelWrapper(self, auxPanel, auxTitle):
        # Initialize auxillary panel
        leftPanel = JPanel()
        leftPanel.layout = BorderLayout()
        leftPanel.addFocusListener(LeftFocusListener(self))

        # NengoStyle.applyStyle(leftPanel);

        if self.showTitle:
            # Create auxillary panel's title bar

            titleBar = JPanel()
            titleBar.border = BorderFactory.createEmptyBorder(0, 0, 5, 0))
            NengoStyle.applyStyle(titleBar)
            titleBar.background = NengoStyle.COLOR_BACKGROUND2
            titleBar.opaque = True
            titleBar.layout = BorderLayout()

            titleLabel = JLabel(title)

            titleLabel.font = NengoStyle.FONT_BIG
            NengoStyle.applyStyle(titleLabel)
            titleLabel.background = NengoStyle.COLOR_BACKGROUND2
            titleLabel.opaque = True

            hideButtonTxt = " >> " if self.orientation == 'right' else " << "

            hideButton = JLabel(hideButtonTxt)
            NengoStyle.applyStyle(hideButton)
            hideButton.background = NengoStyle.COLOR_BACKGROUND2
            hideButton.opaque = True

            # Keep in this order, Swing puts items added first on top.
            # We want the button to be on top
            titleBar.add(hideButton, BorderLayout.EAST)
            titleBar.add(titleLabel, BorderLayout.WEST)

            hideButton.addMouseListener(HideButtonListener(self, hideButton))

            leftPanel.add(titleBar, BorderLayout.NORTH)

        leftPanel.minimumSize = self.minimumSize

        if auxPanel is not None:
            # NengoStyle.applyStyle(auxPanel)
            leftPanel.add(auxPanel, BorderLayout.CENTER)

        return leftPanel
Пример #36
0
    def __init__(self, parent, title, modal, app):
        border = BorderFactory.createEmptyBorder(5, 7, 5, 7)
        self.getContentPane().setBorder(border)
        self.setLayout(BoxLayout(self.getContentPane(), BoxLayout.Y_AXIS))

        #Intro
        falsePositivePng = File.separator.join([app.SCRIPTDIR,
                                                "images",
                                                "icons",
                                                "not_error36.png"])
        introLbl = JMultilineLabel(app.strings.getString("manual_false_positives_info"))
        introLbl.setMaxWidth(600)

        #Table
        table = JTable()
        columns = [app.strings.getString("Tool"),
                   app.strings.getString("Check"),
                   app.strings.getString("Error_id"),
                   app.strings.getString("OSM_id")]
        self.tableModel = MyTableModel([], columns)
        table.setModel(self.tableModel)
        scrollPane = JScrollPane(table)
        scrollPane.setAlignmentX(0.0)

        #OK button
        btnPanel = JPanel(FlowLayout(FlowLayout.CENTER))
        okBtn = JButton("OK",
                        ImageProvider.get("ok"),
                        actionPerformed=self.on_okBtn_clicked)
        btnPanel.add(okBtn)
        btnPanel.setAlignmentX(0.0)

        #Layout
        headerPnl = JPanel()
        headerPnl.setLayout(BoxLayout(headerPnl, BoxLayout.X_AXIS))
        headerPnl.add(JLabel(ImageIcon(falsePositivePng)))
        headerPnl.add(Box.createRigidArea(Dimension(10, 0)))
        headerPnl.add(introLbl)
        headerPnl.setAlignmentX(0.0)
        self.add(headerPnl)
        self.add(Box.createRigidArea(Dimension(0, 10)))
        self.add(scrollPane)
        self.add(Box.createRigidArea(Dimension(0, 10)))
        self.add(btnPanel)

        self.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE)
        self.pack()
Пример #37
0
 def __init__(self, textpane):
     self.component = JTextPane(
         font=textpane.font,
         border=BorderFactory.createEmptyBorder(5, 5, 5, 5),
         editable=False,
         background=awtColor(220, 220, 220),
     )
     self.doc = self.component.document
     self.component.setParagraphAttributes(
         textpane.paragraphAttributes, True
     )
     self.linecount = 0
     self.style = new_style(self.doc, "default",
         foreground=awtColor(100, 100, 100),
     )
     self.reset(1)
     textpane.document.addDocumentListener(self)
Пример #38
0
    def __init__(self, crate, slot, parentCrate):
        JPanel.__init__(self)
        self.bag = GridBag(self)
        # vertical labels
        for y in range(len(self.board.spyShortNameList)):
            name = self.board.spyShortNameList[y]
            self.bag.add(JLabel(name), gridx=0, gridy=y)
        # spy monitors
        self.spyMonitorList = map(
            lambda x, parentCrate=parentCrate: spyMonitor(x, parentCrate),
            self.board.spyList)
        for i in range(self.board.spyNumber):
            self.bag.add(self.spyMonitorList[i], gridx=1, gridy=i)

# set borders - this line is copied by an online Swing tutorial...
        self.border = BorderFactory.createCompoundBorder(
            BorderFactory.createTitledBorder("%s-%d" %
                                             (self.board.type, slot)),
            BorderFactory.createEmptyBorder(5, 5, 5, 5))
Пример #39
0
 def __init__(self):
     self.frame = JFrame("Python Window")
     #self.historyList = JList(DefaultListModel())
     #self.historyList.cellRenderer = MyListCellRenderer()
     scrollpane = JScrollPane()
     inputPanel = JPanel()
     inputPanel.layout = GridLayout(1, 1)
     self.input = JTextArea("")
     self.input.border = BorderFactory.createEmptyBorder(5, 5, 5, 5)
     self.input.tabSize = 4
     self.input.font = Font("Monospaced", Font.PLAIN, 12)
     self.input.addKeyListener(self)
     inputPanel.add(self.input)
     self.outputpane = OutputPane()
     scrollpane.viewport.view = self.outputpane.textpane  #self.historyList
     self.frame.add(scrollpane, BorderLayout.CENTER)
     self.frame.add(inputPanel, BorderLayout.PAGE_END)
     self.frame.size = 500, 600
     self.frame.visible = False
     self.component = None
Пример #40
0
 def __init__(self):
     self.frame = JFrame("Python Window")
     #self.historyList = JList(DefaultListModel())
     #self.historyList.cellRenderer = MyListCellRenderer()
     scrollpane = JScrollPane()
     inputPanel = JPanel()
     inputPanel.layout = GridLayout(1, 1)
     self.input = JTextArea("")
     self.input.border = BorderFactory.createEmptyBorder(5, 5, 5, 5)
     self.input.tabSize = 4
     self.input.font = Font("Monospaced", Font.PLAIN, 12)
     self.input.addKeyListener(self)
     inputPanel.add(self.input)
     self.outputpane = OutputPane()
     scrollpane.viewport.view = self.outputpane.textpane #self.historyList
     self.frame.add(scrollpane, BorderLayout.CENTER)
     self.frame.add(inputPanel, BorderLayout.PAGE_END)
     self.frame.size = 500, 600
     self.frame.visible = False
     self.component = None
Пример #41
0
 def __init__(self, parentCrate=None):
     JPanel.__init__(self)
     self.spy = None
     self.parentCrate = parentCrate
     self.nw = 10  # Number of words (total)
     self.upperPanel = JPanel()
     self.lowerPanel = JPanel()
     self.add(self.upperPanel)
     self.add(self.lowerPanel)
     self.nameLabel = JLabel("n/a")
     self.slotLabel = JLabel("n/a")
     self.textArea = JTextArea("n/a", 1, 70, editable=0)
     self.scrollPane = JScrollPane(self.textArea)
     self.textField = JTextField(3,
                                 actionCommand="textField",
                                 text=("%d" % self.nw))
     self.textField.addActionListener(self)
     self.clearButton = JButton("Stop", actionCommand="button")
     self.clearButton.addActionListener(self)
     self.border = BorderFactory.createEmptyBorder(5, 5, 5, 5)
     self.layout = BoxLayout(self, BoxLayout.Y_AXIS)
     self.upperPanel.layout = BoxLayout(self.upperPanel, BoxLayout.X_AXIS)
     self.lowerPanel.layout = BoxLayout(self.lowerPanel, BoxLayout.X_AXIS)
     self.upperPanel.add(self.clearButton)
     self.upperPanel.add(Box.createRigidArea(Dimension(20, 0)))
     self.upperPanel.add(JLabel("Spy:"))
     self.upperPanel.add(Box.createRigidArea(Dimension(5, 0)))
     self.upperPanel.add(self.nameLabel)
     self.upperPanel.add(Box.createRigidArea(Dimension(20, 0)))
     self.upperPanel.add(JLabel("Slot:"))
     self.upperPanel.add(Box.createRigidArea(Dimension(5, 0)))
     self.upperPanel.add(self.slotLabel)
     self.upperPanel.add(Box.createRigidArea(Dimension(20, 0)))
     self.upperPanel.add(JLabel("Number of words:"))
     self.upperPanel.add(Box.createRigidArea(Dimension(5, 0)))
     self.upperPanel.add(self.textField)
     self.upperPanel.add(Box.createHorizontalGlue())
     self.lowerPanel.add(JLabel("Tail contents:"))
     self.lowerPanel.add(Box.createRigidArea(Dimension(5, 0)))
     self.lowerPanel.add(self.scrollPane)
     self.lowerPanel.add(Box.createHorizontalGlue())
Пример #42
0
    def __init__(self, name, label, text, function=None, button1=None, button2=None):

        length = 1000
        self._name = name
        self._label = JLabel(label)
        self._textfield = JTextField(length) \
            if function is None \
            else JTextField(length, actionPerformed=function)
        self.add(self._label)
        self.add(self._textfield)
        if button1 is not None:
            self._button1 = button1
            self.add(self._button1)
        if button2 is not None:
            self._button2 = button2
            self.add(self._button2)
        self.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5))
        self._textfield.setText("0" * length)
        self._textfield.setMaximumSize(self._textfield.getPreferredSize())
        self.setMaximumSize(self.getPreferredSize())
        self.setText(text)
        self.setLayout(BoxLayout(self, BoxLayout.X_AXIS))
Пример #43
0
    def __init__(self, controller):
        '''
        Creates default empty console-looking panel.
        It should be separated from the rest of the GUI so that users can
        choose to show or hide the console. Or should it be a split panel?
        This panel will display log and validation/lemmatization messages.
        It might need its own toolbar for searching, etc.
        It will also accept commands in later stages of development, if need
        be.
        '''
        # Give reference to controller to delegate action response
        self.controller = controller

        # Make text area occupy all available space and resize with parent
        # window
        self.setLayout(BorderLayout())

        # Create console-looking area
        self.edit_area = JTextArea()
        self.edit_area.setLineWrap(True)
        self.edit_area.setWrapStyleWord(True)
        self.edit_area.border = BorderFactory.createEmptyBorder(4, 4, 4, 4)
        self.edit_area.font = Font("Courier New", Font.BOLD, 14)
        self.edit_area.background = Color.BLACK
        self.edit_area.foreground = Color.WHITE

        # Disable writing in the console
        self.edit_area.setEditable(False)

        # Will need scrolling controls
        scrollingText = JScrollPane(self.edit_area)
        scrollingText.setPreferredSize(Dimension(1, 150))

        # Make text area auto scroll down to last printed line
        caret = self.edit_area.getCaret()
        caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE)

        # Add to parent panel
        self.add(scrollingText, BorderLayout.CENTER)
Пример #44
0
 def __init__(self, frame, title):
     EnhancedDialog.__init__(self, frame, title, 1)
     self.contentPane.layout = layout(5, 5)
     upperPanel = panel(layout(5, 5))
     topPanel = panel(layout(5, 20))
     topPanel.add(label("Hahahaha", label.CENTER), layout.CENTER)
     topPanel.add(
         label(
             getIconFromPlugin("jython.JythonPlugin",
                               "images/PythonIcon.gif"), label.CENTER),
         layout.EAST)
     upperPanel.add(topPanel, layout.NORTH)
     copy = JTextArea(copyright)
     upperPanel.border = BorderFactory.createTitledBorder("Hihihihi")
     copy.border = BorderFactory.createEmptyBorder(5, 5, 5, 5)
     upperPanel.add(copy, layout.SOUTH)
     self.contentPane.add(upperPanel, layout.CENTER)
     lowerPanel = panel()
     lowerPanel.add(
         button(getProperty("common.close"), actionPerformed=self._close))
     self.contentPane.add(lowerPanel, layout.SOUTH)
     self.pack()
Пример #45
0
    def initComponents(self):
        self.setLayout(BoxLayout(self, BoxLayout.Y_AXIS))
        self.setAlignmentX(JComponent.LEFT_ALIGNMENT)
        self.panel1 = JPanel()
        self.panel1.setLayout(BoxLayout(self.panel1, BoxLayout.Y_AXIS))
        self.panel1.setAlignmentY(JComponent.LEFT_ALIGNMENT)
        self.checkbox = JCheckBox("Check to activate/deactivate pHashToCheck",
                                  actionPerformed=self.checkBoxEvent)
        self.label0 = JLabel(" ")
        self.label1 = JLabel("Input your phash value for checking: ")
        self.label2 = JLabel(" ")
        self.panel1.add(self.checkbox)
        self.panel1.add(self.label0)
        self.panel1.add(self.label1)
        self.panel1.add(self.label2)
        self.add(self.panel1)

        self.area = JTextArea(5, 25)
        self.area.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0))
        self.pane = JScrollPane()
        self.pane.getViewport().add(self.area)
        self.add(self.pane)
Пример #46
0
    def initComponents(self):

        self.setLayout(GridBagLayout())

        gc = GridBagConstraints()

        gc.weightx = 1
        gc.weighty = 1

        # First Row
        gc.gridy = 0

        gc.weightx = 1
        gc.weighty = 0.1
        gc.gridx = 0

        gc.fill = GridBagConstraints.NONE
        gc.anchor = GridBagConstraints.LINE_END
        gc.insets = Insets(0, 0, 0, 5)
        self.add(self.vehicleLabel, gc)

        gc.gridx = 1
        gc.anchor = GridBagConstraints.LINE_START
        gc.insets = Insets(0, 0, 0, 0)
        self.add(self.vehicleField, gc)

        #Next Row
        gc.gridy += 1
        gc.weightx = 1
        gc.weighty = 2.0
        gc.gridx = 1
        gc.anchor = GridBagConstraints.FIRST_LINE_START
        self.add(self.bypassBtn, gc)

        innerBorder = BorderFactory.createTitledBorder('Emergency Bypass')
        outerBorder = BorderFactory.createEmptyBorder(5, 5, 5, 5)
        self.setBorder(
            BorderFactory.createCompoundBorder(outerBorder, innerBorder))
Пример #47
0
    def __init__(self, parent, title, modal, app):
        """Restore the tools data by:
           - downloading the tools list
           - downloading the tools jar files
           - extracting the tools data from jar files
        """
        self.app = app
        border = BorderFactory.createEmptyBorder(5, 7, 5, 7)
        mainPane = self.getContentPane()
        mainPane.setLayout(BorderLayout(5, 5))
        mainPane.setBorder(border)
        self.setPreferredSize(Dimension(400, 200))
        self.taskOutput = JMultilineLabel(
            self.app.strings.getString("checking_for_updates"))
        self.taskOutput.setMaxWidth(350)
        self.progressBar = JProgressBar(0, 100, value=0, stringPainted=True)
        self.progressBar.setIndeterminate(True)
        self.cancelBtn = JButton("Cancel",
                                 actionPerformed=self.on_cancelBtn_clicked,
                                 enabled=True)
        self.okBtn = JButton("Ok",
                             actionPerformed=self.on_okBtn_clicked,
                             enabled=False)

        mainPane.add(self.taskOutput, BorderLayout.CENTER)
        bottomPanel = JPanel(BorderLayout(5, 5))
        bottomPanel.add(self.progressBar, BorderLayout.PAGE_START)
        buttonsPanel = JPanel()
        buttonsPanel.add(self.okBtn)
        buttonsPanel.add(self.cancelBtn)
        bottomPanel.add(buttonsPanel, BorderLayout.PAGE_END)
        mainPane.add(bottomPanel, BorderLayout.PAGE_END)
        self.pack()

        self.task = DownloaderTask(self)
        self.task.addPropertyChangeListener(self)
        self.task.execute()
Пример #48
0
    def __init__(self, parent, title, modal, app):
        """Restore the tools data by:
           - downloading the tools list
           - downloading the tools jar files
           - extracting the tools data from jar files
        """
        self.app = app
        border = BorderFactory.createEmptyBorder(5, 7, 5, 7)
        mainPane = self.getContentPane()
        mainPane.setLayout(BorderLayout(5, 5))
        mainPane.setBorder(border)
        self.setPreferredSize(Dimension(400, 200))
        self.taskOutput = JMultilineLabel(self.app.strings.getString("checking_for_updates"))
        self.taskOutput.setMaxWidth(350)
        self.progressBar = JProgressBar(0, 100, value=0, stringPainted=True)
        self.progressBar.setIndeterminate(True)
        self.cancelBtn = JButton("Cancel",
                                 actionPerformed=self.on_cancelBtn_clicked,
                                 enabled=True)
        self.okBtn = JButton("Ok",
                             actionPerformed=self.on_okBtn_clicked,
                             enabled=False)

        mainPane.add(self.taskOutput, BorderLayout.CENTER)
        bottomPanel = JPanel(BorderLayout(5, 5))
        bottomPanel.add(self.progressBar, BorderLayout.PAGE_START)
        buttonsPanel = JPanel()
        buttonsPanel.add(self.okBtn)
        buttonsPanel.add(self.cancelBtn)
        bottomPanel.add(buttonsPanel, BorderLayout.PAGE_END)
        mainPane.add(bottomPanel, BorderLayout.PAGE_END)
        self.pack()

        self.task = DownloaderTask(self)
        self.task.addPropertyChangeListener(self)
        self.task.execute()
Пример #49
0
    def __init__(self, extender, *rows, **kwargs):
        self.extender = extender

        if 'title' in kwargs:
            self.setBorder(
                BorderFactory.createCompoundBorder(
                    BorderFactory.createTitledBorder(kwargs.get('title', '')),
                    BorderFactory.createEmptyBorder(5, 5, 5, 5)))

        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)
Пример #50
0
    def __init__(self, parent, title, app):
        from javax.swing import JCheckBox, JRadioButton, ButtonGroup
        self.app = app
        border = BorderFactory.createEmptyBorder(5, 7, 5, 7)
        self.getContentPane().setBorder(border)
        self.getContentPane().setLayout(BorderLayout(0, 5))
        self.tabbedPane = JTabbedPane()

        #1 Tab: general
        panel1 = JPanel()
        panel1.setBorder(BorderFactory.createEmptyBorder(7, 7, 7, 7))
        panel1.setLayout(BoxLayout(panel1, BoxLayout.PAGE_AXIS))

        #Checkbutton to enable/disable update check when script starts
        self.updateCBtn = JCheckBox(self.app.strings.getString("updateCBtn"))
        self.updateCBtn.setToolTipText(self.app.strings.getString("updateCBtn_tooltip"))

        #Download tools
        downloadBtn = JButton(self.app.strings.getString("updatesBtn"),
                              ImageProvider.get("dialogs", "refresh"),
                              actionPerformed=self.on_downloadBtn_clicked)
        downloadBtn.setToolTipText(self.app.strings.getString("updatesBtn_tooltip"))

        #Checkbuttons for enabling/disabling tools
        toolsPanel = JPanel(BorderLayout(0, 5))
        title = self.app.strings.getString("enable_disable_tools")
        toolsPanel.setBorder(BorderFactory.createTitledBorder(title))
        infoLbl = JLabel(self.app.strings.getString("JOSM_restart_warning"))
        infoLbl.setFont(infoLbl.getFont().deriveFont(Font.ITALIC))
        toolsPanel.add(infoLbl, BorderLayout.PAGE_START)

        toolsStatusPane = JPanel(GridLayout(len(self.app.realTools), 0))
        self.toolsCBtns = []
        for tool in self.app.realTools:
            toolCBtn = JCheckBox()
            toolCBtn.addItemListener(self)
            toolLbl = JLabel(tool.title, tool.bigIcon, JLabel.LEFT)
            self.toolsCBtns.append(toolCBtn)

            toolPane = JPanel()
            toolPane.setLayout(BoxLayout(toolPane, BoxLayout.X_AXIS))
            toolPane.add(toolCBtn)
            toolPane.add(toolLbl)
            toolsStatusPane.add(toolPane)
        toolsPanel.add(toolsStatusPane, BorderLayout.CENTER)

        #Radiobuttons for enabling/disabling layers when a new one
        #is added
        layersPanel = JPanel(GridLayout(0, 1))
        title = self.app.strings.getString("errors_layers_manager")
        layersPanel.setBorder(BorderFactory.createTitledBorder(title))
        errorLayersLbl = JLabel(self.app.strings.getString("errors_layers_info"))
        errorLayersLbl.setFont(errorLayersLbl.getFont().deriveFont(Font.ITALIC))
        layersPanel.add(errorLayersLbl)
        self.layersRBtns = {}
        group = ButtonGroup()
        for mode in self.app.layersModes:
            layerRBtn = JRadioButton(self.app.strings.getString("%s" % mode))
            group.add(layerRBtn)
            layersPanel.add(layerRBtn)
            self.layersRBtns[mode] = layerRBtn

        #Max number of errors text field
        self.maxErrorsNumberTextField = JTextField()
        self.maxErrorsNumberTextField.setToolTipText(self.app.strings.getString("maxErrorsNumberTextField_tooltip"))
        self.maxErrorsNumberTFieldDefaultBorder = self.maxErrorsNumberTextField.getBorder()
        self.maxErrorsNumberTextField.getDocument().addDocumentListener(ErrNumTextListener(self))

        #layout
        self.updateCBtn.setAlignmentX(Component.LEFT_ALIGNMENT)
        panel1.add(self.updateCBtn)
        panel1.add(Box.createRigidArea(Dimension(0, 15)))
        downloadBtn.setAlignmentX(Component.LEFT_ALIGNMENT)
        panel1.add(downloadBtn)
        panel1.add(Box.createRigidArea(Dimension(0, 15)))
        toolsPanel.setAlignmentX(Component.LEFT_ALIGNMENT)
        panel1.add(toolsPanel)
        panel1.add(Box.createRigidArea(Dimension(0, 15)))
        layersPanel.setAlignmentX(Component.LEFT_ALIGNMENT)
        panel1.add(layersPanel)
        panel1.add(Box.createRigidArea(Dimension(0, 15)))
        maxErrP = JPanel(BorderLayout(5, 0))
        maxErrP.add(JLabel(self.app.strings.getString("max_errors_number")), BorderLayout.LINE_START)
        maxErrP.add(self.maxErrorsNumberTextField, BorderLayout.CENTER)
        p = JPanel(BorderLayout())
        p.add(maxErrP, BorderLayout.PAGE_START)
        p.setAlignmentX(Component.LEFT_ALIGNMENT)
        panel1.add(p)

        self.tabbedPane.addTab(self.app.strings.getString("tab_1_title"),
                          None,
                          panel1,
                          None)

        #2 Tab: favourite zones
        panel2 = JPanel(BorderLayout(5, 15))
        panel2.setBorder(BorderFactory.createEmptyBorder(7, 7, 7, 7))

        #status
        topPanel = JPanel()
        topPanel.setLayout(BoxLayout(topPanel, BoxLayout.Y_AXIS))
        infoPanel = HtmlPanel(self.app.strings.getString("fav_zones_info"))
        infoPanel.getEditorPane().addHyperlinkListener(self)
        infoPanel.setAlignmentX(Component.LEFT_ALIGNMENT)
        self.favZoneStatusCBtn = JCheckBox(self.app.strings.getString("activate_fav_area"),
                                           actionListener=self)
        self.favZoneStatusCBtn.setToolTipText(self.app.strings.getString("activate_fav_area_tooltip"))
        self.favZoneStatusCBtn.setAlignmentX(Component.LEFT_ALIGNMENT)
        topPanel.add(infoPanel)
        topPanel.add(Box.createRigidArea(Dimension(0, 10)))
        topPanel.add(self.favZoneStatusCBtn)
        #table
        self.zonesTable = JTable()
        tableSelectionModel = self.zonesTable.getSelectionModel()
        tableSelectionModel.addListSelectionListener(ZonesTableListener(self))
        columns = ["",
                   self.app.strings.getString("Type"),
                   self.app.strings.getString("Name")]
        tableModel = ZonesTableModel([], columns)
        self.zonesTable.setModel(tableModel)
        self.scrollPane = JScrollPane(self.zonesTable)
        #map
        self.zonesMap = JMapViewer()
        self.zonesMap.setZoomContolsVisible(False)
        self.zonesMap.setMinimumSize(Dimension(100, 200))

        #buttons
        self.removeBtn = JButton(self.app.strings.getString("Remove"),
                            ImageProvider.get("dialogs", "delete"),
                            actionPerformed=self.on_removeBtn_clicked)
        self.removeBtn.setToolTipText(self.app.strings.getString("remove_tooltip"))
        newBtn = JButton(self.app.strings.getString("New"),
                         ImageProvider.get("dialogs", "add"),
                         actionPerformed=self.on_newBtn_clicked)
        newBtn.setToolTipText(self.app.strings.getString("new_tooltip"))

        #layout
        panel2.add(topPanel, BorderLayout.PAGE_START)
        panel2.add(self.scrollPane, BorderLayout.LINE_START)
        panel2.add(self.zonesMap, BorderLayout.CENTER)
        self.buttonsPanel = JPanel()
        self.buttonsPanel.add(self.removeBtn)
        self.buttonsPanel.add(newBtn)
        panel2.add(self.buttonsPanel, BorderLayout.PAGE_END)

        self.tabbedPane.addTab(self.app.strings.getString("tab_2_title"),
                          None,
                          panel2,
                          None)

        #3 Tab Tools options
        panel3 = JPanel()
        panel3.setLayout(BoxLayout(panel3, BoxLayout.Y_AXIS))
        panel3.setBorder(BorderFactory.createEmptyBorder(7, 7, 7, 7))
        for tool in self.app.realTools:
            if hasattr(tool, 'prefs'):
                p = JPanel(FlowLayout(FlowLayout.LEFT))
                p.setBorder(BorderFactory.createTitledBorder(tool.title))
                p.add(tool.prefsGui)
                panel3.add(p)

        self.tabbedPane.addTab(self.app.strings.getString("tab_3_title"),
                          None,
                          panel3,
                          None)

        self.add(self.tabbedPane, BorderLayout.CENTER)

        exitPanel = JPanel()
        saveBtn = JButton(self.app.strings.getString("OK"),
                          ImageProvider.get("ok"),
                          actionPerformed=self.on_saveBtn_clicked)
        cancelBtn = JButton(self.app.strings.getString("cancel"),
                            ImageProvider.get("cancel"),
                            actionPerformed=self.on_cancelBtn_clicked)
        saveBtn.setToolTipText(self.app.strings.getString("save_preferences"))
        saveBtn.setAlignmentX(0.5)
        exitPanel.add(saveBtn)
        exitPanel.add(cancelBtn)
        self.add(exitPanel, BorderLayout.PAGE_END)

        self.addWindowListener(self)
        self.pack()
Пример #51
0
	def clientUI(self):
		'''ClientUI and Widget creation
		'''
		#  Colours
		foreground_colour = Color(30,57,68)
		background_colour = Color(247,246,242)
		window_background = Color(145,190,210)
		#  Borders
		self.border2=BorderFactory.createLineBorder(foreground_colour,1, True)
		#  Fonts
		self.font= Font("Ubuntu Light",  Font.BOLD, 20)
		self.label_font= Font("Ubuntu Light",  Font.BOLD, 17)
		self.label_2_font= Font( "Ubuntu Light",Font.BOLD, 12)
		self.btn_font=Font("Ubuntu Light", Font.BOLD, 15)
		
		#  Set the layout parameters
		self.client_layout=GroupLayout(self.getContentPane())
		self.getContentPane().setLayout(self.client_layout)	
		self.getContentPane().setBackground(window_background)
		self.client_layout.setAutoCreateGaps(True)
		self.client_layout.setAutoCreateContainerGaps(True)
		self.setPreferredSize(Dimension(400, 450))
		
		#  Create widgets and assemble the GUI
		#  Main display area
		self.main_content=JTextPane()
		self.main_content.setBackground(background_colour)
		#self.main_content.setForeground(foreground_colour)
		self.main_content.setEditable(False)
		#  Message entry area  		
		self.message=JTextArea( 2,2, border=self.border2, font=self.label_font, keyPressed=self.returnKeyPress)
		self.message.requestFocusInWindow()	
		self.message.setBackground(background_colour)
		self.message.setForeground(foreground_colour)
		self.message.setLineWrap(True)
		self.message.setWrapStyleWord(True)
		self.message.setBorder(BorderFactory.createEmptyBorder(3,3,3,3))
		self.message.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER,0), self.returnKeyPress) 
		#  BUttons
		quit_btn=JButton("Quit!", actionPerformed=ChatApp().closeEvent, border=self.border2, font=self.btn_font)
		go_btn=JButton("Send", actionPerformed=self.grabText, border=self.border2, font=self.btn_font)
		quit_btn.setBackground(background_colour)
		go_btn.setBackground(background_colour)
		quit_btn.setForeground(foreground_colour)
		go_btn.setForeground(foreground_colour)
		
		# Make scrollable
		self.scroll_content=JScrollPane(self.main_content)
		self.scroll_content.setPreferredSize(Dimension(150,275))
		self.scroll_content.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER)
		self.scroll_content.setViewportView(self.main_content)
		self.scroll_content.setBackground(Color.WHITE)
		self.scroll_message=JScrollPane(self.message)
		self.scroll_message.setPreferredSize(Dimension(150,20))
		self.scroll_message.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS)
		
		# Test user label, still not updating after first round of messages
		self.user_label=JLabel(" Users online : %s "%(str(len(self.no_users))),JLabel.RIGHT, font=self.label_2_font)
		
		#  Assemble the components
		#  Horizontal layout
		self.client_layout.setHorizontalGroup(self.client_layout.createParallelGroup()
				.addComponent(self.scroll_content)
				.addGroup(self.client_layout.createParallelGroup(GroupLayout.Alignment.CENTER)
					.addComponent(self.scroll_message))
				.addGroup(self.client_layout.createSequentialGroup()
					.addComponent(quit_btn)
					.addComponent(go_btn).addGap(20))
				.addGroup(self.client_layout.createParallelGroup()
					.addComponent(self.user_label))
		)
		
		#  Vertical layout
		self.client_layout.setVerticalGroup(self.client_layout.createSequentialGroup()
			.addGroup(self.client_layout.createParallelGroup()
				.addComponent(self.scroll_content))
				.addComponent(self.scroll_message)
				.addGroup(self.client_layout.createParallelGroup()
					.addComponent(quit_btn)
					.addComponent(go_btn))
				.addGroup(self.client_layout.createParallelGroup()
					.addComponent(self.user_label))
		)
		
		#  Finalise the GUI
		self.client_layout.linkSize(SwingConstants.HORIZONTAL, [quit_btn,go_btn, self.user_label])
		self.pack()
		self.message.requestFocusInWindow()
		self.setTitle(">>>   Client %s   <<<"%self.username)
		self.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE)
		self.setLocationRelativeTo(None)
		self.setVisible(True)
		#  Display the server greeting
		self.appendText('\n'+self.greeting+'\n')
Пример #52
0
    def __init__(self, name, iconName, tooltip, shortcut, height, app):
        ToggleDialog.__init__(self, name, iconName, tooltip, shortcut, height)
        self.app = app
        tools = app.tools

        #Main panel of the dialog
        mainPnl = JPanel(BorderLayout())
        mainPnl.setBorder(BorderFactory.createEmptyBorder(0, 1, 1, 1))

### First tab: errors selection and download ###########################
        #ComboBox with tools names
        self.toolsComboModel = DefaultComboBoxModel()
        for tool in tools:
            self.add_data_to_models(tool)
        self.toolsCombo = JComboBox(self.toolsComboModel,
                                    actionListener=ToolsComboListener(app))
        renderer = ToolsComboRenderer(self.app)
        renderer.setPreferredSize(Dimension(20, 20))
        self.toolsCombo.setRenderer(renderer)
        self.toolsCombo.setToolTipText(app.strings.getString("Select_a_quality_assurance_tool"))

        #ComboBox with categories names ("views"), of the selected tool
        self.viewsCombo = JComboBox(actionListener=ViewsComboListener(app))
        self.viewsCombo.setToolTipText(app.strings.getString("Select_a_category_of_error"))

        #Popup for checks table
        self.checkPopup = JPopupMenu()
        #add favourite check
        self.menuItemAdd = JMenuItem(self.app.strings.getString("Add_to_favourites"))
        self.menuItemAdd.setIcon(ImageIcon(File.separator.join([self.app.SCRIPTDIR,
                                                                "tools",
                                                                "data",
                                                                "Favourites",
                                                                "icons",
                                                                "tool_16.png"])))
        self.menuItemAdd.addActionListener(PopupActionListener(self.app))
        self.checkPopup.add(self.menuItemAdd)
        #remove favourite check
        self.menuItemRemove = JMenuItem(self.app.strings.getString("Remove_from_favourites"))
        self.menuItemRemove.setIcon(ImageIcon(File.separator.join([self.app.SCRIPTDIR,
                                                                   "tools",
                                                                   "data",
                                                                   "Favourites",
                                                                   "icons",
                                                                   "black_tool_16.png"])))
        self.menuItemRemove.addActionListener(PopupActionListener(self.app))
        self.checkPopup.add(self.menuItemRemove)
        #Help link for selected check
        self.menuItemHelp = JMenuItem(self.app.strings.getString("check_help"))
        self.menuItemHelp.setIcon(ImageIcon(File.separator.join([self.app.SCRIPTDIR,
                                                                 "images",
                                                                 "icons",
                                                                 "info_16.png"])))
        self.checkPopup.add(self.menuItemHelp)
        self.menuItemHelp.addActionListener(PopupActionListener(self.app))

        #Table with checks of selected tool and view
        self.checksTable = JTable()
        self.iconrenderer = IconRenderer()
        self.iconrenderer.setHorizontalAlignment(JLabel.CENTER)
        scrollPane = JScrollPane(self.checksTable)
        self.checksTable.setFillsViewportHeight(True)

        tableSelectionModel = self.checksTable.getSelectionModel()
        tableSelectionModel.addListSelectionListener(ChecksTableListener(app))

        self.checksTable.addMouseListener(ChecksTableClickListener(app,
            self.checkPopup,
            self.checksTable))

        #Favourite area status indicator
        self.favAreaIndicator = JLabel()
        self.update_favourite_zone_indicator()
        self.favAreaIndicator.addMouseListener(FavAreaIndicatorListener(app))

        #label with OSM id of the object currently edited and number of
        #errors still to review
        self.checksTextFld = JTextField("",
                                        editable=0,
                                        border=None,
                                        background=None)

        #checks buttons
        btnsIconsDir = File.separator.join([app.SCRIPTDIR, "images", "icons"])
        downloadIcon = ImageIcon(File.separator.join([btnsIconsDir, "download.png"]))
        self.downloadBtn = JButton(downloadIcon,
                                   actionPerformed=app.on_downloadBtn_clicked,
                                   enabled=0)
        startIcon = ImageIcon(File.separator.join([btnsIconsDir, "start_fixing.png"]))
        self.startBtn = JButton(startIcon,
                                actionPerformed=app.on_startBtn_clicked,
                                enabled=0)
        self.downloadBtn.setToolTipText(app.strings.getString("Download_errors_in_this_area"))
        self.startBtn.setToolTipText(app.strings.getString("Start_fixing_the_selected_errors"))

        #tab layout
        panel1 = JPanel(BorderLayout(0, 1))

        comboboxesPnl = JPanel(GridLayout(0, 2, 5, 0))
        comboboxesPnl.add(self.toolsCombo)
        comboboxesPnl.add(self.viewsCombo)

        checksPnl = JPanel(BorderLayout(0, 1))
        checksPnl.add(scrollPane, BorderLayout.CENTER)
        self.statsPanel = JPanel(BorderLayout(4, 0))
        self.statsPanel_def_color = self.statsPanel.getBackground()
        self.statsPanel.add(self.checksTextFld, BorderLayout.CENTER)
        self.statsPanel.add(self.favAreaIndicator, BorderLayout.LINE_START)
        checksPnl.add(self.statsPanel, BorderLayout.PAGE_END)

        checksButtonsPnl = JPanel(GridLayout(0, 2, 0, 0))
        checksButtonsPnl.add(self.downloadBtn)
        checksButtonsPnl.add(self.startBtn)

        panel1.add(comboboxesPnl, BorderLayout.PAGE_START)
        panel1.add(checksPnl, BorderLayout.CENTER)
        panel1.add(checksButtonsPnl, BorderLayout.PAGE_END)

### Second tab: errors fixing ##########################################
        #label with error stats
        self.errorTextFld = JTextField("",
                                       editable=0,
                                       border=None,
                                       background=None)
        #label with current error description
        self.errorDesc = JLabel("")
        self.errorDesc.setAlignmentX(0.5)

        #error buttons
        errorInfoBtnIcon = ImageProvider.get("info")
        self.errorInfoBtn = JButton(errorInfoBtnIcon,
                                    actionPerformed=app.on_errorInfoBtn_clicked,
                                    enabled=0)
        notErrorIcon = ImageIcon(File.separator.join([btnsIconsDir, "not_error.png"]))
        self.notErrorBtn = JButton(notErrorIcon,
                                   actionPerformed=app.on_falsePositiveBtn_clicked,
                                   enabled=0)
        ignoreIcon = ImageIcon(File.separator.join([btnsIconsDir, "skip.png"]))
        self.ignoreBtn = JButton(ignoreIcon,
                                 actionPerformed=app.on_ignoreBtn_clicked,
                                 enabled=0)
        correctedIcon = ImageIcon(File.separator.join([btnsIconsDir, "corrected.png"]))
        self.correctedBtn = JButton(correctedIcon,
                                    actionPerformed=app.on_correctedBtn_clicked,
                                    enabled=0)
        nextIcon = ImageIcon(File.separator.join([btnsIconsDir, "next.png"]))
        self.nextBtn = JButton(nextIcon,
                               actionPerformed=app.on_nextBtn_clicked,
                               enabled=0)
        #self.nextBtn.setMnemonic(KeyEvent.VK_RIGHT)
        self.errorInfoBtn.setToolTipText(app.strings.getString("open_error_info_dialog"))
        self.notErrorBtn.setToolTipText(app.strings.getString("flag_false_positive"))
        self.ignoreBtn.setToolTipText(app.strings.getString("Skip_and_don't_show_me_this_error_again"))
        self.correctedBtn.setToolTipText(app.strings.getString("flag_corrected_error"))
        self.nextBtn.setToolTipText(app.strings.getString("Go_to_next_error"))

        #tab layout
        self.panel2 = JPanel(BorderLayout())

        self.panel2.add(self.errorTextFld, BorderLayout.PAGE_START)
        self.panel2.add(self.errorDesc, BorderLayout.CENTER)

        errorButtonsPanel = JPanel(GridLayout(0, 5, 0, 0))
        errorButtonsPanel.add(self.errorInfoBtn)
        errorButtonsPanel.add(self.notErrorBtn)
        errorButtonsPanel.add(self.ignoreBtn)
        errorButtonsPanel.add(self.correctedBtn)
        errorButtonsPanel.add(self.nextBtn)
        self.panel2.add(errorButtonsPanel, BorderLayout.PAGE_END)

        #Layout
        self.tabbedPane = JTabbedPane()
        self.tabbedPane.addTab(self.app.strings.getString("Download"),
                               None,
                               panel1,
                               self.app.strings.getString("download_tab"))
        mainPnl.add(self.tabbedPane, BorderLayout.CENTER)
        self.createLayout(mainPnl, False, None)
    def showStackOverlayWindow(self):
        all = JPanel()
        all.setLayout(MigLayout())

        self.imageIDs = WindowManager.getIDList()
        self.imageNames = []

        if self.imageIDs is None:
            IJ.error("No open images", "Stack Overlay requires at least one image to be already open.")
            return

        for i in self.imageIDs:
            self.imageNames.append(WindowManager.getImage(i).getTitle())

        self.baseImageBox = JComboBox(self.imageNames)
        baseImageBoxLabel = JLabel("Base image")
        self.baseImageBox.setSelectedIndex(0)
        all.add(baseImageBoxLabel)
        all.add(self.baseImageBox, "wrap")

        self.overlayImageBox = JComboBox(self.imageNames)
        overlayImageBoxLabel = JLabel("Overlay image")
        if len(self.imageNames) > 1:
            self.overlayImageBox.setSelectedIndex(1)

        all.add(overlayImageBoxLabel)
        all.add(self.overlayImageBox, "wrap")

        all.add(JSeparator(SwingConstants.HORIZONTAL), "span, wrap")

        overlayStyleFrame = JPanel()
        overlayStyleFrame.setLayout(MigLayout())
        overlayStyleFrame.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder("Overlay Style"), BorderFactory.createEmptyBorder(5,5,5,5)))

        colorLabel = JLabel("Overlay color")
        self.overlayColorPreviewLabel = JLabel("           ")
        self.overlayColorPreviewLabel.setBorder(BorderFactory.createEmptyBorder(0,0,1,0))
        self.overlayColorPreviewLabel.setOpaque(True)
        self.overlayColorPreviewLabel.setBackground(Color.red)
        self.overlayColor = Color.red
        colorPicker = JColorChooser()
        colorPicker.setPreviewPanel(self.overlayColorPreviewLabel)
        colorButton = JButton("Select color...", actionPerformed=self.showColorChooser)

        opacityLabel = JLabel("Overlay opacity (%)")
        opacitySpinnerModel = SpinnerNumberModel(100, 0, 100, 1)
        self.opacitySpinner = JSpinner(opacitySpinnerModel)

        overlayStyleFrame.add(colorLabel)
        overlayStyleFrame.add(self.overlayColorPreviewLabel)
        overlayStyleFrame.add(colorButton, "wrap")

        overlayStyleFrame.add(opacityLabel)
        overlayStyleFrame.add(self.opacitySpinner, "wrap")
        

        all.add(overlayStyleFrame, "span, wrap")
        
        self.virtualStackCheckbox = JCheckBox("Use Virtual Stack", True)
        all.add(self.virtualStackCheckbox, "span, wrap")

        # TODO: add non-thermonuclear cancel button functionality
        overlayCancelButton = JButton("Cancel", actionPerformed=self.onQuit)
        overlayStartButton = JButton("Overlay images", actionPerformed=self.overlayImages)
        
        all.add(overlayCancelButton, "gapleft push")
        all.add(overlayStartButton, "gapleft push")

        self.frame = JFrame("Stack Overlay")
        self.frame.getContentPane().add(JScrollPane(all))
        self.frame.pack()
        self.frame.setLocationRelativeTo(None)
        self.frame.setVisible(True)
Пример #54
0
    def __init__(self):
        self.component = NoWrapJTextPane(
            border=BorderFactory.createEmptyBorder(5, 5, 5, 5)
        )
        
        def new_style(name, color=None, bold=None, italic=None, underline=None):
            style = self.doc.addStyle(name, self.parent_style)
            if color is not None:
                if isinstance(color, str):
                    color = awtColor(
                        int(color[0:2], 16),
                        int(color[2:4], 16),
                        int(color[4:6], 16)
                    )
                StyleConstants.setForeground(style, color)
            if bold is not None:
                StyleConstants.setBold(style, bold)
            if italic is not None:
                StyleConstants.setItalic(style, italic)
            if underline is not None:
                StyleConstants.setUnderline(style, underline)
            return style
        
        self.doc = self.component.getStyledDocument()

        attrs = SimpleAttributeSet()
        StyleConstants.setLineSpacing(attrs, 0.2)
        self.component.setParagraphAttributes(attrs, True)
        
        style_context = StyleContext.getDefaultStyleContext()
        default_style = style_context.getStyle(StyleContext.DEFAULT_STYLE)
        self.parent_style = self.doc.addStyle("parent", default_style)
        StyleConstants.setFontFamily(self.parent_style, "Monospaced")

        # Set styles for syntax highlighting
        new_style("kw", "990066", bold=True)
        new_style("number", "0033AA")
        new_style("string", "993300")
        new_style("comment", "FF0000")
        new_style("defname", "0033FF", bold=True)
        new_style("classname", "009900", bold=True)
        new_style("builtin", italic=True)
        new_style("geo", underline=True)
        new_style("decorator", "0033FF")
        
        # Do a dance to set tab size
        font = Font("Monospaced", Font.PLAIN, 12)
        self.component.setFont(font)
        fm = self.component.getFontMetrics(font)
        tabw = float(fm.stringWidth(" "*4))
        tabs = [
            TabStop(tabw*i, TabStop.ALIGN_LEFT, TabStop.LEAD_NONE)
            for i in xrange(1, 51)
        ]
        attr_set = style_context.addAttribute(
            SimpleAttributeSet.EMPTY,
            StyleConstants.TabSet,
            TabSet(tabs)
        )
        self.component.setParagraphAttributes(attr_set, False)
        #Dance done!
        
        self.component.addKeyListener(self)
        # Remove?
        # self.nocheck = LockManager()
        self.doc.addDocumentListener(self)
Пример #55
0
    def __init__(self, parent, title, modal, app):
        from java.awt import CardLayout
        self.app = app
        border = BorderFactory.createEmptyBorder(5, 7, 7, 7)
        self.getContentPane().setBorder(border)
        self.setLayout(BoxLayout(self.getContentPane(), BoxLayout.Y_AXIS))

        self.FAVAREALAYERNAME = "Favourite zone editing"

        info = JLabel(self.app.strings.getString("Create_a_new_favourite_zone"))
        info.setAlignmentX(Component.LEFT_ALIGNMENT)

        #Name
        nameLbl = JLabel(self.app.strings.getString("fav_zone_name"))
        self.nameTextField = JTextField(20)
        self.nameTextField.setMaximumSize(self.nameTextField.getPreferredSize())
        self.nameTextField.setToolTipText(self.app.strings.getString("fav_zone_name_tooltip"))
        namePanel = JPanel()
        namePanel.setLayout(BoxLayout(namePanel, BoxLayout.X_AXIS))
        namePanel.add(nameLbl)
        namePanel.add(Box.createHorizontalGlue())
        namePanel.add(self.nameTextField)

        #Country
        countryLbl = JLabel(self.app.strings.getString("fav_zone_country"))
        self.countryTextField = JTextField(20)
        self.countryTextField.setMaximumSize(self.countryTextField.getPreferredSize())
        self.countryTextField.setToolTipText(self.app.strings.getString("fav_zone_country_tooltip"))
        countryPanel = JPanel()
        countryPanel.setLayout(BoxLayout(countryPanel, BoxLayout.X_AXIS))
        countryPanel.add(countryLbl)
        countryPanel.add(Box.createHorizontalGlue())
        countryPanel.add(self.countryTextField)

        #Type
        modeLbl = JLabel(self.app.strings.getString("fav_zone_type"))
        RECTPANEL = "rectangle"
        POLYGONPANEL = "polygon"
        BOUNDARYPANEL = "boundary"
        self.modesStrings = [RECTPANEL, POLYGONPANEL, BOUNDARYPANEL]
        modesComboModel = DefaultComboBoxModel()
        for i in (self.app.strings.getString("rectangle"),
                  self.app.strings.getString("delimited_by_a_closed_way"),
                  self.app.strings.getString("delimited_by_an_administrative_boundary")):
            modesComboModel.addElement(i)
        self.modesComboBox = JComboBox(modesComboModel,
                                       actionListener=self,
                                       editable=False)

        #- Rectangle
        self.rectPanel = JPanel()
        self.rectPanel.setLayout(BoxLayout(self.rectPanel, BoxLayout.Y_AXIS))

        capturePane = JPanel()
        capturePane.setLayout(BoxLayout(capturePane, BoxLayout.X_AXIS))
        capturePane.setAlignmentX(Component.LEFT_ALIGNMENT)

        josmP = JPanel()
        self.captureRBtn = JRadioButton(self.app.strings.getString("capture_area"))
        self.captureRBtn.addActionListener(self)
        self.captureRBtn.setSelected(True)
        self.bboxFromJosmBtn = JButton(self.app.strings.getString("get_current_area"),
                                       actionPerformed=self.on_bboxFromJosmBtn_clicked)
        self.bboxFromJosmBtn.setToolTipText(self.app.strings.getString("get_capture_area_tooltip"))
        josmP.add(self.bboxFromJosmBtn)
        capturePane.add(self.captureRBtn)
        capturePane.add(Box.createHorizontalGlue())
        capturePane.add(self.bboxFromJosmBtn)

        manualPane = JPanel()
        manualPane.setLayout(BoxLayout(manualPane, BoxLayout.X_AXIS))
        manualPane.setAlignmentX(Component.LEFT_ALIGNMENT)
        self.manualRBtn = JRadioButton(self.app.strings.getString("use_this_bbox"))
        self.manualRBtn.addActionListener(self)
        self.bboxTextField = JTextField(20)
        self.bboxTextField.setMaximumSize(self.bboxTextField.getPreferredSize())
        self.bboxTextField.setToolTipText(self.app.strings.getString("fav_bbox_tooltip"))
        self.bboxTextFieldDefaultBorder = self.bboxTextField.getBorder()
        self.bboxTextField.getDocument().addDocumentListener(TextListener(self))
        manualPane.add(self.manualRBtn)
        manualPane.add(Box.createHorizontalGlue())
        manualPane.add(self.bboxTextField)

        group = ButtonGroup()
        group.add(self.captureRBtn)
        group.add(self.manualRBtn)

        previewPane = JPanel()
        previewPane.setLayout(BoxLayout(previewPane, BoxLayout.X_AXIS))
        previewPane.setAlignmentX(Component.LEFT_ALIGNMENT)
        bboxPreviewInfo = JTextField(self.app.strings.getString("coordinates"),
                                     editable=0,
                                     border=None)
        bboxPreviewInfo.setMaximumSize(bboxPreviewInfo.getPreferredSize())
        self.bboxPreviewTextField = JTextField(20,
                                               editable=0,
                                               border=None)
        self.bboxPreviewTextField.setMaximumSize(self.bboxPreviewTextField.getPreferredSize())
        previewPane.add(bboxPreviewInfo)
        previewPane.add(Box.createHorizontalGlue())
        previewPane.add(self.bboxPreviewTextField)

        self.rectPanel.add(capturePane)
        self.rectPanel.add(Box.createRigidArea(Dimension(0, 10)))
        self.rectPanel.add(manualPane)
        self.rectPanel.add(Box.createRigidArea(Dimension(0, 20)))
        self.rectPanel.add(previewPane)

        #- Polygon (closed way) drawn by hand
        self.polygonPanel = JPanel(BorderLayout())
        self.polygonPanel.setLayout(BoxLayout(self.polygonPanel, BoxLayout.Y_AXIS))

        polyInfo = JLabel("<html>%s</html>" % self.app.strings.getString("polygon_info"))
        polyInfo.setFont(polyInfo.getFont().deriveFont(Font.ITALIC))
        polyInfo.setAlignmentX(Component.LEFT_ALIGNMENT)

        editPolyPane = JPanel()
        editPolyPane.setAlignmentX(Component.LEFT_ALIGNMENT)
        editPolyBtn = JButton(self.app.strings.getString("create_fav_layer"),
                              actionPerformed=self.create_new_zone_editing_layer)
        editPolyBtn.setToolTipText(self.app.strings.getString("create_fav_layer_tooltip"))
        editPolyPane.add(editPolyBtn)

        self.polygonPanel.add(polyInfo)
        self.polygonPanel.add(Box.createRigidArea(Dimension(0, 15)))
        self.polygonPanel.add(editPolyPane)
        self.polygonPanel.add(Box.createRigidArea(Dimension(0, 15)))

        #- Administrative Boundary
        self.boundaryPanel = JPanel()
        self.boundaryPanel.setLayout(BoxLayout(self.boundaryPanel, BoxLayout.Y_AXIS))

        boundaryInfo = JLabel("<html>%s</html>" % app.strings.getString("boundary_info"))
        boundaryInfo.setFont(boundaryInfo.getFont().deriveFont(Font.ITALIC))
        boundaryInfo.setAlignmentX(Component.LEFT_ALIGNMENT)

        boundaryTagsPanel = JPanel(GridLayout(3, 3, 5, 5))
        boundaryTagsPanel.setAlignmentX(Component.LEFT_ALIGNMENT)
        boundaryTagsPanel.add(JLabel("name ="))
        self.nameTagTextField = JTextField(20)
        boundaryTagsPanel.add(self.nameTagTextField)
        boundaryTagsPanel.add(JLabel("admin_level ="))
        self.adminLevelTagTextField = JTextField(20)
        self.adminLevelTagTextField.setToolTipText(self.app.strings.getString("adminLevel_tooltip"))
        boundaryTagsPanel.add(self.adminLevelTagTextField)
        boundaryTagsPanel.add(JLabel(self.app.strings.getString("other_tag")))
        self.optionalTagTextField = JTextField(20)
        self.optionalTagTextField.setToolTipText("key=value")
        boundaryTagsPanel.add(self.optionalTagTextField)

        downloadBoundariesPane = JPanel()
        downloadBoundariesPane.setAlignmentX(Component.LEFT_ALIGNMENT)
        downloadBoundariesBtn = JButton(self.app.strings.getString("download_boundary"),
                                        actionPerformed=self.on_downloadBoundariesBtn_clicked)
        downloadBoundariesBtn.setToolTipText(self.app.strings.getString("download_boundary_tooltip"))
        downloadBoundariesPane.add(downloadBoundariesBtn)

        self.boundaryPanel.add(boundaryInfo)
        self.boundaryPanel.add(Box.createRigidArea(Dimension(0, 15)))
        self.boundaryPanel.add(boundaryTagsPanel)
        self.boundaryPanel.add(Box.createRigidArea(Dimension(0, 10)))
        self.boundaryPanel.add(downloadBoundariesPane)

        self.editingPanels = {"rectangle": self.rectPanel,
                              "polygon": self.polygonPanel,
                              "boundary": self.boundaryPanel}

        #Main buttons
        self.okBtn = JButton(self.app.strings.getString("OK"),
                             ImageProvider.get("ok"),
                             actionPerformed=self.on_okBtn_clicked)
        self.cancelBtn = JButton(self.app.strings.getString("cancel"),
                                 ImageProvider.get("cancel"),
                                 actionPerformed=self.close_dialog)
        self.previewBtn = JButton(self.app.strings.getString("Preview_zone"),
                                  actionPerformed=self.on_previewBtn_clicked)
        self.previewBtn.setToolTipText(self.app.strings.getString("preview_zone_tooltip"))
        okBtnSize = self.okBtn.getPreferredSize()
        viewBtnSize = self.previewBtn.getPreferredSize()
        viewBtnSize.height = okBtnSize.height
        self.previewBtn.setPreferredSize(viewBtnSize)

        #layout
        self.add(info)
        self.add(Box.createRigidArea(Dimension(0, 15)))

        namePanel.setAlignmentX(Component.LEFT_ALIGNMENT)
        self.add(namePanel)
        self.add(Box.createRigidArea(Dimension(0, 15)))

        countryPanel.setAlignmentX(Component.LEFT_ALIGNMENT)
        self.add(countryPanel)
        self.add(Box.createRigidArea(Dimension(0, 15)))

        modeLbl.setAlignmentX(Component.LEFT_ALIGNMENT)
        self.add(modeLbl)
        self.add(Box.createRigidArea(Dimension(0, 5)))

        self.add(self.modesComboBox)
        self.modesComboBox.setAlignmentX(Component.LEFT_ALIGNMENT)
        self.add(Box.createRigidArea(Dimension(0, 15)))

        self.configPanel = JPanel(CardLayout())
        self.configPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5))
        self.configPanel.add(self.rectPanel, RECTPANEL)
        self.configPanel.add(self.polygonPanel, POLYGONPANEL)
        self.configPanel.add(self.boundaryPanel, BOUNDARYPANEL)
        self.configPanel.setAlignmentX(Component.LEFT_ALIGNMENT)
        self.add(self.configPanel)
        buttonsPanel = JPanel()
        buttonsPanel.add(self.okBtn)
        buttonsPanel.add(self.cancelBtn)
        buttonsPanel.add(self.previewBtn)
        buttonsPanel.setAlignmentX(Component.LEFT_ALIGNMENT)
        self.add(buttonsPanel)

        self.addWindowListener(self)
        self.pack()
    def openGUI(self, invocation):
        try:
            # Get values from request or response the extension is invoked from and prepopulate GUI values
            invMessage = invocation.getSelectedMessages()
            message = invMessage[0]
            originalHttpService = message.getHttpService()
            self.originalMsgProtocol = originalHttpService.getProtocol()
            self.originalMsgHost = originalHttpService.getHost()
            self.originalMsgPort = originalHttpService.getPort()
        except:
            self.originalMsgProtocol = ''
            self.originalMsgHost = ''
            self.originalMsgPort = ''

        try:
            self.cookies = self._callbacks.getCookieJarContents()
            self.cookie = ''
        except:
            pass

        self.SSL = 'http://'
        self.listType = ''
        self.parsedList = []

        # Set up main window (JFrame)
        self.window = JFrame("Directory Listing Parser for Burp Suite", preferredSize=(600, 475), windowClosing=self.closeUI)
        self.window.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE)
        emptyBorder = BorderFactory.createEmptyBorder(10, 10, 10, 10)
        self.window.contentPane.setBorder(emptyBorder)
        self.window.contentPane.layout = BorderLayout()

        # Main window title placed at the top of the main window with an invisible bottom border
        titlePanel = JPanel()
        titleBorder = BorderFactory.createEmptyBorder(0, 0, 10, 0)
        title = JLabel("Directory Listing Parser for Burp Suite", JLabel.CENTER)
        title.setBorder(titleBorder)
        title.setFont(Font("Default", Font.PLAIN, 18))
        titlePanel.add(title)
        self.window.contentPane.add("North", titlePanel)

        # Left panel for user input, consisting of hostname, directory prefix, ssl, port, type of listing, and file
        self.leftPanel = JPanel()
        self.leftPanel.layout = GridLayout(14, 1, 3, 3)
        hostnameLabel = JLabel("Hostname:")

        if self.originalMsgHost:
            self.hostnameTextField = JTextField(self.originalMsgHost.rstrip())
        else:
            self.hostnameTextField = JTextField('Hostname')

        dirPrefixLabel = JLabel("Full Directory Prefix (Windows):")
        self.dirPrefixField = JTextField('C:\\var\www\\')
        
        sslLabel = JLabel("SSL:")
        self.radioBtnSslEnabled = JRadioButton('Enabled (https)', actionPerformed=self.radioSsl)
        self.radioBtnSslDisabled = JRadioButton('Disabled (http)', actionPerformed=self.radioSsl)
        sslButtonGroup = ButtonGroup()
        sslButtonGroup.add(self.radioBtnSslEnabled)
        sslButtonGroup.add(self.radioBtnSslDisabled)
        
        if self.originalMsgProtocol == "https":
            self.radioBtnSslEnabled.setSelected(True)
        else:
            self.radioBtnSslDisabled.setSelected(True)
        
        portLabel = JLabel("Port:")

        if self.originalMsgPort:
            self.portTextField = JTextField(str(self.originalMsgPort).rstrip())
        else:
            self.portTextField = JTextField('80')

        osLabel = JLabel("Type of File Listing:")
        self.types = ('Windows \'dir /s\'', 'Linux \'ls -lR\'', 'Linux \'ls -R\'')
        self.comboListingType = JComboBox(self.types)
        uploadLabel = JLabel("Directory Listing File:")
        self.uploadTextField = JTextField('')
        uploadButton = JButton('Choose File', actionPerformed=self.chooseFile)

        self.leftPanel.add(hostnameLabel)
        self.leftPanel.add(self.hostnameTextField)
        self.leftPanel.add(dirPrefixLabel)
        self.leftPanel.add(self.dirPrefixField)
        self.leftPanel.add(sslLabel)
        self.leftPanel.add(self.radioBtnSslEnabled)
        self.leftPanel.add(self.radioBtnSslDisabled)
        self.leftPanel.add(portLabel)
        self.leftPanel.add(self.portTextField)
        self.leftPanel.add(osLabel)
        self.leftPanel.add(self.comboListingType)
        self.leftPanel.add(uploadLabel)
        self.leftPanel.add(self.uploadTextField)
        self.leftPanel.add(uploadButton)

        # Right panel consisting of a text area for the URL list
        self.UrlPanelLabel = JLabel("URL List:")
        self.textArea = JTextArea()
        self.textArea.setEditable(True)
        self.textArea.setFont(Font("Default", Font.PLAIN, 14))
        if self.cookies:
            self.textArea.append('Cookies Found:\n')
            for cookie in self.cookies:
                if cookie.getDomain() in self.originalMsgHost:
                    self.cookie += cookie.getName() + '=' + cookie.getValue() + '; '
                    self.textArea.append(cookie.getName() + '=' + cookie.getValue() + '\n')
        scrollArea = JScrollPane(self.textArea)
        scrollArea.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS)
        scrollArea.setPreferredSize(Dimension(400, 200))
        self.rightPanel = JPanel()
        self.rightPanel.setLayout(BorderLayout(3, 3))
        self.rightPanel.add(self.UrlPanelLabel, BorderLayout.NORTH)
        self.rightPanel.add(scrollArea, BorderLayout.CENTER)
        
        # Panel for the generate URL list and import URL list buttons
        generatePanel = JPanel()
        generatePanel.layout = BorderLayout(3, 3)
        generateButton = JButton('Generate URL List', actionPerformed=self.generateUrlList)
        importButton = JButton('Import URL List to Burp Site Map', actionPerformed=self.confirmImport)
        generatePanel.add("North", generateButton)
        generatePanel.add("South", importButton)
        self.rightPanel.add("South", generatePanel)

        # Add the two main panels to the left and right sides
        self.window.contentPane.add("East", self.rightPanel)
        self.window.contentPane.add("West", self.leftPanel)

        # Create a panel to be used for the file chooser window
        self.uploadPanel = JPanel()
        
        self.window.pack()
        self.window.show()
    def __init__(self, imgData):
        n = imgData.size()
        win = JFrame("Point Marker Panel")
        win.setPreferredSize(Dimension(350, 590))
        win.setSize(win.getPreferredSize())
        pan = JPanel()
        pan.setLayout(BoxLayout(pan, BoxLayout.Y_AXIS))
        win.getContentPane().add(pan)

        progressPanel = JPanel()
        progressPanel.setLayout(BoxLayout(progressPanel, BoxLayout.Y_AXIS))
        positionBar = JProgressBar()
        positionBar.setMinimum(0)
        positionBar.setMaximum(n)
        positionBar.setStringPainted(True)
        progressPanel.add(Box.createGlue())
        progressPanel.add(positionBar)

        progressBar = JProgressBar()
        progressBar.setMinimum(0)
        progressBar.setMaximum(n)
        progressBar.setStringPainted(True)
        progressPanel.add(progressBar)
        progressPanel.setBorder(BorderFactory.createEmptyBorder(0,10,0,10))
        pan.add(progressPanel)

        pan.add(Box.createRigidArea(Dimension(5,5)))
        savePanel = JPanel()
        savePanel.setLayout(BoxLayout(savePanel, BoxLayout.Y_AXIS))
        saveMessageLabel = JLabel("<html><u>Save Often</u></html>")
        savePanel.add(saveMessageLabel)
        savePanel.setAlignmentX(Component.CENTER_ALIGNMENT)
        savePanel.setBorder(BorderFactory.createEmptyBorder(0,10,0,10))
        pan.add(savePanel)
        # pan.add(saveMessageLabel)

        pan.add(Box.createRigidArea(Dimension(5,5)))
        calPanel = JPanel()
        calPanel.setLayout(BoxLayout(calPanel, BoxLayout.Y_AXIS))
        calPanelIn = JPanel()
        calPanelIn.setLayout(BoxLayout(calPanelIn, BoxLayout.X_AXIS))
        pixelSizeText = JTextField(12)
        pixelSizeText.setHorizontalAlignment(JTextField.RIGHT)
        # pixelSizeText.setMaximumSize(pixelSizeText.getPreferredSize())
        unitText = JTextField(10)
        # unitText.setMaximumSize(unitText.getPreferredSize())
        pixelSizeText.setText("Enter Pixel Size Here")
        calPanelIn.add(pixelSizeText)
        unitText.setText("Unit")
        calPanelIn.add(unitText)
        calPanelIn.setAlignmentX(Component.CENTER_ALIGNMENT)
        calPanelIn.setBorder(BorderFactory.createTitledBorder("Custom Calibration"))
        calPanel.add(calPanelIn)
        calPanelIn.setAlignmentX(Component.CENTER_ALIGNMENT)
        calPanel.setBorder(BorderFactory.createEmptyBorder(0,10,0,10))
        pan.add(calPanel)

        pan.add(Box.createRigidArea(Dimension(5,5)))
        helpPanel = JPanel()
        helpPanel.setLayout(BoxLayout(helpPanel, BoxLayout.Y_AXIS))
        helpLable = JLabel("<html><ul>\
                            <li>Focus on Image Window</li>\
                            <li>Select multi-point Tool</li>\
                            <li>Click to Draw Points</li>\
                            <li>Drag to Move Points</li>\
                            <li>\"Alt\" + Click to Erase Points</li>\
                            <li>Optional: Customize Calibration Above\
                                 and Refresh Images\
                                (won't be written to files)</li>\
                            </html>")
        helpLable.setBorder(BorderFactory.createTitledBorder("Usage"))
        keyTagOpen = "<span style=\"background-color: #FFFFFF\"><b><kbd>"
        keyTagClose = "</kbd></b></span>"
        keyLable = JLabel("<html><ul>\
                            <li>Next Image --- " + keyTagOpen + "&lt" + \
                                keyTagClose + "</li>\
                            <li>Previous Image --- " + keyTagOpen + ">" + \
                                keyTagClose + "</li>\
                            <li>Save --- " + keyTagOpen + "`" + keyTagClose + \
                                " (upper-left to TAB key)</li>\
                            <li>Next Unmarked Image --- " + keyTagOpen + \
                                "TAB" + keyTagClose + "</li></ul>\
                            </html>")
        keyLable.setBorder(BorderFactory.createTitledBorder("Keyboard Shortcuts"))
        helpPanel.add(helpLable)
        helpPanel.add(keyLable)
        helpPanel.setAlignmentX(Component.CENTER_ALIGNMENT)
        helpPanel.setBorder(BorderFactory.createEmptyBorder(0,10,0,10))
        pan.add(helpPanel)

        # pan.add(Box.createRigidArea(Dimension(0, 10)))
        infoPanel = JPanel()
        infoPanel.setLayout(BoxLayout(infoPanel, BoxLayout.Y_AXIS))
        infoLabel = JLabel()
        infoLabel.setBorder(BorderFactory.createTitledBorder("Project Info"))
        infoPanel.add(infoLabel)
        infoPanel.setAlignmentX(Component.CENTER_ALIGNMENT)
        infoPanel.setBorder(BorderFactory.createEmptyBorder(0,10,0,10))
        pan.add(infoPanel)

        win.setVisible(True)

        self.imgData = imgData
        self.win = win
        # self.progressPanel = progressPanel
        self.positionBar = positionBar
        self.progressBar = progressBar
        self.saveMessageLabel = saveMessageLabel
        self.infoLabel = infoLabel
        self.pixelSizeText = pixelSizeText
        self.unitText = unitText
        self.update()
Пример #58
0
    def __init__(self, app):
        #java import
        from javax.swing import JPanel, JButton, JLabel, ImageIcon,\
                                JScrollPane, BorderFactory, WindowConstants,\
                                BoxLayout, Box
        from java.awt import FlowLayout, Dimension, Component
        from java.io import File
        #josm import
        from org.openstreetmap.josm import Main
        from org.openstreetmap.josm.tools import ImageProvider
        from org.openstreetmap.josm.gui.widgets import HtmlPanel, UrlLabel
        JDialog.__init__(self,
                         Main.parent,
                         app.strings.getString("error_info_title"),
                         True)
        self.app = app
        self.setSize(400, 480)
        border = BorderFactory.createEmptyBorder(5, 7, 5, 7)
        self.getContentPane().setBorder(border)
        self.setLayout(BoxLayout(self.getContentPane(), BoxLayout.Y_AXIS))

        #Intro
        intro = HtmlPanel("<html><i>%s</i></html>" % self.app.strings.getString("error_info_intro"))
        intro.setAlignmentX(Component.LEFT_ALIGNMENT)

        #User info
        userLbl = JLabel(self.app.strings.getString("Last_user"))
        userLbl.setAlignmentX(JLabel.LEFT_ALIGNMENT)

        self.userInfoPanel = HtmlPanel()
        self.userInfoPanel.getEditorPane().addHyperlinkListener(self)
        self.userInfoPanel.setAlignmentX(Component.LEFT_ALIGNMENT)

        #Panel with current error's info
        errorLbl = JLabel(self.app.strings.getString("Error_info"))
        errorLbl.setAlignmentX(JLabel.LEFT_ALIGNMENT)
        self.errorInfoPanel = HtmlPanel()
        self.errorInfoPanel.getEditorPane().addHyperlinkListener(self)
        self.scrollPane = JScrollPane(self.errorInfoPanel)
        self.scrollPane.setAlignmentX(Component.LEFT_ALIGNMENT)

        #OK button
        btnPanel = JPanel(FlowLayout(FlowLayout.CENTER))
        okBtn = JButton(self.app.strings.getString("OK"),
                        ImageProvider.get("ok"),
                        actionPerformed=self.on_okBtn_clicked)
        btnPanel.add(okBtn)
        btnPanel.setAlignmentX(Component.LEFT_ALIGNMENT)

        #Layout
        self.add(intro)
        self.add(Box.createRigidArea(Dimension(0, 7)))
        self.add(userLbl)
        self.add(Box.createRigidArea(Dimension(0, 5)))
        self.add(self.userInfoPanel)
        self.add(Box.createRigidArea(Dimension(0, 7)))
        self.add(errorLbl)
        self.add(Box.createRigidArea(Dimension(0, 5)))
        self.add(self.scrollPane)
        self.add(Box.createRigidArea(Dimension(0, 7)))
        self.add(btnPanel)

        self.setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE)
Пример #59
0
    def	registerExtenderCallbacks(self, callbacks):
        print "PhantomJS RIA Crawler extension"
        print "Nikolay Matyunin @autorak <*****@*****.**>"

        # keep a reference to our callbacks object and helpers object
        self._callbacks = callbacks
        self._helpers = callbacks.getHelpers()

        # extension name
        callbacks.setExtensionName("Phantom RIA Crawler")

        # Create Tab UI components
        self._jPanel = JPanel()
        self._jPanel.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));

        _titleLabel = JLabel("Phantom RIA Crawler", SwingConstants.LEFT)
        _titleLabelFont = _titleLabel.font
        _titleLabelFont = _titleLabelFont.deriveFont(Font.BOLD, 12);
        _titleLabel.setFont(_titleLabelFont);
        _titleLabel.setForeground(Color(230, 142, 11))

        self._addressTextField = JTextField('')
        self._addressTextField.setColumns(50)
        _addressTextLabel = JLabel("Target URL:", SwingConstants.RIGHT)
        self._addressTextField.getDocument().addDocumentListener(self)

        self._phantomJsPathField = JTextField('phantomjs') # TODO: set permanent config value
        self._phantomJsPathField.setColumns(50)
        _phantomJsPathLabel = JLabel("PhantomJS path:", SwingConstants.RIGHT)

        self._startButton = JToggleButton('Start', actionPerformed=self.startToggled)
        self._startButton.setEnabled(False)

        _requestsMadeLabel = JLabel("DEPs found:", SwingConstants.RIGHT)
        self._requestsMadeInfo = JLabel("", SwingConstants.LEFT)
        _statesFoundLabel = JLabel("States found:", SwingConstants.RIGHT)
        self._statesFoundInfo = JLabel("", SwingConstants.LEFT)

        _separator = JSeparator(SwingConstants.HORIZONTAL)

        _configLabel = JLabel("Crawling configuration:")
        self._configButton = JButton("Load config", actionPerformed=self.loadConfigClicked)
        self._configFile = ""

        _listenersLabel= JLabel("Burp proxy listener:", SwingConstants.RIGHT)
        self._listenersCombo = JComboBox()
        self._configTimer = Timer(5000, None)
        self._configTimer.actionPerformed = self._configUpdated
        self._configTimer.stop()
        self._configUpdated(None)

        self._commandClient = CommandClient(self)

        # Layout management
        self._groupLayout = GroupLayout(self._jPanel)
        self._jPanel.setLayout(self._groupLayout)
        self._groupLayout.setAutoCreateGaps(True)
        self._groupLayout.setAutoCreateContainerGaps(True)

        self._groupLayout.setHorizontalGroup(self._groupLayout.createParallelGroup()
            .addComponent(_titleLabel)
            .addGroup(self._groupLayout.createSequentialGroup()
                .addComponent(_addressTextLabel)
                .addGroup(self._groupLayout.createParallelGroup()
                    .addComponent(self._addressTextField, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
                    .addGroup(self._groupLayout.createSequentialGroup()
                        .addComponent(_requestsMadeLabel)
                        .addComponent(self._requestsMadeInfo))
                    .addGroup(self._groupLayout.createSequentialGroup()
                        .addComponent(_statesFoundLabel)
                        .addComponent(self._statesFoundInfo)))
                .addComponent(self._startButton))
            .addComponent(_separator)
            .addGroup(self._groupLayout.createSequentialGroup()
                .addComponent(_configLabel)
                .addComponent(self._configButton))
            .addGroup(self._groupLayout.createSequentialGroup()
                .addComponent(_phantomJsPathLabel)
                .addComponent(self._phantomJsPathField, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE))
            .addGroup(self._groupLayout.createSequentialGroup()
                .addComponent(_listenersLabel)
                .addComponent(self._listenersCombo, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE))
        )

        self._groupLayout.setVerticalGroup(self._groupLayout.createSequentialGroup()
            .addComponent(_titleLabel)
            .addGroup(self._groupLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                .addComponent(_addressTextLabel)
                .addComponent(self._addressTextField)
                .addComponent(self._startButton))
            .addGroup(self._groupLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                .addComponent(_requestsMadeLabel)
                .addComponent(self._requestsMadeInfo))
            .addGroup(self._groupLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                .addComponent(_statesFoundLabel)
                .addComponent(self._statesFoundInfo))
            .addComponent(_separator, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
            .addGroup(self._groupLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                .addComponent(_configLabel)
                .addComponent(self._configButton))
            .addGroup(self._groupLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                .addComponent(_phantomJsPathLabel)
                .addComponent(self._phantomJsPathField))
            .addGroup(self._groupLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                .addComponent(_listenersLabel)
                .addComponent(self._listenersCombo))
        )

        self._groupLayout.linkSize(SwingConstants.HORIZONTAL, _configLabel, _phantomJsPathLabel);
        self._groupLayout.linkSize(SwingConstants.HORIZONTAL, _configLabel, _listenersLabel);
        self._groupLayout.linkSize(SwingConstants.HORIZONTAL, _statesFoundLabel, _requestsMadeLabel);


        # context menu data
        self._contextMenuData = None;
        self._running = False;

        # register callbacks
        callbacks.customizeUiComponent(self._jPanel)
        callbacks.registerContextMenuFactory(self)
        callbacks.addSuiteTab(self)

        return