예제 #1
0
    def __init__(self, parent, title, modal, app):
        JDialog.__init__(self, parent, title, modal)

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

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

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

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

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

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

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

        self.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE)
        self.pack()
예제 #2
0
 def initUI(self):
     basic = JPanel()
     basic.setLayout(BoxLayout(basic, BoxLayout.Y_AXIS))
     self.add(basic)
     basic.add(Box.createVerticalGlue())
     bottom = JPanel()
     bottom.setAlignmentX(1.0)
     bottom.setLayout(BoxLayout(bottom, BoxLayout.X_AXIS))
     #okButton = JButton("OK", actionPerformed=self.onQuit)
     self.text_area = JTextArea(editable = False,
           wrapStyleWord = True,
           lineWrap = True,)
     basic.add(self.text_area)
     self.text_area.text=str(config.DHOSTS)
     closeButton = JButton(u"Close 关闭", actionPerformed=self.onQuit)
     #bottom.add(okButton)
     bottom.add(Box.createRigidArea(Dimension(5, 0)))
     bottom.add(closeButton)
     bottom.add(Box.createRigidArea(Dimension(15, 0)))
     basic.add(bottom)
     basic.add(Box.createRigidArea(Dimension(0, 15)))
     self.setTitle(u"A DNS Proxy using TCP...一个使用TCP协议的DNS代理")
     self.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE)
     self.setSize(500, 300)
     self.setLocationRelativeTo(None)
     self.setVisible(True)
예제 #3
0
    def __init__(self, table):

        self.setTitle("Add Proxy")
        self.setSize(200, 100)
        self.setVisible(True)
        self.table = table
        #self.getContentPane().add(about,BorderLayout.CENTER)

        boxHorizontal = Box.createHorizontalBox()
        boxVertical = Box.createVerticalBox()
        boxHorizontal.add(JLabel("IP:"))
        self.jIpText = JTextField(20)
        boxHorizontal.add(self.jIpText)
        boxVertical.add(boxHorizontal)

        boxHorizontal = Box.createHorizontalBox()
        boxHorizontal.add(JLabel("PROT:"))
        self.jPortText = JTextField(20)
        boxHorizontal.add(self.jPortText)
        boxVertical.add(boxHorizontal)

        boxHorizontal = Box.createHorizontalBox()
        boxHorizontal.add(JButton("Add", actionPerformed=self.addIP))
        boxVertical.add(boxHorizontal)

        self.getContentPane().add(boxVertical, BorderLayout.CENTER)
예제 #4
0
    def registerExtenderCallbacks(self, callbacks):
        self.callbacks = callbacks
        self.helpers = callbacks.getHelpers()
        self.callbacks.setExtensionName("KkMultiProxy")
        self.PROXY_LIST = []

        self.jPanel = JPanel()
        boxVertical = Box.createVerticalBox()
        boxHorizontal = Box.createHorizontalBox()

        boxHorizontal.add(JButton("File", actionPerformed=self.getFile))
        self.FileText = JTextField("")
        boxHorizontal.add(self.FileText)
        boxVertical.add(boxHorizontal)

        TableHeader = ('IP', 'PORT')
        TableModel = DefaultTableModel(self.PROXY_LIST, TableHeader)
        self.Table = JTable(TableModel)
        boxVertical.add(self.Table)

        boxHorizontal = Box.createHorizontalBox()
        boxHorizontal.add(JButton("Add", actionPerformed=self.addIP))
        boxHorizontal.add(JButton("Delete", actionPerformed=self.deleteIP))
        boxHorizontal.add(JButton("Save", actionPerformed=self.saveIP))
        boxVertical.add(boxHorizontal)

        self.jPanel.add(boxVertical)

        self.callbacks.addSuiteTab(self)
        self.callbacks.registerHttpListener(self)
        return
예제 #5
0
    def __init__(self,table):

        self.setTitle("Add Proxy")
        self.setSize(200,100)
        self.setVisible(True)
        self.table = table
        #self.getContentPane().add(about,BorderLayout.CENTER)

        boxHorizontal = Box.createHorizontalBox()
        boxVertical = Box.createVerticalBox()
        boxHorizontal.add(JLabel("IP:"))
        self.jIpText = JTextField(20)
        boxHorizontal.add(self.jIpText)
        boxVertical.add(boxHorizontal)

        boxHorizontal = Box.createHorizontalBox()
        boxHorizontal.add(JLabel("PROT:"))
        self.jPortText = JTextField(20)
        boxHorizontal.add(self.jPortText)
        boxVertical.add(boxHorizontal)

        boxHorizontal = Box.createHorizontalBox()
        boxHorizontal.add(JButton("Add",actionPerformed=self.addIP))
        boxVertical.add(boxHorizontal)

        self.getContentPane().add(boxVertical,BorderLayout.CENTER)
예제 #6
0
    def run(self):
        frame = JFrame('horizontalBox',
                       locationRelativeTo=None,
                       defaultCloseOperation=JFrame.EXIT_ON_CLOSE)

        vert = Box.createVerticalBox()
        vert.add(Box.createGlue())
        vert.add(JButton('<>'))
        vert.add(Box.createVerticalStrut(5))
        vert.add(JButton('<>'))
        vert.add(Box.createVerticalStrut(5))
        vert.add(JButton('<>'))
        vert.add(Box.createGlue())

        hor = Box.createHorizontalBox()
        hor.add(Box.createGlue())
        hor.add(JButton('<>'))
        hor.add(Box.createHorizontalStrut(5))

        hor.add(vert)

        hor.add(Box.createHorizontalStrut(5))
        hor.add(JButton('<>'))
        hor.add(Box.createGlue())

        frame.add(hor)
        frame.pack()
        frame.setVisible(1)
예제 #7
0
    def registerExtenderCallbacks(self,callbacks):
        self.callbacks = callbacks
        self.helpers = callbacks.getHelpers()
        self.callbacks.setExtensionName("KkMultiProxy")
        self.PROXY_LIST = []

        self.jPanel = JPanel()
        boxVertical = Box.createVerticalBox()
        boxHorizontal = Box.createHorizontalBox()

        boxHorizontal.add(JButton("File",actionPerformed=self.getFile))
        self.FileText = JTextField("")
        boxHorizontal.add(self.FileText)
        boxVertical.add(boxHorizontal)

        TableHeader = ('IP','PORT')
        TableModel = DefaultTableModel(self.PROXY_LIST,TableHeader)
        self.Table = JTable(TableModel)
        boxVertical.add(self.Table)

        boxHorizontal = Box.createHorizontalBox()
        boxHorizontal.add(JButton("Add",actionPerformed=self.addIP))
        boxHorizontal.add(JButton("Delete",actionPerformed=self.deleteIP))
        boxHorizontal.add(JButton("Save",actionPerformed=self.saveIP))
        boxVertical.add(boxHorizontal)

        self.jPanel.add(boxVertical)

        self.callbacks.addSuiteTab(self)
        self.callbacks.registerHttpListener(self)
        return
예제 #8
0
    def __init__(self, parent, title, modal, app):
        JDialog.__init__(self, parent, title, modal)

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

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

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

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

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

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

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

        self.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE)
        self.pack()
예제 #9
0
    def run( self ) :
        frame = JFrame(
            'Box1',
            locationRelativeTo = None,
            defaultCloseOperation = JFrame.EXIT_ON_CLOSE
        )
        name = 'A'
        size = Dimension( 46, 26 )
        vBox = Box.createVerticalBox()
        for row in range( 5 ) :
            hBox = Box.createHorizontalBox()
            for col in range( 5 ) :
                button = JButton( name )
#               button = JButton(
#                   name,
#                   size = size,
#                   minimumSize = size,
#                   maximumSize = size,
#                   preferredSize = size
#               )
                hBox.add( button )
                self.showSizes( name, button )
                name = chr( ord( name ) + 1 )
            vBox.add( hBox )
        frame.add( vBox )
        frame.pack()
        frame.setVisible( 1 )
예제 #10
0
def leftJustify( panel ):
    b = Box.createHorizontalBox()
    b.add( panel )
    b.add( Box.createHorizontalGlue() )
    # (Note that you could throw a lot more components
    # and struts and glue in here.)
    return b
예제 #11
0
    def createButtonPane(self):
        """Create a new button pane for the message editor tab"""
        self._button_listener = EditorButtonListener(self)

        panel = JPanel()
        panel.setLayout(BoxLayout(panel, BoxLayout.Y_AXIS))
        panel.setBorder(EmptyBorder(5, 5, 5, 5))

        panel.add(Box.createRigidArea(Dimension(0, 5)))
        type_scroll_pane = JScrollPane(self._type_list_component)
        type_scroll_pane.setMaximumSize(Dimension(200, 100))
        type_scroll_pane.setMinimumSize(Dimension(150, 100))
        panel.add(type_scroll_pane)
        panel.add(Box.createRigidArea(Dimension(0, 3)))

        new_type_panel = JPanel()
        new_type_panel.setLayout(BoxLayout(new_type_panel, BoxLayout.X_AXIS))
        new_type_panel.add(self._new_type_field)
        new_type_panel.add(Box.createRigidArea(Dimension(3, 0)))
        new_type_panel.add(
            self.createButton(
                "New", "new-type", "Save this message's type under a new name"
            )
        )
        new_type_panel.setMaximumSize(Dimension(200, 20))
        new_type_panel.setMinimumSize(Dimension(150, 20))

        panel.add(new_type_panel)

        button_panel = JPanel()
        button_panel.setLayout(FlowLayout())
        if self._editable:
            button_panel.add(
                self.createButton(
                    "Validate", "validate", "Validate the message can be encoded."
                )
            )
        button_panel.add(
            self.createButton("Edit Type", "edit-type", "Edit the message type")
        )
        button_panel.add(
            self.createButton(
                "Reset Message", "reset", "Reset the message and undo changes"
            )
        )
        button_panel.add(
            self.createButton(
                "Clear Type", "clear-type", "Reparse the message with an empty type"
            )
        )
        button_panel.setMinimumSize(Dimension(100, 200))
        button_panel.setPreferredSize(Dimension(200, 1000))

        panel.add(button_panel)

        return panel
예제 #12
0
    def __init__(self, parent, title, modal, app):
        border = BorderFactory.createEmptyBorder(5, 7, 5, 7)
        self.getContentPane().setBorder(border)
        self.setLayout(BoxLayout(self.getContentPane(), BoxLayout.Y_AXIS))

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

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

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

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

        self.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE)
        self.pack()
예제 #13
0
    def __init__(self):
        #color = Color(.25,.25,.25,1)
        self.ng = ca.nengo.ui.NengoGraphics.getInstance()
        self.toolbar = JToolBar("Nengo actions", floatable=False)
        #self.toolbar.setBackground(color)

        ### Make and add buttons
        self.toolbar.add(make_button('open', self.do_open, 'open file'))
        self.toolbar.add(make_button(
                'savefile', self.do_save, 'save selected network'))
        self.button_scriptgen = make_button(
            'scriptgen', self.do_scriptgen,
            'generate selected network script', enabled=False)
        self.toolbar.add(self.button_scriptgen)
        self.toolbar.add(make_button('clear', self.do_clear_all, 'clear all'))

        self.toolbar.add(Box.createHorizontalGlue())

        self.toolbar.add(make_button('inspect', self.do_inspect, 'inspect'))
        self.button_run = make_button(
            'interactive', self.do_run, 'interactive plots', enabled=False)
        self.toolbar.add(self.button_run)

        SelectionHandler.addSelectionListener(self)
        self.ng.getWorld().getGround().addChildrenListener(self)

        self.ng.setToolbar(self.toolbar)
예제 #14
0
    def run(self):
        frame = JFrame('verticalBox',
                       locationRelativeTo=None,
                       defaultCloseOperation=JFrame.EXIT_ON_CLOSE)
        box = Box.createVerticalBox()
        box.add(Box.createGlue())
        box.add(JLabel('<---- Top ---->'))
        box.add(JSeparator())
        box.add(JLabel('<---- Mid ---->'))
        box.add(JSeparator())
        box.add(JLabel('<---- Bot ---->'))
        box.add(Box.createGlue())

        frame.add(box)
        frame.pack()
        frame.setVisible(1)
