Search in sources :

Example 6 with JKseTable

use of org.kse.gui.JKseTable in project keystore-explorer by kaikramer.

the class DJarInfo method initComponents.

private void initComponents() throws IOException {
    JarFile[] jarFiles = getClassPathJars();
    JarInfoTableModel jiModel = new JarInfoTableModel();
    jiModel.load(jarFiles);
    jtJarInfo = new JKseTable(jiModel);
    jtJarInfo.setRowMargin(0);
    jtJarInfo.getColumnModel().setColumnMargin(0);
    jtJarInfo.getTableHeader().setReorderingAllowed(false);
    jtJarInfo.setAutoResizeMode(JKseTable.AUTO_RESIZE_OFF);
    RowSorter<TableModel> sorter = new TableRowSorter<TableModel>(jiModel);
    jtJarInfo.setRowSorter(sorter);
    for (int i = 0; i < jtJarInfo.getColumnCount(); i++) {
        TableColumn column = jtJarInfo.getColumnModel().getColumn(i);
        column.setPreferredWidth(150);
        column.setCellRenderer(new JarInfoTableCellRend());
    }
    jspJarInfoTable = PlatformUtil.createScrollPane(jtJarInfo, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    jspJarInfoTable.getViewport().setBackground(jtJarInfo.getBackground());
    jpJarInfoTable = new JPanel(new BorderLayout(10, 10));
    jpJarInfoTable.setPreferredSize(new Dimension(500, 200));
    jpJarInfoTable.add(jspJarInfoTable, BorderLayout.CENTER);
    jpJarInfoTable.setBorder(new EmptyBorder(5, 5, 5, 5));
    jbOK = new JButton(res.getString("DJarInfo.jbOK.text"));
    jbOK.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent evt) {
            okPressed();
        }
    });
    jpOK = PlatformUtil.createDialogButtonPanel(jbOK, true);
    getContentPane().add(jpJarInfoTable, BorderLayout.CENTER);
    getContentPane().add(jpOK, BorderLayout.SOUTH);
    setResizable(true);
    addWindowListener(new WindowAdapter() {

        @Override
        public void windowClosing(WindowEvent evt) {
            closeDialog();
        }
    });
    getRootPane().setDefaultButton(jbOK);
    pack();
    SwingUtilities.invokeLater(new Runnable() {

        @Override
        public void run() {
            jbOK.requestFocus();
        }
    });
}
Also used : JPanel(javax.swing.JPanel) ActionEvent(java.awt.event.ActionEvent) JKseTable(org.kse.gui.JKseTable) JButton(javax.swing.JButton) WindowAdapter(java.awt.event.WindowAdapter) Dimension(java.awt.Dimension) JarFile(java.util.jar.JarFile) TableColumn(javax.swing.table.TableColumn) BorderLayout(java.awt.BorderLayout) ActionListener(java.awt.event.ActionListener) WindowEvent(java.awt.event.WindowEvent) EmptyBorder(javax.swing.border.EmptyBorder) TableModel(javax.swing.table.TableModel) TableRowSorter(javax.swing.table.TableRowSorter)

Example 7 with JKseTable

use of org.kse.gui.JKseTable in project keystore-explorer by kaikramer.

the class DViewCrl method initComponents.

