Search in sources :

Example 1 with JXPanel

use of org.jdesktop.swingx.JXPanel in project jgnash by ccavanaugh.

the class AccountRowFooterPanel method buildFooter.

private JComponent buildFooter() {
    FormLayout layout = new FormLayout("d:g", "d");
    DefaultFormBuilder builder = new DefaultFormBuilder(layout, new JXPanel());
    NumberFormat format = CommodityFormat.getFullNumberFormat(resultsModel.getBaseCurrency());
    footerTable = new BudgetResultsTable(new FooterModel(), format);
    footerTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    footerTable.setFocusable(false);
    footerTable.setCellSelectionEnabled(false);
    builder.add(footerTable, CC.xy(1, 1));
    builder.border(ShadowBorder.getCompondShadowBorder());
    return builder.getPanel();
}
Also used : FormLayout(com.jgoodies.forms.layout.FormLayout) DefaultFormBuilder(com.jgoodies.forms.builder.DefaultFormBuilder) JXPanel(org.jdesktop.swingx.JXPanel) NumberFormat(java.text.NumberFormat)

Example 2 with JXPanel

use of org.jdesktop.swingx.JXPanel in project zaproxy by zaproxy.

the class AlertViewPanel method getAlertDisplay.

private JPanel getAlertDisplay() {
    if (alertDisplay == null) {
        alertDisplay = new JXPanel();
        alertDisplay.setLayout(new GridBagLayout());
        alertDisplay.setScrollableHeightHint(ScrollableSizeHint.NONE);
        alertDisplay.setName("alertDisplay");
        // Create the labels
        alertEditName = new JComboBox<>();
        alertEditName.setEditable(true);
        nameListModel = new DefaultComboBoxModel<>();
        List<String> allVulns = getAllVulnerabilityNames();
        // Default to blank
        nameListModel.addElement("");
        for (String vuln : allVulns) {
            nameListModel.addElement(vuln);
        }
        alertEditName.setModel(nameListModel);
        alertEditName.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                if ("comboBoxChanged".equals(e.getActionCommand())) {
                    Vulnerability v = getVulnerability((String) alertEditName.getSelectedItem());
                    if (v != null) {
                        if (v.getDescription() != null && v.getDescription().length() > 0) {
                            setAlertDescription(v.getDescription());
                        }
                        if (v.getSolution() != null && v.getSolution().length() > 0) {
                            setAlertSolution(v.getSolution());
                        }
                        if (v.getReferences() != null) {
                            StringBuilder sb = new StringBuilder();
                            for (String ref : v.getReferences()) {
                                sb.append(ref);
                                sb.append('\n');
                            }
                            setAlertReference(sb.toString());
                        }
                        alertEditWascId.setValue(v.getWascId());
                    }
                }
            }
        });
        alertEditRisk = new JComboBox<>(Alert.MSG_RISK);
        alertEditConfidence = new JComboBox<>(Alert.MSG_CONFIDENCE);
        alertEditConfidence.setSelectedItem(Alert.MSG_CONFIDENCE[Alert.CONFIDENCE_MEDIUM]);
        alertEditAttack = new ZapTextField();
        paramListModel = new DefaultComboBoxModel<>();
        // Default is empty so user can type anything in
        paramListModel.addElement("");
        alertEditParam = new JComboBox<>();
        alertEditParam.setModel(paramListModel);
        alertEditParam.setEditable(true);
        alertEditEvidence = new ZapTextField();
        alertEditCweId = new ZapNumberSpinner();
        if (alertEditCweId.getEditor() instanceof JSpinner.DefaultEditor) {
            ((JSpinner.DefaultEditor) alertEditCweId.getEditor()).getTextField().setHorizontalAlignment(JTextField.LEFT);
        }
        alertEditWascId = new ZapNumberSpinner();
        if (alertEditWascId.getEditor() instanceof JSpinner.DefaultEditor) {
            ((JSpinner.DefaultEditor) alertEditWascId.getEditor()).getTextField().setHorizontalAlignment(JTextField.LEFT);
        }
        // Read only ones
        alertName = new ZapLabel();
        alertName.setFont(FontUtils.getFont(Font.BOLD));
        alertName.setLineWrap(true);
        alertRisk = new JLabel();
        alertConfidence = new JLabel();
        alertParam = new ZapLabel();
        alertParam.setLineWrap(true);
        alertAttack = new ZapLabel();
        alertAttack.setLineWrap(true);
        alertEvidence = new ZapLabel();
        alertEvidence.setLineWrap(true);
        alertCweId = new ZapLabel();
        alertWascId = new ZapLabel();
        alertSource = new ZapLabel();
        alertSource.setLineWrap(true);
        alertUrl = new ZapLabel();
        alertUrl.setLineWrap(true);
        alertDescription = createZapTextArea();
        JScrollPane descSp = createJScrollPane(Constant.messages.getString("alert.label.desc"));
        descSp.setViewportView(alertDescription);
        alertDescription.addKeyListener(new KeyAdapter() {

            // Change tab key to transfer focus to the next element
            @Override
            public void keyPressed(java.awt.event.KeyEvent evt) {
                if (evt.getKeyCode() == KeyEvent.VK_TAB) {
                    alertDescription.transferFocus();
                }
            }
        });
        alertOtherInfo = createZapTextArea();
        JScrollPane otherSp = createJScrollPane(Constant.messages.getString("alert.label.other"));
        otherSp.setViewportView(alertOtherInfo);
        alertOtherInfo.addKeyListener(new KeyAdapter() {

            // Change tab key to transfer focus to the next element
            @Override
            public void keyPressed(java.awt.event.KeyEvent evt) {
                if (evt.getKeyCode() == KeyEvent.VK_TAB) {
                    alertOtherInfo.transferFocus();
                }
            }
        });
        alertSolution = createZapTextArea();
        JScrollPane solutionSp = createJScrollPane(Constant.messages.getString("alert.label.solution"));
        solutionSp.setViewportView(alertSolution);
        alertSolution.addKeyListener(new KeyAdapter() {

            // Change tab key to transfer focus to the next element
            @Override
            public void keyPressed(java.awt.event.KeyEvent evt) {
                if (evt.getKeyCode() == KeyEvent.VK_TAB) {
                    alertSolution.transferFocus();
                }
            }
        });
        alertReference = createZapTextArea();
        JScrollPane referenceSp = createJScrollPane(Constant.messages.getString("alert.label.ref"));
        referenceSp.setViewportView(alertReference);
        alertReference.addKeyListener(new KeyAdapter() {

            // Change tab key to transfer focus to the next element
            @Override
            public void keyPressed(java.awt.event.KeyEvent evt) {
                if (evt.getKeyCode() == KeyEvent.VK_TAB) {
                    alertReference.transferFocus();
                }
            }
        });
        int gbcRow = 0;
        alertDisplay.add(editable ? alertEditName : alertName, LayoutHelper.getGBC(0, gbcRow, 2, 0, DEFAULT_INSETS));
        // Show a blank label instead of the edit button if already editing
        gbcRow++;
        alertDisplay.add(getUrlLabel(), LayoutHelper.getGBC(0, gbcRow, 1, 0, DEFAULT_INSETS));
        alertDisplay.add(alertUrl, LayoutHelper.getGBC(1, gbcRow, 1, 1, DEFAULT_INSETS));
        gbcRow++;
        alertDisplay.add(getRiskLabel(), LayoutHelper.getGBC(0, gbcRow, 1, 0, DEFAULT_INSETS));
        alertDisplay.add(editable ? alertEditRisk : alertRisk, LayoutHelper.getGBC(1, gbcRow, 1, 1, DEFAULT_INSETS));
        gbcRow++;
        alertDisplay.add(getConfidenceLabel(), LayoutHelper.getGBC(0, gbcRow, 1, 0, DEFAULT_INSETS));
        alertDisplay.add(editable ? alertEditConfidence : alertConfidence, LayoutHelper.getGBC(1, gbcRow, 1, 1, DEFAULT_INSETS));
        gbcRow++;
        alertDisplay.add(getParameterLabel(), LayoutHelper.getGBC(0, gbcRow, 1, 0, DEFAULT_INSETS));
        alertDisplay.add(editable ? alertEditParam : alertParam, LayoutHelper.getGBC(1, gbcRow, 1, 1, DEFAULT_INSETS));
        gbcRow++;
        alertDisplay.add(getAttackLabel(), LayoutHelper.getGBC(0, gbcRow, 1, 0, DEFAULT_INSETS));
        alertDisplay.add(editable ? alertEditAttack : alertAttack, LayoutHelper.getGBC(1, gbcRow, 1, 1, DEFAULT_INSETS));
        gbcRow++;
        alertDisplay.add(getEvidenceLabel(), LayoutHelper.getGBC(0, gbcRow, 1, 0, DEFAULT_INSETS));
        alertDisplay.add(editable ? alertEditEvidence : alertEvidence, LayoutHelper.getGBC(1, gbcRow, 1, 1, DEFAULT_INSETS));
        gbcRow++;
        alertDisplay.add(getCweidLabel(), LayoutHelper.getGBC(0, gbcRow, 1, 0, DEFAULT_INSETS));
        alertDisplay.add(editable ? alertEditCweId : alertCweId, LayoutHelper.getGBC(1, gbcRow, 1, 1, DEFAULT_INSETS));
        gbcRow++;
        alertDisplay.add(getWascidLabel(), LayoutHelper.getGBC(0, gbcRow, 1, 0, DEFAULT_INSETS));
        alertDisplay.add(editable ? alertEditWascId : alertWascId, LayoutHelper.getGBC(1, gbcRow, 1, 1, DEFAULT_INSETS));
        gbcRow++;
        if (!editable) {
            alertDisplay.add(getSourceLabel(), LayoutHelper.getGBC(0, gbcRow, 1, 0, DEFAULT_INSETS));
            alertDisplay.add(alertSource, LayoutHelper.getGBC(1, gbcRow, 1, 1, DEFAULT_INSETS));
            gbcRow++;
        }
        alertDisplay.add(descSp, LayoutHelper.getGBC(0, gbcRow, 2, 1.0D, 1.0D, GridBagConstraints.BOTH, DEFAULT_INSETS));
        gbcRow++;
        alertDisplay.add(otherSp, LayoutHelper.getGBC(0, gbcRow, 2, 1.0D, 1.0D, GridBagConstraints.BOTH, DEFAULT_INSETS));
        gbcRow++;
        alertDisplay.add(solutionSp, LayoutHelper.getGBC(0, gbcRow, 2, 1.0D, 1.0D, GridBagConstraints.BOTH, DEFAULT_INSETS));
        gbcRow++;
        alertDisplay.add(referenceSp, LayoutHelper.getGBC(0, gbcRow, 2, 1.0D, 1.0D, GridBagConstraints.BOTH, DEFAULT_INSETS));
        gbcRow++;
        alertDisplay.add(createAlertTagsPanel(), LayoutHelper.getGBC(0, gbcRow, 2, 1.0D, 1.0D, GridBagConstraints.BOTH, DEFAULT_INSETS));
    }
    return alertDisplay;
}
Also used : JScrollPane(javax.swing.JScrollPane) GridBagLayout(java.awt.GridBagLayout) ActionEvent(java.awt.event.ActionEvent) KeyAdapter(java.awt.event.KeyAdapter) JLabel(javax.swing.JLabel) Vulnerability(org.zaproxy.zap.model.Vulnerability) ZapLabel(org.zaproxy.zap.utils.ZapLabel) KeyEvent(java.awt.event.KeyEvent) ScrollableSizeHint(org.jdesktop.swingx.ScrollableSizeHint) ActionListener(java.awt.event.ActionListener) ZapNumberSpinner(org.zaproxy.zap.utils.ZapNumberSpinner) ZapTextField(org.zaproxy.zap.utils.ZapTextField) JSpinner(javax.swing.JSpinner) JXPanel(org.jdesktop.swingx.JXPanel)

