Пример #1
0
    def __init__(self, cattr):
	self.attr = cattr
	self.cbox = JColorChooser(self.attr.color)
	self.sym_panel = EditSymbolAttr(cattr.sym_prop)
	self.thickness_field = JTextField(str(cattr.thickness),2)
	self.draw_symbol_box = JCheckBox("Draw Symbol?",cattr.draw_symbol)
	self.dps_field = JTextField(str(self.attr.data_per_symbol),2)
	self.dash_box = JComboBox(CurveProps.DASH_TYPES.keys())
	self.dash_box.setSelectedItem(self.attr.dash_type)
	self.dash_box.setBorder(BorderFactory.createTitledBorder("Dash type: (Only JDK2 & Slow!)"))
	tpanelx = JPanel()
	tpanelx.add(self.thickness_field)
	tpanelx.setBorder(BorderFactory.createTitledBorder("curve thickness (integer)"))
	tpanely = JPanel()
	tpanely.add(self.dps_field)
	tpanely.setBorder(BorderFactory.createTitledBorder("data per symbol(integer)"))
	tpanel = JPanel();tpanel.setLayout(GridLayout(2,2));
	tpanel.add(self.draw_symbol_box); tpanel.add(tpanelx);
	tpanel.add(tpanely); tpanel.add(self.dash_box);
	panel1 = JPanel()
	panel1.setLayout(BorderLayout())
	panel1.add(self.cbox,BorderLayout.CENTER)
	panel1.add(tpanel, BorderLayout.SOUTH)
	panel2 = JPanel()
	panel2.setLayout(BorderLayout())
	panel2.add(self.sym_panel,BorderLayout.CENTER)
	tp1 = JTabbedPane()
	tp1.addTab("Curve Attributes",panel1)
	tp1.addTab("Symbol Attributes",panel2)
	tp1.setSelectedComponent(panel1)
	self.setLayout(BorderLayout())
	self.add(tp1,BorderLayout.CENTER)
Пример #2
0
    def __init__(self):

        self.setBorder(BorderFactory.createTitledBorder(
                                        "Setup a session handling action to" +
                                        " remove named cookies from Burp's" +
                                        " cookie jar"))

        self.setLayout(BoxLayout(self, BoxLayout.Y_AXIS))

        self._rowpanel1 = PTListPanel("Cookies to remove", [])

        self._rowpanel2 = JPanel()
        self._rowpanel2.setLayout(BoxLayout(self._rowpanel2, BoxLayout.X_AXIS))

        self._button_update = JButton(
                                "Add a new \"Remove cookies\" session handler"
                                " for these cookies",
                                actionPerformed=self._button_update_pressed
                            )

        self._rowpanel2.add(Box.createHorizontalGlue())
        self._rowpanel2.add(self._button_update)

        self.add(self._rowpanel1)
        self.add(self._rowpanel2)
Пример #3
0
    def __init__(self):

        self.setBorder(
            BorderFactory.createTitledBorder(
                            "Registered session handling actions"
                            )
            )

        self.setLayout(BoxLayout(self, BoxLayout.Y_AXIS))
        self._rowpanel1 = JPanel()
        self._rowpanel1.setLayout(BoxLayout(self._rowpanel1, BoxLayout.X_AXIS))

        self.listModel = DefaultListModel()

        self.List = JList(self.listModel)

        self.List.setSelectionMode(
                    ListSelectionModel.MULTIPLE_INTERVAL_SELECTION
                    )
        self.List.setSelectedIndex(0)
        self.List.setVisibleRowCount(5)

        self.ScrollPane = JScrollPane(self.List)

        self.remove_button = JButton(
                                "De-register selected",
                                actionPerformed=self.button_remove_pressed
                            )

        self._rowpanel1.add(self.ScrollPane)
        self._rowpanel1.add(self.remove_button)

        self.add(self._rowpanel1)
Пример #4
0
    def __init__(self, cattrs):
	#JDialog.__init__(self,"Curve Attribute Editor")
	#("Curve Attribute Editor")
	if cattrs == None or len(cattrs) == 0:
	    raise "No curve attributes specified"
	self.attrs = cattrs
	self.cpanel = EditCurveAttr(cattrs[0])
	pane = self.getContentPane()
	pane.setLayout(BorderLayout())
	x = map(lambda x: x+1,range(len(self.attrs)))
	self.curveBox = JComboBox(x)
	self.curveBox.setBorder(BorderFactory.createTitledBorder("Curve #"))
	self.curveBox.setSelectedItem(0)
	class CListener(ItemListener):
	    def __init__(self,cbox,cpanel,cattrs):
		self.cbox = cbox
		self.cpanel = cpanel
		self.attrs = cattrs
	    def itemStateChanged(self, evt):
		crvNo = self.cbox.getSelectedItem()
		self.cpanel.update()
		self.cpanel.setAttribute(self.attrs[crvNo-1])
	self.curveBox.addItemListener(CListener(self.curveBox, self.cpanel,self.attrs))
	okBtn = JButton("OK",actionPerformed=self.ok_action)
	cancelBtn = JButton("Cancel",actionPerformed=self.cancel_action)
	btnPanel = JPanel()
	btnPanel.setLayout(GridLayout(1,3))
	btnPanel.add(self.curveBox)
	btnPanel.add(okBtn)
	btnPanel.add(cancelBtn)
	pane.add(self.cpanel,BorderLayout.CENTER)
	pane.add(btnPanel, BorderLayout.SOUTH)
	self.setLocation(100,100)
	self.pack()
	self.setVisible(1)
    def render(self):
        '''Render on the frame the login panel with the fields needed to
        authenticate with the Asterisk manager.'''
        self.layout = GridLayout(0,2)

        self.setBorder(BorderFactory.createTitledBorder('Asterisk account information'))

        self.hostname = EnhancedTextField('localhost', 15)
        self.add(JLabel('Hostname:'))
        self.add(self.hostname)

        self.username = EnhancedTextField('manager', 15)
        self.add(JLabel('Username:'******'pa55word', 15)
        self.add(JLabel('Password:'******'SIP/John', 15)
        self.add(JLabel('Extension:'))
        self.add(self.extension)

        self.login = JButton('Log in', actionPerformed=self.buttonAction)
        self.add(self.login)

        self.status = JLabel('Awaiting information...')
        self.add(self.status)
Пример #6
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))
Пример #7
0
    def renderMainPanel(self):
        '''Render on the frame the main panel with a status label'''
        self.mainPanel = JPanel(GridLayout(0,2))
        self.frame.add(self.mainPanel)

        self.mainPanel.setBorder(BorderFactory.createTitledBorder('Application status'))

        self.mainPanel.add(JLabel('Status:'))
        self.statusLabel = JTextField('Running...', 15)
        self.statusLabel.editable = False
        self.mainPanel.add(self.statusLabel)
Пример #8
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))
Пример #9
0
    def __init__(self, sattr):
	self.attr = sattr
	self.cbox = JColorChooser(self.attr.color)
	self.sz_field = JTextField(str(self.attr.size))
	szpanel = JPanel()
	szpanel.add(self.sz_field)
	szpanel.setBorder(BorderFactory.createTitledBorder("symbol size (integer)"))
	self.filled_box = JCheckBox("Filled ?:",self.attr.filled)
	self.shape_cbox = JComboBox(SymbolProps.sym_shape_map.keys())
	self.shape_cbox.setSelectedItem(self.attr.shape)
	self.shape_cbox.setBorder(BorderFactory.createTitledBorder("Shape"))
	panel1 = JPanel()
	panel1.setLayout(BorderLayout())
	panel1.add(szpanel,BorderLayout.NORTH)
	panel2 = JPanel()
	panel2.setLayout(GridLayout(1,2))
	panel2.add(self.shape_cbox)
	panel2.add(self.filled_box)
	panel1.add(panel2,BorderLayout.SOUTH)
	self.setLayout(BorderLayout())
	self.add(self.cbox,BorderLayout.CENTER)
	self.add(panel1,BorderLayout.SOUTH)
Пример #10
0
 def __init__(self, cattr):
     self.attr = cattr
     self.cbox = JColorChooser(self.attr.color)
     self.sym_panel = EditSymbolAttr(cattr.sym_prop)
     self.thickness_field = JTextField(str(cattr.thickness), 2)
     self.draw_symbol_box = JCheckBox("Draw Symbol?", cattr.draw_symbol)
     self.dps_field = JTextField(str(self.attr.data_per_symbol), 2)
     self.dash_box = JComboBox(CurveProps.DASH_TYPES.keys())
     self.dash_box.setSelectedItem(self.attr.dash_type)
     self.dash_box.setBorder(
         BorderFactory.createTitledBorder("Dash type: (Only JDK2 & Slow!)"))
     tpanelx = JPanel()
     tpanelx.add(self.thickness_field)
     tpanelx.setBorder(
         BorderFactory.createTitledBorder("curve thickness (integer)"))
     tpanely = JPanel()
     tpanely.add(self.dps_field)
     tpanely.setBorder(
         BorderFactory.createTitledBorder("data per symbol(integer)"))
     tpanel = JPanel()
     tpanel.setLayout(GridLayout(2, 2))
     tpanel.add(self.draw_symbol_box)
     tpanel.add(tpanelx)
     tpanel.add(tpanely)
     tpanel.add(self.dash_box)
     panel1 = JPanel()
     panel1.setLayout(BorderLayout())
     panel1.add(self.cbox, BorderLayout.CENTER)
     panel1.add(tpanel, BorderLayout.SOUTH)
     panel2 = JPanel()
     panel2.setLayout(BorderLayout())
     panel2.add(self.sym_panel, BorderLayout.CENTER)
     tp1 = JTabbedPane()
     tp1.addTab("Curve Attributes", panel1)
     tp1.addTab("Symbol Attributes", panel2)
     tp1.setSelectedComponent(panel1)
     self.setLayout(BorderLayout())
     self.add(tp1, BorderLayout.CENTER)
