Search in sources :

Example 1 with Asn1Dump

use of org.kse.utilities.asn1.Asn1Dump in project keystore-explorer by kaikramer.

the class DViewAsn1Dump method initComponents.

private void initComponents() throws Asn1Exception, IOException {
    jbCopy = new JButton(res.getString("DViewAsn1Dump.jbCopy.text"));
    PlatformUtil.setMnemonic(jbCopy, res.getString("DViewAsn1Dump.jbCopy.mnemonic").charAt(0));
    jbCopy.setToolTipText(res.getString("DViewAsn1Dump.jbCopy.tooltip"));
    jbCopy.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent evt) {
            try {
                CursorUtil.setCursorBusy(DViewAsn1Dump.this);
                copyPressed();
            } finally {
                CursorUtil.setCursorFree(DViewAsn1Dump.this);
            }
        }
    });
    jbOK = new JButton(res.getString("DViewAsn1Dump.jbOK.text"));
    jbOK.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent evt) {
            okPressed();
        }
    });
    jpButtons = PlatformUtil.createDialogButtonPanel(jbOK, null, jbCopy, true);
    jpAsn1Dump = new JPanel(new BorderLayout());
    jpAsn1Dump.setBorder(new EmptyBorder(5, 5, 5, 5));
    Asn1Dump asn1Dump = new Asn1Dump();
    if (certificate != null) {
        jtaAsn1Dump = new JTextArea(asn1Dump.dump(certificate));
    } else if (crl != null) {
        jtaAsn1Dump = new JTextArea(asn1Dump.dump(crl));
    } else if (extension != null) {
        jtaAsn1Dump = new JTextArea(asn1Dump.dump(extension));
    } else if (privateKey != null) {
        jtaAsn1Dump = new JTextArea(asn1Dump.dump(privateKey));
    } else if (publicKey != null) {
        jtaAsn1Dump = new JTextArea(asn1Dump.dump(publicKey));
    } else if (pkcs10Csr != null) {
        jtaAsn1Dump = new JTextArea(asn1Dump.dump(pkcs10Csr.getEncoded()));
    } else {
        jtaAsn1Dump = new JTextArea(asn1Dump.dump(spkac.getEncoded()));
    }
    jtaAsn1Dump.setCaretPosition(0);
    jtaAsn1Dump.setEditable(false);
    jtaAsn1Dump.setFont(new Font(Font.MONOSPACED, Font.PLAIN, LnfUtil.getDefaultFontSize()));
    // JGoodies - keep uneditable color same as editable
    jtaAsn1Dump.putClientProperty("JTextArea.infoBackground", Boolean.TRUE);
    jspAsn1Dump = PlatformUtil.createScrollPane(jtaAsn1Dump, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
    jspAsn1Dump.setPreferredSize(new Dimension(500, 300));
    jpAsn1Dump.add(jspAsn1Dump, BorderLayout.CENTER);
    getContentPane().add(jpAsn1Dump, BorderLayout.CENTER);
    getContentPane().add(jpButtons, 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) JTextArea(javax.swing.JTextArea) ActionEvent(java.awt.event.ActionEvent) JButton(javax.swing.JButton) Asn1Dump(org.kse.utilities.asn1.Asn1Dump) WindowAdapter(java.awt.event.WindowAdapter) Dimension(java.awt.Dimension) Font(java.awt.Font) ActionListener(java.awt.event.ActionListener) BorderLayout(java.awt.BorderLayout) WindowEvent(java.awt.event.WindowEvent) EmptyBorder(javax.swing.border.EmptyBorder)

Aggregations

BorderLayout (java.awt.BorderLayout)1 Dimension (java.awt.Dimension)1 Font (java.awt.Font)1 ActionEvent (java.awt.event.ActionEvent)1 ActionListener (java.awt.event.ActionListener)1 WindowAdapter (java.awt.event.WindowAdapter)1 WindowEvent (java.awt.event.WindowEvent)1 JButton (javax.swing.JButton)1 JPanel (javax.swing.JPanel)1 JTextArea (javax.swing.JTextArea)1 EmptyBorder (javax.swing.border.EmptyBorder)1 Asn1Dump (org.kse.utilities.asn1.Asn1Dump)1