private void initComponents() {
    GridBagConstraints gbcLbl = new GridBagConstraints();
    gbcLbl.gridx = 0;
    gbcLbl.gridwidth = 1;
    gbcLbl.gridheight = 1;
    gbcLbl.insets = new Insets(5, 5, 5, 5);
    gbcLbl.anchor = GridBagConstraints.EAST;
    GridBagConstraints gbcCtrl = new GridBagConstraints();
    gbcCtrl.gridx = 1;
    gbcCtrl.gridwidth = 1;
    gbcCtrl.gridheight = 1;
    gbcCtrl.insets = new Insets(5, 5, 5, 5);
    gbcCtrl.anchor = GridBagConstraints.WEST;
    jlVersion = new JLabel(res.getString("DViewCrl.jlVersion.text"));
    GridBagConstraints gbc_jlVersion = (GridBagConstraints) gbcLbl.clone();
    gbc_jlVersion.gridy = 0;
    jtfVersion = new JTextField(3);
    jtfVersion.setEditable(false);
    jtfVersion.setToolTipText(res.getString("DViewCrl.jtfVersion.tooltip"));
    GridBagConstraints gbc_jtfVersion = (GridBagConstraints) gbcCtrl.clone();
    gbc_jtfVersion.gridy = 0;
    jlIssuer = new JLabel(res.getString("DViewCrl.jlIssuer.text"));
    GridBagConstraints gbc_jlIssuer = (GridBagConstraints) gbcLbl.clone();
    gbc_jlIssuer.gridy = 1;
    jdnIssuer = new JDistinguishedName(res.getString("DViewCrl.Issuer.Title"), 30, false);
    jdnIssuer.setToolTipText(res.getString("DViewCrl.jdnIssuer.tooltip"));
    GridBagConstraints gbc_jdnIssuer = (GridBagConstraints) gbcCtrl.clone();
    gbc_jdnIssuer.gridy = 1;
    jlEffectiveDate = new JLabel(res.getString("DViewCrl.jlEffectiveDate.text"));
    GridBagConstraints gbc_jlEffectiveDate = (GridBagConstraints) gbcLbl.clone();
    gbc_jlEffectiveDate.gridy = 2;
    jtfEffectiveDate = new JTextField(30);
    jtfEffectiveDate.setEditable(false);
    jtfEffectiveDate.setToolTipText(res.getString("DViewCrl.jtfEffectiveDate.tooltip"));
    GridBagConstraints gbc_jtfEffectiveDate = (GridBagConstraints) gbcCtrl.clone();
    gbc_jtfEffectiveDate.gridy = 2;
    jlNextUpdate = new JLabel(res.getString("DViewCrl.jlNextUpdate.text"));
    GridBagConstraints gbc_jlNextUpdate = (GridBagConstraints) gbcLbl.clone();
    gbc_jlNextUpdate.gridy = 3;
    jtfNextUpdate = new JTextField(30);
    jtfNextUpdate.setEditable(false);
    jtfNextUpdate.setToolTipText(res.getString("DViewCrl.jtfNextUpdate.tooltip"));
    GridBagConstraints gbc_jtfNextUpdate = (GridBagConstraints) gbcCtrl.clone();
    gbc_jtfNextUpdate.gridy = 3;
    jlSignatureAlgorithm = new JLabel(res.getString("DViewCrl.jlSignatureAlgorithm.text"));
    GridBagConstraints gbc_jlSignatureAlgorithm = (GridBagConstraints) gbcLbl.clone();
    gbc_jlSignatureAlgorithm.gridy = 4;
    jtfSignatureAlgorithm = new JTextField(15);
    jtfSignatureAlgorithm.setEditable(false);
    jtfSignatureAlgorithm.setToolTipText(res.getString("DViewCrl.jtfSignatureAlgorithm.tooltip"));
    GridBagConstraints gbc_jtfSignatureAlgorithm = (GridBagConstraints) gbcCtrl.clone();
    gbc_jtfSignatureAlgorithm.gridy = 4;
    jbCrlExtensions = new JButton(res.getString("DViewCrl.jbCrlExtensions.text"));
    PlatformUtil.setMnemonic(jbCrlExtensions, res.getString("DViewCrl.jbCrlExtensions.mnemonic").charAt(0));
    jbCrlExtensions.setToolTipText(res.getString("DViewCrl.jbCrlExtensions.tooltip"));
    jbCrlExtensions.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent evt) {
            try {
                CursorUtil.setCursorBusy(DViewCrl.this);
                crlExtensionsPressed();
            } finally {
                CursorUtil.setCursorFree(DViewCrl.this);
            }
        }
    });
    jbCrlAsn1 = new JButton(res.getString("DViewCrl.jbCrlAsn1.text"));
    PlatformUtil.setMnemonic(jbCrlAsn1, res.getString("DViewCrl.jbCrlAsn1.mnemonic").charAt(0));
    jbCrlAsn1.setToolTipText(res.getString("DViewCrl.jbCrlAsn1.tooltip"));
    jbCrlAsn1.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent evt) {
            try {
                CursorUtil.setCursorBusy(DViewCrl.this);
                asn1DumpPressed();
            } finally {
                CursorUtil.setCursorFree(DViewCrl.this);
            }
        }
    });
    jpCrlButtons = new JPanel(new FlowLayout(FlowLayout.LEFT, 5, 0));
    jpCrlButtons.add(jbCrlExtensions);
    jpCrlButtons.add(jbCrlAsn1);
    GridBagConstraints gbc_jpCrlButtons = new GridBagConstraints();
    gbc_jpCrlButtons.gridx = 0;
    gbc_jpCrlButtons.gridy = 5;
    gbc_jpCrlButtons.gridwidth = 2;
    gbc_jpCrlButtons.gridheight = 1;
    gbc_jpCrlButtons.insets = new Insets(5, 0, 5, 0);
    gbc_jpCrlButtons.anchor = GridBagConstraints.EAST;
    jlRevokedCerts = new JLabel(res.getString("DViewCrl.jlRevokedCerts.text"));
    RevokedCertsTableModel rcModel = new RevokedCertsTableModel();
    jtRevokedCerts = new JKseTable(rcModel);
    RowSorter<TableModel> sorter = new TableRowSorter<TableModel>(rcModel);
    jtRevokedCerts.setRowSorter(sorter);
    jtRevokedCerts.setShowGrid(false);
    jtRevokedCerts.setRowMargin(0);
    jtRevokedCerts.getColumnModel().setColumnMargin(0);
    jtRevokedCerts.getTableHeader().setReorderingAllowed(false);
    jtRevokedCerts.setAutoResizeMode(JKseTable.AUTO_RESIZE_ALL_COLUMNS);
    for (int i = 0; i < jtRevokedCerts.getColumnCount(); i++) {
        TableColumn column = jtRevokedCerts.getColumnModel().getColumn(i);
        if (i == 0) {
            column.setPreferredWidth(100);
        }
        column.setHeaderRenderer(new RevokedCertsTableHeadRend(jtRevokedCerts.getTableHeader().getDefaultRenderer()));
        column.setCellRenderer(new RevokedCertsTableCellRend());
    }
    ListSelectionModel listSelectionModel = jtRevokedCerts.getSelectionModel();
    listSelectionModel.addListSelectionListener(new ListSelectionListener() {

        @Override
        public void valueChanged(ListSelectionEvent evt) {
            if (// Ignore spurious
            !evt.getValueIsAdjusting()) // events
            {
                try {
                    CursorUtil.setCursorBusy(DViewCrl.this);
                    crlEntrySelection();
                } finally {
                    CursorUtil.setCursorFree(DViewCrl.this);
                }
            }
        }
    });
    jtRevokedCerts.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseClicked(MouseEvent evt) {
            maybeDisplayCrlEntryExtensions(evt);
        }
    });
    jspRevokedCertsTable = PlatformUtil.createScrollPane(jtRevokedCerts, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    jspRevokedCertsTable.getViewport().setBackground(jtRevokedCerts.getBackground());
    jpRevokedCertsTable = new JPanel(new BorderLayout(10, 10));
    jpRevokedCertsTable.setPreferredSize(new Dimension(100, 200));
    jpRevokedCertsTable.add(jlRevokedCerts, BorderLayout.NORTH);
    jpRevokedCertsTable.add(jspRevokedCertsTable, BorderLayout.CENTER);
    jpRevokedCertsTable.setBorder(new CompoundBorder(new EtchedBorder(), new EmptyBorder(5, 5, 5, 5)));
    jbCrlEntryExtensions = new JButton(res.getString("DViewCrl.jbCrlEntryExtensions.text"));
    PlatformUtil.setMnemonic(jbCrlEntryExtensions, res.getString("DViewCrl.jbCrlEntryExtensions.mnemonic").charAt(0));
    jbCrlEntryExtensions.setToolTipText(res.getString("DViewCrl.jbCrlEntryExtensions.tooltip"));
    jbCrlEntryExtensions.setEnabled(false);
    jbCrlEntryExtensions.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent evt) {
            try {
                CursorUtil.setCursorBusy(DViewCrl.this);
                crlEntryExtensionsPressed();
            } finally {
                CursorUtil.setCursorFree(DViewCrl.this);
            }
        }
    });
    jpCrlEntryExtensions = new JPanel(new FlowLayout(FlowLayout.RIGHT));
    jpCrlEntryExtensions.add(jbCrlEntryExtensions);
    jpRevokedCertsTable.add(jpCrlEntryExtensions, BorderLayout.SOUTH);
    GridBagConstraints gbc_jpRevokedCertsTable = new GridBagConstraints();
    gbc_jpRevokedCertsTable.gridx = 0;
    gbc_jpRevokedCertsTable.gridy = 6;
    gbc_jpRevokedCertsTable.gridwidth = 2;
    gbc_jpRevokedCertsTable.gridheight = 1;
    gbc_jpRevokedCertsTable.insets = new Insets(5, 5, 5, 5);
    gbc_jpRevokedCertsTable.fill = GridBagConstraints.BOTH;
    gbc_jpRevokedCertsTable.anchor = GridBagConstraints.CENTER;
    jpCRL = new JPanel(new GridBagLayout());
    jpCRL.setBorder(new CompoundBorder(new EmptyBorder(10, 10, 10, 10), new EtchedBorder()));
    jpCRL.add(jlVersion, gbc_jlVersion);
    jpCRL.add(jtfVersion, gbc_jtfVersion);
    jpCRL.add(jlIssuer, gbc_jlIssuer);
    jpCRL.add(jdnIssuer, gbc_jdnIssuer);
    jpCRL.add(jlEffectiveDate, gbc_jlEffectiveDate);
    jpCRL.add(jtfEffectiveDate, gbc_jtfEffectiveDate);
    jpCRL.add(jlNextUpdate, gbc_jlNextUpdate);
    jpCRL.add(jtfNextUpdate, gbc_jtfNextUpdate);
    jpCRL.add(jlSignatureAlgorithm, gbc_jlSignatureAlgorithm);
    jpCRL.add(jtfSignatureAlgorithm, gbc_jtfSignatureAlgorithm);
    jpCRL.add(jpCrlButtons, gbc_jpCrlButtons);
    jpCRL.add(jpRevokedCertsTable, gbc_jpRevokedCertsTable);
    populateDialog();
    jbOK = new JButton(res.getString("DViewCrl.jbOK.text"));
    jbOK.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent evt) {
            okPressed();
        }
    });
    jpOK = PlatformUtil.createDialogButtonPanel(jbOK, false);
    getContentPane().add(jpCRL, BorderLayout.CENTER);
    getContentPane().add(jpOK, BorderLayout.SOUTH);
    setResizable(false);
    addWindowListener(new WindowAdapter() {

        @Override
        public void windowClosing(WindowEvent evt) {
            closeDialog();
        }
    });
    getRootPane().setDefaultButton(jbOK);
    pack();
    SwingUtilities.invokeLater(new Runnable() {

        @Override
        public void run() {
            jbOK.requestFocus();
        }
    });
}
Also used : JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) Insets(java.awt.Insets) FlowLayout(java.awt.FlowLayout) GridBagLayout(java.awt.GridBagLayout) ActionEvent(java.awt.event.ActionEvent) JButton(javax.swing.JButton) ListSelectionEvent(javax.swing.event.ListSelectionEvent) WindowAdapter(java.awt.event.WindowAdapter) JTextField(javax.swing.JTextField) JDistinguishedName(org.kse.gui.crypto.JDistinguishedName) BorderLayout(java.awt.BorderLayout) CompoundBorder(javax.swing.border.CompoundBorder) EmptyBorder(javax.swing.border.EmptyBorder) TableRowSorter(javax.swing.table.TableRowSorter) MouseEvent(java.awt.event.MouseEvent) JKseTable(org.kse.gui.JKseTable) MouseAdapter(java.awt.event.MouseAdapter) JLabel(javax.swing.JLabel) ListSelectionModel(javax.swing.ListSelectionModel) Dimension(java.awt.Dimension) TableColumn(javax.swing.table.TableColumn) Point(java.awt.Point) ListSelectionListener(javax.swing.event.ListSelectionListener) EtchedBorder(javax.swing.border.EtchedBorder) ActionListener(java.awt.event.ActionListener) WindowEvent(java.awt.event.WindowEvent) TableModel(javax.swing.table.TableModel)