Пример #11
0
 def __init__(self, sattr):
     self.attr = sattr
     self.cbox = JColorChooser(self.attr.color)
     self.sz_field = JTextField(str(self.attr.size))
     szpanel = JPanel()
     szpanel.add(self.sz_field)
     szpanel.setBorder(
         BorderFactory.createTitledBorder("symbol size (integer)"))
     self.filled_box = JCheckBox("Filled ?:", self.attr.filled)
     self.shape_cbox = JComboBox(SymbolProps.sym_shape_map.keys())
     self.shape_cbox.setSelectedItem(self.attr.shape)
     self.shape_cbox.setBorder(BorderFactory.createTitledBorder("Shape"))
     panel1 = JPanel()
     panel1.setLayout(BorderLayout())
     panel1.add(szpanel, BorderLayout.NORTH)
     panel2 = JPanel()
     panel2.setLayout(GridLayout(1, 2))
     panel2.add(self.shape_cbox)
     panel2.add(self.filled_box)
     panel1.add(panel2, BorderLayout.SOUTH)
     self.setLayout(BorderLayout())
     self.add(self.cbox, BorderLayout.CENTER)
     self.add(panel1, BorderLayout.SOUTH)
Пример #12
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))
Пример #13
0
    def __init__(self,options):
        self.options=options
        self.layout=BoxLayout(self,BoxLayout.Y_AXIS)

        self.area=JCheckBox('CI area',False,actionPerformed=self.options.changed)
        self.add(self.area)
        self.x_axis=JComboBox(['equal','linear','log'],editable=False)
        self.x_axis.selectedIndex=0
        self.x_axis.addActionListener(self)
        self.y_axis=JComboBox(['linear','log'],editable=False)
        self.y_axis.selectedIndex=0
        self.y_axis.addActionListener(self)
        axis=JPanel(border=BorderFactory.createTitledBorder('axis'))
        axis.layout=BoxLayout(axis,BoxLayout.X_AXIS)
        axis.add(JLabel('x:'))
        axis.add(self.x_axis)
        axis.add(JLabel('y:'))
        axis.add(self.y_axis)
        axis.maximumSize=axis.minimumSize
        self.add(axis)
Пример #14
0
 def createLayeredPane(self):
     colors = [('Red', Color.red), ('Orange', Color.orange),
               ('Yellow', Color.yellow), ('Green', Color.green),
               ('Blue', Color.blue), ('Indigo', Color(75, 0, 130)),
               ('Violet', Color(143, 0, 255))]
     result = JLayeredPane(
         border=BorderFactory.createTitledBorder('Layered Pane'),
         preferredSize=Dimension(290, 280))
     position, level = Point(10, 20), 0
     for name, color in colors:
         label = self.createColoredLabel('Layer %d = %s' % (level, name),
                                         color)
         label.setLocation(position)
         position.x += 20
         position.y += 20
         result.add(label, level, 0)
         #           result.add( label, level )
         #           print level, result.getLayer( label ), result.getPosition( label )
         level += 1
     return result
Пример #15
0
 def __init__(self, view, sys):
     JDialog.__init__(self, view,
                      jEdit.getProperty("jython.pathhandler.title"))
     self.sys = sys
     content = self.contentPane
     content.layout = BorderLayout()
     upperPanel = JPanel(BorderLayout())
     leftPanel = JPanel(BorderLayout(), border = \
      BorderFactory.createTitledBorder(jEdit.getProperty("jython.pathhandler.pathborder")))
     self.model = DefaultListModel()
     for s in sys.path:
         self.model.addElement(s)
     self.pathlist = JList(
         self.model, selectionMode=ListSelectionModel.SINGLE_SELECTION)
     leftPanel.add(JScrollPane(self.pathlist))
     rightPanel = JPanel(GridBagLayout())
     constraints = GridBagConstraints()
     constraints.insets = Insets(5, 5, 5, 5)
     constraints.gridy = GridBagConstraints.RELATIVE
     constraints.gridx = 0
     buttons = [("Plus.png", "New...", self.new), \
      ("ButtonProperties.png", "Edit...", self.edit),
      ("Minus.png", "Remove", self.remove), \
      ("ArrowU.png", "Move Up", self.up), \
      ("ArrowD.png", "Move down", self.down)]
     for (i, t, a) in buttons:
         rightPanel.add(JButton(icon = GUIUtilities.loadIcon(i), \
          toolTipText=t, actionPerformed=a), constraints)
     upperPanel.add(leftPanel, BorderLayout.CENTER)
     upperPanel.add(rightPanel, BorderLayout.EAST)
     content.add(upperPanel, BorderLayout.CENTER)
     lowerPanel = JPanel(FlowLayout(FlowLayout.RIGHT))
     self.saveAsk = JCheckBox(jEdit.getProperty("options.jython.saveJythonPathTitle"), \
      selected = jEdit.getBooleanProperty("options.jython.saveJythonPath"), actionPerformed = self.saveAsk)
     ok = JButton("Ok", actionPerformed=self.__ok)
     lowerPanel.add(self.saveAsk)
     lowerPanel.add(ok)
     self.rootPane.defaultButton = ok
     lowerPanel.add(JButton("Cancel", actionPerformed=self.__cancel))
     content.add(lowerPanel, BorderLayout.SOUTH)
Пример #16
0
    def __init__(self, cattrs):
        #JDialog.__init__(self,"Curve Attribute Editor")
        #("Curve Attribute Editor")
        if cattrs == None or len(cattrs) == 0:
            raise "No curve attributes specified"
        self.attrs = cattrs
        self.cpanel = EditCurveAttr(cattrs[0])
        pane = self.getContentPane()
        pane.setLayout(BorderLayout())
        x = map(lambda x: x + 1, range(len(self.attrs)))
        self.curveBox = JComboBox(x)
        self.curveBox.setBorder(BorderFactory.createTitledBorder("Curve #"))
        self.curveBox.setSelectedItem(0)

        class CListener(ItemListener):
            def __init__(self, cbox, cpanel, cattrs):
                self.cbox = cbox
                self.cpanel = cpanel
                self.attrs = cattrs

            def itemStateChanged(self, evt):
                crvNo = self.cbox.getSelectedItem()
                self.cpanel.update()
                self.cpanel.setAttribute(self.attrs[crvNo - 1])

        self.curveBox.addItemListener(
            CListener(self.curveBox, self.cpanel, self.attrs))
        okBtn = JButton("OK", actionPerformed=self.ok_action)
        cancelBtn = JButton("Cancel", actionPerformed=self.cancel_action)
        btnPanel = JPanel()
        btnPanel.setLayout(GridLayout(1, 3))
        btnPanel.add(self.curveBox)
        btnPanel.add(okBtn)
        btnPanel.add(cancelBtn)
        pane.add(self.cpanel, BorderLayout.CENTER)
        pane.add(btnPanel, BorderLayout.SOUTH)
        self.setLocation(100, 100)
        self.pack()
        self.setVisible(1)
Пример #17
0
    def _initUI(self):
        frame = JFrame('Simple popup',
                       defaultCloseOperation=JFrame.DISPOSE_ON_CLOSE,
                       size=(300, 300))
        frame.setLayout(BoxLayout(frame.contentPane, BoxLayout.PAGE_AXIS))

        # Call-back to close popup
        def closeDialog(event):
            frame.visible = False
            frame.dispose()

        # Instantiate components
        self.text_area = JTextArea()
        msgScroller = JScrollPane()
        msgScroller.setBorder(BorderFactory.createTitledBorder("Accounts"))
        msgScroller.setViewportView(self.text_area)
        self.close_button = JButton('Close', actionPerformed=closeDialog)

        # Add components to frame
        frame.add(msgScroller)
        frame.add(self.close_button)
        frame.visible = True
