def buildSessionCheck(self, state, callbacks): """ Builds the session check portion of the config page """ rules = JPanel() rules.setLayout(None) rules.setMaximumSize(Dimension(self.CONFIG_PAGE_WIDTH, 300)) title = self.getTitle("Session Check", 20, 10) check = self.getButton("Check", 20, 50) check.addActionListener(self.callbacks.checkButtonClicked) resendAll = self.getButton("Resend ALL", 20, 90) resendAll.addActionListener(self.callbacks.resendAllButtonClicked) fuzz = self.getButton("FUZZ", 20, 130) fuzz.addActionListener(self.callbacks.fuzzButtonClicked) textarea = self.getTextArea() state.sessionCheckTextarea = textarea.viewport.view state.sessionCheckTextarea.setText( callbacks.loadExtensionSetting("scopeCheckRequest")) rules.add(title) rules.add(check) rules.add(resendAll) rules.add(fuzz) rules.add(textarea) return rules
def buildScope(self, state, callbacks): """ Builds the scope pane in the configuration page """ scope = JPanel() scope.setLayout(None) scope.setMaximumSize(Dimension(self.CONFIG_PAGE_WIDTH, 300)) title = self.getTitle("Scope Selection", 20, 10) refresh = self.getButton("Refresh", 20, 50) refresh.addActionListener(self.callbacks.refreshButtonClicked) textarea = self.getTextArea() state.scopeTextArea = textarea.viewport.view scopeText = callbacks.loadExtensionSetting("scopes") state.scopeTextArea.setText(scopeText) scope.add(title) scope.add(refresh) scope.add(textarea) if scopeText: refresh.doClick() # refresh automatically to save users one click. return scope
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 buildReplacementRules(self, state, callbacks): """ Builds the replacement rules section in the configuration page """ rules = JPanel() rules.setLayout(None) rules.setMaximumSize(Dimension(self.CONFIG_PAGE_WIDTH, 300)) title = self.getTitle("Replacement Rules", 20, 10) add = self.getButton("Add", 20, 50) add.addActionListener(self.callbacks.addButtonClicked) edit = self.getButton("Edit", 20, 90) edit.addActionListener(self.callbacks.editButtonClicked) delete = self.getButton("Delete", 20, 130) delete.addActionListener(self.callbacks.deleteButtonClicked) table = Table(state.replacementRuleTableModel) tableView = JScrollPane(table) tableView.setBounds(180, 50, 800, 240) rules.add(title) rules.add(add) rules.add(edit) rules.add(delete) rules.add(tableView) try: storedReplacementRules = callbacks.loadExtensionSetting( "replacementRules") if storedReplacementRules: state.replacementRuleTableModel.importJsonRules( storedReplacementRules) else: log("No replacement rules stored.") except (ValueError, KeyError): log("Invalid replacement rules stored. Ignoring.") pass return rules
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 reloadComponent(game,dialog,node): c = None text = node.getAttribute("text") if node.hasAttribute("text") else "" align = int(node.getAttribute("align")) if node.hasAttribute("align") else 0 #Components if node.nodeName=="jpanel": c = JPanel() c.setBackground(Color.BLACK) layout = createLayoutManager(c,node.getAttribute("layout") if node.hasAttribute("layout") else "flow") c.setLayout(layout) c.setOpaque(False) if node.getAttribute("opaque"): c.setOpaque(node.getAttribute("opaque")=="true") if node.getAttribute("background"): if(node.getAttribute("background")=="orange"): c.setBackground(Color.ORANGE) elif(node.getAttribute("background")=="green"): c.setBackground(Color.GREEN) for child in node.childNodes: if child.nodeName!="#text": if node.getAttribute("layout")=="gridbag": c.add(reloadComponent(game,dialog,child),getGridBagConstraints(game,child)) else: c.add(reloadComponent(game,dialog,child)) elif node.nodeName=="jlabel": c = JLabel(text,align) elif node.nodeName=="jbutton": c = JButton(text) if node.hasAttribute("enabled"): c.setEnabled(node.getAttribute("enabled")=="true"); elif node.nodeName=="settingspanel": c = SettingsPanel(game) for g in node.childNodes: if g.nodeName=="group": c.addGroup(int(g.getAttribute("id")),g.getAttribute("label")) for h in g.childNodes: if h.nodeName=="heading": c.addHeading(int(g.getAttribute("id")),h.getAttribute("label")) for s in h.childNodes: if s.nodeName=="setting": #<setting id="1" name="DISPLAY_REAL_WORLD_TIME" type="checkbox" label="Show Real-World Time"></setting> if s.getAttribute("items")!="": c.addSettingWithItems(int(g.getAttribute("id")),int(s.getAttribute("id")),s.getAttribute("label"),s.getAttribute("type"),s.getAttribute("items").split(",")) else: c.addSetting(int(g.getAttribute("id")),int(s.getAttribute("id")),s.getAttribute("label"),s.getAttribute("type")) c.finalizeSettingsPanel() dialog.registerSettingsPanel(int(node.getAttribute("id")),c) elif node.nodeName=="logspanel": c = LogsPanel(game) for g in node.childNodes: if g.nodeName=="group": c.addLog(int(g.getAttribute("id")),g.getAttribute("label")) c.finalizeLogsPanel() dialog.registerLogsPanel(int(node.getAttribute("id")),c) elif node.nodeName=="nglcanvas": c = NGLCanvas(game,int(getCascadingAttribute(game,node,"width")),int(getCascadingAttribute(game,node,"height"))) dialog.registerCanvas(int(node.getAttribute("id")),c) #Layout if node.parentNode.getAttribute("layout")=="absolute": c.setBounds(getBounds(game,node)) elif node.parentNode.getAttribute("layout")=="box-y": c.setAlignmentX(Component.CENTER_ALIGNMENT); if node.hasAttribute("width") and node.hasAttribute("height"): c.setPreferredSize(Dimension(int(getCascadingAttribute(game,node,"width")),int(getCascadingAttribute(game,node,"height")))) if node.hasAttribute("minWidth") and node.hasAttribute("minHeight"): c.setMinimumSize(Dimension(int(node.getAttribute("minWidth")),int(node.getAttribute("minHeight")))) if node.hasAttribute("maxWidth") and node.hasAttribute("maxHeight"): c.setMaximumSize(Dimension(int(node.getAttribute("maxWidth")),int(node.getAttribute("maxHeight")))) elif node.parentNode.getAttribute("layout")=="box-x": c.setAlignmentY(Component.CENTER_ALIGNMENT); if node.hasAttribute("width") and node.hasAttribute("height"): c.setPreferredSize(Dimension(int(getCascadingAttribute(game,node,"width")),int(getCascadingAttribute(game,node,"height")))) if node.hasAttribute("minWidth") and node.hasAttribute("minHeight"): c.setMinimumSize(Dimension(int(node.getAttribute("minWidth")),int(node.getAttribute("minHeight")))) if node.hasAttribute("maxWidth") and node.hasAttribute("maxHeight"): c.setMaximumSize(Dimension(int(node.getAttribute("maxWidth")),int(node.getAttribute("maxHeight")))) if node.nodeName!="nglcanvas" and node.nodeName!="jpanel" and node.nodeName!="settingspanel": addListeners(game,c,node) return c;
display.addReference(amandaRef) modulesRef = DataReferenceImpl("modules") modulesRef.setData(modules) 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())