Example 8 with JKseTable

use of org.kse.gui.JKseTable in project keystore-explorer by kaikramer.

the class DAddExtensions method initComponents.

private void initComponents() {
    jbAdd = new JButton(new ImageIcon(Toolkit.getDefaultToolkit().createImage(getClass().getResource(res.getString("DAddExtensions.jbAdd.image")))));
    jbAdd.setMargin(new Insets(2, 2, 0, 0));
    jbAdd.setToolTipText(res.getString("DAddExtensions.jbAdd.tooltip"));
    jbAdd.setMnemonic(res.getString("DAddExtensions.jbAdd.mnemonic").charAt(0));
    jbAdd.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent evt) {
            try {
                CursorUtil.setCursorBusy(DAddExtensions.this);
                addPressed();
            } finally {
                CursorUtil.setCursorFree(DAddExtensions.this);
            }
        }
    });
    jbEdit = new JButton(new ImageIcon(Toolkit.getDefaultToolkit().createImage(getClass().getResource(res.getString("DAddExtensions.jbEdit.image")))));
    jbEdit.setMargin(new Insets(2, 2, 0, 0));
    jbEdit.setToolTipText(res.getString("DAddExtensions.jbEdit.tooltip"));
    jbEdit.setMnemonic(res.getString("DAddExtensions.jbEdit.mnemonic").charAt(0));
    jbEdit.setEnabled(false);
    jbEdit.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent evt) {
            try {
                CursorUtil.setCursorBusy(DAddExtensions.this);
                editPressed();
            } finally {
                CursorUtil.setCursorFree(DAddExtensions.this);
            }
        }
    });
    jbToggleCriticality = new JButton(new ImageIcon(Toolkit.getDefaultToolkit().createImage(getClass().getResource(res.getString("DAddExtensions.jbToggleCriticality.image")))));
    jbToggleCriticality.setMargin(new Insets(2, 2, 0, 0));
    jbToggleCriticality.setToolTipText(res.getString("DAddExtensions.jbToggleCriticality.tooltip"));
    jbToggleCriticality.setMnemonic(res.getString("DAddExtensions.jbToggleCriticality.mnemonic").charAt(0));
    jbToggleCriticality.setEnabled(false);
    jbToggleCriticality.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent evt) {
            try {
                CursorUtil.setCursorBusy(DAddExtensions.this);
                toggleCriticalityPressed();
            } finally {
                CursorUtil.setCursorFree(DAddExtensions.this);
            }
        }
    });
    jbRemove = new JButton(new ImageIcon(Toolkit.getDefaultToolkit().createImage(getClass().getResource(res.getString("DAddExtensions.jbRemove.image")))));
    jbRemove.setMargin(new Insets(2, 2, 0, 0));
    jbRemove.setToolTipText(res.getString("DAddExtensions.jbRemove.tooltip"));
    jbRemove.setMnemonic(res.getString("DAddExtensions.jbRemove.mnemonic").charAt(0));
    jbRemove.setEnabled(false);
    jbRemove.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent evt) {
            try {
                CursorUtil.setCursorBusy(DAddExtensions.this);
                removePressed();
            } finally {
                CursorUtil.setCursorFree(DAddExtensions.this);
            }
        }
    });
    jpExtensionButtons = new JPanel();
    jpExtensionButtons.setLayout(new BoxLayout(jpExtensionButtons, BoxLayout.Y_AXIS));
    jpExtensionButtons.add(Box.createVerticalGlue());
    jpExtensionButtons.add(jbAdd);
    jpExtensionButtons.add(Box.createVerticalStrut(3));
    jpExtensionButtons.add(jbEdit);
    jpExtensionButtons.add(Box.createVerticalStrut(3));
    jpExtensionButtons.add(jbToggleCriticality);
    jpExtensionButtons.add(Box.createVerticalStrut(3));
    jpExtensionButtons.add(jbRemove);
    jpExtensionButtons.add(Box.createVerticalGlue());
    ExtensionsTableModel extensionsTableModel = new ExtensionsTableModel();
    jtExtensions = new JKseTable(extensionsTableModel);
    TableRowSorter<TableModel> sorter = new TableRowSorter<TableModel>(extensionsTableModel);
    sorter.setComparator(2, new ObjectIdComparator());
    jtExtensions.setRowSorter(sorter);
    jtExtensions.setShowGrid(false);
    jtExtensions.setRowMargin(0);
    jtExtensions.getColumnModel().setColumnMargin(0);
    jtExtensions.getTableHeader().setReorderingAllowed(false);
    jtExtensions.setAutoResizeMode(JKseTable.AUTO_RESIZE_ALL_COLUMNS);
    jtExtensions.setRowHeight(Math.max(18, jtExtensions.getRowHeight()));
    for (int i = 0; i < jtExtensions.getColumnCount(); i++) {
        TableColumn column = jtExtensions.getColumnModel().getColumn(i);
        column.setHeaderRenderer(new ExtensionsTableHeadRend(jtExtensions.getTableHeader().getDefaultRenderer()));
        column.setCellRenderer(new ExtensionsTableCellRend());
    }
    TableColumn criticalCol = jtExtensions.getColumnModel().getColumn(0);
    criticalCol.setResizable(false);
    criticalCol.setMinWidth(28);
    criticalCol.setMaxWidth(28);
    criticalCol.setPreferredWidth(28);
    ListSelectionModel selectionModel = jtExtensions.getSelectionModel();
    selectionModel.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    selectionModel.addListSelectionListener(new ListSelectionListener() {

        @Override
        public void valueChanged(ListSelectionEvent evt) {
            if (!evt.getValueIsAdjusting()) {
                try {
                    CursorUtil.setCursorBusy(DAddExtensions.this);
                    updateButtonControls();
                } finally {
                    CursorUtil.setCursorFree(DAddExtensions.this);
                }
            }
        }
    });
    jtExtensions.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseClicked(MouseEvent evt) {
            maybeEditExtension(evt);
        }
    });
    jtExtensions.addKeyListener(new KeyAdapter() {

        boolean deleteLastPressed = false;

        @Override
        public void keyPressed(KeyEvent evt) {
            // Record delete pressed on non-Macs
            if (!OperatingSystem.isMacOs()) {
                deleteLastPressed = evt.getKeyCode() == KeyEvent.VK_DELETE;
            }
        }

        @Override
        public void keyReleased(KeyEvent evt) {
            // Delete on non-Mac if delete was pressed and is now released
            if (!OperatingSystem.isMacOs() && deleteLastPressed && evt.getKeyCode() == KeyEvent.VK_DELETE) {
                try {
                    CursorUtil.setCursorBusy(DAddExtensions.this);
                    deleteLastPressed = false;
                    removeSelectedExtension();
                } finally {
                    CursorUtil.setCursorFree(DAddExtensions.this);
                }
            }
        }

        @Override
        public void keyTyped(KeyEvent evt) {
            // Delete on Mac if back space typed
            if (OperatingSystem.isMacOs() && evt.getKeyChar() == 0x08) {
                try {
                    CursorUtil.setCursorBusy(DAddExtensions.this);
                    removeSelectedExtension();
                } finally {
                    CursorUtil.setCursorFree(DAddExtensions.this);
                }
            }
        }
    });
    jspExtensionsTable = PlatformUtil.createScrollPane(jtExtensions, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    jspExtensionsTable.getViewport().setBackground(jtExtensions.getBackground());
    jbLoadTemplate = new JButton(res.getString("DAddExtensions.jbLoadTemplate.text"));
    jbLoadTemplate.setMnemonic(res.getString("DAddExtensions.jbLoadTemplate.mnemonic").charAt(0));
    jbLoadTemplate.setToolTipText(res.getString("DAddExtensions.jbLoadTemplate.tooltip"));
    jbLoadTemplate.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent evt) {
            try {
                CursorUtil.setCursorBusy(DAddExtensions.this);
                loadTemplatePressed();
            } finally {
                CursorUtil.setCursorFree(DAddExtensions.this);
            }
        }
    });
    jbSaveTemplate = new JButton(res.getString("DAddExtensions.jbSaveTemplate.text"));
    jbSaveTemplate.setMnemonic(res.getString("DAddExtensions.jbSaveTemplate.mnemonic").charAt(0));
    jbSaveTemplate.setToolTipText(res.getString("DAddExtensions.jbSaveTemplate.tooltip"));
    jbSaveTemplate.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent evt) {
            try {
                CursorUtil.setCursorBusy(DAddExtensions.this);
                saveTemplatePressed();
            } finally {
                CursorUtil.setCursorFree(DAddExtensions.this);
            }
        }
    });
    jpLoadSaveTemplate = new JPanel();
    jpLoadSaveTemplate.setLayout(new BoxLayout(jpLoadSaveTemplate, BoxLayout.X_AXIS));
    jpLoadSaveTemplate.add(Box.createHorizontalGlue());
    jpLoadSaveTemplate.add(jbLoadTemplate);
    jpLoadSaveTemplate.add(Box.createHorizontalStrut(5));
    jpLoadSaveTemplate.add(jbSaveTemplate);
    jpExtensions = new JPanel(new BorderLayout(5, 5));
    jpExtensions.setPreferredSize(new Dimension(450, 200));
    jpExtensions.add(jspExtensionsTable, BorderLayout.CENTER);
    jpExtensions.add(jpExtensionButtons, BorderLayout.EAST);
    jpExtensions.add(jpLoadSaveTemplate, BorderLayout.SOUTH);
    jpExtensions.setBorder(new CompoundBorder(new EmptyBorder(5, 5, 5, 5), new CompoundBorder(new EtchedBorder(), new EmptyBorder(5, 5, 5, 5))));
    jbOK = new JButton(res.getString("DAddExtensions.jbOK.text"));
    jbOK.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent evt) {
            okPressed();
        }
    });
    jbCancel = new JButton(res.getString("DAddExtensions.jbCancel.text"));
    jbCancel.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent evt) {
            cancelPressed();
        }
    });
    jbCancel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), CANCEL_KEY);
    jbCancel.getActionMap().put(CANCEL_KEY, new AbstractAction() {

        private static final long serialVersionUID = 1L;

        @Override
        public void actionPerformed(ActionEvent evt) {
            cancelPressed();
        }
    });
    jpButtons = PlatformUtil.createDialogButtonPanel(jbOK, jbCancel, false);
    reloadExtensionsTable();
    selectFirstExtensionInTable();
    updateButtonControls();
    getContentPane().setLayout(new BorderLayout());
    getContentPane().add(jpExtensions, BorderLayout.CENTER);
    getContentPane().add(jpButtons, BorderLayout.SOUTH);
    addWindowListener(new WindowAdapter() {

        @Override
        public void windowClosing(WindowEvent evt) {
            closeDialog();
        }
    });
    setResizable(false);
    getRootPane().setDefaultButton(jbOK);
    pack();
}
Also used : ImageIcon(javax.swing.ImageIcon) JPanel(javax.swing.JPanel) Insets(java.awt.Insets) ActionEvent(java.awt.event.ActionEvent) BoxLayout(javax.swing.BoxLayout) KeyAdapter(java.awt.event.KeyAdapter) JButton(javax.swing.JButton) ListSelectionEvent(javax.swing.event.ListSelectionEvent) WindowAdapter(java.awt.event.WindowAdapter) ObjectIdComparator(org.kse.utilities.oid.ObjectIdComparator) KeyEvent(java.awt.event.KeyEvent) BorderLayout(java.awt.BorderLayout) CompoundBorder(javax.swing.border.CompoundBorder) EmptyBorder(javax.swing.border.EmptyBorder) AbstractAction(javax.swing.AbstractAction) TableRowSorter(javax.swing.table.TableRowSorter) MouseEvent(java.awt.event.MouseEvent) JKseTable(org.kse.gui.JKseTable) MouseAdapter(java.awt.event.MouseAdapter) ListSelectionModel(javax.swing.ListSelectionModel) Dimension(java.awt.Dimension) TableColumn(javax.swing.table.TableColumn) Point(java.awt.Point) ListSelectionListener(javax.swing.event.ListSelectionListener) EtchedBorder(javax.swing.border.EtchedBorder) ActionListener(java.awt.event.ActionListener) WindowEvent(java.awt.event.WindowEvent) TableModel(javax.swing.table.TableModel)