예제 #15
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)
예제 #16
0
    def __init__(self, program):
        self.setLayout(BorderLayout())
        title = JLabel(program.title)
        title.setFont(Font("Arial", Font.BOLD, 28))
        title.setHorizontalAlignment(JLabel.CENTER)
        title.setVerticalAlignment(JLabel.CENTER)
        title.setBorder(createEmptyBorder(15, 5, 15, 5))

        if not program.public:
            lbl = JLabel("Private")
            lbl.setFont(Font("Arial", Font.BOLD, 20))
            lbl.setForeground(Color(0xFF2424))
            lbl.setBorder(createEmptyBorder(15, 15, 15, 15))
            leftbox = lbl
        else:
            leftbox = Box.createHorizontalGlue()
        btnbox = TitleBtnBox(program)
        btnbox.setBorder(createEmptyBorder(5, 5, 5, 5))
        self.add(leftbox, BorderLayout.LINE_START)
        self.add(title, BorderLayout.CENTER)
        self.add(btnbox, BorderLayout.LINE_END)

        same_size(leftbox, btnbox)

        self.setMaximumSize(Dimension(99999, self.getPreferredSize().height))
예제 #17
0
    def __init__(self, program):
        self.setLayout(BorderLayout())

        left_col = RulesBox(program.rules_html)

        right_col = ColumnPanel()

        scopes = ScopesBox(program.scopes)
        right_col.add(scopes)

        if program.out_of_scope:
            out_of_scopes = OutOfScopeBox(program.out_of_scope)
            right_col.add(out_of_scopes)
        if program.user_agent:
            right_col.add(UABox(program))

        reward_stat = FixedRowPanel()
        reward_stat.add(RewardBox(program))
        reward_stat.add(StatsBox(program))
        reward_stat.setMaximumSize(
            Dimension(99999, reward_stat.getPreferredSize().height)
        )

        right_col.add(reward_stat)
        right_col.add(Box.createVerticalGlue())

        cols = FixedRowPanel()
        cols.add(left_col)
        cols.add(right_col)

        self.add(TitleBox(program), BorderLayout.PAGE_START)
        self.add(cols, BorderLayout.CENTER)
예제 #18
0
    def __init__(self, parent, title, modal, app):
        border = BorderFactory.createEmptyBorder(5, 7, 5, 7)
        self.getContentPane().setBorder(border)
        self.setLayout(BoxLayout(self.getContentPane(), BoxLayout.Y_AXIS))

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

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

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

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

        self.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE)
        self.pack()
예제 #19
0
    def __init__(self):
        super(BeautifierPanel, self).__init__()
        self.setLayout(BorderLayout())

        self.beautifyTextArea = JTextArea(5, 10)
        self.beautifyTextArea.setLineWrap(True)
        self.beautifyTextArea.setDocument(self.CustomUndoPlainDocument())
        # The undo doesn't work well before replace text. Below is rough fix, so not need to know how undo work for now
        self.beautifyTextArea.setText(" ")
        self.beautifyTextArea.setText("")

        self.undoManager = UndoManager()
        self.beautifyTextArea.getDocument().addUndoableEditListener(
            self.undoManager)
        self.beautifyTextArea.getDocument().addDocumentListener(
            self.BeautifyDocumentListener(self))

        beautifyTextWrapper = JPanel(BorderLayout())
        beautifyScrollPane = JScrollPane(self.beautifyTextArea)
        beautifyTextWrapper.add(beautifyScrollPane, BorderLayout.CENTER)
        self.add(beautifyTextWrapper, BorderLayout.CENTER)

        self.beautifyButton = JButton("Beautify")
        self.beautifyButton.addActionListener(self.beautifyListener)
        self.undoButton = JButton("Undo")
        self.undoButton.addActionListener(self.undoListener)

        formatLabel = JLabel("Format:")
        self.formatsComboBox = JComboBox()
        for f in supportedFormats:
            self.formatsComboBox.addItem(f)

        self.statusLabel = JLabel("Status: Ready")
        preferredDimension = self.statusLabel.getPreferredSize()
        self.statusLabel.setPreferredSize(
            Dimension(preferredDimension.width + 20,
                      preferredDimension.height))
        self.sizeLabel = JLabel("0 B")
        preferredDimension = self.sizeLabel.getPreferredSize()
        self.sizeLabel.setPreferredSize(
            Dimension(preferredDimension.width + 64,
                      preferredDimension.height))
        self.sizeLabel.setHorizontalAlignment(SwingConstants.RIGHT)

        buttonsPanel = JPanel(FlowLayout())
        buttonsPanel.add(formatLabel)
        buttonsPanel.add(self.formatsComboBox)
        buttonsPanel.add(Box.createHorizontalStrut(10))
        buttonsPanel.add(self.beautifyButton)
        buttonsPanel.add(self.undoButton)

        bottomPanel = JPanel(BorderLayout())
        bottomPanel.add(self.statusLabel, BorderLayout.WEST)
        bottomPanel.add(buttonsPanel, BorderLayout.CENTER)
        bottomPanel.add(self.sizeLabel, BorderLayout.EAST)
        self.add(bottomPanel, BorderLayout.SOUTH)

        self.currentBeautifyThread = None
예제 #20
0
    def run(self):
        frame = JFrame('flexible Box',
                       locationRelativeTo=None,
                       defaultCloseOperation=JFrame.EXIT_ON_CLOSE)
        print '\nscreenSize:', Toolkit.getDefaultToolkit().getScreenSize()

        box = Box.createHorizontalBox()
        box.add(Box.createGlue())
        box.add(Box.createRigidArea(Dimension(5, 5)))
        box.add(JLabel('Name:'))
        box.add(Box.createRigidArea(Dimension(5, 5)))
        self.tf = box.add(
            JTextField(
                10  # ,
                #               maximumSize = Dimension(   2000, 20 )
                #               maximumSize = Dimension(  20000, 20 )
                #               maximumSize = Dimension( 200000, 20 )
            ))
        box.add(Box.createRigidArea(Dimension(5, 5)))
        box.add(JButton('Submit', actionPerformed=self.buttonPress))
        box.add(Box.createRigidArea(Dimension(5, 5)))
        box.add(Box.createGlue())

        frame.add(box)
        frame.pack()
        frame.setVisible(1)
예제 #21
0
    def getUiComponent(self):
        self.panel = JPanel()
        self.panel.setLayout(BoxLayout(self.panel, BoxLayout.PAGE_AXIS))

        self.uiCommandLine = JPanel()
        self.uiCommandLine.setLayout(
            BoxLayout(self.uiCommandLine, BoxLayout.LINE_AXIS))
        self.uiCommandLine.setAlignmentX(JPanel.LEFT_ALIGNMENT)
        self.uiCommandLine.add(JLabel("Command line for local search: "))
        self.uiCommand = JTextField(40)
        self.uiCommand.setMaximumSize(self.uiCommand.getPreferredSize())
        self.uiCommandLine.add(self.uiCommand)
        self.panel.add(self.uiCommandLine)

        uiOptionsLine = JPanel()
        uiOptionsLine.setLayout(BoxLayout(uiOptionsLine, BoxLayout.LINE_AXIS))
        uiOptionsLine.setAlignmentX(JPanel.LEFT_ALIGNMENT)
        self.uiHaveIBeenPwnd = JCheckBox("haveibeenpwned")
        uiOptionsLine.add(self.uiHaveIBeenPwnd)
        uiOptionsLine.add(Box.createRigidArea(Dimension(10, 0)))

        self.uiLocalCheck = JCheckBox("Local check")
        uiOptionsLine.add(self.uiLocalCheck)
        uiOptionsLine.add(Box.createRigidArea(Dimension(10, 0)))
        self.panel.add(uiOptionsLine)
        self.panel.add(Box.createRigidArea(Dimension(0, 10)))

        uiButtonsLine = JPanel()
        uiButtonsLine.setLayout(BoxLayout(uiButtonsLine, BoxLayout.LINE_AXIS))
        uiButtonsLine.setAlignmentX(JPanel.LEFT_ALIGNMENT)
        uiButtonsLine.add(JButton("Apply", actionPerformed=self.applyConfigUI))
        uiButtonsLine.add(JButton("Reset", actionPerformed=self.resetConfigUI))
        self.panel.add(uiButtonsLine)

        self.uiAbout = JPanel()
        self.uiAbout.setLayout(BoxLayout(self.uiAbout, BoxLayout.LINE_AXIS))
        self.uiAbout.setAlignmentX(JPanel.LEFT_ALIGNMENT)
        self.uiAbout.add(
            JLabel(
                "<html><a href=\"https://twitter.com/_chipik\">https://twitter.com/_chipik</a></html>"
            ))
        self.panel.add(self.uiAbout)

        self.resetConfigUI(None)
        return self.panel
예제 #22
0
    def add_UI_entry(self,key, dico=dict()):
        UI_key_dict = dict()
        UI_key_dict['JP'] = JPanel()
        UI_key_dict['JP'].setLayout(BoxLayout(UI_key_dict['JP'], BoxLayout.X_AXIS))
        UI_key_dict['JRB'] = JRadioButton()
        self.select_key_rb_group.add(UI_key_dict['JRB'])
        self.hash4keys[UI_key_dict['JRB']] = key
        UI_key_dict['JB'] = JButton(key, actionPerformed=self.set_key)
        UI_key_dict['JB'].setPreferredSize(Dimension(100,25))
        UI_key_dict['JPP'] = JPanel()

        UI_key_dict['JP'].add(UI_key_dict['JRB'])
        UI_key_dict['JP'].add(UI_key_dict['JB'])
        UI_key_dict['JP'].add(Box.createRigidArea(Dimension(15, 0)))
        UI_key_dict['JP'].add(UI_key_dict['JPP'])
        UI_key_dict['JPP'].setLayout(BoxLayout(UI_key_dict['JPP'], BoxLayout.Y_AXIS))
        self.panelEntries.add(UI_key_dict['JP'])
        for param in self.param_list:
            if param not in dico.keys(): continue
            if param == 'DEFAULT':
                UI_key_dict[param] = {'JP':JPanel(), 'JRB': JRadioButton('is Default')}
                UI_key_dict[param]['JP'].setLayout(BoxLayout(
                                    UI_key_dict[param]['JP'], BoxLayout.X_AXIS))
                UI_key_dict[param]['JP'].add(UI_key_dict[param]['JRB'])
                UI_key_dict[param]['JP'].add(Box.createHorizontalGlue())
                self.select_default_rb_group.add(UI_key_dict[param]['JRB'])
                UI_key_dict['JPP'].add(UI_key_dict[param]['JP'])
                UI_key_dict[param]['JRB'].setSelected(dico[param])
                self.hash4keys[UI_key_dict[param]['JRB']] = key
                continue
            UI_key_dict[param] = { 'JP':JPanel(), 'JL': JLabel(param+": "), 
                                 'JB': JButton(dico[param]) }
            self.hash4keys[UI_key_dict[param]['JB']] = key
            UI_key_dict[param]['JL'].setPreferredSize(Dimension(100,25)) 
            UI_key_dict[param]['JB'].actionPerformed = self.actions_list[param] 
            UI_key_dict[param]['JP'].setLayout(BoxLayout(UI_key_dict[param]['JP'], BoxLayout.X_AXIS))
            UI_key_dict[param]['JP'].add(UI_key_dict[param]['JL'])
            UI_key_dict[param]['JP'].add(UI_key_dict[param]['JB'])
            UI_key_dict[param]['JP'].add(Box.createHorizontalGlue())
            UI_key_dict['JPP'].add(UI_key_dict[param]['JP'])
        UI_key_dict['JPP'].add(Box.createRigidArea(Dimension(0, 20)))
        self.config_item_dict[key]=UI_key_dict
        self.pack()
        pass
    def loadPanel(self):
        panel = JPanel()

        panel.setLayout(BoxLayout(panel, BoxLayout.Y_AXIS))

        bottomButtonBarPanel = JPanel()
        bottomButtonBarPanel.setLayout(BoxLayout(bottomButtonBarPanel, BoxLayout.X_AXIS))
        bottomButtonBarPanel.setAlignmentX(1.0)

        self.runButton = JButton("Run", actionPerformed=self.start)
        self.cancelButton = JButton("Close", actionPerformed=self.cancel)

        bottomButtonBarPanel.add(Box.createHorizontalGlue());
        bottomButtonBarPanel.add(self.runButton)
        bottomButtonBarPanel.add(self.cancelButton)

        # Dimension(width,height)    
        bottom = JPanel()
        bottom.setLayout(BoxLayout(bottom, BoxLayout.X_AXIS))
        bottom.setAlignmentX(1.0)

        self.progressBar = JProgressBar()
        self.progressBar.setIndeterminate(False)
        self.progressBar.setMaximum(100)
        self.progressBar.setValue(0)

        bottom.add(self.progressBar)

        self.statusTextArea = JTextArea()
        self.statusTextArea.setEditable(False)
        scrollPane = JScrollPane(self.statusTextArea)
        scrollPanel = JPanel()
        scrollPanel.setLayout(BoxLayout(scrollPanel, BoxLayout.X_AXIS))
        scrollPanel.setAlignmentX(1.0)
        scrollPanel.add(scrollPane)

        panel.add(scrollPanel)
        panel.add(bottomButtonBarPanel)
        panel.add(bottom)

        self.add(panel)
        self.setTitle("Determine Session Cookie(s)")
        self.setSize(450, 300)
        self.setLocationRelativeTo(None)
        self.setVisible(True)


        original_request_bytes = self.selected_message.getRequest()
        http_service = self.selected_message.getHttpService()
        helpers = self.callbacks.getHelpers()
        request_info = helpers.analyzeRequest(http_service, original_request_bytes)
        parameters = request_info.getParameters();
        cookie_parameters = [parameter for parameter in parameters if parameter.getType() == IParameter.PARAM_COOKIE]
        num_requests_needed = len(cookie_parameters) + 2
        self.statusTextArea.append("This may require up to " + str(num_requests_needed) + " requests to be made. Hit 'Run' to begin.\n")