Пример #18
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()
Пример #19
0
    def renderTwitterLoginPanel(self):
        '''Render on the frame the login panel with the fields needed to
        authenticate with the Twitter API.'''
        self.twitterLoginPanel = JPanel(GridLayout(0,2))
        self.frame.add(self.twitterLoginPanel)
        
        self.twitterLoginPanel.setBorder(BorderFactory.createTitledBorder('Twitter account information'))

        self.twitterLoginField = extragui.EnhancedTextField('asterisk-jython', 15)
        self.twitterLoginPanel.add(JLabel('Username:'******'password', 15)
        self.twitterLoginPanel.add(JLabel('Password:'******'Log in', actionPerformed=self.loginToTwitter)
        self.twitterLoginPanel.add(self.twitterLoginButton)
        self.twitterLoginPanel.getRootPane().setDefaultButton(self.twitterLoginButton)

        self.twitterLoginStatusLabel = JLabel('Awaiting information...')
        self.twitterLoginPanel.add(self.twitterLoginStatusLabel)
Пример #20
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))
    def registerExtenderCallbacks(self, callbacks):
        # save the helpers for later
        self.helpers = callbacks.getHelpers()

        # set our extension name
        callbacks.setExtensionName("Custom Request Handler")
        callbacks.registerSessionHandlingAction(self)
        callbacks.registerContextMenuFactory(self)
        self._text_editor = callbacks.createTextEditor()
        self._text_editor.setEditable(False)

        #How much loaded the table row
        self.current_column_id = 0

        #GUI
        self._split_main = JSplitPane(JSplitPane.VERTICAL_SPLIT)
        self._split_top = JSplitPane(JSplitPane.HORIZONTAL_SPLIT)
        self._split_top.setPreferredSize(Dimension(100, 50))
        self._split_top.setDividerLocation(700)
        self._split_center = JSplitPane(JSplitPane.VERTICAL_SPLIT)

        boxVertical = swing.Box.createVerticalBox()
        box_top = swing.Box.createHorizontalBox()
        boxHorizontal = swing.Box.createHorizontalBox()
        buttonHorizontal = swing.Box.createHorizontalBox()
        boxVertical.add(boxHorizontal)

        box_regex = swing.Box.createVerticalBox()
        border = BorderFactory.createTitledBorder(LineBorder(Color.BLACK),
                                                  "Extract target strings",
                                                  TitledBorder.LEFT,
                                                  TitledBorder.TOP)
        box_regex.setBorder(border)

        self._add_btn = JButton("Add")
        self._add_btn.addActionListener(self)
        self._remove_btn = JButton("Remove")
        self._remove_btn.addActionListener(self)

        items = [
            'JSON',
            'Header',
        ]
        self._dropdown = JComboBox(items)
        type_panel = JPanel(FlowLayout(FlowLayout.LEADING))
        type_panel.add(JLabel('Type:'))
        type_panel.add(self._dropdown)

        self._jLabel_param = JLabel("Name:")
        self._param_error = JLabel("Name is required")

        self._param_error.setVisible(False)
        self._param_error.setFont(Font(Font.MONOSPACED, Font.ITALIC, 12))
        self._param_error.setForeground(Color.red)

        regex_checkbox = JPanel(FlowLayout(FlowLayout.LEADING))
        self._is_use_regex = JCheckBox("Extract from regex group")
        regex_checkbox.add(self._is_use_regex)
        self._jTextIn_param = JTextField(20)
        self._jLabel_regex = JLabel("Regex:")
        self._jTextIn_regex = JTextField(20)
        self._regex_error = JLabel("No group defined")
        self._regex_error.setVisible(False)
        self._regex_error.setFont(Font(Font.MONOSPACED, Font.ITALIC, 12))
        self._regex_error.setForeground(Color.red)

        self._param_panel = JPanel(FlowLayout(FlowLayout.LEADING))
        self._param_panel.add(self._jLabel_param)
        self._param_panel.add(self._jTextIn_param)
        self._param_panel.add(self._param_error)

        self._regex_panel = JPanel(FlowLayout(FlowLayout.LEADING))
        self._regex_panel.add(self._jLabel_regex)
        self._regex_panel.add(self._jTextIn_regex)
        self._regex_panel.add(self._regex_error)
        button_panel = JPanel(FlowLayout(FlowLayout.LEADING))
        #padding
        button_panel.add(JPanel())
        button_panel.add(JPanel())
        button_panel.add(JPanel())
        button_panel.add(self._add_btn)
        button_panel.add(self._remove_btn)
        box_regex.add(type_panel)
        box_regex.add(self._param_panel)
        box_regex.add(regex_checkbox)
        box_regex.add(self._regex_panel)
        buttonHorizontal.add(button_panel)
        box_regex.add(buttonHorizontal)
        boxVertical.add(box_regex)
        box_top.add(boxVertical)

        box_file = swing.Box.createHorizontalBox()
        checkbox_panel = JPanel(FlowLayout(FlowLayout.LEADING))
        border = BorderFactory.createTitledBorder(
            LineBorder(Color.BLACK), 'Payload Sets [Simple list]',
            TitledBorder.LEFT, TitledBorder.TOP)
        box_file.setBorder(border)

        box_param = swing.Box.createVerticalBox()
        box_param.add(checkbox_panel)

        file_column_names = [
            "Type",
            "Name",
            "Payload",
        ]
        data = []
        self.file_table_model = DefaultTableModel(data, file_column_names)
        self.file_table = JTable(self.file_table_model)
        self.file_table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF)

        column_model = self.file_table.getColumnModel()
        for count in xrange(column_model.getColumnCount()):
            column = column_model.getColumn(count)
            column.setPreferredWidth(160)

        self.file_table.preferredScrollableViewportSize = Dimension(500, 70)
        self.file_table.setFillsViewportHeight(True)

        panel_dropdown = JPanel(FlowLayout(FlowLayout.LEADING))
        self._file_dropdown = JComboBox(items)
        panel_dropdown.add(JLabel('Type:'))
        panel_dropdown.add(self._file_dropdown)
        box_param.add(panel_dropdown)
        box_param.add(JScrollPane(self.file_table))
        callbacks.customizeUiComponent(self.file_table)

        file_param_panel = JPanel(FlowLayout(FlowLayout.LEADING))

        self._file_param = JLabel("Name:")
        self._file_param_text = JTextField(20)

        file_param_panel.add(self._file_param)
        file_param_panel.add(self._file_param_text)
        self._error_message = JLabel("Name is required")
        self._error_message.setVisible(False)
        self._error_message.setFont(Font(Font.MONOSPACED, Font.ITALIC, 12))
        self._error_message.setForeground(Color.red)
        file_param_panel.add(self._error_message)
        box_param.add(file_param_panel)

        box_button_file = swing.Box.createVerticalBox()
        self._file_load_btn = JButton("Load")

        self._file_clear_btn = JButton("Clear")
        self._file_clear_btn.addActionListener(self)
        self._file_load_btn.addActionListener(self)
        box_button_file.add(self._file_load_btn)
        box_button_file.add(self._file_clear_btn)
        box_file.add(box_button_file)
        box_file.add(box_param)
        boxVertical.add(box_file)

        regex_column_names = [
            "Type",
            "Name",
            "Regex",
            "Start at offset",
            "End at offset",
        ]
        #clear target.json
        with open("target.json", "w") as f:
            pass
        data = []
        self.target_table_model = DefaultTableModel(data, regex_column_names)
        self.target_table = JTable(self.target_table_model)
        self.target_table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF)
        column_model = self.target_table.getColumnModel()
        for count in xrange(column_model.getColumnCount()):
            column = column_model.getColumn(count)
            column.setPreferredWidth(100)

        self.target_table.preferredScrollableViewportSize = Dimension(500, 70)
        self.target_table.setFillsViewportHeight(True)
        callbacks.customizeUiComponent(self.target_table)
        callbacks.customizeUiComponent(boxVertical)
        table_panel = swing.Box.createVerticalBox()
        table_panel.add(JScrollPane(self.target_table))
        box_top.add(table_panel)

        self._jScrollPaneOut = JScrollPane()
        #self._split_main.setBottomComponent(self._jScrollPaneOut)
        self._split_main.setBottomComponent(self._text_editor.getComponent())
        self._split_main.setTopComponent(box_top)
        self._split_main.setDividerLocation(450)
        callbacks.customizeUiComponent(self._split_main)
        callbacks.addSuiteTab(self)
        return
Пример #22
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()
Пример #23
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()
Пример #24
0
    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()
Пример #25
0
 def __init__(self):
     '''
     Constructor
     '''
     #Create classifiers
     #Character classifier
     path_to_this_dir = File(str(inspect.getfile( inspect.currentframe() ))).getParent()
     character_classifier_file = open(File(path_to_this_dir,"character_classifier.dat").getPath(),'r')
     self.character_classifier = CharacterClassifier(from_string_string=character_classifier_file.read())
     character_classifier_file.close()
     #Word classifier
     word_classifier_file = open(File(path_to_this_dir,"word_classifier.dat").getPath(),'r')
     self.word_classifier= WordClassifier(from_string_string=word_classifier_file.read())
     word_classifier_file.close()
     #Set up window
     self.setTitle("HandReco Writer")
     self.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE)
     self.setLocationRelativeTo(None)
     self.setLayout(BorderLayout())
     #Set up menu
     menu_bar = JMenuBar()
     info_menu = JMenu("Info")
     def instructions(event):
         instr = '''
         The program can just recognise capital English characters.
         See Info -> Available Words... for available word corrections.
         
         Good Luck with the writing!'''
         JOptionPane.showMessageDialog(self, instr, 
                       "Instructions", 
                       JOptionPane.INFORMATION_MESSAGE)
     instructions_menu_item = JMenuItem("Instructions...",actionPerformed=instructions)
     info_menu.add(instructions_menu_item)
     def word_corrections(event):
         words_string = ""
         for word in self.word_classifier.words:
             words_string = words_string + word.upper() + "\n"
         text = "The words that can be corrected are:\n\n" +words_string
         dialog = JOptionPane(text, 
                              JOptionPane.INFORMATION_MESSAGE)
         dialog_wrapper = JDialog(self,"Available Words",False)
         dialog_wrapper.setContentPane(dialog)
         dialog_wrapper.pack()
         dialog_wrapper.setVisible(True)
     word_corrections_menu_item = JMenuItem("Available Words...",actionPerformed=word_corrections)
     info_menu.add(word_corrections_menu_item)
     menu_bar.add(info_menu)
     self.setJMenuBar(menu_bar)
     #Input panel
     input_panel = JPanel()
     input_panel.setLayout(BoxLayout(input_panel, BoxLayout.X_AXIS))
     input_panel.setBorder(BorderFactory.createTitledBorder("Input"))
     self.paint_area = PaintArea(100,100)
     input_panel.add(self.paint_area)
     input_options_panel = JPanel()
     input_options_panel.setLayout(BoxLayout(input_options_panel, BoxLayout.Y_AXIS))
     #Write Char
     write_char_panel = JPanel(BorderLayout())
     def write_char(event):
         char = self.character_classifier.classify_image(self.paint_area.image())
         self.text_area.setText(self.text_area.getText() + char)
         self.paint_area.clear()
     write_char_panel.add(JButton("Write Char", actionPerformed=write_char), BorderLayout.NORTH)
     input_options_panel.add(write_char_panel)
     #Space and Correct
     space_and_correct_panel = JPanel(BorderLayout())
     def space_and_correct(event):
         text = self.text_area.getText()
         words = text.split(" ")
         string = words[-1]
         try:
             word = self.word_classifier.classify(string.lower())
             words[-1] = word.upper()
         except:
             JOptionPane.showMessageDialog(self, "Have you entered a character which is not in the alphabet?", 
                           "Could not Correct", 
                           JOptionPane.ERROR_MESSAGE)
             self.text_area.setText(text + " ")
             return
         newText = ""
         for w in words:
             newText = newText + w + " "
         self.text_area.setText(newText)
     space_and_correct_panel.add(JButton("Space and Correct", actionPerformed=space_and_correct), BorderLayout.NORTH)
     input_options_panel.add(space_and_correct_panel)
     #Space
     space_panel = JPanel(BorderLayout())
     def space(event):
         self.text_area.setText(self.text_area.getText() + " ")
     space_panel.add(JButton("Space", actionPerformed=space), BorderLayout.NORTH)
     input_options_panel.add(space_panel)
     #Clear Input Area
     clear_input_area_panel = JPanel(BorderLayout())
     def clear(event):
         self.paint_area.clear()
     clear_input_area_panel.add(JButton("Clear Input Area", actionPerformed=clear), BorderLayout.NORTH)
     input_options_panel.add(clear_input_area_panel)
     input_panel.add(input_options_panel)
     self.add(input_panel, BorderLayout.NORTH)
     text_area_panel = JPanel()
     text_area_panel.setLayout(BorderLayout())
     text_area_panel.setBorder(BorderFactory.createTitledBorder("Text"))
     self.text_area = JTextArea()
     self.text_area.setLineWrap(True)
     #Increase font size
     font = self.text_area.getFont() 
     self.text_area.setFont(Font(font.getName(), Font.BOLD, 24))
     
     text_area_panel.add(JScrollPane(self.text_area), BorderLayout.CENTER)
     self.add(text_area_panel, BorderLayout.CENTER)
     self.pack()
     self.setSize(Dimension(300,300))
     self.setVisible(True)