Example 3 with JXPanel

use of org.jdesktop.swingx.JXPanel in project adempiere by adempiere.

the class WindowMenu method createSelectionPanel.

private JXPanel createSelectionPanel() {
    GridLayout l = new GridLayout(3, 3);
    l.setHgap(5);
    l.setVgap(5);
    JXPanel p = new JXPanel();
    p.setLayout(l);
    return p;
}
Also used : GridLayout(java.awt.GridLayout) JXPanel(org.jdesktop.swingx.JXPanel)

Example 4 with JXPanel

use of org.jdesktop.swingx.JXPanel in project zaproxy by zaproxy.

the class AlertViewPanel method createAlertTagsPanel.

private JPanel createAlertTagsPanel() {
    JPanel alertTagsPanel = new JXPanel(new BorderLayout());
    alertTagsPanel.setName("Alert Tags Panel");
    alertTagsPanel.setBorder(BorderFactory.createTitledBorder(null, Constant.messages.getString("alert.label.tags"), TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, FontUtils.getFont(FontUtils.Size.standard)));
    alertTagsTableModel = new AlertTagsTableModel();
    alertTagsTable = new ZapTable(alertTagsTableModel);
    alertTagsTable.setPreferredScrollableViewportSize(new Dimension(alertTagsTable.getPreferredSize().width, alertTagsTable.getRowHeight() * 5));
    if (!editable) {
        alertTagsTable.setCellSelectionEnabled(true);
    }
    JScrollPane alertTagsSp = new JScrollPane();
    alertTagsSp.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    alertTagsSp.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
    alertTagsSp.setViewportView(alertTagsTable);
    alertTagsSp.addKeyListener(new KeyAdapter() {

        // Change tab key to transfer focus to the next element
        @Override
        public void keyPressed(java.awt.event.KeyEvent evt) {
            if (evt.getKeyCode() == KeyEvent.VK_TAB) {
                alertTagsTable.transferFocus();
            }
        }
    });
    if (editable) {
        JToolBar alertTagsToolBar = new JToolBar();
        alertTagsToolBar.setEnabled(true);
        alertTagsToolBar.setFloatable(false);
        alertTagsToolBar.setRollover(true);
        alertTagsToolBar.setName("Alert Tags Editing Toolbar");
        JButton addTagButton = new JButton();
        addTagButton.setToolTipText(Constant.messages.getString("alert.tags.button.add"));
        addTagButton.setIcon(DisplayUtils.getScaledIcon(new ImageIcon(AlertViewPanel.class.getResource("/resource/icon/16/103.png"))));
        addTagButton.addActionListener(e -> showAddAlertTagDialogue());
        alertTagsToolBar.add(addTagButton);
        JButton deleteTagButton = new JButton();
        deleteTagButton.setToolTipText(Constant.messages.getString("alert.tags.button.delete"));
        deleteTagButton.setIcon(DisplayUtils.getScaledIcon(new ImageIcon(AlertViewPanel.class.getResource("/resource/icon/16/104.png"))));
        deleteTagButton.addActionListener(e -> alertTagsTableModel.deleteTags(alertTagsTable.getSelectedRows()));
        deleteTagButton.setEnabled(false);
        alertTagsToolBar.add(deleteTagButton);
        JButton editTagButton = new JButton();
        editTagButton.setToolTipText(Constant.messages.getString("alert.tags.button.modify"));
        editTagButton.setIcon(DisplayUtils.getScaledIcon(new ImageIcon(AlertViewPanel.class.getResource("/resource/icon/16/018.png"))));
        editTagButton.addActionListener(e -> showModifyAlertTagDialogue());
        editTagButton.setEnabled(false);
        alertTagsToolBar.add(editTagButton);
        alertTagsTable.getSelectionModel().addListSelectionListener(e -> {
            if (alertTagsTable.getSelectedRow() == -1) {
                deleteTagButton.setEnabled(false);
                editTagButton.setEnabled(false);
                return;
            }
            if (!deleteTagButton.isEnabled()) {
                deleteTagButton.setEnabled(true);
            }
            if (!editTagButton.isEnabled()) {
                editTagButton.setEnabled(true);
            }
        });
        alertTagsTable.addMouseListener(new MouseAdapter() {

            @Override
            public void mouseClicked(MouseEvent e) {
                JTable table = (JTable) e.getSource();
                if (e.getClickCount() == 2 && table.getSelectedRow() != -1) {
                    showModifyAlertTagDialogue();
                }
            }
        });
        alertTagsPanel.add(alertTagsToolBar, BorderLayout.PAGE_START);
    }
    alertTagsPanel.add(alertTagsSp, BorderLayout.CENTER);
    return alertTagsPanel;
}
Also used : JScrollPane(javax.swing.JScrollPane) JPanel(javax.swing.JPanel) ImageIcon(javax.swing.ImageIcon) MouseEvent(java.awt.event.MouseEvent) KeyAdapter(java.awt.event.KeyAdapter) JButton(javax.swing.JButton) MouseAdapter(java.awt.event.MouseAdapter) Dimension(java.awt.Dimension) JToolBar(javax.swing.JToolBar) KeyEvent(java.awt.event.KeyEvent) BorderLayout(java.awt.BorderLayout) ZapTable(org.zaproxy.zap.view.ZapTable) JTable(javax.swing.JTable) JXPanel(org.jdesktop.swingx.JXPanel)

Aggregations

JXPanel (org.jdesktop.swingx.JXPanel)4 KeyAdapter (java.awt.event.KeyAdapter)2 KeyEvent (java.awt.event.KeyEvent)2 JScrollPane (javax.swing.JScrollPane)2 DefaultFormBuilder (com.jgoodies.forms.builder.DefaultFormBuilder)1 FormLayout (com.jgoodies.forms.layout.FormLayout)1 BorderLayout (java.awt.BorderLayout)1 Dimension (java.awt.Dimension)1 GridBagLayout (java.awt.GridBagLayout)1 GridLayout (java.awt.GridLayout)1 ActionEvent (java.awt.event.ActionEvent)1 ActionListener (java.awt.event.ActionListener)1 MouseAdapter (java.awt.event.MouseAdapter)1 MouseEvent (java.awt.event.MouseEvent)1 NumberFormat (java.text.NumberFormat)1 ImageIcon (javax.swing.ImageIcon)1 JButton (javax.swing.JButton)1 JLabel (javax.swing.JLabel)1 JPanel (javax.swing.JPanel)1 JSpinner (javax.swing.JSpinner)1