예제 #24
0
    def createButtonPane(self):
        """Create a new button pane with the type editor window"""
        self._button_listener = TypeEditorButtonListener(self)

        panel = JPanel()
        panel.setLayout(BoxLayout(panel, BoxLayout.Y_AXIS))

        panel.add(Box.createRigidArea(Dimension(0, 5)))
        panel.add(
            self.createButton("Validate", "validate",
                              "Check if typedef is valid"))
        panel.add(Box.createRigidArea(Dimension(0, 3)))
        panel.add(self.createButton("Save", "save", "Save the typedef"))
        panel.add(Box.createRigidArea(Dimension(0, 3)))
        panel.add(self.createButton("Reset", "reset", "Reset to original"))
        panel.add(Box.createRigidArea(Dimension(0, 3)))
        panel.add(self.createButton("Exit", "exit", "Close window and reset"))
        panel.add(Box.createRigidArea(Dimension(0, 3)))

        return panel
예제 #25
0
    def buildAddEditPrompt(self,
                           typeValue=None,
                           searchValue=None,
                           replacementValue=None):
        """
        Builds the replacement rules add/edit prompt.

        Args:
            typeValue: the value that will be set on the type JLabel.
            searchValue: the value that will be set on the search JLabel.
            replacementValue: the value that will be set on the replacement JLabel.

        Return:
            tuple: (type, search, replacement) as input by user.
        """
        panel = Box.createVerticalBox()

        typeLabel = JLabel("Replacement type")
        type = JComboBox([REPLACE_HEADER_NAME])
        searchLabel = JLabel("Header Name / Search String")
        search = JTextField()
        replaceLabel = JLabel("Replacement Value")
        replacement = JTextField()

        panel.add(typeLabel)
        panel.add(type)
        panel.add(searchLabel)
        panel.add(search)
        panel.add(replaceLabel)
        panel.add(replacement)

        if typeValue:
            type.setSelectedItem(typeValue)

        if searchValue:
            search.text = searchValue

        if replacementValue:
            replacement.text = replacementValue

        title = "Add Replacement Rule" if type == None else "Edit Replacement Rule"

        result = JOptionPane.showConfirmDialog(None, panel,
                                               "Add Replacement Rule",
                                               JOptionPane.PLAIN_MESSAGE)

        if result == JOptionPane.OK_OPTION:
            if search.text.strip() == "":
                self.messageDialog("Header name must be non-blank.")
                raise InvalidInputException()
            else:
                return type.selectedItem, search.text, replacement.text
        else:
            raise InvalidInputException()
예제 #26
0
    def buildConfigPane(self, state, callbacks):
        """
        Builds the config pane, section per section.
        """
        configPage = Box.createVerticalBox()
        configPage.setBorder(BorderFactory.createLineBorder(Color.black))

        configPage.add(self.buildScope(state, callbacks))
        configPage.add(self.buildReplacementRules(state, callbacks))
        configPage.add(self.buildSessionCheck(state, callbacks))

        return configPage
예제 #27
0
    def makeComponents(self):
        # text specific operations
        self.randomUUIDButton = JButton("Generate random UUID", actionPerformed=self.randomUUIDPressed)
        self.clearButton = JButton("Clear", actionPerformed=self.clearPressed)
        self.runButton = JButton("Run as Jython", actionPerformed=self.runPressed)
        self.revertButton = JButton("Revert", actionPerformed=self.revertPressed)

        self.buttonPanel = Box(BoxLayout.X_AXIS) 
        self.buttonPanel.add(Box.createRigidArea(Dimension(5,0)))
        self.buttonPanel.add(self.randomUUIDButton)
        self.buttonPanel.add(Box.createRigidArea(Dimension(5,0)))
        self.buttonPanel.add(self.clearButton)
        self.buttonPanel.add(Box.createRigidArea(Dimension(5,0)))
        self.buttonPanel.add(self.runButton)
        self.buttonPanel.add(Box.createRigidArea(Dimension(5,0)))
        self.buttonPanel.add(self.revertButton)
        self.buttonPanel.add(Box.createRigidArea(Dimension(5,0)))
 
        self.textEditor = JTextPane()
        self.textEditor.setFont(Font("monospaced", Font.PLAIN, 12))
        #self.textEditor.setTabSize(4) # still inserts tabs instead of spaces
        TabKeyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_TAB, 0, False)
        MyTabActionKey = Object()
        self.textEditor.getInputMap().put(TabKeyStroke, MyTabActionKey)
        actionMap = self.textEditor.getActionMap()
        actionMap.put(MyTabActionKey, AddFourSpacesAction())
        
        self.layout = BorderLayout()
        self.add(self.buttonPanel, BorderLayout.NORTH)
        self.add(JScrollPane(self.textEditor), BorderLayout.CENTER)
예제 #28
0
    def createButtonPane(self):
        """Create AWT window panel for buttons"""
        self._button_listener = TypeDefinitionButtonListener(self)

        panel = JPanel()
        panel.setLayout(BoxLayout(panel, BoxLayout.Y_AXIS))

        panel.add(Box.createRigidArea(Dimension(0, 5)))
        panel.add(self.createButton("Add", "new-type", "Create a new type"))
        panel.add(Box.createRigidArea(Dimension(0, 3)))
        panel.add(
            self.createButton("Edit", "edit-type", "Edit the selected type"))
        panel.add(Box.createRigidArea(Dimension(0, 3)))
        panel.add(
            self.createButton("Rename", "rename-type",
                              "Rename the selected type"))
        panel.add(Box.createRigidArea(Dimension(0, 3)))
        panel.add(
            self.createButton("Remove", "delete-type",
                              "Delete all selected types"))
        panel.add(Box.createRigidArea(Dimension(0, 3)))
        panel.add(
            self.createButton(
                "Save All Types To File",
                "save-types",
                "Save all known types as JSON to a file",
            ))
        panel.add(Box.createRigidArea(Dimension(0, 3)))
        panel.add(
            self.createButton("Load All Types From File", "load-types",
                              "Load types from JSON file"))
        panel.add(Box.createRigidArea(Dimension(0, 3)))
        panel.add(
            self.createButton(
                "Export All types As .proto",
                "export-proto",
                "Export all types as .proto",
            ))
        panel.add(Box.createRigidArea(Dimension(0, 3)))
        panel.add(
            self.createButton("Import .proto", "import-proto",
                              "Import types from a .proto file"))
        panel.add(Box.createRigidArea(Dimension(0, 3)))
        return panel
예제 #29
0
 def __init__(self, parentCrate=None):
     JPanel.__init__(self)
     self.spy = None
     self.parentCrate = parentCrate
     self.nw = 10  # Number of words (total)
     self.upperPanel = JPanel()
     self.lowerPanel = JPanel()
     self.add(self.upperPanel)
     self.add(self.lowerPanel)
     self.nameLabel = JLabel("n/a")
     self.slotLabel = JLabel("n/a")
     self.textArea = JTextArea("n/a", 1, 70, editable=0)
     self.scrollPane = JScrollPane(self.textArea)
     self.textField = JTextField(3,
                                 actionCommand="textField",
                                 text=("%d" % self.nw))
     self.textField.addActionListener(self)
     self.clearButton = JButton("Stop", actionCommand="button")
     self.clearButton.addActionListener(self)
     self.border = BorderFactory.createEmptyBorder(5, 5, 5, 5)
     self.layout = BoxLayout(self, BoxLayout.Y_AXIS)
     self.upperPanel.layout = BoxLayout(self.upperPanel, BoxLayout.X_AXIS)
     self.lowerPanel.layout = BoxLayout(self.lowerPanel, BoxLayout.X_AXIS)
     self.upperPanel.add(self.clearButton)
     self.upperPanel.add(Box.createRigidArea(Dimension(20, 0)))
     self.upperPanel.add(JLabel("Spy:"))
     self.upperPanel.add(Box.createRigidArea(Dimension(5, 0)))
     self.upperPanel.add(self.nameLabel)
     self.upperPanel.add(Box.createRigidArea(Dimension(20, 0)))
     self.upperPanel.add(JLabel("Slot:"))
     self.upperPanel.add(Box.createRigidArea(Dimension(5, 0)))
     self.upperPanel.add(self.slotLabel)
     self.upperPanel.add(Box.createRigidArea(Dimension(20, 0)))
     self.upperPanel.add(JLabel("Number of words:"))
     self.upperPanel.add(Box.createRigidArea(Dimension(5, 0)))
     self.upperPanel.add(self.textField)
     self.upperPanel.add(Box.createHorizontalGlue())
     self.lowerPanel.add(JLabel("Tail contents:"))
     self.lowerPanel.add(Box.createRigidArea(Dimension(5, 0)))
     self.lowerPanel.add(self.scrollPane)
     self.lowerPanel.add(Box.createHorizontalGlue())
예제 #30
0
    def run(self):
        frame = JFrame('horizontalBox',
                       locationRelativeTo=None,
                       defaultCloseOperation=JFrame.EXIT_ON_CLOSE)
        box = Box.createHorizontalBox()
        #       box.add( Box.createGlue() )
        box.add(JLabel('<---- Left ---->'))
        #       box.add( Box.createGlue() )
        box.add(JLabel('<---- Middle ---->'))
        #       box.add( Box.createGlue() )
        box.add(JLabel('<---- Right ---->'))
        #       box.add( Box.createGlue() )

        frame.add(box)
        frame.pack()
        frame.setVisible(1)
예제 #31
0
    def __init__(self, extension, burp_callbacks):
        self._burp_callbacks = burp_callbacks
        self._extension = extension

        self._type_list_component = JList(extension.known_message_model)
        self._type_list_component.setSelectionMode(
            ListSelectionModel.MULTIPLE_INTERVAL_SELECTION)

        self._component = JPanel()
        self._component.setLayout(BoxLayout(self._component, BoxLayout.Y_AXIS))

        splitPane = JSplitPane(JSplitPane.HORIZONTAL_SPLIT)
        splitPane.setRightComponent(JScrollPane(self._type_list_component))
        splitPane.setLeftComponent(self.createButtonPane())
        splitPane.setResizeWeight(0.03)
        splitPane.setMaximumSize(Dimension(1000, 1000))

        self._component.add(splitPane)
        self._component.add(Box.createVerticalGlue())
        self._component.setBorder(EmptyBorder(10, 10, 10, 10))
예제 #32
0
 def __init__(self, view, doc):
     EnhancedDialog.__init__(self, view,
                             jEdit.getProperty("jython.export.title"), 1)
     self.view = view
     self.doc = doc
     panel = Box.createVerticalBox()
     panel.border = EmptyBorder(10, 10, 10, 10)
     self.header = JCheckBox(jEdit.getProperty("jython.export.header"), 0)
     panel.add(self.header)
     self.prompts = JCheckBox(jEdit.getProperty("jython.export.prompts"), 0)
     panel.add(self.prompts)
     self.errors = JCheckBox(jEdit.getProperty("jython.export.errors"), 0)
     panel.add(self.errors)
     self.contentPane.layout = BorderLayout()
     self.contentPane.add(panel, BorderLayout.CENTER)
     lowerPanel = JPanel(FlowLayout.LEFT)
     lowerPanel.add(JButton(jEdit.getProperty("common.ok"), actionPerformed = \
      self._ok))
     lowerPanel.add(JButton(jEdit.getProperty("common.cancel"), actionPerformed = \
      self._cancel))
     self.contentPane.add(lowerPanel, BorderLayout.SOUTH)