Пример #26
0
    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)
Пример #27
0
    def __init__(self, arg_dict):
        super(CumulusUI, self).__init__()

        # Load argument from the command line
        self.start_time = arg_dict['start_time']
        self.end_time = arg_dict['end_time']
        self.dss_path = arg_dict['dss_path']
        self.cwms_home = arg_dict['cwms_home']
        self.config = arg_dict['config']

        # Get the DSS Path if one was saved in the "cumulus.config" file
        if os.path.isfile(self.config):
            with open(os.path.join(APPDATA, "cumulus.config")) as f:
                self.dss_path = f.read()

        # Get the basins and products, load JSON, create lists for JList, and create dictionaries
        self.basin_download = json.loads(self.http_get(url_basins))        
        self.jlist_basins = ["{}:{}".format(b['office_symbol'], b['name']) for b in self.basin_download]
        self.basin_meta = dict(zip(self.jlist_basins, self.basin_download))
        self.jlist_basins.sort()

        self.product_download = json.loads(self.http_get(url_products))
        self.jlist_products = ["{}".format(p['name'].replace("_", " ").title()) for p in self.product_download]
        self.product_meta = dict(zip(self.jlist_products, self.product_download))
        self.jlist_products.sort()

        btn_submit = JButton()
        lbl_start_date = JLabel()
        lbl_end_date = JLabel()
        self.txt_select_file = JTextField()
        btn_select_file = JButton()
        lbl_origin = JLabel()
        lbl_extent = JLabel()
        lbl_select_file = JLabel()

        self.txt_start_time = JTextField()
        self.txt_end_time = JTextField()

        jScrollPane1 = JScrollPane()
        self.lst_product = JList()
        self.lst_product = JList(self.jlist_products, valueChanged = self.choose_product)
        
        jScrollPane2 = JScrollPane()
        self.lst_watershed = JList()
        self.lst_watershed = JList(self.jlist_basins, valueChanged = self.choose_watershed)

        self.cwms_dssname = JCheckBox()

        self.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE)
        self.setTitle("Cumulus CAVI UI")
        self.setLocation(Point(10, 10))
        self.setLocationByPlatform(True)
        self.setName("CumulusCaviUi")
        self.setResizable(False)

        btn_submit.setFont(Font("Tahoma", 0, 18))
        btn_submit.setText("Submit")
        btn_submit.actionPerformed = self.submit

        lbl_start_date.setText("Start Date/Time")

        lbl_end_date.setText("End Date/Time")

        self.txt_select_file.setToolTipText("FQPN to output file (.dss)")

        btn_select_file.setText("...")
        btn_select_file.setToolTipText("Select File...")
        btn_select_file.actionPerformed = self.select_file

        lbl_origin.setText("Minimum (x,y):")

        lbl_extent.setText("Maximum (x,y):")

        lbl_select_file.setText("Output File Location")

        self.txt_start_time.setToolTipText("Start Time")
        self.txt_end_time.setToolTipText("End Time")

        self.lst_product.setBorder(BorderFactory.createTitledBorder(None, "Available Products", TitledBorder.CENTER, TitledBorder.TOP, Font("Tahoma", 0, 14)))
        self.lst_product.setFont(Font("Tahoma", 0, 14))
        jScrollPane1.setViewportView(self.lst_product)
        self.lst_product.getAccessibleContext().setAccessibleName("Available Products")
        self.lst_product.getAccessibleContext().setAccessibleParent(jScrollPane2)

        self.lst_watershed.setBorder(BorderFactory.createTitledBorder(None, "Available Watersheds", TitledBorder.CENTER, TitledBorder.TOP, Font("Tahoma", 0, 14)))
        self.lst_watershed.setFont(Font("Tahoma", 0, 14))
        self.lst_watershed.setSelectionMode(ListSelectionModel.SINGLE_SELECTION)
        jScrollPane2.setViewportView(self.lst_watershed)

        self.cwms_dssname.setText("CWMS DSS filename")
        self.cwms_dssname.setToolTipText("Parameter.yyyy.mm.dss")
        self.cwms_dssname.setVisible(False)

        layout = GroupLayout(self.getContentPane());
        self.getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING, False)
                    .addComponent(lbl_select_file)
                    .addComponent(jScrollPane1)
                    .addComponent(jScrollPane2)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(GroupLayout.Alignment.TRAILING)
                            .addComponent(btn_submit)
                            .addComponent(self.txt_select_file, GroupLayout.PREFERRED_SIZE, 377, GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(btn_select_file))
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
                            .addComponent(lbl_start_date)
                            .addComponent(self.txt_start_time, GroupLayout.PREFERRED_SIZE, 170, GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
                            .addComponent(self.txt_end_time, GroupLayout.PREFERRED_SIZE, 170, GroupLayout.PREFERRED_SIZE)
                            .addComponent(lbl_end_date))))
                .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        )
        layout.setVerticalGroup(
            layout.createParallelGroup(GroupLayout.Alignment.LEADING)
            .addGroup(GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addGap(25, 25, 25)
                .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                    .addComponent(lbl_start_date)
                    .addComponent(lbl_end_date))
                .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
                    .addComponent(self.txt_start_time, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
                    .addComponent(self.txt_end_time, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addComponent(jScrollPane2, GroupLayout.PREFERRED_SIZE, 201, GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(jScrollPane1, GroupLayout.PREFERRED_SIZE, 201, GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, Short.MAX_VALUE)
                .addComponent(lbl_select_file)
                .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                    .addComponent(self.txt_select_file, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
                    .addComponent(btn_select_file))
                .addGap(18, 18, 18)
                .addComponent(btn_submit)
                .addContainerGap())
        )

        self.txt_select_file.setText(self.dss_path)
        self.txt_start_time.setText(self.start_time)
        self.txt_end_time.setText(self.end_time)

        self.pack()
        self.setLocationRelativeTo(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)
Пример #29
0
    def registerExtenderCallbacks(self, callbacks):
        print "JSON&HTTPP by [Vulkey_Chen]\nBlog: gh0st.cn\nTeam: MSTSEC"
        self._cb = callbacks
        self._hp = callbacks.getHelpers()
        self._cb.setExtensionName("JSON&HTTPP")
        self.mainPanel = JPanel()
        self.mainPanel.setLayout(BorderLayout())

        self.jsonTextArea = JTextArea(20, 0)
        self.jsonTextArea.setLineWrap(True)

        self.dictTextArea = JTextArea()
        self.dictTextArea.setLineWrap(True)

        self.keyTextArea = JTextArea()
        self.keyTextArea.setLineWrap(True)

        self.valueTextArea = JTextArea()
        self.valueTextArea.setLineWrap(True)

        self.resultPanel = JPanel()
        # self.resultPanel.setLayout(BorderLayout())
        self.resultPanel.layout = GridLayout(1, 3)

        self.jsonTextWrapper = JPanel()
        self.jsonTextWrapper.setLayout(BorderLayout())
        self.jsonTextWrapper.border = BorderFactory.createTitledBorder("Input")
        self.dictTextWrapper = JPanel()
        self.dictTextWrapper.setLayout(BorderLayout())
        self.dictTextWrapper.border = BorderFactory.createTitledBorder(
            "Output")
        self.keyTextWrapper = JPanel()
        self.keyTextWrapper.setLayout(BorderLayout())
        self.keyTextWrapper.border = BorderFactory.createTitledBorder("Keys")
        self.valueTextWrapper = JPanel()
        self.valueTextWrapper.setLayout(BorderLayout())
        self.valueTextWrapper.border = BorderFactory.createTitledBorder(
            "Values")

        self.jsonScrollPane = JScrollPane(self.jsonTextArea)
        self.dictScrollPane = JScrollPane(self.dictTextArea)
        self.valueScrollPane = JScrollPane(self.valueTextArea)
        self.keyScrollPane = JScrollPane(self.keyTextArea)

        self.jsonTextWrapper.add(self.jsonScrollPane, BorderLayout.CENTER)
        self.dictTextWrapper.add(self.dictScrollPane, BorderLayout.CENTER)
        self.keyTextWrapper.add(self.keyScrollPane, BorderLayout.CENTER)
        self.valueTextWrapper.add(self.valueScrollPane, BorderLayout.CENTER)

        self.resultPanel.add(self.dictTextWrapper, BorderLayout.WEST)
        self.resultPanel.add(self.keyTextWrapper, BorderLayout.CENTER)
        self.resultPanel.add(self.valueTextWrapper, BorderLayout.EAST)

        self.mainPanel.add(self.jsonTextWrapper, BorderLayout.NORTH)
        self.mainPanel.add(self.resultPanel, BorderLayout.CENTER)

        self.beautifyButton_1 = JButton("JSON2HTTPP",
                                        actionPerformed=self.onClick1)
        self.beautifyButton_2 = JButton("HTTPP2JSON",
                                        actionPerformed=self.onClick2)
        self.clearButton = JButton("CLEAR", actionPerformed=self.onClear)

        self.buttons = JPanel()
        self.buttons.add(self.beautifyButton_1, BorderLayout.CENTER)
        self.buttons.add(self.beautifyButton_2, BorderLayout.CENTER)
        self.buttons.add(self.clearButton, BorderLayout.CENTER)

        self.mainPanel.add(self.buttons, BorderLayout.SOUTH)

        self._cb.customizeUiComponent(self.mainPanel)
        self._cb.addSuiteTab(self)
    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()
Пример #31
0
    def __init__(self, extender):
        super(BeautifierOptionsPanel, self).__init__()
        self._extender = extender

        self.contentWrapper = JPanel(GridBagLayout())
        self.setViewportView(self.contentWrapper)
        self.getVerticalScrollBar().setUnitIncrement(16)
        self.addMouseListener(self.RequestFocusListener(
            self))  # Let textArea lose focus when click empty area

        innerContainer = JPanel(GridBagLayout())
        innerContainer.setFocusable(
            True
        )  # make sure the maxSizeText TextField is not focused when BeautifierOptionsPanel display

        # generalOptionPanel and it's inner component
        maxSizeLabel = JLabel("Max Size: ")
        self.maxSizeText = JTextField(5)
        self.maxSizeText.setHorizontalAlignment(SwingConstants.RIGHT)
        self.maxSizeText.addFocusListener(self.MaxSizeTextListener(self))
        sizeUnitLabel = JLabel("KB")

        generalOptionPanel = JPanel(GridBagLayout())
        generalOptionPanel.setBorder(
            BorderFactory.createTitledBorder("General Options"))
        gbc = GridBagConstraints()
        gbc.anchor = GridBagConstraints.WEST
        gbc.gridx = 0
        gbc.gridy = 0
        generalOptionPanel.add(maxSizeLabel, gbc)
        gbc.fill = GridBagConstraints.HORIZONTAL
        gbc.gridx = 1
        gbc.gridy = 0
        generalOptionPanel.add(self.maxSizeText, gbc)
        gbc.fill = GridBagConstraints.NONE
        gbc.gridx = 2
        gbc.gridy = 0
        gbc.weightx = 1.0
        generalOptionPanel.add(sizeUnitLabel, gbc)

        gbc = GridBagConstraints()
        gbc.fill = GridBagConstraints.BOTH
        gbc.gridx = 1
        gbc.gridy = 0
        gbc.gridheight = 2
        innerContainer.add(generalOptionPanel, gbc)

        # messageTabOptionPanel and it's inner component
        self.messageTabFormatCheckBoxs = []
        for f in supportedFormats:
            ckb = JCheckBox(f)
            ckb.addItemListener(self.messageTabFormatListener)
            self.messageTabFormatCheckBoxs.append(ckb)

        messageTabOptionPanel = JPanel()
        messageTabOptionPanel.setLayout(
            BoxLayout(messageTabOptionPanel, BoxLayout.Y_AXIS))
        messageTabOptionPanel.setBorder(
            BorderFactory.createTitledBorder("Enable in MessageEditorTab"))
        for b in self.messageTabFormatCheckBoxs:
            messageTabOptionPanel.add(b)

        gbc.gridx = 1
        gbc.gridy = 2
        gbc.gridheight = 9

        innerContainer.add(messageTabOptionPanel, gbc)

        # replaceResponsePanel and it's inner component
        self.chkEnableReplace = JCheckBox("Enable")
        self.chkEnableReplace.addItemListener(self.repalceResponseBoxListener)
        replaceResponseFormatLabel = JLabel("Format")
        self.replaceResponseFormatCheckBoxs = []
        for f in supportedFormats:
            ckb = JCheckBox(f)
            ckb.addItemListener(self.replaceResponseFormatListener)
            self.replaceResponseFormatCheckBoxs.append(ckb)
        replaceResponseIncludeLabel = JLabel(
            "Include URL that matches below(one item one line)")
        self.URLIncludeTextArea = JTextArea(6, 32)
        self.URLIncludeTextArea.addFocusListener(
            self.URLIncludeFocusListener(self))
        URLIncludeScrollPane = JScrollPane(self.URLIncludeTextArea)
        URLIncludeScrollPane.setAlignmentX(Component.LEFT_ALIGNMENT)
        replaceResponseExcludeLabel = JLabel(
            "Exclude URL that matches below(one item one line)")
        self.URLExcludeTextArea = JTextArea(5, 32)
        self.URLExcludeTextArea.addFocusListener(
            self.URLExcludeFocusListener(self))
        URLExcludeScrollPane = JScrollPane(self.URLExcludeTextArea)
        URLExcludeScrollPane.setAlignmentX(Component.LEFT_ALIGNMENT)

        replaceResponsePanel = JPanel()
        replaceResponsePanel.setLayout(
            BoxLayout(replaceResponsePanel, BoxLayout.Y_AXIS))
        replaceResponsePanel.setBorder(
            BorderFactory.createTitledBorder("Replace PROXY Response"))
        replaceResponsePanel.add(self.chkEnableReplace)
        replaceResponsePanel.add(Box.createVerticalStrut(10))
        replaceResponsePanel.add(replaceResponseFormatLabel)
        for b in self.replaceResponseFormatCheckBoxs:
            replaceResponsePanel.add(b)
        replaceResponsePanel.add(Box.createVerticalStrut(10))
        replaceResponsePanel.add(replaceResponseIncludeLabel)
        replaceResponsePanel.add(URLIncludeScrollPane)
        replaceResponsePanel.add(Box.createVerticalStrut(10))
        replaceResponsePanel.add(replaceResponseExcludeLabel)
        replaceResponsePanel.add(URLExcludeScrollPane)

        gbc.gridy = 11
        innerContainer.add(replaceResponsePanel, gbc)

        # let innerContainer keep away from left and up
        gbc = GridBagConstraints()
        gbc.gridx = 1
        gbc.gridy = 1
        self.contentWrapper.add(Box.createHorizontalStrut(15), gbc)

        # gbc.ipadx = gbc.ipady = 25
        gbc.gridx = 2
        self.contentWrapper.add(innerContainer, gbc)

        # let innerContainer stay left side
        gbc = GridBagConstraints()
        gbc.gridx = 3
        gbc.gridy = 2
        gbc.gridwidth = 1
        gbc.weightx = gbc.weighty = 1
        paddingPanel = JPanel()
        self.contentWrapper.add(paddingPanel, gbc)

        self.setDefaultOptionDisplay()
Пример #32
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)
Пример #33
0
	def run(self, cells, path) :
		
		self.__cells=cells
		cells.sort()
		self.__cells.sort()
		self.__path=path
	
		if len(cells) <= 6 :
			cols=len(cells)
			rows=1
		else :
			cols=6
			rows=int(len(cells)/6)+1

		#print "cols", cols, "rows", rows
		self.setFont(awt.Font("Courrier", 1, 10))
		#self.size=(max(200*cols, 1100), max(70*rows, 300))
		self.size=(max(150*cols, 800), max(50*rows, 250))
		line = BorderFactory.createEtchedBorder(EtchedBorder.LOWERED)
			
		self.contentPane.layout = awt.BorderLayout()
		self.__display = swing.JTextField(preferredSize=(400, 30), horizontalAlignment=swing.SwingConstants.LEFT)
		self.__setDisplay()

		northpanel=swing.JPanel(awt.FlowLayout(awt.FlowLayout.LEFT))
		northpanel.setBorder(line)
		#northpanel.add(self.__display, awt.BorderLayout.NORTH)
		northpanel.add(self.__display)
		selectall = swing.JButton("select ALL", size=(100, 70), actionPerformed=self.__selectall)
		#northpanel.add(selectall, awt.BorderLayout.WEST)
		northpanel.add(selectall)
		selectnone = swing.JButton("select NONE", size=(100, 70), actionPerformed=self.__selectnone)
		#northpanel.add(selectnone, awt.BorderLayout.EAST)
		northpanel.add(selectnone)
		mem = swing.JButton("Memorize", size=(100, 70), actionPerformed= self.__memorize)
		northpanel.add(mem)
		recall = swing.JButton("Recall", size=(100, 70), actionPerformed=self.__recall)
		northpanel.add(recall)
		
		southpanel=swing.JPanel(awt.FlowLayout(awt.FlowLayout.RIGHT))
		southpanel.setBorder(line)
		self.__label=swing.JLabel("validate selection with ok")
		southpanel.add(self.__label)
		ok = swing.JButton("ok", size=(100, 70), actionPerformed=self.__ok)
		southpanel.add(ok)
		close = swing.JButton("close", size=(100, 70), actionPerformed=self.__close)
		southpanel.add(close)
		
		westpanel=swing.JPanel(awt.FlowLayout(awt.FlowLayout.CENTER), preferredSize=(150, 200))
		westpanel.setBorder(line)
		
		show = swing.JButton("show overlay", size=(100, 70), actionPerformed=self.__show)
		westpanel.add(show)
		hide = swing.JButton("hide overlay", size=(100, 70), actionPerformed=self.__hide)
		westpanel.add(hide)
		allframes = swing.JButton("show all", size=(100, 70), actionPerformed=self.__showall)
		westpanel.add(allframes)
		oneframe = swing.JButton("show one frame", size=(100, 70), actionPerformed=self.__showone)
		westpanel.add(oneframe)
		reset = swing.JButton("reset", size=(100, 70), actionPerformed=self.__reset)
		westpanel.add(reset)

		title = BorderFactory.createTitledBorder("Edit Cells")
		title.setTitleJustification(TitledBorder.CENTER)

		eastpanel = swing.JPanel(awt.FlowLayout(awt.FlowLayout.CENTER), preferredSize=(130, 200))
		eastpanel.setBorder(title)
		split = swing.JButton("split", size=(100, 70), actionPerformed=self.__split)
		eastpanel.add(split)
		
		grid = awt.GridLayout()
		grid.setRows(rows)
		checkpanel=swing.JPanel(grid)
		checkpanel.setFont(awt.Font("Courrier", 1, 10))
		self.__boxes=[swing.JCheckBox(actionPerformed=self.__boxaction) for i in range(len(cells))]
		for b in self.__boxes : b.setFont(awt.Font("Courrier", 1, 10))
		#self.__mem=[True for i in range(len(cells))]
		
		for i in range(len(self.__boxes)) : 
			self.__dictBox[cells[i]]=(cells[i], self.__boxes[i])
			
		for i in range(len(self.__boxes)) :
			self.__boxes[i].setText(str(cells[i]))
			self.__boxes[i].setSelected(True)
			checkpanel.add(self.__boxes[i])
		for i in range(rows*cols-len(self.__boxes)) : checkpanel.add(awt.Label(""))
		
		self.contentPane.add(northpanel, awt.BorderLayout.NORTH)
		self.contentPane.add(checkpanel, awt.BorderLayout.CENTER)
		self.contentPane.add(westpanel, awt.BorderLayout.WEST)
		self.contentPane.add(eastpanel, awt.BorderLayout.EAST)
		self.contentPane.add(southpanel, awt.BorderLayout.SOUTH)
		self.contentPane.setFont(awt.Font("Courrier", 1, 10))

		self.__rm = RoiManager.getInstance()
		if (self.__rm==None): self.__rm = RoiManager()
		self.__rm.runCommand("reset")
		
		listfilescells=[]
		listfilescells.extend(glob.glob(path+"*.zip"))


		#includecells = [filename for filename in listfilescells if filename.rsplit("/",1)[1][0:-4] in cells]
		includecells = [filename for filename in listfilescells if os.path.splitext(os.path.split(filename)[1])[0] in cells]
		
		for cell in includecells : 
			#c = cell.rsplit("/",1)[1][0:-4]
			c=os.path.splitext(os.path.split(cell)[1])[0]
			self.__dictFiles[c] = (c, cell)
Пример #34
0
    def __init__(self):

        self.fields = [
                    PTTextField(
                            "domain",
                            "Set cookies to be valid for domain: ",
                            cb.demo_domain, None
                        ),
                    PTSeparator(),
                    PTTextField(
                            "phantomJS_path", "Path to PhantomJS binary: ",
                            "/usr/bin/phantomjs", None,
                            JButton(
                                "Browse for binary...",
                                actionPerformed=self._button_browse_pressed
                            )
                        ),
                    PTTextField(
                            "phantomJS_args",
                            "Optional PhantomJS arguments: ",
                            "--ignore-ssl-errors=true" +
                            " --web-security=false",
                            None,
                            JButton(
                                PhantomJS.uri,
                                actionPerformed=self._button_web_browser_pressed
                            )
                        ),
                    PTTextField(
                            "url",
                            "Obtain cookies from this URL: ",
                            cb.demo_url,
                            None,
                            JButton(
                                "Open in Browser",
                                actionPerformed=self._button_web_browser_pressed
                            ),
                            JButton(
                                "Send to Repeater",
                                actionPerformed=self._button_repeater_pressed
                            )
                        ),
                    PTTextField(
                            "duration",
                            "Milliseconds that PhantomJs should wait " +
                            "for cookies to be set: ",
                            "500", None
                        )
                ]

        self.values = {}

        bordertitle = "Setup a session handling action which uses PhantomJS" +\
            " to obtain named cookies to add to Burp's cookie jar"

        self.setBorder(BorderFactory.createTitledBorder(bordertitle))

        self.setLayout(BoxLayout(self, BoxLayout.Y_AXIS))

        self._rowpanel1 = JPanel()
        self._rowpanel1.setLayout(BoxLayout(self._rowpanel1, BoxLayout.Y_AXIS))
        self._rowpanel1.setBorder(
                            BorderFactory.createTitledBorder(
                                            BorderFactory.createEmptyBorder(),
                                            "Settings"
                                        )
                        )

        self._rowpanel2 = PTListPanel("Cookies to obtain", [cb.demo_cookie])

        self._rowpanel3 = JPanel()
        self._rowpanel3.setLayout(BoxLayout(self._rowpanel3, BoxLayout.X_AXIS))

        self._button_update = JButton(
                                "Add a new \"Get cookies\" session handler " +
                                "with these settings for these cookies",
                                actionPerformed=self._button_update_pressed
                            )

        for field in self.fields:
            self._rowpanel1.add(field)

        _panel_test = JPanel()
        _panel_test.add(Box.createHorizontalGlue())
        _panel_test.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5))

        _button_test = JButton(
                        "Verify these settings and fetch cookies now",
                        actionPerformed=self._cookie_fetch_test
                    )
        _panel_test.add(_button_test)

        self._rowpanel1.add(_panel_test)

        self._rowpanel1.add(PTSeparator())

        self._rowpanel3.add(Box.createHorizontalGlue())
        self._rowpanel3.add(self._button_update)

        self.add(self._rowpanel1)
        self.add(self._rowpanel2)
        self.add(self._rowpanel3)