Example 9 with JKseTable

use of org.kse.gui.JKseTable in project keystore-explorer by kaikramer.

the class DSystemProperties method initComponents.

private void initComponents() {
    SystemPropertiesTableModel spModel = new SystemPropertiesTableModel();
    spModel.load();
    jtSystemProperties = new JKseTable(spModel);
    jtSystemProperties.setRowMargin(0);
    jtSystemProperties.getColumnModel().setColumnMargin(0);
    jtSystemProperties.getTableHeader().setReorderingAllowed(false);
    jtSystemProperties.setAutoResizeMode(JKseTable.AUTO_RESIZE_OFF);
    RowSorter<TableModel> sorter = new TableRowSorter<TableModel>(spModel);
    jtSystemProperties.setRowSorter(sorter);
    for (int i = 0; i < jtSystemProperties.getColumnCount(); i++) {
        TableColumn column = jtSystemProperties.getColumnModel().getColumn(i);
        if (i == 0) {
            column.setPreferredWidth(200);
        } else {
            column.setPreferredWidth(300);
        }
        column.setCellRenderer(new SystemPropertiesTableCellRend());
    }
    jspSystemPropertiesTable = PlatformUtil.createScrollPane(jtSystemProperties, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    jspSystemPropertiesTable.getViewport().setBackground(jtSystemProperties.getBackground());
    jpSystemPropertiesTable = new JPanel(new BorderLayout(10, 10));
    jpSystemPropertiesTable.setPreferredSize(new Dimension(500, 300));
    jpSystemPropertiesTable.add(jspSystemPropertiesTable, BorderLayout.CENTER);
    jpSystemPropertiesTable.setBorder(new EmptyBorder(5, 5, 5, 5));
    jbOK = new JButton(res.getString("DSystemProperties.jbOK.text"));
    jbOK.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent evt) {
            okPressed();
        }
    });
    jpOK = PlatformUtil.createDialogButtonPanel(jbOK, false);
    getContentPane().add(jpSystemPropertiesTable, BorderLayout.CENTER);
    getContentPane().add(jpOK, BorderLayout.SOUTH);
    setResizable(false);
    addWindowListener(new WindowAdapter() {

        @Override
        public void windowClosing(WindowEvent evt) {
            closeDialog();
        }
    });
    getRootPane().setDefaultButton(jbOK);
    pack();
    SwingUtilities.invokeLater(new Runnable() {

        @Override
        public void run() {
            jbOK.requestFocus();
        }
    });
}
Also used : JPanel(javax.swing.JPanel) ActionEvent(java.awt.event.ActionEvent) JKseTable(org.kse.gui.JKseTable) JButton(javax.swing.JButton) WindowAdapter(java.awt.event.WindowAdapter) Dimension(java.awt.Dimension) TableColumn(javax.swing.table.TableColumn) BorderLayout(java.awt.BorderLayout) ActionListener(java.awt.event.ActionListener) WindowEvent(java.awt.event.WindowEvent) EmptyBorder(javax.swing.border.EmptyBorder) TableModel(javax.swing.table.TableModel) TableRowSorter(javax.swing.table.TableRowSorter)