def choose_series(filepath, params):
	"""if input file contains more than one image series (xy position), prompt user to choose which one to use"""
	# todo: if necessary (e.g. if lots of series), can improve thumbnail visuals based loosely on https://github.com/ome/bio-formats-imagej/blob/master/src/main/java/loci/plugins/in/SeriesDialog.java
	import_opts = ImporterOptions();
	import_opts.setId(filepath);
	
	reader = ImageReader();
	ome_meta = MetadataTools.createOMEXMLMetadata();
	reader.setMetadataStore(ome_meta);
	reader.setId(filepath);
	no_series = reader.getSeriesCount();
	if no_series == 1:
		return import_opts, params;
	else:
		series_names = [ome_meta.getImageName(idx) for idx in range(no_series)];
		dialog = GenericDialog("Select series to load...");
		dialog.addMessage("There are multiple series in this file! \n" + 
						"This is probably because there are multiple XY stage positions. \n " + 
						"Please choose which series to load: ");
		thumbreader = BufferedImageReader(reader);
		cbg = CheckboxGroup();
		for idx in range(no_series):
			p = Panel();
			p.add(Box.createRigidArea(Dimension(thumbreader.getThumbSizeX(), thumbreader.getThumbSizeY())));
			ThumbLoader.loadThumb(thumbreader, idx, p, True);
			dialog.addPanel(p);
			cb = Checkbox(series_names[idx], cbg, idx==0);
			p.add(cb);

		dialog.showDialog();
		if dialog.wasCanceled():
			raise KeyboardInterrupt("Run canceled");
		if dialog.wasOKed():
			selected_item = cbg.getSelectedCheckbox().getLabel();
			selected_index = series_names.index(selected_item);
			params.setSelectedSeriesIndex(selected_index);
			for idx in range(0, no_series):
				import_opts.setSeriesOn(idx, True) if (idx==selected_index) else import_opts.setSeriesOn(idx, False);
	reader.close();
	return import_opts, params
예제 #34
0
파일: mason.py 프로젝트: olrunsrc/fc-public
 def __init__(self, wrapper):
     """Initialises the behaviour inspector.
     
     @param wrapper: The object wrapper given to the portrayal.
     @type wrapper: sim.portrayal.LocationWrapper
     """
     Inspector.__init__(self)
     # getObject() returns the MASON behaviour -> .agent to access agent
     agent = wrapper.getObject().agent
     # get list of behaviours and sort them by name
     beh_list = agent.getBehaviours()
     beh_list.sort(lambda x, y: cmp(x.getName().upper(),
                                    y.getName().upper()))
     beh_names = []
     for beh in beh_list:
         beh_names.append(beh.getName())
     self.setLayout(BoxLayout(self, BoxLayout.PAGE_AXIS))
     # add agent information
     agentList = LabelledList("Agent")
     agentList.addLabelled("Name ", JLabel(agent.MASON.getAgentName()))
     agentList.addLabelled("Behaviours ", JLabel(", ".join(beh_names)))
     # need to restrict maximum size to allow for glue at end of panel to
     # expand
     agentList.setMaximumSize(
         Dimension(int(agentList.getMaximumSize().getWidth()),
                   int(agentList.getMinimumSize().getHeight())))
     self.add(agentList)
     # build the behaviour inspectors one by one, and collect their
     # properties
     self._properties = []
     for beh in beh_list:
         self._properties.extend(self._buildInspectorGUI(beh))
     # give message if no inspectors defined
     if not self._properties:
         self.add(JLabel("No inspectors defined!"))
     self.add(Box.createVerticalGlue())
예제 #35
0
 def _add_with_padding(self, component, padding):
     self.add(component)
     self.add(Box.createRigidArea(Dimension(0, padding)))
예제 #36
0
 def gui(self):
   xnode = self.xdoc.getDocumentElement()
   tnode = self.createTree(xnode)  
   # create tree and display
   jt = JTree(tnode)
   jsp = JScrollPane(jt)
   tree_box = Box(BoxLayout.Y_AXIS)
   tree_box.add(jsp)
   tree_box.add(Box.createHorizontalStrut(10))
   headerSorter = TableSorter(DefaultTableModel())
   jtb = JTable(headerSorter)
   headerSorter.addMouseListenerToHeaderInTable(jtb)
   jtb.setAutoResizeMode(JTable.AUTO_RESIZE_OFF)
   jsp2 = JScrollPane(jtb)
   table_box = Box(BoxLayout.Y_AXIS)
   table_box.add(jsp2)
   table_box.add(Box.createHorizontalStrut(500))
   mp = JPanel()
   mp.setLayout(BoxLayout(mp,BoxLayout.X_AXIS))
   mp.add(tree_box)
   mp.add(table_box)
   # add listeners
   nsl = NodeSelectionListener(jtb,xnode)
   jt.addTreeSelectionListener(nsl)
   #
   return mp
예제 #37
0
    def __init__(self, app):
        #java import
        from javax.swing import JPanel, JButton, JLabel, ImageIcon,\
                                JScrollPane, BorderFactory, WindowConstants,\
                                BoxLayout, Box
        from java.awt import FlowLayout, Dimension, Component
        from java.io import File
        #josm import
        from org.openstreetmap.josm import Main
        from org.openstreetmap.josm.tools import ImageProvider
        from org.openstreetmap.josm.gui.widgets import HtmlPanel, UrlLabel
        JDialog.__init__(self,
                         Main.parent,
                         app.strings.getString("error_info_title"),
                         True)
        self.app = app
        self.setSize(400, 480)
        border = BorderFactory.createEmptyBorder(5, 7, 5, 7)
        self.getContentPane().setBorder(border)
        self.setLayout(BoxLayout(self.getContentPane(), BoxLayout.Y_AXIS))

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

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

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

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

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

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

        self.setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE)
예제 #38
0
    def __init__(self, parent, title, modal, app):
        from javax.swing import JTextArea

        border = BorderFactory.createEmptyBorder(5, 7, 7, 7)
        self.getContentPane().setBorder(border)
        self.setLayout(BoxLayout(self.getContentPane(), BoxLayout.Y_AXIS))

        #Icon
        icon = ImageIcon(File.separator.join([app.SCRIPTDIR,
                                              "images",
                                              "icons",
                                              "logo.png"]))
        iconLbl = JLabel(icon)
        iconLbl.setAlignmentX(JLabel.CENTER_ALIGNMENT)

        #Name
        titleLbl = JLabel("Quality Assurance Tools script")
        titleLbl.setAlignmentX(JLabel.CENTER_ALIGNMENT)

        #Version
        p = JPanel()
        versionPanel = JPanel(GridLayout(2, 2))
        versionPanel.add(JLabel("script: "))
        versionPanel.add(JLabel(app.SCRIPTVERSION))
        versionPanel.add(JLabel("tools: "))
        self.toolsVersionLbl = JLabel(app.TOOLSVERSION)
        versionPanel.add(self.toolsVersionLbl)
        versionPanel.setAlignmentX(Component.CENTER_ALIGNMENT)
        p.add(versionPanel)

        #Wiki
        wikiLblPanel = JPanel(FlowLayout(FlowLayout.CENTER))
        wikiLbl = UrlLabel(app.SCRIPTWEBSITE, "Wiki", 2)
        wikiLblPanel.add(wikiLbl)
        wikiLblPanel.setAlignmentX(JLabel.CENTER_ALIGNMENT)

        #Author, contributors and credits
        creditsTextArea = JTextArea(15, 35, editable=False)
        creditsTextArea.setBackground(None)
        contribFile = open(File.separator.join([app.SCRIPTDIR, "CONTRIBUTORS"]), "r")
        contribText = contribFile.read()
        contribFile.close()
        creditsTextArea.append(contribText)
        creditsTextArea.setCaretPosition(0)
        creditScrollPane = JScrollPane(creditsTextArea)

        #OK button
        okBtn = JButton("OK",
                        ImageProvider.get("ok"),
                        actionPerformed=self.on_okBtn_clicked)
        okBtn.setAlignmentX(JButton.CENTER_ALIGNMENT)

        #Layout
        self.add(Box.createRigidArea(Dimension(0, 7)))
        self.add(iconLbl)
        self.add(Box.createRigidArea(Dimension(0, 7)))
        self.add(titleLbl)
        self.add(Box.createRigidArea(Dimension(0, 7)))
        self.add(p)
        self.add(wikiLblPanel)
        self.add(Box.createRigidArea(Dimension(0, 7)))
        self.add(creditScrollPane)
        self.add(Box.createRigidArea(Dimension(0, 7)))
        self.add(okBtn)

        self.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE)
        self.pack()