Пример #35
0
    def initUI(self):
        
        inputPanel = JPanel()
        inputPanel.setBorder(BorderFactory.createTitledBorder("Where are your control and treament images?"))
        inputLayout = GroupLayout(inputPanel, autoCreateContainerGaps=True, autoCreateGaps=True)
        inputPanel.setLayout(inputLayout)
        
        annotatePanel = JPanel()
        annotatePanel.setBorder(BorderFactory.createTitledBorder("How do you want to annotate your data?"))
        anLayout = GroupLayout(annotatePanel, autoCreateContainerGaps=True, autoCreateGaps=True)
        annotatePanel.setLayout(anLayout)
        
        exportPanel = JPanel()
        exportPanel.setBorder(BorderFactory.createTitledBorder("Where do you want to export your data"))
        exportLayout = GroupLayout(exportPanel, autoCreateContainerGaps=True, autoCreateGaps=True)
        exportPanel.setLayout(exportLayout)
        
        btnPanel = JPanel()
        btnLayout = GroupLayout(btnPanel, autoCreateContainerGaps=True, autoCreateGaps=True)
        btnPanel.setLayout(btnLayout)
        
        layout = GroupLayout(self.getContentPane(), autoCreateContainerGaps=True, autoCreateGaps=True)
        self.getContentPane().setLayout(layout)

        self.setModalityType(ModalityType.APPLICATION_MODAL)
        self.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE)# JFrame.EXIT_ON_CLOSE)
        # definition of elements
        # labels
        cPathLabel = JLabel("Control Path:")
        tPathLabel = JLabel("Treatment Path:")
        exPathLabel = JLabel("Save Results in:")
        
        #textfields
        self.cPathField = JTextField("/Users/schiklen/DotData/131118_dummy/131118_2926/cutout/", 16)
        self.tPathField = JTextField("/Users/schiklen/DotData/131118_dummy/131118_2926/cutout/", 16)
        self.exPathField = JTextField("/Users/schiklen/DotData/131118_dummy/131118_2926/cutout/", 16)
        
        #Radiobuttons
        yesNoRButton = JRadioButton("Yes / No / Ignore", selected=True, actionCommand="yesNoIgnore", actionPerformed=self.setAnnotationTypeDialog)
        intRButton = JRadioButton("Integer", actionCommand="int", actionPerformed=self.setAnnotationTypeDialog)
        nRButton = JRadioButton("Number", actionCommand="float", actionPerformed=self.setAnnotationTypeDialog)
        listRButton = JRadioButton("From List...", actionCommand="list", actionPerformed=self.openListDialog)

        self.rBGroup = ButtonGroup()
        self.rBGroup.add(yesNoRButton)
        self.rBGroup.add(intRButton)
        self.rBGroup.add(nRButton)
        self.rBGroup.add(listRButton)
        
        #self.customListButton = JButton("Custom List...", actionPerformed=self.makeCustomList, enabled=0)
        
        #buttons
        cPathButton = JButton("Browse...", actionPerformed=self.browseC) # lambda on fieldvalue
        tPathButton = JButton("Browse...", actionPerformed=self.browseT) # lambda on fieldvalue
        exPathButton = JButton("Browse...", actionPerformed=self.browseE)
        OKButton = JButton("OK", actionPerformed=self.okayEvent)
        CancelButton = JButton("Cancel", actionPerformed=self.cancel)
        
        '''General ContentPane Layout'''
        layout.setHorizontalGroup(layout.createParallelGroup()
                                  .addComponent(inputPanel)
                                  .addComponent(annotatePanel)
                                  .addComponent(exportPanel)
                                  .addComponent(btnPanel)
                                  )
        layout.linkSize(SwingConstants.HORIZONTAL, inputPanel, annotatePanel, exportPanel, btnPanel)
        layout.setVerticalGroup(layout.createSequentialGroup()
                                .addComponent(inputPanel)
                                .addComponent(annotatePanel)
                                .addComponent(exportPanel)
                                .addComponent(btnPanel)
                                )
        
        ''' Input panel Layout '''
        inputLayout.setHorizontalGroup(inputLayout.createSequentialGroup()
                                       .addGroup(inputLayout.createParallelGroup(GroupLayout.Alignment.TRAILING)
                                                 .addComponent(cPathLabel)
                                                 .addComponent(tPathLabel))
                                       .addGroup(inputLayout.createParallelGroup(GroupLayout.Alignment.TRAILING)
                                                 .addComponent(self.cPathField)
                                                 .addComponent(self.tPathField))
                                       .addGroup(inputLayout.createParallelGroup()
                                                 .addComponent(cPathButton)
                                                 .addComponent(tPathButton))
                                       )
        
        inputLayout.setVerticalGroup(inputLayout.createSequentialGroup()
                                       .addGroup(inputLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                                                 .addComponent(cPathLabel)
                                                 .addComponent(self.cPathField)
                                                 .addComponent(cPathButton))
                                       .addGroup(inputLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                                                 .addComponent(tPathLabel)
                                                 .addComponent(self.tPathField)
                                                 .addComponent(tPathButton))
                                     )
        
        '''Annotate panel layout'''
        anLayout.setHorizontalGroup(anLayout.createParallelGroup()
                                    .addComponent(yesNoRButton)
                                    .addComponent(intRButton)
                                    .addComponent(nRButton)
                                    .addComponent(listRButton)
                                    #.addComponent(self.customListButton)
                                    )
        anLayout.setVerticalGroup(anLayout.createSequentialGroup()
                                    .addComponent(yesNoRButton)
                                    .addComponent(intRButton)
                                    .addComponent(nRButton)
                                    .addComponent(listRButton)
                                    #.addComponent(self.customListButton)
                                    )
        
        
        '''Export panel layout'''
        exportLayout.setHorizontalGroup(exportLayout.createSequentialGroup()
                                        .addComponent(exPathLabel)
                                        .addComponent(self.exPathField)
                                        .addComponent(exPathButton))
        exportLayout.setVerticalGroup(exportLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                                        .addComponent(exPathLabel)
                                        .addComponent(self.exPathField)
                                        .addComponent(exPathButton))
        
        
        '''Buttons Panel Layout'''
        btnLayout.setHorizontalGroup(btnLayout.createSequentialGroup()
                                     .addComponent(CancelButton)
                                     .addComponent(OKButton)
                                     )
        btnLayout.setVerticalGroup(btnLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                                   .addComponent(CancelButton)
                                   .addComponent(OKButton)
                                   )

        self.setTitle("Random Picture Picker")

        self.pack()
        self.setLocationRelativeTo(None)
        self.setVisible(True)
