def addLine(self, objectID, category, text): """ Add a new panel containing the text corresponding to one line in the ATF file. This panel will show the line type (ruling, comment, text, translation...), followed by the line content and a group of icons to add, edit or remove the line. """ linePanel = JPanel() linePanel.setLayout(BorderLayout()) label = JLabel(category) combo = JComboBox(text) combo.setEditable(True) combo.setPreferredSize(Dimension(500, 20)) combo.setSize(combo.getPreferredSize()) combo.setMinimumSize(combo.getPreferredSize()) combo.setMaximumSize(combo.getPreferredSize()) buttonsPanel = JPanel() addButton = JButton("Add") editButton = JButton("Edit") deleteButton = JButton("Delete") buttonsPanel.add(addButton) buttonsPanel.add(editButton) buttonsPanel.add(deleteButton) linePanel.add(label, BorderLayout.WEST) linePanel.add(combo, BorderLayout.CENTER) linePanel.add(buttonsPanel, BorderLayout.EAST) # Add metadataPanel to object tab in main panel self.objectTabs[objectID].add(linePanel)
def addDetails(self): jf0 = JFrame() jf0.setTitle("Add Issue"); jf0.setLayout(None); txtEnterIssue = JTextField(); txtEnterIssue.setName("Enter Issue Name"); txtEnterIssue.setToolTipText("Enter Issue Name Here"); txtEnterIssue.setBounds(182, 58, 473, 40); jf0.add(txtEnterIssue); txtEnterIssue.setColumns(10); btnNewButton = JButton("Add"); btnNewButton.setBounds(322, 178, 139, 41); jf0.add(btnNewButton); comboBox = JComboBox(); comboBox.setMaximumRowCount(20); comboBox.setEditable(True); comboBox.setToolTipText("Objective Name"); comboBox.setBounds(182, 125, 473, 40); jf0.add(comboBox); lblNewLabel = JLabel("Issue Name Here"); lblNewLabel.setFont(Font("Tahoma", Font.PLAIN, 16)); lblNewLabel.setBounds(25, 58, 130, 40); jf0.add(lblNewLabel); lblNewLabel_1 = JLabel("Objective Name"); lblNewLabel_1.setFont(Font("Tahoma", Font.PLAIN, 16)); lblNewLabel_1.setBounds(25, 125, 130, 40); jf0.add(lblNewLabel_1); jf0.setVisible(True) jf0.setBounds(400, 300, 700, 300) jf0.EXIT_ON_CLOSE txtEnterIssue.addKeyListener(self)
def gui(self): file_field = JTextField(self.dsm2file,15) load_btn = JButton('Load input ') chan_box = JComboBox() chan_box.setEditable(1) do_btn = JButton('Plot channel') choices = [JRadioButton('XSection'), JRadioButton('Area'), JRadioButton('Width'), JRadioButton('Perimeter'), JRadioButton('Rh'), JRadioButton('Xc'), JRadioButton('Zc')] #bg = ButtonGroup() #for choice in choices: bg.add(choice) class load_listener(ActionListener): def __init__(self,file_field,load_btn, chan_box,do_btn, choices): self.file_field = file_field self.load_btn = load_btn self.chan_box = chan_box self.do_btn = do_btn self.do_btn.setEnabled(0) self.load_btn.addActionListener(self) self.do_btn.addActionListener(self) self.choices=choices def actionPerformed(self,evt): if evt.getSource() == self.load_btn : self.ig = IrregGeom(self.file_field.getText()) import javax.swing md = javax.swing.DefaultComboBoxModel(self.ig.getChanList()) self.chan_box.setModel(md) self.do_btn.setEnabled(1) elif evt.getSource() == self.do_btn : if self.ig: for choice in self.choices: if choice.isSelected(): self.ig.plot(self.chan_box.getSelectedItem(),choice.getText()) ll = load_listener(file_field, load_btn, chan_box, do_btn,choices) p1 = JPanel() p1.setLayout(BorderLayout()) p1.add(file_field,BorderLayout.CENTER) p1.add(load_btn,BorderLayout.EAST) p2 = JPanel() p2.setLayout(BorderLayout()) p2.add(chan_box,BorderLayout.CENTER) p2.add(do_btn,BorderLayout.EAST) p3 = JPanel() p3.setLayout(GridLayout(1,2)) p3.add(choices[0]); p3.add(choices[1]) p4 = JPanel() p4.setLayout(GridLayout(1,2)) p4.add(choices[2]); p4.add(choices[3]) p5 = JPanel() p5.setLayout(GridLayout(1,2)) p5.add(choices[4]); p5.add(choices[5]) p6 = JPanel() p6.setLayout(GridLayout(1,2)) p6.add(choices[6]) # mp = JPanel() mp.setLayout(GridLayout(6,1)) mp.add(p1) mp.add(p2) mp.add(p3) mp.add(p4) mp.add(p5) mp.add(p6) return mp
class NewAtfView(JDialog): ''' Prompt user to choose some options to create a template for a new ATF file. ''' def __init__(self, controller, projects, languages, protocols): self.modalityType = Dialog.ModalityType.APPLICATION_MODAL self.controller = controller self.projects = projects self.languages = languages self.protocols = protocols self.cancelled = False self.springLayout = SpringLayout() self.pane = self.getContentPane() def display(self): ''' Displays window. ''' self.build() self.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE) self.setResizable(False) self.setTitle("New ATF template") self.pack() self.setLocationRelativeTo(None) self.visible = 1 def build(self): ''' Puts all the window components together in the JFrame ''' layout = BoxLayout(self.getContentPane(), BoxLayout.Y_AXIS) self.setLayout(layout) # Create all necessary panels ampersand_panel = self.build_ampersand_row() project_panel = self.build_projects_row() language_panel = self.build_language_row() buttons_panel = self.build_buttons_row() # Add panels to main JFrame self.add(ampersand_panel) self.add(project_panel) self.add(language_panel) self.add(buttons_panel) def build_ampersand_row(self): ''' Builds the &-line row. ''' # Build own panel with SpringLayout. panel = JPanel() layout = SpringLayout() panel.setLayout(layout) # Create necessary components and add them to panel. ampersand_label = JLabel("CDLI's ID: ") self.left_field = JTextField('&') equals_label = JLabel('=') self.right_field = JTextField() tooltip_text = ("<html><body>This is the ID and text's designation " "according to<br/>the CDLI catalog. If your text is " "not yet in the<br/>catalog, please email " "[email protected] to get<br/>an ID and designation.") help_label = self.build_help_label(tooltip_text) panel.add(ampersand_label) panel.add(self.left_field) panel.add(equals_label) panel.add(self.right_field) panel.add(help_label) # Set up constraints to tell panel how to position components. layout.putConstraint(SpringLayout.WEST, ampersand_label, 20, SpringLayout.WEST, panel) layout.putConstraint(SpringLayout.NORTH, ampersand_label, 23, SpringLayout.NORTH, panel) layout.putConstraint(SpringLayout.WEST, self.left_field, 90, SpringLayout.WEST, panel) layout.putConstraint(SpringLayout.NORTH, self.left_field, 20, SpringLayout.NORTH, panel) layout.putConstraint(SpringLayout.WEST, equals_label, 5, SpringLayout.EAST, self.left_field) layout.putConstraint(SpringLayout.NORTH, equals_label, 23, SpringLayout.NORTH, panel) layout.putConstraint(SpringLayout.WEST, self.right_field, 5, SpringLayout.EAST, equals_label) layout.putConstraint(SpringLayout.NORTH, self.right_field, 20, SpringLayout.NORTH, panel) layout.putConstraint(SpringLayout.WEST, help_label, 5, SpringLayout.EAST, self.right_field) layout.putConstraint(SpringLayout.NORTH, help_label, 23, SpringLayout.NORTH, panel) layout.putConstraint(SpringLayout.EAST, panel, 15, SpringLayout.EAST, help_label) layout.putConstraint(SpringLayout.SOUTH, panel, 10, SpringLayout.SOUTH, help_label) # Add this to NewAtf JFrame return panel def build_projects_row(self): ''' Builds the projects row. ''' # Build own panel with SpringLayout. panel = JPanel() layout = SpringLayout() panel.setLayout(layout) # Create necessary components and add them to panel. project_label = JLabel('Project: ') self.right_combo = JComboBox() self.right_combo.setEditable(True) def create_project_list(): ''' Prepares list of projects and subprojects ordered with the default one first. ''' default_project = self.projects['default'][0].split('/')[0] if '/' in self.projects['default']: default_subproject = self.projects['default'].split('/')[1] else: default_subproject = '' projects = [default_project] subprojects = [default_subproject] # User created projects might not be in default dictionary for project in self.projects.keys(): if (project != default_project and project != 'default'): projects.append(project) # Default project might not have subproject if default_project in self.projects.keys(): if default_subproject: for subproject in self.projects[default_project]: if (subproject != default_subproject): subprojects.append(subproject) return projects, subprojects self.left_combo = JComboBox(create_project_list()[0]) # Make left combo keep size no matter how long project names are self.left_combo.setPreferredSize(Dimension(125, 30)) self.left_combo.setMinimumSize(self.left_combo.getPreferredSize()) self.left_combo.setMaximumSize(self.left_combo.getPreferredSize()) self.left_combo.setSize(self.left_combo.getPreferredSize()) self.right_combo = JComboBox(create_project_list()[1]) # Prevent right combo to change sizes dynamically self.right_combo.setPreferredSize(Dimension(100, 30)) self.right_combo.setMinimumSize(self.left_combo.getPreferredSize()) self.right_combo.setMaximumSize(self.left_combo.getPreferredSize()) self.right_combo.setSize(self.left_combo.getPreferredSize()) action_listener = ComboActionListener(self.right_combo, self.projects) self.left_combo.addActionListener(action_listener) self.left_combo.setEditable(True) self.right_combo.setEditable(True) slash_label = JLabel('/') tooltip_text = ("<html><body>Choose project from list or insert a new " "one.<br/>You can leave the right-hand field blank." "</body><html>") help_label = self.build_help_label(tooltip_text) panel.add(project_label) panel.add(self.left_combo) panel.add(slash_label) panel.add(self.right_combo) panel.add(help_label) # Set up constraints to tell panel how to position components. layout.putConstraint(SpringLayout.WEST, project_label, 15, SpringLayout.WEST, panel) layout.putConstraint(SpringLayout.NORTH, project_label, 18, SpringLayout.NORTH, panel) layout.putConstraint(SpringLayout.WEST, self.left_combo, 90, SpringLayout.WEST, panel) layout.putConstraint(SpringLayout.NORTH, self.left_combo, 15, SpringLayout.NORTH, panel) layout.putConstraint(SpringLayout.WEST, slash_label, 5, SpringLayout.EAST, self.left_combo) layout.putConstraint(SpringLayout.NORTH, slash_label, 18, SpringLayout.NORTH, panel) layout.putConstraint(SpringLayout.WEST, self.right_combo, 5, SpringLayout.EAST, slash_label) layout.putConstraint(SpringLayout.NORTH, self.right_combo, 15, SpringLayout.NORTH, panel) layout.putConstraint(SpringLayout.WEST, help_label, 5, SpringLayout.EAST, self.right_combo) layout.putConstraint(SpringLayout.NORTH, help_label, 18, SpringLayout.NORTH, panel) layout.putConstraint(SpringLayout.EAST, panel, 15, SpringLayout.EAST, help_label) layout.putConstraint(SpringLayout.SOUTH, panel, 10, SpringLayout.SOUTH, help_label) # Add this to NewAtf JFrame return panel def build_language_row(self): ''' Builds the language row. ''' # Build own panel with SpringLayout. panel = JPanel() layout = SpringLayout() panel.setLayout(layout) # Get language list from settings.yaml, removing the default one from # the list languages = self.languages.keys() languages.remove('default') # Create necessary components and add them to panel. language_label = JLabel('Language: ') self.language_combo = JComboBox(languages) # Set selected language to default self.language_combo.setSelectedItem(self.languages['default']) tooltip_text = "Choose a language from the dropdown menu." help_label = self.build_help_label(tooltip_text) panel.add(language_label) panel.add(self.language_combo) panel.add(help_label) # Set up constraints to tell panel how to position components. layout.putConstraint(SpringLayout.WEST, language_label, 15, SpringLayout.WEST, panel) layout.putConstraint(SpringLayout.NORTH, language_label, 18, SpringLayout.NORTH, panel) layout.putConstraint(SpringLayout.WEST, self.language_combo, 90, SpringLayout.WEST, panel) layout.putConstraint(SpringLayout.NORTH, self.language_combo, 15, SpringLayout.NORTH, panel) layout.putConstraint(SpringLayout.WEST, help_label, 5, SpringLayout.EAST, self.language_combo) layout.putConstraint(SpringLayout.NORTH, help_label, 18, SpringLayout.NORTH, panel) layout.putConstraint(SpringLayout.EAST, panel, 15, SpringLayout.EAST, help_label) layout.putConstraint(SpringLayout.SOUTH, panel, 10, SpringLayout.SOUTH, help_label) # Add this to NewAtf JFrame return panel def build_buttons_row(self): ''' Add OK/Cancel/Blank buttons. ''' # Build own panel with SpringLayout. panel = JPanel() layout = SpringLayout() panel.setLayout(layout) # Create necessary components and add them to panel. create_button = JButton('Create template', actionPerformed=self.create_template) leave_button = JButton('Leave blank', actionPerformed=self.blank) cancel_button = JButton('Cancel', actionPerformed=self.cancel) panel.add(create_button) panel.add(leave_button) panel.add(cancel_button) # Set up constraints to tell panel how to position components. layout.putConstraint(SpringLayout.WEST, create_button, 15, SpringLayout.WEST, panel) layout.putConstraint(SpringLayout.NORTH, create_button, 15, SpringLayout.NORTH, panel) layout.putConstraint(SpringLayout.WEST, leave_button, 5, SpringLayout.EAST, create_button) layout.putConstraint(SpringLayout.NORTH, leave_button, 15, SpringLayout.NORTH, panel) layout.putConstraint(SpringLayout.WEST, cancel_button, 5, SpringLayout.EAST, leave_button) layout.putConstraint(SpringLayout.NORTH, cancel_button, 15, SpringLayout.NORTH, panel) layout.putConstraint(SpringLayout.EAST, panel, 15, SpringLayout.EAST, cancel_button) layout.putConstraint(SpringLayout.SOUTH, panel, 10, SpringLayout.SOUTH, cancel_button) # Add this to NewAtf JFrame return panel def build_help_label(self, tooltip_text): icon = ImageIcon(find_image_resource('smallhelp')) label = JLabel() label.setIcon(icon) label.setToolTipText(tooltip_text) return label def cancel(self, event): self.cancelled = True self.dispose() def blank(self, event): self.controller.show_template() self.dispose() def create_template(self, event): ''' Put together user selected elements of the template following ATF file format. ''' # &-line # E.g. &X001001 = JCS 48, 089 and_line = "{} = {}".format(self.left_field.getText().encode('utf-8'), self.right_field.getText().encode('utf-8')) # Project line # E.g. #project: cams/gkab # E.g. #project: rimanum project_line = "#project: {}".format( self.left_combo.getSelectedItem().encode('utf-8')) if self.right_combo.getSelectedItem(): project_line = "{}/{}".format( project_line, self.right_combo.getSelectedItem().encode('utf-8')) # Language line # E.g. #atf: lang akk-x-stdbab language = self.language_combo.getSelectedItem() language_code = self.languages[language] # Protocol line/s # E.g. #atf: use unicode protocols = '' for protocol in self.protocols: protocols += '#atf: use {}\n'.format(protocol) # Put together all lines to create the template and show in ATF area self.controller.template = ('{}\n' '{}\n' '#atf: lang {}\n' '{}\n'.format(and_line, project_line, language_code, protocols)) self.controller.show_template() self.dispose()
class NewAtfView(JDialog): ''' Prompt user to choose some options to create a template for a new ATF file. ''' def __init__(self, controller, projects, languages, protocols): self.modalityType = Dialog.ModalityType.APPLICATION_MODAL self.controller = controller self.projects = projects self.languages = languages self.protocols = protocols self.cancelled = False self.springLayout = SpringLayout() self.pane = self.getContentPane() def display(self): ''' Displays window. ''' self.build() self.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE) self.setResizable(False) self.setTitle("New ATF template") self.pack() self.setLocationRelativeTo(None) self.visible = 1 def build(self): ''' Puts all the window components together in the JFrame ''' layout = BoxLayout(self.getContentPane(), BoxLayout.Y_AXIS) self.setLayout(layout) # Create all necessary panels ampersand_panel = self.build_ampersand_row() project_panel = self.build_projects_row() language_panel = self.build_language_row() buttons_panel = self.build_buttons_row() # Add panels to main JFrame self.add(ampersand_panel) self.add(project_panel) self.add(language_panel) self.add(buttons_panel) def build_ampersand_row(self): ''' Builds the &-line row. ''' # Build own panel with SpringLayout. panel = JPanel() layout = SpringLayout() panel.setLayout(layout) # Create necessary components and add them to panel. ampersand_label = JLabel("CDLI's ID: ") self.left_field = JTextField('&') equals_label = JLabel('=') self.right_field = JTextField() tooltip_text = ("<html><body>This is the ID and text's designation " "according to<br/>the CDLI catalog. If your text is " "not yet in the<br/>catalog, please email " "[email protected] to get<br/>an ID and designation." ) help_label = self.build_help_label(tooltip_text) panel.add(ampersand_label) panel.add(self.left_field) panel.add(equals_label) panel.add(self.right_field) panel.add(help_label) # Set up constraints to tell panel how to position components. layout.putConstraint(SpringLayout.WEST, ampersand_label, 20, SpringLayout.WEST, panel) layout.putConstraint(SpringLayout.NORTH, ampersand_label, 23, SpringLayout.NORTH, panel) layout.putConstraint(SpringLayout.WEST, self.left_field, 90, SpringLayout.WEST, panel) layout.putConstraint(SpringLayout.NORTH, self.left_field, 20, SpringLayout.NORTH, panel) layout.putConstraint(SpringLayout.WEST, equals_label, 5, SpringLayout.EAST, self.left_field) layout.putConstraint(SpringLayout.NORTH, equals_label, 23, SpringLayout.NORTH, panel) layout.putConstraint(SpringLayout.WEST, self.right_field, 5, SpringLayout.EAST, equals_label) layout.putConstraint(SpringLayout.NORTH, self.right_field, 20, SpringLayout.NORTH, panel) layout.putConstraint(SpringLayout.WEST, help_label, 5, SpringLayout.EAST, self.right_field) layout.putConstraint(SpringLayout.NORTH, help_label, 23, SpringLayout.NORTH, panel) layout.putConstraint(SpringLayout.EAST, panel, 15, SpringLayout.EAST, help_label) layout.putConstraint(SpringLayout.SOUTH, panel, 10, SpringLayout.SOUTH, help_label) # Add this to NewAtf JFrame return panel def build_projects_row(self): ''' Builds the projects row. ''' # Build own panel with SpringLayout. panel = JPanel() layout = SpringLayout() panel.setLayout(layout) # Create necessary components and add them to panel. project_label = JLabel('Project: ') self.right_combo = JComboBox() self.right_combo.setEditable(True) def create_project_list(): ''' Prepares list of projects and subprojects ordered with the default one first. ''' default_project = self.projects['default'][0].split('/')[0] if '/' in self.projects['default']: default_subproject = self.projects['default'].split('/')[1] else: default_subproject = '' projects = [default_project] subprojects = [default_subproject] # User created projects might not be in default dictionary for project in self.projects.keys(): if (project != default_project and project != 'default'): projects.append(project) # Default project might not have subproject if default_project in self.projects.keys(): if default_subproject: for subproject in self.projects[default_project]: if (subproject != default_subproject): subprojects.append(subproject) return projects, subprojects self.left_combo = JComboBox(create_project_list()[0]) # Make left combo keep size no matter how long project names are self.left_combo.setPreferredSize(Dimension(125, 30)) self.left_combo.setMinimumSize(self.left_combo.getPreferredSize()) self.left_combo.setMaximumSize(self.left_combo.getPreferredSize()) self.left_combo.setSize(self.left_combo.getPreferredSize()) self.right_combo = JComboBox(create_project_list()[1]) # Prevent right combo to change sizes dynamically self.right_combo.setPreferredSize(Dimension(100, 30)) self.right_combo.setMinimumSize(self.left_combo.getPreferredSize()) self.right_combo.setMaximumSize(self.left_combo.getPreferredSize()) self.right_combo.setSize(self.left_combo.getPreferredSize()) action_listener = ComboActionListener(self.right_combo, self.projects) self.left_combo.addActionListener(action_listener) self.left_combo.setEditable(True) self.right_combo.setEditable(True) slash_label = JLabel('/') tooltip_text = ("<html><body>Choose project from list or insert a new " "one.<br/>You can leave the right-hand field blank." "</body><html>") help_label = self.build_help_label(tooltip_text) panel.add(project_label) panel.add(self.left_combo) panel.add(slash_label) panel.add(self.right_combo) panel.add(help_label) # Set up constraints to tell panel how to position components. layout.putConstraint(SpringLayout.WEST, project_label, 15, SpringLayout.WEST, panel) layout.putConstraint(SpringLayout.NORTH, project_label, 18, SpringLayout.NORTH, panel) layout.putConstraint(SpringLayout.WEST, self.left_combo, 90, SpringLayout.WEST, panel) layout.putConstraint(SpringLayout.NORTH, self.left_combo, 15, SpringLayout.NORTH, panel) layout.putConstraint(SpringLayout.WEST, slash_label, 5, SpringLayout.EAST, self.left_combo) layout.putConstraint(SpringLayout.NORTH, slash_label, 18, SpringLayout.NORTH, panel) layout.putConstraint(SpringLayout.WEST, self.right_combo, 5, SpringLayout.EAST, slash_label) layout.putConstraint(SpringLayout.NORTH, self.right_combo, 15, SpringLayout.NORTH, panel) layout.putConstraint(SpringLayout.WEST, help_label, 5, SpringLayout.EAST, self.right_combo) layout.putConstraint(SpringLayout.NORTH, help_label, 18, SpringLayout.NORTH, panel) layout.putConstraint(SpringLayout.EAST, panel, 15, SpringLayout.EAST, help_label) layout.putConstraint(SpringLayout.SOUTH, panel, 10, SpringLayout.SOUTH, help_label) # Add this to NewAtf JFrame return panel def build_language_row(self): ''' Builds the language row. ''' # Build own panel with SpringLayout. panel = JPanel() layout = SpringLayout() panel.setLayout(layout) # Get language list from settings.yaml, removing the default one from # the list languages = self.languages.keys() languages.remove('default') # Create necessary components and add them to panel. language_label = JLabel('Language: ') self.language_combo = JComboBox(languages) # Set selected language to default self.language_combo.setSelectedItem(self.languages['default']) tooltip_text = "Choose a language from the dropdown menu." help_label = self.build_help_label(tooltip_text) panel.add(language_label) panel.add(self.language_combo) panel.add(help_label) # Set up constraints to tell panel how to position components. layout.putConstraint(SpringLayout.WEST, language_label, 15, SpringLayout.WEST, panel) layout.putConstraint(SpringLayout.NORTH, language_label, 18, SpringLayout.NORTH, panel) layout.putConstraint(SpringLayout.WEST, self.language_combo, 90, SpringLayout.WEST, panel) layout.putConstraint(SpringLayout.NORTH, self.language_combo, 15, SpringLayout.NORTH, panel) layout.putConstraint(SpringLayout.WEST, help_label, 5, SpringLayout.EAST, self.language_combo) layout.putConstraint(SpringLayout.NORTH, help_label, 18, SpringLayout.NORTH, panel) layout.putConstraint(SpringLayout.EAST, panel, 15, SpringLayout.EAST, help_label) layout.putConstraint(SpringLayout.SOUTH, panel, 10, SpringLayout.SOUTH, help_label) # Add this to NewAtf JFrame return panel def build_buttons_row(self): ''' Add OK/Cancel/Blank buttons. ''' # Build own panel with SpringLayout. panel = JPanel() layout = SpringLayout() panel.setLayout(layout) # Create necessary components and add them to panel. create_button = JButton('Create template', actionPerformed=self.create_template) leave_button = JButton('Leave blank', actionPerformed=self.blank) cancel_button = JButton('Cancel', actionPerformed=self.cancel) panel.add(create_button) panel.add(leave_button) panel.add(cancel_button) # Set up constraints to tell panel how to position components. layout.putConstraint(SpringLayout.WEST, create_button, 15, SpringLayout.WEST, panel) layout.putConstraint(SpringLayout.NORTH, create_button, 15, SpringLayout.NORTH, panel) layout.putConstraint(SpringLayout.WEST, leave_button, 5, SpringLayout.EAST, create_button) layout.putConstraint(SpringLayout.NORTH, leave_button, 15, SpringLayout.NORTH, panel) layout.putConstraint(SpringLayout.WEST, cancel_button, 5, SpringLayout.EAST, leave_button) layout.putConstraint(SpringLayout.NORTH, cancel_button, 15, SpringLayout.NORTH, panel) layout.putConstraint(SpringLayout.EAST, panel, 15, SpringLayout.EAST, cancel_button) layout.putConstraint(SpringLayout.SOUTH, panel, 10, SpringLayout.SOUTH, cancel_button) # Add this to NewAtf JFrame return panel def build_help_label(self, tooltip_text): icon = ImageIcon(find_image_resource('smallhelp')) label = JLabel() label.setIcon(icon) label.setToolTipText(tooltip_text) return label def cancel(self, event): self.cancelled = True self.dispose() def blank(self, event): self.controller.show_template() self.dispose() def create_template(self, event): ''' Put together user selected elements of the template following ATF file format. ''' # &-line # E.g. &X001001 = JCS 48, 089 and_line = "{} = {}".format(self.left_field.getText().encode('utf-8'), self.right_field.getText().encode('utf-8')) # Project line # E.g. #project: cams/gkab # E.g. #project: rimanum project_line = "#project: {}".format( self.left_combo.getSelectedItem().encode('utf-8')) if self.right_combo.getSelectedItem(): project_line = "{}/{}".format( project_line, self.right_combo.getSelectedItem().encode('utf-8')) # Language line # E.g. #atf: lang akk-x-stdbab language = self.language_combo.getSelectedItem() language_code = self.languages[language] # Protocol line/s # E.g. #atf: use unicode protocols = '' for protocol in self.protocols: protocols += '#atf: use {}\n'.format(protocol) # Put together all lines to create the template and show in ATF area self.controller.template = ('{}\n' '{}\n' '#atf: lang {}\n' '{}\n'.format(and_line, project_line, language_code, protocols) ) self.controller.show_template() self.dispose()
class GUI(ITab, ActionListener, KeyAdapter): def __init__(self): return def getTabCaption(self): return "BurpExtension" def getUiComponent(self): return self.UI() def UI(self): self.val="" self.tabbedPane = JTabbedPane(JTabbedPane.TOP) self.panel = JPanel() self.tabbedPane.addTab("App Details", None, self.panel, None) # Details of app currently under pentest would be pulled into here through API self.panel_1 = JPanel() self.tabbedPane.addTab("Results", None, self.panel_1, None) # passed results would go inside this and connected to reporting system via API self.panel_2 = JPanel() self.tabbedPane.addTab("Failed Cases", None, self.panel_2, None) #list of failed tests would go inside this self.textField = JTextField() self.textField.setBounds(12, 13, 207, 39) self.panel.add(self.textField) self.textField.setColumns(10) self.comboBox = JComboBox() self.comboBox.setEditable(True) self.comboBox.addItem("Default") self.comboBox.addItem("High") self.comboBox.addItem("Low") self.comboBox.setBounds(46, 65, 130, 28) self.comboBox.addActionListener(self) self.panel.add(self.comboBox) self.btnNewButton = JButton("Submit") self.btnNewButton.setBounds(60, 125, 97, 25) self.panel.add(self.btnNewButton) editorPane = JEditorPane(); editorPane.setBounds(12, 35, 1000, 800); self.panel_2.add(editorPane); self.panel_2.setLayout(BorderLayout()) return self.tabbedPane def getAppRating(self): sys.stdout.write(str(self.val)) return str(self.val) def actionPerformed(self, e): if(e.getSource()==self.comboBox): self.val = self.comboBox.getSelectedItem() else: self.addDetails() def addDetails(self): jf0 = JFrame() jf0.setTitle("Add Issue"); jf0.setLayout(None); txtEnterIssue = JTextField(); txtEnterIssue.setName("Enter Issue Name"); txtEnterIssue.setToolTipText("Enter Issue Name Here"); txtEnterIssue.setBounds(182, 58, 473, 40); jf0.add(txtEnterIssue); txtEnterIssue.setColumns(10); btnNewButton = JButton("Add"); btnNewButton.setBounds(322, 178, 139, 41); jf0.add(btnNewButton); comboBox = JComboBox(); comboBox.setMaximumRowCount(20); comboBox.setEditable(True); comboBox.setToolTipText("Objective Name"); comboBox.setBounds(182, 125, 473, 40); jf0.add(comboBox); lblNewLabel = JLabel("Issue Name Here"); lblNewLabel.setFont(Font("Tahoma", Font.PLAIN, 16)); lblNewLabel.setBounds(25, 58, 130, 40); jf0.add(lblNewLabel); lblNewLabel_1 = JLabel("Objective Name"); lblNewLabel_1.setFont(Font("Tahoma", Font.PLAIN, 16)); lblNewLabel_1.setBounds(25, 125, 130, 40); jf0.add(lblNewLabel_1); jf0.setVisible(True) jf0.setBounds(400, 300, 700, 300) jf0.EXIT_ON_CLOSE txtEnterIssue.addKeyListener(self) def keyPressed(self, e): self.search_string.__add__(self.search_string) self.jtf1.setText(self.search_string) sys.stdout.write(self.search_string)