Example 10 with JKseTable

use of org.kse.gui.JKseTable in project keystore-explorer by kaikramer.

the class JGeneralNames method initComponents.

private void initComponents() {
    jbAdd = new JButton(new ImageIcon(Toolkit.getDefaultToolkit().createImage(getClass().getResource(res.getString("JGeneralNames.jbAdd.image")))));
    jbAdd.setMargin(new Insets(2, 2, 0, 0));
    jbAdd.setToolTipText(res.getString("JGeneralNames.jbAdd.tooltip"));
    jbAdd.setMnemonic(res.getString("JGeneralNames.jbAdd.mnemonic").charAt(0));
    jbAdd.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent evt) {
            try {
                CursorUtil.setCursorBusy(JGeneralNames.this);
                addPressed();
            } finally {
                CursorUtil.setCursorFree(JGeneralNames.this);
            }
        }
    });
    jbEdit = new JButton(new ImageIcon(Toolkit.getDefaultToolkit().createImage(getClass().getResource(res.getString("JGeneralNames.jbEdit.image")))));
    jbEdit.setMargin(new Insets(2, 2, 0, 0));
    jbEdit.setToolTipText(res.getString("JGeneralNames.jbEdit.tooltip"));
    jbEdit.setMnemonic(res.getString("JGeneralNames.jbEdit.mnemonic").charAt(0));
    jbEdit.setEnabled(false);
    jbEdit.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent evt) {
            try {
                CursorUtil.setCursorBusy(JGeneralNames.this);
                editPressed();
            } finally {
                CursorUtil.setCursorFree(JGeneralNames.this);
            }
        }
    });
    jbRemove = new JButton(new ImageIcon(Toolkit.getDefaultToolkit().createImage(getClass().getResource(res.getString("JGeneralNames.jbRemove.image")))));
    jbRemove.setMargin(new Insets(2, 2, 0, 0));
    jbRemove.setToolTipText(res.getString("JGeneralNames.jbRemove.tooltip"));
    jbRemove.setMnemonic(res.getString("JGeneralNames.jbRemove.mnemonic").charAt(0));
    jbRemove.setEnabled(false);
    jbRemove.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent evt) {
            try {
                CursorUtil.setCursorBusy(JGeneralNames.this);
                removePressed();
            } finally {
                CursorUtil.setCursorFree(JGeneralNames.this);
            }
        }
    });
    jpGeneralNameButtons = new JPanel();
    jpGeneralNameButtons.setLayout(new BoxLayout(jpGeneralNameButtons, BoxLayout.Y_AXIS));
    jpGeneralNameButtons.add(Box.createVerticalGlue());
    jpGeneralNameButtons.add(jbAdd);
    jpGeneralNameButtons.add(Box.createVerticalStrut(3));
    jpGeneralNameButtons.add(jbEdit);
    jpGeneralNameButtons.add(Box.createVerticalStrut(3));
    jpGeneralNameButtons.add(jbRemove);
    jpGeneralNameButtons.add(Box.createVerticalGlue());
    GeneralNamesTableModel generalNamesTableModel = new GeneralNamesTableModel();
    jtGeneralNames = new JKseTable(generalNamesTableModel);
    TableRowSorter<TableModel> sorter = new TableRowSorter<TableModel>(generalNamesTableModel);
    sorter.setComparator(0, new GeneralNamesTableModel.GeneralNameComparator());
    jtGeneralNames.setRowSorter(sorter);
    jtGeneralNames.setShowGrid(false);
    jtGeneralNames.setRowMargin(0);
    jtGeneralNames.getColumnModel().setColumnMargin(0);
    jtGeneralNames.getTableHeader().setReorderingAllowed(false);
    jtGeneralNames.setAutoResizeMode(JKseTable.AUTO_RESIZE_ALL_COLUMNS);
    jtGeneralNames.setRowHeight(Math.max(18, jtGeneralNames.getRowHeight()));
    for (int i = 0; i < jtGeneralNames.getColumnCount(); i++) {
        TableColumn column = jtGeneralNames.getColumnModel().getColumn(i);
        column.setHeaderRenderer(new GeneralNamesTableHeadRend(jtGeneralNames.getTableHeader().getDefaultRenderer()));
        column.setCellRenderer(new GeneralNamesTableCellRend());
    }
    ListSelectionModel selectionModel = jtGeneralNames.getSelectionModel();
    selectionModel.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    selectionModel.addListSelectionListener(new ListSelectionListener() {

        @Override
        public void valueChanged(ListSelectionEvent evt) {
            if (!evt.getValueIsAdjusting()) {
                updateButtonControls();
            }
        }
    });
    jtGeneralNames.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseClicked(MouseEvent evt) {
            maybeEditGeneralName(evt);
        }
    });
    jtGeneralNames.addKeyListener(new KeyAdapter() {

        boolean deleteLastPressed = false;

        @Override
        public void keyPressed(KeyEvent evt) {
            // Record delete pressed on non-Macs
            if (!OperatingSystem.isMacOs()) {
                deleteLastPressed = evt.getKeyCode() == KeyEvent.VK_DELETE;
            }
        }

        @Override
        public void keyReleased(KeyEvent evt) {
            // Delete on non-Mac if delete was pressed and is now released
            if (!OperatingSystem.isMacOs() && deleteLastPressed && evt.getKeyCode() == KeyEvent.VK_DELETE) {
                try {
                    CursorUtil.setCursorBusy(JGeneralNames.this);
                    deleteLastPressed = false;
                    removeSelectedGeneralName();
                } finally {
                    CursorUtil.setCursorFree(JGeneralNames.this);
                }
            }
        }

        @Override
        public void keyTyped(KeyEvent evt) {
            // Delete on Mac if back space typed
            if (OperatingSystem.isMacOs() && evt.getKeyChar() == 0x08) {
                try {
                    CursorUtil.setCursorBusy(JGeneralNames.this);
                    removeSelectedGeneralName();
                } finally {
                    CursorUtil.setCursorFree(JGeneralNames.this);
                }
            }
        }
    });
    jspGeneralNames = PlatformUtil.createScrollPane(jtGeneralNames, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    jspGeneralNames.getViewport().setBackground(jtGeneralNames.getBackground());
    this.setLayout(new BorderLayout(5, 5));
    setPreferredSize(new Dimension(250, 150));
    add(jspGeneralNames, BorderLayout.CENTER);
    add(jpGeneralNameButtons, BorderLayout.EAST);
    selectFirstGeneralNameInTable();
    updateButtonControls();
}
Also used : ImageIcon(javax.swing.ImageIcon) JPanel(javax.swing.JPanel) Insets(java.awt.Insets) ActionEvent(java.awt.event.ActionEvent) BoxLayout(javax.swing.BoxLayout) KeyAdapter(java.awt.event.KeyAdapter) JButton(javax.swing.JButton) ListSelectionEvent(javax.swing.event.ListSelectionEvent) KeyEvent(java.awt.event.KeyEvent) BorderLayout(java.awt.BorderLayout) TableRowSorter(javax.swing.table.TableRowSorter) MouseEvent(java.awt.event.MouseEvent) JKseTable(org.kse.gui.JKseTable) MouseAdapter(java.awt.event.MouseAdapter) ListSelectionModel(javax.swing.ListSelectionModel) Dimension(java.awt.Dimension) TableColumn(javax.swing.table.TableColumn) Point(java.awt.Point) ListSelectionListener(javax.swing.event.ListSelectionListener) ActionListener(java.awt.event.ActionListener) TableModel(javax.swing.table.TableModel)

Aggregations

BorderLayout (java.awt.BorderLayout)12 Dimension (java.awt.Dimension)12 ActionEvent (java.awt.event.ActionEvent)12 ActionListener (java.awt.event.ActionListener)12 JButton (javax.swing.JButton)12 JPanel (javax.swing.JPanel)12 TableColumn (javax.swing.table.TableColumn)12 TableModel (javax.swing.table.TableModel)12 TableRowSorter (javax.swing.table.TableRowSorter)12 JKseTable (org.kse.gui.JKseTable)12 ListSelectionModel (javax.swing.ListSelectionModel)9 ListSelectionEvent (javax.swing.event.ListSelectionEvent)9 ListSelectionListener (javax.swing.event.ListSelectionListener)9 Insets (java.awt.Insets)8 Point (java.awt.Point)8 MouseAdapter (java.awt.event.MouseAdapter)8 MouseEvent (java.awt.event.MouseEvent)8 KeyAdapter (java.awt.event.KeyAdapter)7 KeyEvent (java.awt.event.KeyEvent)7 BoxLayout (javax.swing.BoxLayout)7