Пример #36
0
    def __init__(self):
        '''
        Constructor
        '''
        #Create classifiers
        #Character classifier
        path_to_this_dir = File(str(inspect.getfile(
            inspect.currentframe()))).getParent()
        character_classifier_file = open(
            File(path_to_this_dir,
                 "character_classifier_11_segments_4_6_cf.dat").getPath(), 'r')
        self.character_classifier = CharacterClassifier(
            from_string_string=character_classifier_file.read())
        character_classifier_file.close()
        #Word classifier
        word_classifier_file = open(
            File(path_to_this_dir, "word_classifier.dat").getPath(), 'r')
        self.word_classifier = WordClassifier(
            from_string_string=word_classifier_file.read())
        word_classifier_file.close()
        #Set up window
        self.setTitle("HandReco Writer")
        self.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE)
        self.setLocationRelativeTo(None)
        self.setLayout(BorderLayout())
        #Set up menu
        menu_bar = JMenuBar()
        info_menu = JMenu("Info")

        def instructions(event):
            instr = '''
            The program can just recognise capital English characters.
            See Info -> Available Words... for available word corrections.
            
            Good Luck with the writing!'''
            JOptionPane.showMessageDialog(self, instr, "Instructions",
                                          JOptionPane.INFORMATION_MESSAGE)

        instructions_menu_item = JMenuItem("Instructions...",
                                           actionPerformed=instructions)
        info_menu.add(instructions_menu_item)

        def word_corrections(event):
            words_string = ""
            for word in self.word_classifier.words:
                words_string = words_string + word.upper() + "\n"
            text = "The words that can be corrected are:\n\n" + words_string
            dialog = JOptionPane(text, JOptionPane.INFORMATION_MESSAGE)
            dialog_wrapper = JDialog(self, "Available Words", False)
            dialog_wrapper.setContentPane(dialog)
            dialog_wrapper.pack()
            dialog_wrapper.setVisible(True)

        word_corrections_menu_item = JMenuItem(
            "Available Words...", actionPerformed=word_corrections)
        info_menu.add(word_corrections_menu_item)
        menu_bar.add(info_menu)
        self.setJMenuBar(menu_bar)
        #Input panel
        input_panel = JPanel()
        input_panel.setLayout(BoxLayout(input_panel, BoxLayout.X_AXIS))
        input_panel.setBorder(BorderFactory.createTitledBorder("Input"))
        self.paint_area = PaintArea(100, 100)
        input_panel.add(self.paint_area)
        input_options_panel = JPanel()
        input_options_panel.setLayout(
            BoxLayout(input_options_panel, BoxLayout.Y_AXIS))
        #Write Char
        write_char_panel = JPanel(BorderLayout())

        def write_char(event):
            char = self.character_classifier.classify_image(
                self.paint_area.image())
            self.text_area.setText(self.text_area.getText() + char)
            self.paint_area.clear()

        write_char_panel.add(JButton("Write Char", actionPerformed=write_char),
                             BorderLayout.NORTH)
        input_options_panel.add(write_char_panel)
        #Space and Correct
        space_and_correct_panel = JPanel(BorderLayout())

        def space_and_correct(event):
            text = self.text_area.getText()
            words = text.split(" ")
            string = words[-1]
            try:
                word = self.word_classifier.classify(string.lower())
                words[-1] = word.upper()
            except:
                JOptionPane.showMessageDialog(
                    self,
                    "Have you entered a character which is not in the alphabet?",
                    "Could not Correct", JOptionPane.ERROR_MESSAGE)
                self.text_area.setText(text + " ")
                return
            newText = ""
            for w in words:
                newText = newText + w + " "
            self.text_area.setText(newText)

        space_and_correct_panel.add(
            JButton("Space and Correct", actionPerformed=space_and_correct),
            BorderLayout.NORTH)
        input_options_panel.add(space_and_correct_panel)
        #Space
        space_panel = JPanel(BorderLayout())

        def space(event):
            self.text_area.setText(self.text_area.getText() + " ")

        space_panel.add(JButton("Space", actionPerformed=space),
                        BorderLayout.NORTH)
        input_options_panel.add(space_panel)
        #Clear Input Area
        clear_input_area_panel = JPanel(BorderLayout())

        def clear(event):
            self.paint_area.clear()

        clear_input_area_panel.add(
            JButton("Clear Input Area", actionPerformed=clear),
            BorderLayout.NORTH)
        input_options_panel.add(clear_input_area_panel)
        input_panel.add(input_options_panel)
        self.add(input_panel, BorderLayout.NORTH)
        text_area_panel = JPanel()
        text_area_panel.setLayout(BorderLayout())
        text_area_panel.setBorder(BorderFactory.createTitledBorder("Text"))
        self.text_area = JTextArea()
        self.text_area.setLineWrap(True)
        #Increase font size
        font = self.text_area.getFont()
        self.text_area.setFont(Font(font.getName(), Font.BOLD, 24))

        text_area_panel.add(JScrollPane(self.text_area), BorderLayout.CENTER)
        self.add(text_area_panel, BorderLayout.CENTER)
        self.pack()
        self.setSize(Dimension(300, 300))
        self.setVisible(True)
