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 __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()
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)
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()
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)
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
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()
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()
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
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 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
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
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
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())
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)
def __init__(self, parent, title, modal, app): from java.awt import CardLayout self.app = app border = BorderFactory.createEmptyBorder(5, 7, 7, 7) self.getContentPane().setBorder(border) self.setLayout(BoxLayout(self.getContentPane(), BoxLayout.Y_AXIS)) self.FAVAREALAYERNAME = "Favourite zone editing" info = JLabel(self.app.strings.getString("Create_a_new_favourite_zone")) info.setAlignmentX(Component.LEFT_ALIGNMENT) #Name nameLbl = JLabel(self.app.strings.getString("fav_zone_name")) self.nameTextField = JTextField(20) self.nameTextField.setMaximumSize(self.nameTextField.getPreferredSize()) self.nameTextField.setToolTipText(self.app.strings.getString("fav_zone_name_tooltip")) namePanel = JPanel() namePanel.setLayout(BoxLayout(namePanel, BoxLayout.X_AXIS)) namePanel.add(nameLbl) namePanel.add(Box.createHorizontalGlue()) namePanel.add(self.nameTextField) #Country countryLbl = JLabel(self.app.strings.getString("fav_zone_country")) self.countryTextField = JTextField(20) self.countryTextField.setMaximumSize(self.countryTextField.getPreferredSize()) self.countryTextField.setToolTipText(self.app.strings.getString("fav_zone_country_tooltip")) countryPanel = JPanel() countryPanel.setLayout(BoxLayout(countryPanel, BoxLayout.X_AXIS)) countryPanel.add(countryLbl) countryPanel.add(Box.createHorizontalGlue()) countryPanel.add(self.countryTextField) #Type modeLbl = JLabel(self.app.strings.getString("fav_zone_type")) RECTPANEL = "rectangle" POLYGONPANEL = "polygon" BOUNDARYPANEL = "boundary" self.modesStrings = [RECTPANEL, POLYGONPANEL, BOUNDARYPANEL] modesComboModel = DefaultComboBoxModel() for i in (self.app.strings.getString("rectangle"), self.app.strings.getString("delimited_by_a_closed_way"), self.app.strings.getString("delimited_by_an_administrative_boundary")): modesComboModel.addElement(i) self.modesComboBox = JComboBox(modesComboModel, actionListener=self, editable=False) #- Rectangle self.rectPanel = JPanel() self.rectPanel.setLayout(BoxLayout(self.rectPanel, BoxLayout.Y_AXIS)) capturePane = JPanel() capturePane.setLayout(BoxLayout(capturePane, BoxLayout.X_AXIS)) capturePane.setAlignmentX(Component.LEFT_ALIGNMENT) josmP = JPanel() self.captureRBtn = JRadioButton(self.app.strings.getString("capture_area")) self.captureRBtn.addActionListener(self) self.captureRBtn.setSelected(True) self.bboxFromJosmBtn = JButton(self.app.strings.getString("get_current_area"), actionPerformed=self.on_bboxFromJosmBtn_clicked) self.bboxFromJosmBtn.setToolTipText(self.app.strings.getString("get_capture_area_tooltip")) josmP.add(self.bboxFromJosmBtn) capturePane.add(self.captureRBtn) capturePane.add(Box.createHorizontalGlue()) capturePane.add(self.bboxFromJosmBtn) manualPane = JPanel() manualPane.setLayout(BoxLayout(manualPane, BoxLayout.X_AXIS)) manualPane.setAlignmentX(Component.LEFT_ALIGNMENT) self.manualRBtn = JRadioButton(self.app.strings.getString("use_this_bbox")) self.manualRBtn.addActionListener(self) self.bboxTextField = JTextField(20) self.bboxTextField.setMaximumSize(self.bboxTextField.getPreferredSize()) self.bboxTextField.setToolTipText(self.app.strings.getString("fav_bbox_tooltip")) self.bboxTextFieldDefaultBorder = self.bboxTextField.getBorder() self.bboxTextField.getDocument().addDocumentListener(TextListener(self)) manualPane.add(self.manualRBtn) manualPane.add(Box.createHorizontalGlue()) manualPane.add(self.bboxTextField) group = ButtonGroup() group.add(self.captureRBtn) group.add(self.manualRBtn) previewPane = JPanel() previewPane.setLayout(BoxLayout(previewPane, BoxLayout.X_AXIS)) previewPane.setAlignmentX(Component.LEFT_ALIGNMENT) bboxPreviewInfo = JTextField(self.app.strings.getString("coordinates"), editable=0, border=None) bboxPreviewInfo.setMaximumSize(bboxPreviewInfo.getPreferredSize()) self.bboxPreviewTextField = JTextField(20, editable=0, border=None) self.bboxPreviewTextField.setMaximumSize(self.bboxPreviewTextField.getPreferredSize()) previewPane.add(bboxPreviewInfo) previewPane.add(Box.createHorizontalGlue()) previewPane.add(self.bboxPreviewTextField) self.rectPanel.add(capturePane) self.rectPanel.add(Box.createRigidArea(Dimension(0, 10))) self.rectPanel.add(manualPane) self.rectPanel.add(Box.createRigidArea(Dimension(0, 20))) self.rectPanel.add(previewPane) #- Polygon (closed way) drawn by hand self.polygonPanel = JPanel(BorderLayout()) self.polygonPanel.setLayout(BoxLayout(self.polygonPanel, BoxLayout.Y_AXIS)) polyInfo = JLabel("<html>%s</html>" % self.app.strings.getString("polygon_info")) polyInfo.setFont(polyInfo.getFont().deriveFont(Font.ITALIC)) polyInfo.setAlignmentX(Component.LEFT_ALIGNMENT) editPolyPane = JPanel() editPolyPane.setAlignmentX(Component.LEFT_ALIGNMENT) editPolyBtn = JButton(self.app.strings.getString("create_fav_layer"), actionPerformed=self.create_new_zone_editing_layer) editPolyBtn.setToolTipText(self.app.strings.getString("create_fav_layer_tooltip")) editPolyPane.add(editPolyBtn) self.polygonPanel.add(polyInfo) self.polygonPanel.add(Box.createRigidArea(Dimension(0, 15))) self.polygonPanel.add(editPolyPane) self.polygonPanel.add(Box.createRigidArea(Dimension(0, 15))) #- Administrative Boundary self.boundaryPanel = JPanel() self.boundaryPanel.setLayout(BoxLayout(self.boundaryPanel, BoxLayout.Y_AXIS)) boundaryInfo = JLabel("<html>%s</html>" % app.strings.getString("boundary_info")) boundaryInfo.setFont(boundaryInfo.getFont().deriveFont(Font.ITALIC)) boundaryInfo.setAlignmentX(Component.LEFT_ALIGNMENT) boundaryTagsPanel = JPanel(GridLayout(3, 3, 5, 5)) boundaryTagsPanel.setAlignmentX(Component.LEFT_ALIGNMENT) boundaryTagsPanel.add(JLabel("name =")) self.nameTagTextField = JTextField(20) boundaryTagsPanel.add(self.nameTagTextField) boundaryTagsPanel.add(JLabel("admin_level =")) self.adminLevelTagTextField = JTextField(20) self.adminLevelTagTextField.setToolTipText(self.app.strings.getString("adminLevel_tooltip")) boundaryTagsPanel.add(self.adminLevelTagTextField) boundaryTagsPanel.add(JLabel(self.app.strings.getString("other_tag"))) self.optionalTagTextField = JTextField(20) self.optionalTagTextField.setToolTipText("key=value") boundaryTagsPanel.add(self.optionalTagTextField) downloadBoundariesPane = JPanel() downloadBoundariesPane.setAlignmentX(Component.LEFT_ALIGNMENT) downloadBoundariesBtn = JButton(self.app.strings.getString("download_boundary"), actionPerformed=self.on_downloadBoundariesBtn_clicked) downloadBoundariesBtn.setToolTipText(self.app.strings.getString("download_boundary_tooltip")) downloadBoundariesPane.add(downloadBoundariesBtn) self.boundaryPanel.add(boundaryInfo) self.boundaryPanel.add(Box.createRigidArea(Dimension(0, 15))) self.boundaryPanel.add(boundaryTagsPanel) self.boundaryPanel.add(Box.createRigidArea(Dimension(0, 10))) self.boundaryPanel.add(downloadBoundariesPane) self.editingPanels = {"rectangle": self.rectPanel, "polygon": self.polygonPanel, "boundary": self.boundaryPanel} #Main buttons self.okBtn = JButton(self.app.strings.getString("OK"), ImageProvider.get("ok"), actionPerformed=self.on_okBtn_clicked) self.cancelBtn = JButton(self.app.strings.getString("cancel"), ImageProvider.get("cancel"), actionPerformed=self.close_dialog) self.previewBtn = JButton(self.app.strings.getString("Preview_zone"), actionPerformed=self.on_previewBtn_clicked) self.previewBtn.setToolTipText(self.app.strings.getString("preview_zone_tooltip")) okBtnSize = self.okBtn.getPreferredSize() viewBtnSize = self.previewBtn.getPreferredSize() viewBtnSize.height = okBtnSize.height self.previewBtn.setPreferredSize(viewBtnSize) #layout self.add(info) self.add(Box.createRigidArea(Dimension(0, 15))) namePanel.setAlignmentX(Component.LEFT_ALIGNMENT) self.add(namePanel) self.add(Box.createRigidArea(Dimension(0, 15))) countryPanel.setAlignmentX(Component.LEFT_ALIGNMENT) self.add(countryPanel) self.add(Box.createRigidArea(Dimension(0, 15))) modeLbl.setAlignmentX(Component.LEFT_ALIGNMENT) self.add(modeLbl) self.add(Box.createRigidArea(Dimension(0, 5))) self.add(self.modesComboBox) self.modesComboBox.setAlignmentX(Component.LEFT_ALIGNMENT) self.add(Box.createRigidArea(Dimension(0, 15))) self.configPanel = JPanel(CardLayout()) self.configPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)) self.configPanel.add(self.rectPanel, RECTPANEL) self.configPanel.add(self.polygonPanel, POLYGONPANEL) self.configPanel.add(self.boundaryPanel, BOUNDARYPANEL) self.configPanel.setAlignmentX(Component.LEFT_ALIGNMENT) self.add(self.configPanel) buttonsPanel = JPanel() buttonsPanel.add(self.okBtn) buttonsPanel.add(self.cancelBtn) buttonsPanel.add(self.previewBtn) buttonsPanel.setAlignmentX(Component.LEFT_ALIGNMENT) self.add(buttonsPanel) self.addWindowListener(self) self.pack()
def __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()
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 + "<" + \ 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()
def __init__(self): #obtain prefixes from folder self.dict1 = self.obtain_prefixes( ) #Run prefix selection function - sets source directory, requests prefix size, outputs prefix dictionary lst = list(self.dict1.keys()) #pull prefixes only, as list self.lang = lst self.lst = JList(self.lang, valueChanged=self.listSelect ) # pass prefix list to GUI selection list # general GUI layout parameters, no data processing here self.frame = JFrame("Image Selection") self.frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE) self.frame.setLocation(100, 100) self.frame.setSize(800, 350) self.frame.setLayout(BorderLayout()) self.frame.add(self.lst, BorderLayout.NORTH) self.lst.selectionMode = ListSelectionModel.MULTIPLE_INTERVAL_SELECTION self.button1 = JButton('Select item(s)', actionPerformed=self.clickhere) #Save option radio buttons and file extension selection #set main right panel (sub panels will fit within this) rightpanel = JPanel() rightpanel.setLayout(BoxLayout(rightpanel, BoxLayout.Y_AXIS)) #set up savestate panel buttonpanel = JPanel() self.radiobutton1 = JRadioButton( "Open selected 3D stacks and max projections \n and save max projections", True) self.radiobutton2 = JRadioButton( "Open selected 3D stacks and max projections \n and DO NOT save max projections" ) infoLabel = JLabel( "<html>Hold ctrl and click multiple prefixes to select multiple options. Will load stacks and MIPs separately <br><br> Type file extension in text field below:</html>", SwingConstants.LEFT) grp = ButtonGroup() grp.add(self.radiobutton1) grp.add(self.radiobutton2) #buttonpanel.setLayout(BoxLayout(buttonpanel, BoxLayout.Y_AXIS)) buttonpanel.add(Box.createVerticalGlue()) buttonpanel.add(infoLabel) buttonpanel.add(Box.createRigidArea(Dimension(0, 5))) buttonpanel.add(self.radiobutton1) buttonpanel.add(Box.createRigidArea(Dimension(0, 5))) buttonpanel.add(self.radiobutton2) #file extension instruction panel infopanel = JPanel() infopanel.setLayout(FlowLayout(FlowLayout.LEFT)) infopanel.setMaximumSize( infopanel.setPreferredSize(Dimension(650, 100))) infopanel.add(infoLabel) #file extension input inputPanel = JPanel() inputPanel.setLayout(BoxLayout(inputPanel, BoxLayout.X_AXIS)) self.filetype = JTextField(".tif", 15) self.filetype.setMaximumSize(self.filetype.getPreferredSize()) inputPanel.add(self.filetype) ########### WIP - integrate prefix selection with main pane, with dynamically updating prefix list ##infoLabel3 = JLabel("how long is the file prefix to group by?(integer value only)") ##self.prefix_init = JTextField() ##buttonpanel.add(infoLabel3) ##buttonpanel.add(self.prefix_init) ########### !WIP #add file extension and savestate panels to main panel rightpanel.add(infopanel) rightpanel.add(inputPanel) rightpanel.add(buttonpanel, BorderLayout.EAST) #split list and radiobutton pane (construct overall window) spl = JSplitPane(JSplitPane.HORIZONTAL_SPLIT) spl.leftComponent = JScrollPane(self.lst) spl.setDividerLocation(150) spl.rightComponent = rightpanel self.frame.add(spl) self.frame.add(self.button1, BorderLayout.SOUTH) # GUI layout done, initialise GUI to select prefixes, file extension and save option self.frame.setVisible(True)
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 + "<" + \ 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()
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)
def __init__(self, app): from java.awt import Dialog from java.awt import CardLayout JDialog.__init__(self, app.preferencesFrame, app.strings.getString("Create_a_new_favourite_zone"), Dialog.ModalityType.DOCUMENT_MODAL) 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(UrlLabel("http://wiki.openstreetmap.org/wiki/Key:admin_level#admin_level", "admin_level =")) self.adminLevelTagTextField = JTextField(20) self.adminLevelTagTextField.setToolTipText(self.app.strings.getString("adminLevel_tooltip")) boundaryTagsPanel.add(self.adminLevelTagTextField) boundaryTagsPanel.add(JLabel(self.app.strings.getString("other_tag"))) self.optionalTagTextField = JTextField(20) self.optionalTagTextField.setToolTipText("key=value") boundaryTagsPanel.add(self.optionalTagTextField) downloadBoundariesPane = JPanel() downloadBoundariesPane.setAlignmentX(Component.LEFT_ALIGNMENT) downloadBoundariesBtn = JButton(self.app.strings.getString("download_boundary"), actionPerformed=self.on_downloadBoundariesBtn_clicked) downloadBoundariesBtn.setToolTipText(self.app.strings.getString("download_boundary_tooltip")) downloadBoundariesPane.add(downloadBoundariesBtn) self.boundaryPanel.add(boundaryInfo) self.boundaryPanel.add(Box.createRigidArea(Dimension(0, 15))) self.boundaryPanel.add(boundaryTagsPanel) self.boundaryPanel.add(Box.createRigidArea(Dimension(0, 10))) self.boundaryPanel.add(downloadBoundariesPane) self.editingPanels = {"rectangle": self.rectPanel, "polygon": self.polygonPanel, "boundary": self.boundaryPanel} #Main buttons self.okBtn = JButton(self.app.strings.getString("OK"), ImageProvider.get("ok"), actionPerformed=self.on_okBtn_clicked) self.cancelBtn = JButton(self.app.strings.getString("cancel"), ImageProvider.get("cancel"), actionPerformed=self.close_dialog) self.previewBtn = JButton(self.app.strings.getString("Preview_zone"), actionPerformed=self.on_previewBtn_clicked) self.previewBtn.setToolTipText(self.app.strings.getString("preview_zone_tooltip")) okBtnSize = self.okBtn.getPreferredSize() viewBtnSize = self.previewBtn.getPreferredSize() viewBtnSize.height = okBtnSize.height self.previewBtn.setPreferredSize(viewBtnSize) #layout self.add(info) self.add(Box.createRigidArea(Dimension(0, 15))) namePanel.setAlignmentX(Component.LEFT_ALIGNMENT) self.add(namePanel) self.add(Box.createRigidArea(Dimension(0, 15))) countryPanel.setAlignmentX(Component.LEFT_ALIGNMENT) self.add(countryPanel) self.add(Box.createRigidArea(Dimension(0, 15))) modeLbl.setAlignmentX(Component.LEFT_ALIGNMENT) self.add(modeLbl) self.add(Box.createRigidArea(Dimension(0, 5))) self.add(self.modesComboBox) self.modesComboBox.setAlignmentX(Component.LEFT_ALIGNMENT) self.add(Box.createRigidArea(Dimension(0, 15))) self.configPanel = JPanel(CardLayout()) self.configPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)) self.configPanel.add(self.rectPanel, RECTPANEL) self.configPanel.add(self.polygonPanel, POLYGONPANEL) self.configPanel.add(self.boundaryPanel, BOUNDARYPANEL) self.configPanel.setAlignmentX(Component.LEFT_ALIGNMENT) self.add(self.configPanel) buttonsPanel = JPanel() buttonsPanel.add(self.okBtn) buttonsPanel.add(self.cancelBtn) buttonsPanel.add(self.previewBtn) buttonsPanel.setAlignmentX(Component.LEFT_ALIGNMENT) self.add(buttonsPanel) self.addWindowListener(self) self.pack()
def 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, 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()
def getUiComponent(self): ui_panel = JPanel() ui_panel.setLayout(BoxLayout(ui_panel, BoxLayout.PAGE_AXIS)) ui_host_line = JPanel() ui_host_line.setLayout(BoxLayout(ui_host_line, BoxLayout.LINE_AXIS)) ui_host_line.setAlignmentX(JPanel.LEFT_ALIGNMENT) ui_host_line.add(JLabel("ElasticSearch Host: ")) self.ui_es_host = JTextField(40) self.ui_es_host.setMaximumSize(self.ui_es_host.getPreferredSize()) self.ui_es_host.setText(self.es_host) ui_host_line.add(self.ui_es_host) ui_panel.add(ui_host_line) ui_index_line = JPanel() ui_index_line.setLayout(BoxLayout(ui_index_line, BoxLayout.LINE_AXIS)) ui_index_line.setAlignmentX(JPanel.LEFT_ALIGNMENT) ui_index_line.add(JLabel("ElasticSearch Index: ")) self.ui_es_index = JTextField(40) self.ui_es_index.setText(self.es_index) self.ui_es_index.setMaximumSize(self.ui_es_index.getPreferredSize()) ui_index_line.add(self.ui_es_index) ui_panel.add(ui_index_line) ui_whitelist_line = JPanel() ui_whitelist_line.setLayout( BoxLayout(ui_whitelist_line, BoxLayout.LINE_AXIS)) ui_whitelist_line.setAlignmentX(JPanel.LEFT_ALIGNMENT) ui_whitelist_line.add(JLabel("Host whitelist: ")) self.ui_whitelist = JTextField(40) self.ui_whitelist.setText(self.whitelist) self.ui_whitelist.setMaximumSize(self.ui_whitelist.getPreferredSize()) ui_whitelist_line.add(self.ui_whitelist) ui_panel.add(ui_whitelist_line) ui_tools_panel = JPanel() ui_tools_panel.setLayout( BoxLayout(ui_tools_panel, BoxLayout.LINE_AXIS)) ui_tools_panel.setAlignmentX(JPanel.LEFT_ALIGNMENT) self.ui_tool_suite = JCheckBox( "Suite", self.tools & ECallbacks.TOOL_SUITE != 0) ui_tools_panel.add(self.ui_tool_suite) ui_tools_panel.add(Box.createRigidArea(Dimension(10, 0))) self.ui_tool_target = JCheckBox( "Target", self.tools & ECallbacks.TOOL_TARGET != 0) ui_tools_panel.add(self.ui_tool_target) ui_tools_panel.add(Box.createRigidArea(Dimension(10, 0))) self.ui_tool_proxy = JCheckBox( "Proxy", self.tools & ECallbacks.TOOL_PROXY != 0) ui_tools_panel.add(self.ui_tool_proxy) ui_tools_panel.add(Box.createRigidArea(Dimension(10, 0))) self.ui_tool_spider = JCheckBox( "Spider", self.tools & ECallbacks.TOOL_SPIDER != 0) ui_tools_panel.add(self.ui_tool_spider) ui_tools_panel.add(Box.createRigidArea(Dimension(10, 0))) self.ui_tool_scanner = JCheckBox( "Scanner", self.tools & ECallbacks.TOOL_SCANNER != 0) ui_tools_panel.add(self.ui_tool_scanner) ui_tools_panel.add(Box.createRigidArea(Dimension(10, 0))) self.ui_tool_intruder = JCheckBox( "Intruder", self.tools & ECallbacks.TOOL_INTRUDER != 0) ui_tools_panel.add(self.ui_tool_intruder) ui_tools_panel.add(Box.createRigidArea(Dimension(10, 0))) self.ui_tool_repeater = JCheckBox( "Repeater", self.tools & ECallbacks.TOOL_REPEATER != 0) ui_tools_panel.add(self.ui_tool_repeater) ui_tools_panel.add(Box.createRigidArea(Dimension(10, 0))) self.ui_tool_sequencer = JCheckBox( "Sequencer", self.tools & ECallbacks.TOOL_SEQUENCER != 0) ui_tools_panel.add(self.ui_tool_sequencer) ui_tools_panel.add(Box.createRigidArea(Dimension(10, 0))) self.ui_tool_extender = JCheckBox( "Extender", self.tools & ECallbacks.TOOL_EXTENDER != 0) ui_tools_panel.add(self.ui_tool_extender) ui_panel.add(ui_tools_panel) ui_panel.add(Box.createRigidArea(Dimension(0, 10))) ui_log_line = JPanel() ui_log_line.setLayout(BoxLayout(ui_log_line, BoxLayout.LINE_AXIS)) ui_log_line.setAlignmentX(JPanel.LEFT_ALIGNMENT) ui_debug = JRadioButton("DEBUG", self.log_level == 'DEBUG') ui_log_line.add(ui_debug) ui_log_line.add(Box.createRigidArea(Dimension(10, 0))) ui_info = JRadioButton("INFO", self.log_level == 'INFO') ui_log_line.add(ui_info) ui_log_line.add(Box.createRigidArea(Dimension(10, 0))) ui_warning = JRadioButton("WARNING", self.log_level == 'WARNING') ui_log_line.add(ui_warning) ui_log_line.add(Box.createRigidArea(Dimension(10, 0))) ui_error = JRadioButton("ERROR", self.log_level == 'ERROR') ui_log_line.add(ui_error) ui_log_line.add(Box.createRigidArea(Dimension(10, 0))) ui_critical = JRadioButton( "CRITICAL", self.log_level == 'CRITICAL') ui_log_line.add(ui_critical) ui_log_line.add(Box.createRigidArea(Dimension(10, 0))) ui_panel.add(ui_log_line) ui_panel.add(Box.createRigidArea(Dimension(0, 10))) self.ui_log_level = ButtonGroup() self.ui_log_level.add(ui_debug) self.ui_log_level.add(ui_info) self.ui_log_level.add(ui_warning) self.ui_log_level.add(ui_error) self.ui_log_level.add(ui_critical) ui_buttons_line = JPanel() ui_buttons_line.setLayout( BoxLayout(ui_buttons_line, BoxLayout.LINE_AXIS)) ui_buttons_line.setAlignmentX(JPanel.LEFT_ALIGNMENT) ui_buttons_line.add( JButton("Save config", actionPerformed=self.save_config)) ui_panel.add(ui_buttons_line) return ui_panel
def _add_with_padding(self, component, padding): self.add(component) self.add(Box.createRigidArea(Dimension(0, padding)))
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, 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 __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()
label_panel_location.text = start_file #row13b2.text = icons_file row11b2.text = run_file #os.rename(r'filepath/old_filename.file type',r'file path/NEW file name.file type') row0 = JPanel() row0.setLayout(BoxLayout(row0, BoxLayout.X_AXIS)) txt = JTextField(140) txt.setMaximumSize( txt.getPreferredSize() ); txt.setBorder(BorderFactory.createCompoundBorder( BorderFactory.createLineBorder(Color.red), txt.getBorder())); label_panel_location = JLabel() btnpanelLocation = JButton("Set Panel Location", actionPerformed = btnpanelLocation_action) row0.add(Box.createVerticalGlue()) row0.add(Box.createRigidArea(Dimension(20, 0))) row0.add(btnpanelLocation) row0.add(Box.createRigidArea(Dimension(20, 0))) row0.add(label_panel_location) row0.add(Box.createRigidArea(Dimension(20, 0))) row12 = JPanel() row12.setLayout(BoxLayout(row12, BoxLayout.X_AXIS)) row12b1 = JLabel("Dispatcher System: Modifies panels to produce a running system") row12b1.add( Box.createHorizontalGlue() ); row12b1.setAlignmentX( row12b1.LEFT_ALIGNMENT ) msg = "" row12b2 = JLabel(msg) row12b2.setAlignmentX( row12b1.RIGHT_ALIGNMENT ) row12.add(Box.createVerticalGlue())