예제 #39
0
class Browser:
    def __init__(self, repository):
        self.repository = repository
        # want a better solution, with domains, perhaps user specifies
        self.currentUserReference = System.getProperty("user.name")
        
        self.currentRecord = None
                
        self.window = JFrame("Pointrel browser", windowClosing=self.exit)
        self.window.contentPane.layout = BorderLayout() # redundant as the default
        self.window.bounds = (100, 100, 800, 600)
        
        self.menuBar = JMenuBar()
        self.window.JMenuBar = self.menuBar
        fileMenu = JMenu("File")
        fileMenu.add(JMenuItem("Open...", actionPerformed=self.open))
        fileMenu.add(JMenuItem("Reload", actionPerformed=self.reloadPressed))
        fileMenu.addSeparator()
        fileMenu.add(JMenuItem("Import from other repository...", actionPerformed=self.importFromOtherRepository))
        fileMenu.addSeparator()
        fileMenu.add(JMenuItem("Close", actionPerformed=self.close))
        self.menuBar.add(fileMenu)

        exportMenu = JMenu("Export")
        exportMenu.add(JMenuItem("Choose current export file...", actionPerformed=self.exportChooseCurrentFile))
        exportMenu.addSeparator()        
        exportMenu.add(JMenuItem("Export selected record", actionPerformed=self.exportSelectedRecord))
        exportMenu.add(JMenuItem("Export record history for selected attribute", actionPerformed=self.exportAllRecordsForSelectedAttribute))
        exportMenu.addSeparator()
        exportMenu.add(JMenuItem("Export current records for all attributes of selected entity", actionPerformed=self.exportLatestRecordsForSelectedEntity))
        exportMenu.add(JMenuItem("Export entire record history for all attributes of selected entity", actionPerformed=self.exportAllRecordsForSelectedEntity))
        self.menuBar.add(exportMenu)
        
        self.exportFileName = "export.pointrel"

        #self.reloadButton = JButton("Reload Repository", actionPerformed=self.reloadPressed)
                        
        self.entitiesList = JList(DefaultListModel(), mouseClicked=self.entitiesListClicked)
        self.entitiesList.model.addElement("root")
        self.entitiesList.mousePressed = self.entitiesListMousePressed
        self.entitiesList.mouseReleased = self.entitiesListMousePressed
        
        self.attributesList = JList(DefaultListModel(), mouseClicked=self.attributesListClicked)
        
        self.versionsList = JList(DefaultListModel(), mouseClicked=self.versionsListClicked)
        
        self.listPanel = JPanel(layout=GridLayout(1, 2))
        self.listPanel.add(JScrollPane(self.entitiesList))
        self.listPanel.add(JScrollPane(self.attributesList))
        self.listPanel.add(JScrollPane(self.versionsList))
        
        self.navigationPanel = JPanel(layout=BorderLayout())
        #self.navigationPanel.add(self.reloadButton, BorderLayout.NORTH)
        self.navigationPanel.add(self.listPanel, BorderLayout.CENTER)
                
        self.entityTextField = JTextField(preferredSize=(200,20))
        self.attributeTextField = JTextField(preferredSize=(200,20))
        self.deletedButton = JCheckBox("Deleted", actionPerformed=self.deletedPressed)
        
        # only one right now -- and no support for switching editor panels yet
        examples = ["pointrel:text/utf-8", ]
        self.valueTypeComboBox = JComboBox(examples, preferredSize=(200,20), editable=True)

        self.attributePanel = Box(BoxLayout.X_AXIS) 
        self.attributePanel.add(Box.createRigidArea(Dimension(5,0)))
        self.attributePanel.add(JLabel("Entity:"))
        self.attributePanel.add(Box.createRigidArea(Dimension(2,0)))
        self.attributePanel.add(self.entityTextField)
        self.attributePanel.add(Box.createRigidArea(Dimension(5,0)))
        self.attributePanel.add(JLabel("Attribute:"))
        self.attributePanel.add(Box.createRigidArea(Dimension(2,0)))
        self.attributePanel.add(self.attributeTextField)
        self.attributePanel.add(Box.createRigidArea(Dimension(5,0)))
        self.attributePanel.add(JLabel("Value type:"))
        self.attributePanel.add(Box.createRigidArea(Dimension(2,0)))
        self.attributePanel.add(self.valueTypeComboBox)
        self.attributePanel.add(Box.createRigidArea(Dimension(5,0)))
        self.attributePanel.add(self.deletedButton)
        self.attributePanel.add(Box.createRigidArea(Dimension(5,0)))
        
        self.showAllDeletedButton = JCheckBox("Show all deleted", actionPerformed=self.showAllDeletedPressed)
        self.statusText = JTextField(preferredSize=(100,20))
        self.saveButton = JButton("Save", actionPerformed=self.savePressed)
        self.normalSaveButtonColor = self.saveButton.background
        self.changedSaveButtonColor = Color.YELLOW

        self.statusPanel = Box(BoxLayout.X_AXIS)
        self.statusPanel.add(Box.createRigidArea(Dimension(5,0)))
        self.statusPanel.add(self.showAllDeletedButton)
        self.statusPanel.add(Box.createRigidArea(Dimension(25,0)))
        self.statusPanel.add(JLabel("Message:") )
        self.statusPanel.add(Box.createRigidArea(Dimension(2,0)))
        self.statusPanel.add(self.statusText) 
        self.statusPanel.add(Box.createRigidArea(Dimension(5,0)))
        self.statusPanel.add(self.saveButton)
        self.statusPanel.add(Box.createRigidArea(Dimension(1,0)))       
        
        self.currentEditorPanel = EditorPanel_text_utf_8(self, "pointrel:text/utf-8")
        
        self.topPanel = Box(BoxLayout.Y_AXIS)
        self.topPanel.add(Box.createRigidArea(Dimension(0,5))) 
        self.topPanel.add(self.attributePanel)
        self.topPanel.add(Box.createRigidArea(Dimension(0,5))) 
        
        self.editorPanel = JPanel(layout=BorderLayout())
        self.editorPanel.add(self.topPanel, BorderLayout.NORTH)
        self.editorPanel.add(self.currentEditorPanel, BorderLayout.CENTER)
        self.editorPanel.add(self.statusPanel, BorderLayout.SOUTH)
        
        self.browserPanel = JSplitPane(JSplitPane.VERTICAL_SPLIT)
        self.browserPanel.add(self.navigationPanel)
        self.browserPanel.add(self.editorPanel)
        
        self.window.contentPane.add(self.browserPanel, BorderLayout.CENTER)
        
        self.setTitleForRepository()
        self.window.show()
        
        # background timer for updating save button color
        self.timer = Timer(1000, CallbackActionListener(self.timerEvent))
        self.timer.initialDelay = 1000
        self.timer.start()
        
    def close(self, event):
        System.exit(0)
        
    def open(self, event):
        dialog = FileDialog(self.window)
        fileName = dialog.go(PointrelFileTypes)
        if not fileName:
            return
        repository = Repository(fileName)
        self.repository = repository
        self.currentRecord = None
        self.clearAllEntityNames()
        self.refreshBrowser()
        self.setTitleForRepository()
        
    def setTitleForRepository(self):
        self.window.title = "Pointrel browser on %s" % self.repository.fileName

    def setStatus(self, messageText):
        self.statusText.text = messageText
        
    def getCurrentEntityName(self):
        return self.entityTextField.text

    def setCurrentEntityName(self, newAttributeName):
        self.entityTextField.text = newAttributeName
           
    def getCurrentAttributeName(self):
        return self.attributeTextField.text

    def setCurrentAttributeName(self, newAttributeName):
        self.attributeTextField.text = newAttributeName
           
    def getCurrentValueType(self):
        #return self.valueTypeComboBox.selectedItem
        return self.valueTypeComboBox.editor.editorComponent.text
    
    def setCurrentValueType(self, newValueType):
        self.valueTypeComboBox.selectedItem = newValueType
        # PDF FIX __ NEED TO CHANGE EDITOR TYPE
            
    def reportStatistics(self):
        contents = self.currentEditorPanel.getCurrentValueBytes()
        words = len(contents.split())
        lines = contents.count('\n')
        characters = len(contents)
        report = "%d lines; %d words; %d characters" % (lines, words, characters)
        self.setStatus(report)
        
    def timerEvent(self, event):
        self.manageSaveButtonColor()
        self.reportStatistics()
        
    def exit(self, event=None):
        System.exit(0)
        
    def reloadPressed(self, event):
        print "reloading repository; ", 
        self.repository.reload()
        self.refreshBrowser()
        print "done"
        
    def importCodeFromRepository(self, name, globals=None, locals=None, fromlist=None):
        # seems to fail with stack overflow if print while importing while trying jconsole (it reassigns stdio)
        debug = 0
        self.importLevel += 1
        if debug: print "  " * self.importLevel,
        if debug: print "importCodeFromRepository", name
        try:
            if debug: print "  " * self.importLevel,
            if debug: print "  globals: ", globals
            if debug: print "  " * self.importLevel,
            if debug: print "  locals", locals
            if debug: print "  " * self.importLevel,
            if debug: print "  fromlist", fromlist
        except UnboundLocalError:
            if debug: print "  " * self.importLevel,
            if debug: print "unbound error"
        # Fast path: see if the module has already been imported.
        # though this is wrong -- as need to check repository if code has been changed
        # broken as does not consider fromlist
        #try:
        #    return sys.modules[name]
        #except KeyError:
        #    pass
        # check if local module
        record = self.repository.findLatestRecordForEntityAttribute(self.contextUUID, name + ".py")
        if record:
            if debug: print "  " * self.importLevel,
            if debug: print "  Loading from repository"
            #file = StringIO.StringIO(record.valueBytes)
            #try:
            #module = imp.load_source(name, name, file)
            #print module
            modifiedName = self.contextUUID[7:] + "." + name
            modifiedName = modifiedName.replace("-", "_")
            if debug: print "modifiedName", modifiedName
            if debug: print "sys.module.items", sys.modules.items()
            try:
                module = sys.modules[modifiedName]
            except KeyError:
                module = None
            # use the latest if this one is not
            if module:
                if module.__pointrelIdentifier__ != record.identifierString:
                    module = None
            if not module:
                file = ByteArrayInputStream(record.valueBytes)
                module = imp.load_module(modifiedName, file, modifiedName + ".py", (".py", "r", imp.PY_SOURCE))
                module.__pointrelIdentifier__ = record.identifierString
            if fromlist:
                if debug: print "  " * self.importLevel,
                if debug: print "processing fromlist"
                for fromItemName in fromlist:
                    if debug: print "  " * self.importLevel,
                    if debug: print "fromitemname", fromItemName
                    if fromItemName == "*":
                        for moduleItemName in dir(module):
                            if debug: print "  " * self.importLevel,
                            if debug: print "moduleItemName", moduleItemName
                            if moduleItemName[1] != '_':
                                result = getattr(module, moduleItemName)
                                #print "  " * self.importLevel,
                                #print "result", result
                                #print "  " * self.importLevel,
                                #print "globals", globals
                                globals[moduleItemName] = result
                    else:
                        result = getattr(module, fromItemName)
                        globals[fromItemName] = result
                        if debug: print "finished set", fromItemName
                
            #finally:
            #    file.close()
            if debug: print "  " * self.importLevel,
            if debug: print "  Done loading"
            self.importLevel -= 1
            result = module
        else:
            if debug: print "  " * self.importLevel,
            if debug: print "default loading", name, fromlist
            try:
                result = self.oldimport(name, globals, locals, fromlist)
            except UnboundLocalError:
                # deal with strange Jython error
                result = self.oldimport(name)
            self.importLevel -= 1
        return result
    
    def importFromOtherRepository(self, event):
        dialog = FileDialog(self.window, loadOrSave="load")
        fileName = dialog.go(PointrelFileTypes)
        if not fileName:
            return
        
        print "Importing from: ", fileName
        self.repository.importRecordsFromAnotherRepository(fileName)
        print "Done with import"
        
        self.refreshBrowser()
    
    def exportChooseCurrentFile(self, event):
        dialog = FileDialog(self.window, loadOrSave="save")
        fileName = dialog.go(PointrelFileTypes)
        if not fileName:
            return
        self.exportFileName = fileName
        print "File selected for exports:", self.exportFileName
             
    def exportSelectedRecord(self, event):
        if not self.currentRecord:
            print "No record selected"
            return
        oldRecords = [self.currentRecord]
        print "Exporting current record to repository %s" % self.exportFileName
        repository = Repository(self.exportFileName)
        repository.addRecordsFromAnotherRepository(oldRecords)
        print "Done"
    
    def exportAllRecordsForSelectedAttribute(self, event):
        entityName = self.getCurrentEntityName()
        if not entityName:
           print "No entity selected" 
           return
        attributeName = self.getCurrentAttributeName()
        if not attributeName:
           print "No attribute selected"   
           return   
        print "Exporting all records for entity '%s' attribute '%s' to repository %s" % (entityName, attributeName, self.exportFileName)
        oldRecords = self.repository.findAllRecordsForEntityAttribute(entityName, attributeName)
        oldRecords.reverse()
        repository = Repository(self.exportFileName)
        repository.addRecordsFromAnotherRepository(oldRecords)
        print "Done"
            
    def exportLatestRecordsForSelectedEntity(self, event):
        entityName = self.getCurrentEntityName()
        if not entityName:
           print "No entity selected" 
           return
        print "Exporting latest records for all entity '%s' attributes to repository %s" % (entityName, self.exportFileName)
        oldRecords = self.repository.findLatestRecordsForAllEntityAttributes(entityName)
        oldRecords.reverse()
        repository = Repository(self.exportFileName)
        repository.addRecordsFromAnotherRepository(oldRecords)
        print "Done"
        
    def exportAllRecordsForSelectedEntity(self, event):
        entityName = self.getCurrentEntityName()
        if not entityName:
           print "No entity selected" 
           return
        print "Exporting all records for entity '%s' to repository %s" % (entityName, self.exportFileName)
        oldRecords = self.repository.findAllRecordsForEntity(entityName)
        oldRecords.reverse()
        repository = Repository(self.exportFileName)
        repository.addRecordsFromAnotherRepository(oldRecords)
        print "Done"
               
    def setCurrentRecord(self, aRecord):
        self.currentRecord = aRecord
        if aRecord:
            self.setCurrentEntityName(aRecord.entity)
            self.entityTextField.caretPosition = 0
            self.setCurrentAttributeName(aRecord.attribute)
            self.attributeTextField.caretPosition = 0
            self.setCurrentValueType(aRecord.valueType)
            self.currentEditorPanel.setCurrentValueBytes(aRecord.valueBytes)
            self.deletedButton.model.setSelected(aRecord.deleted)
        else:
            entityName = self.entitiesList.selectedValue
            if entityName == None:
                entityName = ""
            self.setCurrentEntityName(entityName)
            self.entityTextField.caretPosition = 0
            self.setCurrentAttributeName("")
            self.setCurrentValueType(DefaultValueType)
            self.currentEditorPanel.setCurrentValueBytes("") 
            self.deletedButton.model.selected = False
                
    def manageSaveButtonColor(self):
        if self.isCurrentRecordChanged():
            self.saveButton.background = self.changedSaveButtonColor
        else:
            self.saveButton.background = self.normalSaveButtonColor
            
    def isCurrentRecordChanged(self):
        if not self.currentRecord:
            if self.getCurrentAttributeName() or self.currentEditorPanel.getCurrentValueBytes():
                return True
            return False
        if self.getCurrentEntityName() != self.currentRecord.entity:
            return True
        if self.getCurrentAttributeName() != self.currentRecord.attribute:
            return True
        if self.getCurrentValueType() != self.currentRecord.valueType:
            return True
        if self.currentEditorPanel.isChangedFromOriginal():
             return True
        # funky comparison because may be booleans and integers?
        # decided not to test as not really linked to save button
        #if (self.deletedButton.model.selected and not self.currentRecord.deleted) or (not self.deletedButton.model.selected and self.currentRecord.deleted):
        #    return True
        return False

    def deletedPressed(self, event):
        deleteFlag = self.deletedButton.model.selected
        if self.currentRecord == None:
            return 
        self.repository.deleteOrUndelete(self.currentRecord, self.currentUserReference, deleteFlag=deleteFlag)
        if not self.isDeletedViewable():
            self.refreshBrowser()
            
    def refreshBrowser(self):
        entityName = self.entitiesList.selectedValue
        attributeName = self.attributesList.selectedValue
        versionName = self.versionsList.selectedValue
        self.entitiesListClicked(None, entityName, attributeName, versionName)
                    
    def showAllDeletedPressed(self, event):
        self.refreshBrowser()
        
    def isDeletedViewable(self):
        return self.showAllDeletedButton.model.selected
                  
    def savePressed(self, event):
        #entityName = self.entitiesList.selectedValue
        entityName = self.getCurrentEntityName()
        if entityName:
            attributeName = self.getCurrentAttributeName()
            if attributeName:
                attributeValue = self.currentEditorPanel.getCurrentValueBytes()
                attributeType = self.getCurrentValueType()
                newRecord = self.repository.add(entityName, attributeName, attributeValue, attributeType, self.currentUserReference)
                self.setCurrentRecord(newRecord)
                self.entitiesListClicked(None, self.entitiesList.selectedValue, attributeName)
                # refresh list if changed
                if attributeName != self.attributesList.selectedValue:
                    # ? self.attributesList.model.addElement(attributeName)
                    # need to select new version
                    self.entitiesListClicked(None)
                        
    def test(self):
        print "test OK"

    def clearAllEntityNames(self):
        self.entitiesList.model.clear()
        self.addEntityNameToEntitiesList("root")
            
    def deleteEntityNameFromList(self):
        entityName = self.entitiesList.selectedValue
        if entityName:
           self.entitiesList.model.removeElement(entityName)
            
    def addEntitytNameToList(self):
        entityName = JOptionPane.showInputDialog("Enter an entity name: ")
        if entityName:
            self.addEntityNameToEntitiesList(entityName)
            
    def addAllEntityNamesToList(self, addMeta):
        entityNames = self.repository.lastUser.keys()
        entityNames.sort()
        for entityName in entityNames:
            if addMeta or entityName.find("pointrel://tripleID/") != 0:
                self.addEntityNameToEntitiesList(entityName)
           
    def entitiesListMousePressed(self, event):
        if event.isPopupTrigger():
            # options should be a list of (name, function, [arg1, [arg2]]) tuples
            options = [
                       ("add to list..", self.addEntitytNameToList),
                       ("delete from list", self.deleteEntityNameFromList), 
                       (None),
                       ("clear", self.clearAllEntityNames), 
                       (None),
                       ("add all except meta", self.addAllEntityNamesToList, False), 
                       ("add all", self.addAllEntityNamesToList, True), 
                       ]
            menu = OptionsCallbackPopupMenu(event.component, event.x, event.y, options)

    def entitiesListClicked(self, event, entityName=None, attributeName=None, versionName=None):
        if event:
            self.setCurrentRecord(None)
        if entityName:
            self.entitiesList.setSelectedValue(entityName, True)
        else:
            entityName = self.entitiesList.selectedValue
        if entityName:
            self.versionsList.model.clear()
            model = self.attributesList.model 
            model.clear()
            attributes = self.repository.allAttributesForEntity(entityName, self.isDeletedViewable())
            attributes.sort()
            for attribute in attributes:
                model.addElement(attribute)
            if attributeName:
                self.attributesList.setSelectedValue(attributeName, True)
                self.attributesListClicked(None, versionName)
        
    def attributesListClicked(self, event, versionName=None):
        if event:
            self.setCurrentRecord(None)
        entityName = self.entitiesList.selectedValue
        if entityName:
            attributeName = self.attributesList.selectedValue
            if event:
                self.setCurrentAttributeName(attributeName)
            if attributeName:
                model = self.versionsList.model 
                model.clear()
                versions = self.repository.findAllRecordsForEntityAttribute(entityName, attributeName, self.isDeletedViewable())
                for version in versions:
                    versionDescription = "%s %s" % (version.timestamp, version.userReference)
                    model.addElement(versionDescription)
                selectedRecord = None
                if versions:
                    if versionName == None or not model.contains(versionName):
                        self.versionsList.selectedIndex = 0
                        selectedRecord = versions[0]
                    else:
                        versionIndex = model.indexOf(versionName)
                        self.versionsList.selectedIndex = versionIndex
                        selectedRecord = versions[versionIndex]
                self.setCurrentRecord(selectedRecord)
        
                if event and event.clickCount == 2:
                    self.followResource(self.currentRecord)
            else:
                self.setCurrentRecord(None)
        else:
            self.setCurrentRecord(None)
                    
    def versionsListClicked(self, event):
        entityName = self.entitiesList.selectedValue
        if entityName:
            attributeName = self.attributesList.selectedValue
            if event:
                self.setCurrentAttributeName(attributeName)
            if attributeName:
                index = self.versionsList.selectedIndex
                versions = self.repository.findAllRecordsForEntityAttribute(entityName, attributeName, self.isDeletedViewable())
                if versions:
                    versionRecord = versions[index]
                    self.setCurrentRecord(versionRecord)

                    if event and event.clickCount == 2:
                        self.followResource(versionRecord)
                else:
                    self.setCurrentRecord(None)
                    
    def followResource(self, record):
        if not record:
            return
        if '\n' in record.valueBytes:
            print "not following a resource with a newline"
            return
        self.addEntityNameToEntitiesList(record.valueBytes)

    def addEntityNameToEntitiesList(self, entityName):
        self.entitiesList.model.addElement(entityName)
        self.entitiesList.selectedIndex = self.entitiesList.model.size() - 1
        self.entitiesListClicked(None)
        self.setCurrentRecord(None)