Пример #37
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.nameLabel, gc)

        gc.gridx = 1
        gc.anchor = GridBagConstraints.LINE_START
        gc.insets = Insets(0, 0, 0, 0)
        self.add(self.nameField, 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.mobLabel, gc)

        gc.gridx = 1

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

        #Third Row
        gc.gridy += 1

        gc.weightx = 1
        gc.weighty = 0.1
        gc.gridx = 0
        gc.anchor = GridBagConstraints.FIRST_LINE_END
        gc.insets = Insets(0, 0, 0, 5)
        self.add(self.emailLabel, gc)

        gc.weightx = 1
        gc.weighty = 0.2
        gc.gridx = 1
        gc.anchor = GridBagConstraints.FIRST_LINE_START
        gc.insets = Insets(0, 0, 0, 0)
        self.add(self.emailField, gc)

        #Next Row
        gc.gridy += 1
        gc.weightx = 1
        gc.weighty = 0.1
        gc.gridx = 0
        gc.anchor = GridBagConstraints.FIRST_LINE_END
        gc.insets = Insets(0, 0, 0, 5)
        self.add(self.vehicleLabel, gc)

        gc.weightx = 1
        gc.weighty = 0.2
        gc.gridx = 1
        gc.anchor = GridBagConstraints.FIRST_LINE_START
        gc.insets = Insets(0, 0, 0, 0)
        self.add(self.vehicleField, gc)

        gc.weightx = 1
        gc.weighty = 0.2
        gc.gridx = 2
        gc.anchor = GridBagConstraints.FIRST_LINE_START
        gc.insets = Insets(0, 0, 0, 0)
        self.add(self.automateRecogBtn, 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.regBtn, gc)

        innerBorder = BorderFactory.createTitledBorder('Register Vehicle')
        outerBorder = BorderFactory.createEmptyBorder(5, 5, 5, 5)
        self.setBorder(
            BorderFactory.createCompoundBorder(outerBorder, innerBorder))
