Exemplo n.º 1
0
    def update_table(self):
        """Updates the table with new data"""

        columns = ["Type", "Action", "Name", "Value"]
        data = []
        for param in self._extender.sm.selected_session.params:
            data.append(param.as_table_row())

        data.append([
            Parameter.type_mapping[Parameter.PARAM_COOKIE],
            Parameter.ACTION_MODIFY, "", ""
        ])
        data_model = DefaultTableModel(data,
                                       columns,
                                       tableChanged=self.tableChanged)
        self.modification_table.setModel(data_model)

        # type combobox
        type_combo = JComboBox(self._types)
        type_column = self.modification_table.getColumnModel().getColumn(0)
        type_column.setCellEditor(DefaultCellEditor(type_combo))
        type_column.setMaxWidth(75)

        # action combobox
        action_combo = JComboBox(self._actions)
        action_column = self.modification_table.getColumnModel().getColumn(1)
        action_column.setCellEditor(DefaultCellEditor(action_combo))
        action_column.setMaxWidth(75)
        action_combo.setSelectedItem("replace")
Exemplo n.º 2
0
    def initParameterColumn(self, table):
        parameterTypes = JComboBox(sorted(PARAMETER_TYPES.keys()))
        parameterTypes.setSelectedItem('PARAM_BODY')
        parameterColumn = table.getColumnModel().getColumn(0)
        parameterColumn.setCellEditor(DefaultCellEditor(parameterTypes))

        whenTypes = JComboBox(['Before', 'After'])
        whenTypes.setSelectedItem('Before')
        whenColumn = table.getColumnModel().getColumn(2)
        whenColumn.setCellEditor(DefaultCellEditor(whenTypes))

        ruleTypes = JComboBox(sorted(RULES.keys()))
        ruleColumn = table.getColumnModel().getColumn(3)
        ruleColumn.setCellEditor(DefaultCellEditor(ruleTypes))
        return
Exemplo n.º 3
0
 def getTableCellEditorComponent(self, table, value, isSelected, row,
                                 column):
     if self.__form == None:
         return DefaultCellEditor.getTableCellEditorComponent(
             self, table, value, isSelected, row, column)
     item = self.__form[row]
     if isinstance(item, MobileFormItemUnknown):
         return DefaultCellEditor.getTableCellEditorComponent(
             self, table, value, isSelected, row, column)
     factory = item.getFactory()
     itemPanel = factory.createPreviewPanel()
     if itemPanel == None:
         return self
     itemPanel.put(item)
     panel = itemPanel.asJComponent()
     table.setRowHeight(row, int(panel.getPreferredSize().getHeight()))
     return panel
Exemplo n.º 4
0
 def stopCellEditing(self):
     try:
         val = Integer.valueOf(self.textfield.getText())
         if not (-1 < val < 65536):
             raise NumberFormatException()
         result = DefaultCellEditor.stopCellEditing(self)
     except:
         self.textfield.setBorder(LineBorder(Color.red))
         result = 0  # false
     return result
Exemplo n.º 5
0
    def create_scanner_pane(self, scanner_pane, issue_name, issue_param):
        scanner_issues = self.get_scanner_issues()
        request_table_pane = scanner_pane.getTopComponent()

        scanner_table_model = ScannerTableModel()
        scanner_table_model.addColumn("Checked")
        scanner_table_model.addColumn("Host")
        scanner_table_model.addColumn("Path")

        # Search all issues for the correct issue. Once found, add it into
        # the scanner table model to be showed in the UI.
        for scanner_issue in scanner_issues:
            is_same_name = scanner_issue.getIssueName() == issue_name
            is_same_param = scanner_issue.getParameter() == issue_param
            is_same_issue = is_same_name and is_same_param

            if is_same_issue:
                scanner_table_model.addRow([
                    False,
                    scanner_issue.getHttpService().getHost(),
                    scanner_issue.getUrl()
                ])

        scanner_table = JTable(scanner_table_model)
        scanner_table.getColumnModel().getColumn(0).setCellEditor(
            DefaultCellEditor(JCheckBox()))
        scanner_table.putClientProperty("terminateEditOnFocusLost", True)
        scanner_table_listener = ScannerTableListener(self, scanner_table,
                                                      issue_name, issue_param)
        scanner_table_model.addTableModelListener(scanner_table_listener)
        scanner_table_list_listener = IssueListener(self, scanner_table,
                                                    scanner_pane, issue_name,
                                                    issue_param)
        scanner_table.getSelectionModel().addListSelectionListener(
            scanner_table_list_listener)

        self.set_scanner_table(scanner_pane, scanner_table)

        request_table_pane.getViewport().setView(scanner_table)
        request_table_pane.revalidate()
        request_table_pane.repaint()
Exemplo n.º 6
0
    def initProfilesTable(self):
        profile_table = JTable()

        self.profile_table_model = self.ProfileTableModel()
        profile_table.setModel(self.profile_table_model)

        cm = profile_table.getColumnModel()
        # Set column widths
        for i in range(0, 4):
            width = self.profile_table_model.column_widths.get(i)
            if width is not None:
                column = cm.getColumn(i)
                column.setPreferredWidth(width)
                column.setMaxWidth(width)

        profile_table.setFillsViewportHeight(True)

        def doAction(event):
            print event

        # Add the actions dropdown
        actionCol = cm.getColumn(3)
        actions = JComboBox()
        actions.addItem("Activate")
        actions.addItem("Unactivate")
        actions.addItem("Edit")
        actions.addItem("Export to Script")
        actions.addItem("Delete")
        actionCol.setCellEditor(DefaultCellEditor(actions))
        self.profile_table_model.actions_combo = actions

        renderer = self.ComboBoxTableCellRenderer()
        actionCol.setCellRenderer(renderer)

        actions.addActionListener(self.ComboActionListener(self))

        return profile_table
Exemplo n.º 7
0
 def __init__(self):
     DefaultCellEditor.__init__(self, JTextField())
     self.spinner = JSpinner(SpinnerListModel(choices))
     self.spinner.setEditor(JSpinner.ListEditor(self.spinner))
Exemplo n.º 8
0
 def __init__(self):
     DefaultCellEditor.__init__(self, JTextField())
     values = 'Bacon,Eggs,Spam'.split(',')
     self.spinner = JSpinner(SpinnerListModel(values))
     self.spinner.setEditor(JSpinner.ListEditor(self.spinner))
Exemplo n.º 9
0
 def __init__(self):
     self.comboBox = JComboBox(choices)
     DefaultCellEditor.__init__(self, self.comboBox)
Exemplo n.º 10
0
 def __init__(self):
     DefaultCellEditor.__init__(self, JTextField())
     self.__form = None
Exemplo n.º 11
0
 def __init__(self):
     choices = 'The,quick,brown,fox,jumped'.split(',')
     choices.extend('over,the,lazy,spam'.split(','))
     self.comboBox = JComboBox(choices)
     DefaultCellEditor.__init__(self, self.comboBox)
Exemplo n.º 12
0
 def __init__(self):
     self.textfield = JTextField(horizontalAlignment=JTextField.RIGHT)
     DefaultCellEditor.__init__(self, self.textfield)