예제 #40
0
    def getUiComponent(self):
        self.panel = JPanel()
        self.panel.setLayout(BoxLayout(self.panel, BoxLayout.PAGE_AXIS))

        self.uiESHostLine = JPanel()
        self.uiESHostLine.setLayout(BoxLayout(self.uiESHostLine, BoxLayout.LINE_AXIS))
        self.uiESHostLine.setAlignmentX(JPanel.LEFT_ALIGNMENT)
        self.uiESHostLine.add(JLabel("ElasticSearch Host: "))
        self.uiESHost = JTextField(40)
        self.uiESHost.setMaximumSize(self.uiESHost.getPreferredSize())
        self.uiESHostLine.add(self.uiESHost)
        self.panel.add(self.uiESHostLine)

        self.uiESIndexLine = JPanel()
        self.uiESIndexLine.setLayout(BoxLayout(self.uiESIndexLine, BoxLayout.LINE_AXIS))
        self.uiESIndexLine.setAlignmentX(JPanel.LEFT_ALIGNMENT)
        self.uiESIndexLine.add(JLabel("ElasticSearch Index: "))
        self.uiESIndex = JTextField(40)
        self.uiESIndex.setMaximumSize(self.uiESIndex.getPreferredSize())
        self.uiESIndexLine.add(self.uiESIndex)
        self.panel.add(self.uiESIndexLine)

        uiToolsLine = JPanel()
        uiToolsLine.setLayout(BoxLayout(uiToolsLine, BoxLayout.LINE_AXIS))
        uiToolsLine.setAlignmentX(JPanel.LEFT_ALIGNMENT)
        self.uiCBSuite = JCheckBox("Suite")
        uiToolsLine.add(self.uiCBSuite)
        uiToolsLine.add(Box.createRigidArea(Dimension(10, 0)))
        self.uiCBTarget = JCheckBox("Target")
        uiToolsLine.add(self.uiCBTarget)
        uiToolsLine.add(Box.createRigidArea(Dimension(10, 0)))
        self.uiCBProxy = JCheckBox("Proxy")
        uiToolsLine.add(self.uiCBProxy)
        uiToolsLine.add(Box.createRigidArea(Dimension(10, 0)))
        self.uiCBSpider = JCheckBox("Spider")
        uiToolsLine.add(self.uiCBSpider)
        uiToolsLine.add(Box.createRigidArea(Dimension(10, 0)))
        self.uiCBScanner = JCheckBox("Scanner")
        uiToolsLine.add(self.uiCBScanner)
        uiToolsLine.add(Box.createRigidArea(Dimension(10, 0)))
        self.uiCBIntruder = JCheckBox("Intruder")
        uiToolsLine.add(self.uiCBIntruder)
        uiToolsLine.add(Box.createRigidArea(Dimension(10, 0)))
        self.uiCBRepeater = JCheckBox("Repeater")
        uiToolsLine.add(self.uiCBRepeater)
        uiToolsLine.add(Box.createRigidArea(Dimension(10, 0)))
        self.uiCBSequencer = JCheckBox("Sequencer")
        uiToolsLine.add(self.uiCBSequencer)
        uiToolsLine.add(Box.createRigidArea(Dimension(10, 0)))
        self.uiCBExtender = JCheckBox("Extender")
        uiToolsLine.add(self.uiCBExtender)
        self.panel.add(uiToolsLine)
        self.panel.add(Box.createRigidArea(Dimension(0, 10)))

        uiOptionsLine = JPanel()
        uiOptionsLine.setLayout(BoxLayout(uiOptionsLine, BoxLayout.LINE_AXIS))
        uiOptionsLine.setAlignmentX(JPanel.LEFT_ALIGNMENT)
        self.uiCBOptRespOnly = JCheckBox("Process only responses (include requests)")
        uiOptionsLine.add(self.uiCBOptRespOnly)
        self.panel.add(uiOptionsLine)
        self.panel.add(Box.createRigidArea(Dimension(0, 10)))

        uiButtonsLine = JPanel()
        uiButtonsLine.setLayout(BoxLayout(uiButtonsLine, BoxLayout.LINE_AXIS))
        uiButtonsLine.setAlignmentX(JPanel.LEFT_ALIGNMENT)
        uiButtonsLine.add(JButton("Apply", actionPerformed=self.applyConfigUI))
        uiButtonsLine.add(JButton("Reset", actionPerformed=self.resetConfigUI))
        self.panel.add(uiButtonsLine)
        self.resetConfigUI(None)

        return self.panel
 def __init__(self, *args, **kwargs):
     # do not create any class members before calling JFrame.__init__ !
     s, size, title, savemode = None, None, None, False
     self.OKstatus = True
     if 'settings_config' in kwargs:
         s = kwargs.pop('settings_config')
     else:
         s = None
     if 'size' in kwargs:
         size = kwargs.pop('size')
     else:
         size = (300, 300)
     if 'widget' in kwargs:
         widget = kwargs.pop('widget')
     else:
         widget = None
     if 'savemode' in kwargs:
         savemode = kwargs.pop('savemode')
     defaultdir = None
     if 'defaultdir' in kwargs:
         defaultdir = kwargs.pop('defaultdir')
     if len(args) > 0:
         title = args[0]
     else:
         title = 'Save Settings'
     JFrame.__init__(self, title, size=size, **kwargs)
     self.widget = widget
     if self.widget == None:
         print "Need to pass keyword argument widget=widget when creating SettingsTableFrame"
     self.s = s
     self.savemode = savemode
     self.defaultdir = defaultdir
     # create FileChooser, make its window bigger and choose smaller font
     if self.defaultdir != None:
         self.fc = JFileChooser(self.defaultdir)
     else:
         self.fc = JFileChooser()
     self.fc.setPreferredSize(Dimension(800, 600))
     smallfont = Font("Lucida Sans", Font.PLAIN, 12)
     SetFontRecursively(self.fc.getComponents(), smallfont)
     filefilter = FileNameExtensionFilter("Settings Files",
                                          (DEFAULT_EXTENSION, ))
     self.fc.setFileFilter(filefilter)
     # fill the table, in save mode only with the current values, in load mode with current and setting values
     self.prepare_tabledata()
     # if not savemode, we first pop up a filechooser to select a loadable setting
     if self.savemode == False:
         self.OKstatus = self.load_setting()
         if not self.OKstatus:
             return
     # listener for data edited by user, good for providing PV write access within the table to the user
     self.dataListener = MyTableModelListener(savemode=self.savemode)
     self.dataModel.addTableModelListener(self.dataListener)
     self.table = JTable(self.dataModel)
     # create Buttons
     self.bu_do_label = "Save" if self.savemode == True else "Load"
     self.bu_do_handler = self.bu_save_handler if self.savemode == True else self.bu_load_handler
     self.bu_do = JButton(self.bu_do_label,
                          actionPerformed=self.bu_do_handler)
     self.bu_cancel = JButton("Cancel",
                              actionPerformed=self.bu_cancel_handler)
     # BEGIN visual adaptations of JTable
     self.table.setRowHeight(24)
     self.table.getColumnModel().getColumn(0).setMinWidth(200)
     if self.savemode:
         self.table.getColumnModel().getColumn(3).setMaxWidth(60)
     else:
         self.table.getColumnModel().getColumn(4).setMaxWidth(60)
     smallfontr = MyTableCellRenderer(font=FONT_FAMILY,
                                      style=Font.PLAIN,
                                      fontsize=10)
     smallfontr.setHorizontalAlignment(JLabel.CENTER)
     bigfontplainr = MyTableCellRenderer(font=FONT_FAMILY,
                                         style=Font.PLAIN,
                                         fontsize=18)
     bigfontplainr.setHorizontalAlignment(JLabel.CENTER)
     bigfontr = MyTableCellRenderer(font=FONT_FAMILY,
                                    style=Font.BOLD,
                                    fontsize=18)
     bigfontr.setHorizontalAlignment(JLabel.CENTER)
     self.table.getColumnModel().getColumn(0).setCellRenderer(smallfontr)
     self.table.getColumnModel().getColumn(1).setCellRenderer(bigfontplainr)
     self.table.getColumnModel().getColumn(2).setCellRenderer(bigfontr)
     if not self.savemode:
         self.table.getColumnModel().getColumn(3).setCellRenderer(bigfontr)
     # END visual adaptations of JTable
     ## BEGIN layout of window (JFrame)
     self.getContentPane().setLayout(BorderLayout())
     self.add(JScrollPane(self.table))
     self.bottompanel = JPanel()
     self.bottompanel.setLayout(
         BoxLayout(self.bottompanel, BoxLayout.LINE_AXIS))
     self.bottompanel.add(Box.createHorizontalGlue())
     self.bottompanel.add(self.bu_do)
     self.bottompanel.add(Box.createRigidArea(Dimension(20, 0)))
     self.bottompanel.add(self.bu_cancel)
     self.bottompanel.add(Box.createHorizontalGlue())
     self.add(self.bottompanel, BorderLayout.SOUTH)