Пример #38
0
    def __init__(self, pP):
        '''
        Constructor
        '''
        self.pP = pP
        self.annotationType = self.pP.getAnnotationType()
        
        self.setTitle("Random Picture Picker")

        #annotation Panel
        annoPanel = JPanel()
        annoPanel.setBorder(BorderFactory.createTitledBorder("Annotations"))
        annoPLayout = GroupLayout(annoPanel)
        annoPanel.setLayout(annoPLayout)
        annoPLayout.setAutoCreateContainerGaps(True)
        annoPLayout.setAutoCreateGaps(True)        

        # dynamic creation of annotation panel
        # yesNoIgnore, int, number, list
        if len(self.pP.getAnnotationType()) == 1:
            self.annoField = JTextField("", 16)
            annoPLayout.setHorizontalGroup(annoPLayout.createParallelGroup().addComponent(self.annoField))
            annoPLayout.setVerticalGroup(annoPLayout.createSequentialGroup().addComponent(self.annoField))
        elif len(self.pP.getAnnotationType()) > 1:
            choices = pP.getAnnotationType()
            print "choices", choices
            choiceBtns = []
            self.annoField = ButtonGroup()
            for c in choices:
                Btn = JRadioButton(c, actionCommand=c)
                self.annoField.add(Btn)
                choiceBtns.append(Btn)
          
            h = annoPLayout.createParallelGroup()
            for b in choiceBtns:
                h.addComponent(b)
            annoPLayout.setHorizontalGroup(h)
            
            v = annoPLayout.createSequentialGroup()
            for b in choiceBtns:
                v.addComponent(b)
            annoPLayout.setVerticalGroup(v)


        # Control Panel
        ctrlPanel = JPanel()
        ctrlPLayout = GroupLayout(ctrlPanel, autoCreateContainerGaps=True, autoCreateGaps=True)
        ctrlPanel.setLayout(ctrlPLayout)
        
        nextImgButton = JButton("Next >", actionPerformed=self.nextPicture)
        prevImgButton = JButton("< Prev", actionPerformed=self.pP.prevPicture)
        quitButton = JButton("Quit", actionPerformed=self.exit)

        ctrlPLayout.setHorizontalGroup(ctrlPLayout.createParallelGroup(GroupLayout.Alignment.CENTER)
                                       .addGroup(ctrlPLayout.createSequentialGroup()
                                                 .addComponent(prevImgButton)
                                                 .addComponent(nextImgButton))
                                       .addComponent(quitButton))
        ctrlPLayout.setVerticalGroup(ctrlPLayout.createSequentialGroup()
                                     .addGroup(ctrlPLayout.createParallelGroup()
                                               .addComponent(prevImgButton)
                                               .addComponent(nextImgButton))
                                     .addComponent(quitButton))
        ctrlPLayout.linkSize(SwingConstants.HORIZONTAL, quitButton)

        
        statusPanel = JPanel()   # contains status information: progress bar
        self.progressBar = JProgressBar()
        self.progressBar.setStringPainted(True)
        self.progressBar.setValue(0)
        statusPanel.add(self.progressBar)
        
        #MainLayout
        mainLayout = GroupLayout(self.getContentPane())
        self.getContentPane().setLayout(mainLayout)
        
        mainLayout.setHorizontalGroup(mainLayout.createParallelGroup(GroupLayout.Alignment.CENTER)
                                    .addComponent(annoPanel)
                                    .addComponent(ctrlPanel)
                                    .addComponent(statusPanel)
                                    )
        mainLayout.setVerticalGroup(mainLayout.createSequentialGroup()
                                    .addComponent(annoPanel)
                                    .addComponent(ctrlPanel)
                                    .addComponent(statusPanel)
                                    )
        mainLayout.linkSize(SwingConstants.HORIZONTAL, annoPanel, ctrlPanel, statusPanel)
         
      
        self.pack()
        self.setVisible(True)
        
        self.pP.nextPicture()
Пример #39
0
    def __init__(self, title, listElements):

        self.setBorder(
                BorderFactory.createTitledBorder(
                                BorderFactory.createEmptyBorder(),
                                title
                            )
            )
        listModel = DefaultListModel()

        self.List = JList(listModel)

        self.List.setComponentPopupMenu(ListPopUpMenu(self))

        self.List.setSelectionMode(
                    ListSelectionModel.MULTIPLE_INTERVAL_SELECTION
                    )
        self.List.setSelectedIndex(0)
        self.List.setVisibleRowCount(5)

        self.addelements(listElements)

        ScrollPane = JScrollPane(self.List)
        addButton = JButton(
                        "^ Add ^",
                        actionPerformed=self._button_add_pressed
                        )
        delButton = JButton(
                        "v Remove selected v",
                        actionPerformed=self._button_del_pressed
                        )
        clearButton = JButton(
                        "Clear all",
                        actionPerformed=self._button_clear_pressed
                        )

        self._addtextbox = PTTextField(
                            "add",
                            "Enter cookie name: ",
                            "", self._button_add_pressed
                            )

        self._addtextbox.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5))

        self.setLayout(BoxLayout(self, BoxLayout.Y_AXIS))
        self.add(ScrollPane)

        self._buttonspanel = JPanel()

        self._buttonspanel.setLayout(BoxLayout(
                                        self._buttonspanel,
                                        BoxLayout.LINE_AXIS
                                     ))
        self._buttonspanel.add(self._addtextbox)

        self._addtextbox.add(addButton)
        self._addtextbox.add(delButton)
        self._addtextbox.add(clearButton)

        self.add(self._buttonspanel)

        model = self.List.getModel()
        model.addElement("0"*500)
        self.List.setMaximumSize(
                              self.List.getPreferredSize()
                                )
        self.setMaximumSize(self.getPreferredSize())
        model.removeElement("0"*500)
Пример #40
0
    def __init__(self):

        self.profiles = []

        self.setBorder(
            BorderFactory.createTitledBorder("Profiles")
            )
        self.setLayout(BoxLayout(self, BoxLayout.Y_AXIS))
        self._rowpanel1 = JPanel()
        self._rowpanel1.setLayout(BoxLayout(self._rowpanel1, BoxLayout.X_AXIS))

        self._profiles_combo = \
            JComboBox(
                      self.profiles
                      )
        self._profiles_combo.addItem("0"*40)
        self._profiles_combo.setMaximumSize(
                                self._profiles_combo.getPreferredSize()
                                )
        self._profiles_combo.removeItem("0" * 40)

        self._profiles_combo_panel = border_X_panel()

        self._demo_panel = button_panel(
                            "Demo",
                            self._button_demo_pressed
                            )
        self._quit_panel = button_panel(
                            "Unload WAF Cookie Fetcher",
                            self._button_quit_pressed
                            )

        self._profile_textfield = \
            PTTextField(
                        "profile",
                        "Profile name: ",
                        "bao7uo WAF bypass", None,
                        JButton(
                               "Save profile",
                               actionPerformed=self._button_save_fields_pressed
                            )
                    )

        self._profiles_combo_panel.add(self._profiles_combo)

        self._button_delete_profile = \
            JButton(
                    "Delete profile",
                    actionPerformed=self._button_delete_profile_pressed
                    )

        self._profiles_combo_panel.add(self._button_delete_profile)

        self._profiles_combo.addActionListener(actionlistener(self))

        self._rowpanel1.add(self._profiles_combo_panel)
        self._rowpanel1.add(Box.createHorizontalGlue())
        self._rowpanel1.add(self._profile_textfield)

        self._rowpanel1.add(Box.createHorizontalGlue())

        self._rowpanel1.add(self._demo_panel)
        self._rowpanel1.add(self._quit_panel)

        self.add(self._rowpanel1)
Пример #41
0
    def initComponents(self):

        #set the layout and add form components
        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.nameLabel, gc)

        gc.gridx = 1
        gc.anchor = GridBagConstraints.LINE_START
        gc.insets = Insets(0, 0, 0, 0)
        self.add(self.nameField, 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.mobLabel, gc)

        gc.gridx = 1

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

        #Third Row
        gc.gridy += 1

        gc.weightx = 1
        gc.weighty = 0.1
        gc.gridx = 0
        gc.anchor = GridBagConstraints.FIRST_LINE_END
        gc.insets = Insets(0, 0, 0, 5)
        self.add(self.emailLabel, gc)

        gc.weightx = 1
        gc.weighty = 0.2
        gc.gridx = 1
        gc.anchor = GridBagConstraints.FIRST_LINE_START
        gc.insets = Insets(0, 0, 0, 0)
        self.add(self.emailField, gc)

        #Next Row
        gc.gridy += 1
        gc.weightx = 1
        gc.weighty = 0.1
        gc.gridx = 0
        gc.anchor = GridBagConstraints.FIRST_LINE_END
        gc.insets = Insets(0, 0, 0, 5)
        self.add(self.userNameLabel, gc)

        gc.weightx = 1
        gc.weighty = 0.2
        gc.gridx = 1
        gc.anchor = GridBagConstraints.FIRST_LINE_START
        gc.insets = Insets(0, 0, 0, 0)
        self.add(self.userNameField, gc)

        # Next Row
        gc.gridy += 1
        gc.weightx = 1
        gc.weighty = 0.1
        gc.gridx = 0
        gc.anchor = GridBagConstraints.FIRST_LINE_END
        gc.insets = Insets(0, 0, 0, 5)
        self.add(self.passwordLabel, gc)

        gc.weightx = 1
        gc.weighty = 0.2
        gc.gridx = 1
        gc.anchor = GridBagConstraints.FIRST_LINE_START
        gc.insets = Insets(0, 0, 0, 0)
        self.add(self.passwordField, gc)

        # Next Row
        gc.gridy += 1
        gc.weightx = 1
        gc.weighty = 0.1
        gc.gridx = 0
        gc.anchor = GridBagConstraints.FIRST_LINE_END
        gc.insets = Insets(0, 0, 0, 5)
        self.add(self.confirmPasswordLabel, gc)

        gc.weightx = 1
        gc.weighty = 0.2
        gc.gridx = 1
        gc.anchor = GridBagConstraints.FIRST_LINE_START
        gc.insets = Insets(0, 0, 0, 0)
        self.add(self.confirmPasswordField, gc)

        # Next Row
        gc.gridy += 1
        gc.weightx = 1
        gc.weighty = 0.1
        gc.gridx = 0
        gc.anchor = GridBagConstraints.FIRST_LINE_END
        gc.insets = Insets(0, 0, 0, 5)
        self.add(self.superPassLabel, gc)

        gc.weightx = 1
        gc.weighty = 0.2
        gc.gridx = 1
        gc.anchor = GridBagConstraints.FIRST_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.addAdminBtn, gc)

        innerBorder = BorderFactory.createTitledBorder('Add Admin')
        outerBorder = BorderFactory.createEmptyBorder(5, 5, 5, 5)
        self.setBorder(
            BorderFactory.createCompoundBorder(outerBorder, innerBorder))
Пример #42
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)