예제 #42
0
파일: AudioPlayer.py 프로젝트: AndTH/JMRI
    def __init__(self):

        # Setup controls - buttons first
        self.playButton.preferredSize = self.refreshButton.preferredSize
        self.playButton.actionCommand = self.PLAY
        self.playButton.actionPerformed = self.whenButtonClicked
        self.pauseButton.preferredSize = self.refreshButton.preferredSize
        self.pauseButton.actionCommand = self.PAUSE
        self.pauseButton.actionPerformed = self.whenButtonClicked
        self.stopButton.preferredSize = self.refreshButton.preferredSize
        self.stopButton.actionCommand = self.STOP
        self.stopButton.actionPerformed = self.whenButtonClicked
        self.refreshButton.actionCommand = self.REFRESH
        self.refreshButton.actionPerformed = self.whenButtonClicked

        # Now combobox and text field
        self.sourceCombo.itemStateChanged = self.whenSourceChanged
        self.updateSourcesList()
        self.rangeSpinner.stateChanged = self.whenRangeChanged

        # Now sliders
        ticksMajor = int(self.posMinMax/4)
        ticksMinor = int(ticksMajor/5)
        labels = Hashtable(3)
        labels.put(-self.posMinMax, JLabel("Left"))
        labels.put(              0, JLabel("Centre"))
        labels.put( self.posMinMax, JLabel("Right"))
        self.positionXSlider.labelTable = labels
        self.positionXSlider.minimum = -self.posMinMax
        self.positionXSlider.maximum = self.posMinMax
        self.positionXSlider.majorTickSpacing = ticksMajor
        self.positionXSlider.minorTickSpacing = ticksMinor
        self.positionXSlider.paintTicks = True
        self.positionXSlider.paintLabels = True
        self.positionXSlider.snapToTicks = True
        self.positionXSlider.value = 0
        self.positionXSlider.stateChanged = self.whenSliderXChanged
        labels = Hashtable(3)
        labels.put(-self.posMinMax, JLabel("Behind"))
        labels.put(              0, JLabel("Centre"))
        labels.put( self.posMinMax, JLabel("In-front"))
        self.positionYSlider.labelTable = labels
        self.positionYSlider.minimum = -self.posMinMax
        self.positionYSlider.maximum = self.posMinMax
        self.positionYSlider.majorTickSpacing = ticksMajor
        self.positionYSlider.minorTickSpacing = ticksMinor
        self.positionYSlider.paintTicks = True
        self.positionYSlider.paintLabels = True
        self.positionYSlider.snapToTicks = True
        self.positionYSlider.value = 0
        self.positionYSlider.orientation = JSlider.VERTICAL
        self.positionYSlider.stateChanged = self.whenSliderYChanged
        labels = Hashtable(3)
        labels.put(-self.posMinMax, JLabel("Below"))
        labels.put(              0, JLabel("Centre"))
        labels.put( self.posMinMax, JLabel("Above"))
        self.positionZSlider.labelTable = labels
        self.positionZSlider.minimum = -self.posMinMax
        self.positionZSlider.maximum = self.posMinMax
        self.positionZSlider.majorTickSpacing = ticksMajor
        self.positionZSlider.minorTickSpacing = ticksMinor
        self.positionZSlider.paintTicks = True
        self.positionZSlider.paintLabels = True
        self.positionZSlider.snapToTicks = True
        self.positionZSlider.value = 0
        self.positionZSlider.orientation = JSlider.VERTICAL
        self.positionZSlider.stateChanged = self.whenSliderZChanged

        # Setup frame
        self.title = "Simple JMRI Audio Player"
        self.contentPane.layout = BoxLayout(self.contentPane, BoxLayout.Y_AXIS)

        # Add controls to frame - combo & buttons first
        p = JPanel(FlowLayout(FlowLayout.LEADING))
        p.add(self.sourceCombo)
        p.add(self.refreshButton)
        p.add(self.playButton)
        p.add(self.pauseButton)
        p.add(self.stopButton)
        #p.add(JLabel("Range"))
        #p.add(self.rangeSpinner)
        self.add(p)
        self.add(Box.createVerticalGlue())

        # Now sliders
        p = JPanel(FlowLayout(FlowLayout.LEADING))
        label = JLabel("Y Position")
        label.UI = VerticalLabelUI() # Default behaviour is anti-clockwise
        p.add(label)
        p.add(self.positionYSlider)
        p2 = JPanel()
        p2.layout = BoxLayout(p2, BoxLayout.Y_AXIS)
        p3 = JPanel()
        p3.add(JLabel("Range"))
        p3.add(self.rangeSpinner)
        p2.add(p3)
        #p2.add(Box.createVerticalGlue())
        p3 = JPanel()
        p3.layout = BoxLayout(p3, BoxLayout.Y_AXIS)
        label = JLabel("X Position")
        label.alignmentX = JLabel.CENTER_ALIGNMENT
        p3.add(label)
        p3.add(self.positionXSlider)
        p2.add(p3)
        p.add(p2)
        label = JLabel("Z Position")
        label.UI = VerticalLabelUI()
        p.add(label)
        p.add(self.positionZSlider)
        self.add(p)

        # Finally pack and show
        self.pack()
        self.show()
예제 #43
0
    def __init__(self, parent, title, modal, app):
        from java.awt import CardLayout
        self.app = app
        border = BorderFactory.createEmptyBorder(5, 7, 7, 7)
        self.getContentPane().setBorder(border)
        self.setLayout(BoxLayout(self.getContentPane(), BoxLayout.Y_AXIS))

        self.FAVAREALAYERNAME = "Favourite zone editing"

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        self.addWindowListener(self)
        self.pack()
예제 #44
0
파일: NuView.py 프로젝트: Devanshi26/visad
display.addReference(modulesRef)

letWidget = LabeledColorWidget(maps.letmap)
# align along left side, to match VisADSlider alignment
#   (if we don't left-align, BoxLayout hoses everything
letWidget.setAlignmentX(Component.LEFT_ALIGNMENT)

eventWidget = EventWidget(file, amanda, amandaRef, maps.trackmap)

widgetPanel = JPanel()
widgetPanel.setLayout(BoxLayout(widgetPanel, BoxLayout.Y_AXIS))
widgetPanel.setMaximumSize(Dimension(400, 600))

widgetPanel.add(letWidget)
widgetPanel.add(eventWidget)
widgetPanel.add(Box.createHorizontalGlue())

displayPanel = display.getComponent()
dim = Dimension(800, 800)
displayPanel.setPreferredSize(dim)
displayPanel.setMinimumSize(dim)

# if widgetPanel alignment doesn't match
#  displayPanel alignment, BoxLayout will freak out
widgetPanel.setAlignmentX(displayPanel.getAlignmentX())
widgetPanel.setAlignmentY(displayPanel.getAlignmentY())

# create JPanel in frame
panel = JPanel()
panel.setLayout(BoxLayout(panel, BoxLayout.X_AXIS))
예제 #45
0
    def __init__(self, repository):
        self.repository = repository
        # want a better solution, with domains, perhaps user specifies
        self.currentUserReference = System.getProperty("user.name")
        
        self.currentRecord = None
                
        self.window = JFrame("Pointrel browser", windowClosing=self.exit)
        self.window.contentPane.layout = BorderLayout() # redundant as the default
        self.window.bounds = (100, 100, 800, 600)
        
        self.menuBar = JMenuBar()
        self.window.JMenuBar = self.menuBar
        fileMenu = JMenu("File")
        fileMenu.add(JMenuItem("Open...", actionPerformed=self.open))
        fileMenu.add(JMenuItem("Reload", actionPerformed=self.reloadPressed))
        fileMenu.addSeparator()
        fileMenu.add(JMenuItem("Import from other repository...", actionPerformed=self.importFromOtherRepository))
        fileMenu.addSeparator()
        fileMenu.add(JMenuItem("Close", actionPerformed=self.close))
        self.menuBar.add(fileMenu)

        exportMenu = JMenu("Export")
        exportMenu.add(JMenuItem("Choose current export file...", actionPerformed=self.exportChooseCurrentFile))
        exportMenu.addSeparator()        
        exportMenu.add(JMenuItem("Export selected record", actionPerformed=self.exportSelectedRecord))
        exportMenu.add(JMenuItem("Export record history for selected attribute", actionPerformed=self.exportAllRecordsForSelectedAttribute))
        exportMenu.addSeparator()
        exportMenu.add(JMenuItem("Export current records for all attributes of selected entity", actionPerformed=self.exportLatestRecordsForSelectedEntity))
        exportMenu.add(JMenuItem("Export entire record history for all attributes of selected entity", actionPerformed=self.exportAllRecordsForSelectedEntity))
        self.menuBar.add(exportMenu)
        
        self.exportFileName = "export.pointrel"

        #self.reloadButton = JButton("Reload Repository", actionPerformed=self.reloadPressed)
                        
        self.entitiesList = JList(DefaultListModel(), mouseClicked=self.entitiesListClicked)
        self.entitiesList.model.addElement("root")
        self.entitiesList.mousePressed = self.entitiesListMousePressed
        self.entitiesList.mouseReleased = self.entitiesListMousePressed
        
        self.attributesList = JList(DefaultListModel(), mouseClicked=self.attributesListClicked)
        
        self.versionsList = JList(DefaultListModel(), mouseClicked=self.versionsListClicked)
        
        self.listPanel = JPanel(layout=GridLayout(1, 2))
        self.listPanel.add(JScrollPane(self.entitiesList))
        self.listPanel.add(JScrollPane(self.attributesList))
        self.listPanel.add(JScrollPane(self.versionsList))
        
        self.navigationPanel = JPanel(layout=BorderLayout())
        #self.navigationPanel.add(self.reloadButton, BorderLayout.NORTH)
        self.navigationPanel.add(self.listPanel, BorderLayout.CENTER)
                
        self.entityTextField = JTextField(preferredSize=(200,20))
        self.attributeTextField = JTextField(preferredSize=(200,20))
        self.deletedButton = JCheckBox("Deleted", actionPerformed=self.deletedPressed)
        
        # only one right now -- and no support for switching editor panels yet
        examples = ["pointrel:text/utf-8", ]
        self.valueTypeComboBox = JComboBox(examples, preferredSize=(200,20), editable=True)

        self.attributePanel = Box(BoxLayout.X_AXIS) 
        self.attributePanel.add(Box.createRigidArea(Dimension(5,0)))
        self.attributePanel.add(JLabel("Entity:"))
        self.attributePanel.add(Box.createRigidArea(Dimension(2,0)))
        self.attributePanel.add(self.entityTextField)
        self.attributePanel.add(Box.createRigidArea(Dimension(5,0)))
        self.attributePanel.add(JLabel("Attribute:"))
        self.attributePanel.add(Box.createRigidArea(Dimension(2,0)))
        self.attributePanel.add(self.attributeTextField)
        self.attributePanel.add(Box.createRigidArea(Dimension(5,0)))
        self.attributePanel.add(JLabel("Value type:"))
        self.attributePanel.add(Box.createRigidArea(Dimension(2,0)))
        self.attributePanel.add(self.valueTypeComboBox)
        self.attributePanel.add(Box.createRigidArea(Dimension(5,0)))
        self.attributePanel.add(self.deletedButton)
        self.attributePanel.add(Box.createRigidArea(Dimension(5,0)))
        
        self.showAllDeletedButton = JCheckBox("Show all deleted", actionPerformed=self.showAllDeletedPressed)
        self.statusText = JTextField(preferredSize=(100,20))
        self.saveButton = JButton("Save", actionPerformed=self.savePressed)
        self.normalSaveButtonColor = self.saveButton.background
        self.changedSaveButtonColor = Color.YELLOW

        self.statusPanel = Box(BoxLayout.X_AXIS)
        self.statusPanel.add(Box.createRigidArea(Dimension(5,0)))
        self.statusPanel.add(self.showAllDeletedButton)
        self.statusPanel.add(Box.createRigidArea(Dimension(25,0)))
        self.statusPanel.add(JLabel("Message:") )
        self.statusPanel.add(Box.createRigidArea(Dimension(2,0)))
        self.statusPanel.add(self.statusText) 
        self.statusPanel.add(Box.createRigidArea(Dimension(5,0)))
        self.statusPanel.add(self.saveButton)
        self.statusPanel.add(Box.createRigidArea(Dimension(1,0)))       
        
        self.currentEditorPanel = EditorPanel_text_utf_8(self, "pointrel:text/utf-8")
        
        self.topPanel = Box(BoxLayout.Y_AXIS)
        self.topPanel.add(Box.createRigidArea(Dimension(0,5))) 
        self.topPanel.add(self.attributePanel)
        self.topPanel.add(Box.createRigidArea(Dimension(0,5))) 
        
        self.editorPanel = JPanel(layout=BorderLayout())
        self.editorPanel.add(self.topPanel, BorderLayout.NORTH)
        self.editorPanel.add(self.currentEditorPanel, BorderLayout.CENTER)
        self.editorPanel.add(self.statusPanel, BorderLayout.SOUTH)
        
        self.browserPanel = JSplitPane(JSplitPane.VERTICAL_SPLIT)
        self.browserPanel.add(self.navigationPanel)
        self.browserPanel.add(self.editorPanel)
        
        self.window.contentPane.add(self.browserPanel, BorderLayout.CENTER)
        
        self.setTitleForRepository()
        self.window.show()
        
        # background timer for updating save button color
        self.timer = Timer(1000, CallbackActionListener(self.timerEvent))
        self.timer.initialDelay = 1000
        self.timer.start()
예제 #46
0
class EditorPanel_text_utf_8(EditorPanel_abstract):
    
    def basicRecordChanged(self, newRecord):
        self.textEditor.caretPosition = 0
        self.saveButton.background = self.normalSaveButtonColor
    
    def makeComponents(self):
        # text specific operations
        self.randomUUIDButton = JButton("Generate random UUID", actionPerformed=self.randomUUIDPressed)
        self.clearButton = JButton("Clear", actionPerformed=self.clearPressed)
        self.runButton = JButton("Run as Jython", actionPerformed=self.runPressed)
        self.revertButton = JButton("Revert", actionPerformed=self.revertPressed)

        self.buttonPanel = Box(BoxLayout.X_AXIS) 
        self.buttonPanel.add(Box.createRigidArea(Dimension(5,0)))
        self.buttonPanel.add(self.randomUUIDButton)
        self.buttonPanel.add(Box.createRigidArea(Dimension(5,0)))
        self.buttonPanel.add(self.clearButton)
        self.buttonPanel.add(Box.createRigidArea(Dimension(5,0)))
        self.buttonPanel.add(self.runButton)
        self.buttonPanel.add(Box.createRigidArea(Dimension(5,0)))
        self.buttonPanel.add(self.revertButton)
        self.buttonPanel.add(Box.createRigidArea(Dimension(5,0)))
 
        self.textEditor = JTextPane()
        self.textEditor.setFont(Font("monospaced", Font.PLAIN, 12))
        #self.textEditor.setTabSize(4) # still inserts tabs instead of spaces
        TabKeyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_TAB, 0, False)
        MyTabActionKey = Object()
        self.textEditor.getInputMap().put(TabKeyStroke, MyTabActionKey)
        actionMap = self.textEditor.getActionMap()
        actionMap.put(MyTabActionKey, AddFourSpacesAction())
        
        self.layout = BorderLayout()
        self.add(self.buttonPanel, BorderLayout.NORTH)
        self.add(JScrollPane(self.textEditor), BorderLayout.CENTER)
        
    def basicGetCurrentValueBytes(self):
        return self.textEditor.text
        
    def basicSetCurrentValueBytes(self, newValueBytes):
        self.textEditor.text = newValueBytes
        self.textEditor.caretPosition = 0
        
    # extra functionality
    def runPressed(self, event):
        print "run pressed"
        codeText = self.getCurrentValueBytes()
        print "=== run code ==="
        exec "from token import *"
        #print codeText
        self.browser.oldimport = __builtin__.__import__
        self.browser.contextUUID = self.browser.entitiesList.selectedValue
        __builtin__.__import__ = self.browser.importCodeFromRepository
        self.browser.importLevel = 0
        try:
            try:
                someGlobals = {"currentBrowser": self.browser, "contextUUID": self.browser.entitiesList.selectedValue}
                exec codeText in someGlobals
            except SyntaxError, e:
                print e
                #print "fileName", e.fileName
                #print "lineno", e.lineno
                print "offset:", e.offset
                print "text:", e.text
                lines = codeText.split('\n')
                position = 0
                for i in range(e.lineno - 1):
                    position += len(lines[i]) + 1
                position += e.offset
                self.textEditor.caretPosition = position
                self.textEditor.requestFocus()
            print "=== done ==="
        finally:
예제 #47
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()
예제 #48
0
파일: Main.py 프로젝트: sedjrodonan/lositan
def createMenuBar(manager):
    global menuHandles, isDominant, isTemporal
    menuHandles = {}
    menuBar = JMenuBar()

    fmenu = JMenu("File")
    menuHandles['File'] = fmenu
    fmenu.setMnemonic(KeyEvent.VK_F)
    menuBar.add(fmenu)
    fmenu.add(createMenuItem('Open Genepop data', "Open", manager))
    fmenu.add(createMenuItem('Use Example data', "Example", manager))
    fmenu.addSeparator()
    fmenu.add(createMenuItem('Citation', "Citation", manager))
    fmenu.addSeparator()
    fmenu.add(createMenuItem("Exit", "Exit", manager))

    if not isTemporal:
        pmenu = JMenu("Populations")
        menuHandles['Populations'] = pmenu
        pmenu.setEnabled(False)
        pmenu.setMnemonic(KeyEvent.VK_P)
        menuBar.add(pmenu)
        pmenu.add(createMenuItem('Load population names', "LoadPop", manager))
        pmenu.add(createMenuItem('Edit population names', "EditPop", manager))
        pmenu.add(createMenuItem('Save population names', "SavePop", manager))

    umenu = JMenu("Data used")
    menuHandles['Data used'] = umenu
    umenu.setEnabled(False)
    umenu.setMnemonic(KeyEvent.VK_U)
    menuBar.add(umenu)
    umenu.add(createMenuItem('Loci Analyzed', "ChooseLoci", manager))
    if isTemporal:
        umenu.add(createMenuItem('Samples Analyzed', "ChoosePops", manager))
    else:
        umenu.add(createMenuItem('Populations Analyzed', "ChoosePops", manager))

    if isDominant:
        fdmenu = JMenu("DFDist")
    elif isTemporal:
        fdmenu = JMenu("FTemp")
    else:
        fdmenu = JMenu("FDist")
    menuHandles['FDist'] = fdmenu
    fdmenu.setEnabled(False)
    fdmenu.setMnemonic(KeyEvent.VK_D)
    menuBar.add(fdmenu)
    if isTemporal:
        fdmenu.add(createMenuItem('Run FTemp', "RunFDist", manager))
    else:
        fdmenu.add(createMenuItem('Run FDist', "RunFDist", manager))
    item5000 = createMenuItem('Run more 5000 sims', "Run5000", manager)
    item5000.setEnabled(False)
    menuHandles['item5000'] = item5000
    fdmenu.add(item5000)
    checkLoci = createMenuItem('Check Loci Status', "CheckLoci", manager)
    checkLoci.setEnabled(False)
    menuHandles['checkLoci'] = checkLoci
    fdmenu.add(checkLoci)

    gmenu = JMenu("Graphic")
    gmenu.setEnabled(False)
    menuHandles['Graphic'] = gmenu
    gmenu.setMnemonic(KeyEvent.VK_G)
    menuBar.add(gmenu)
    gmenu.add(createMenuItem('Colors and loci labels', "ConfGrp", manager))
    #gmenu.add(createMenuItem('Save Graphic as PNG', "SavePNG", manager))
    gmenu.add(createMenuItem('Save as PNG', "SavePNG", manager))
    gmenu.add(createMenuItem('Export as PDF', "SavePDF", manager))
    gmenu.add(createMenuItem('Export as SVG', "SaveSVG", manager))

    menuBar.add(Box.createHorizontalGlue())

    hmenu = JMenu("Help")
    hmenu.setMnemonic(KeyEvent.VK_H)
    menuBar.add(hmenu)
    hmenu.add(createMenuItem('Help', "Help", manager))

    return menuBar
    def loadPanel(self):
        panel = JPanel()

        panel.setLayout(BoxLayout(panel, BoxLayout.Y_AXIS))

        bottomButtonBarPanel = JPanel()
        bottomButtonBarPanel.setLayout(
            BoxLayout(bottomButtonBarPanel, BoxLayout.X_AXIS))
        bottomButtonBarPanel.setAlignmentX(1.0)

        self.runButton = JButton("Run", actionPerformed=self.start)
        self.cancelButton = JButton("Close", actionPerformed=self.cancel)

        bottomButtonBarPanel.add(Box.createHorizontalGlue())
        bottomButtonBarPanel.add(self.runButton)
        bottomButtonBarPanel.add(self.cancelButton)

        # Dimension(width,height)
        bottom = JPanel()
        bottom.setLayout(BoxLayout(bottom, BoxLayout.X_AXIS))
        bottom.setAlignmentX(1.0)

        self.progressBar = JProgressBar()
        self.progressBar.setIndeterminate(False)
        self.progressBar.setMaximum(100)
        self.progressBar.setValue(0)

        bottom.add(self.progressBar)

        self.statusTextArea = JTextArea()
        self.statusTextArea.setEditable(False)
        scrollPane = JScrollPane(self.statusTextArea)
        scrollPanel = JPanel()
        scrollPanel.setLayout(BoxLayout(scrollPanel, BoxLayout.X_AXIS))
        scrollPanel.setAlignmentX(1.0)
        scrollPanel.add(scrollPane)

        panel.add(scrollPanel)
        panel.add(bottomButtonBarPanel)
        panel.add(bottom)

        self.add(panel)
        self.setTitle("Determine Session Cookie(s)")
        self.setSize(450, 300)
        self.setLocationRelativeTo(None)
        self.setVisible(True)

        original_request_bytes = self.selected_message.getRequest()
        http_service = self.selected_message.getHttpService()
        helpers = self.callbacks.getHelpers()
        request_info = helpers.analyzeRequest(http_service,
                                              original_request_bytes)
        parameters = request_info.getParameters()
        cookie_parameters = [
            parameter for parameter in parameters
            if parameter.getType() == IParameter.PARAM_COOKIE
        ]
        num_requests_needed = len(cookie_parameters) + 2
        self.statusTextArea.append(
            "This may require up to " + str(num_requests_needed) +
            " requests to be made. Hit 'Run' to begin.\n")
    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()