Example usage for javax.swing.tree DefaultMutableTreeNode getUserObject

List of usage examples for javax.swing.tree DefaultMutableTreeNode getUserObject

Introduction

In this page you can find the example usage for javax.swing.tree DefaultMutableTreeNode getUserObject.

Prototype

public Object getUserObject() 

Source Link

Document

Returns this node's user object.

Usage

From source file:view.WorkspacePanel.java

@Override
public void onSignatureClick(SignatureValidation sv) {
    if (status != Status.SIGNING) {
        jtValidation.clearSelection();//from  www  .ja  va2s  . co  m
        if (!rightPanel.isVisible()) {
            cl.show(this.rightPanel, String.valueOf(CardEnum.VALIDATE_PANEL));
            rightPanel.setVisible(true);
            jSplitPane1.setDividerSize(5);
            jSplitPane1.setDividerLocation(0.6);
        } else if (this.status == Status.SIGNING) {
            String msg = "";
            Object[] options = { Bundle.getBundle().getString("yes"), Bundle.getBundle().getString("no") };
            int opt = JOptionPane.showOptionDialog(null, msg,
                    Bundle.getBundle().getString("msg.signatureStillNotAppliedCancel1"),
                    JOptionPane.DEFAULT_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[0]);
            if (opt == JOptionPane.YES_OPTION) {
                removeTempSignature();
                cl.show(this.rightPanel, String.valueOf(CardEnum.VALIDATE_PANEL));
            } else {
                return;
            }
        }

        for (int i = 0; i < jtValidation.getRowCount(); i++) {
            TreePath tp = jtValidation.getPathForRow(i);
            DefaultMutableTreeNode dmtn = (DefaultMutableTreeNode) tp.getLastPathComponent();
            if (dmtn.getUserObject() instanceof SignatureValidation) {
                SignatureValidation sVal = (SignatureValidation) dmtn.getUserObject();
                if (sv.equals(sVal)) {
                    jtValidation.setSelectionRow(i);
                    jtValidation.expandRow(i);
                }
            }
        }

        status = Status.READY;
    }
}

From source file:view.WorkspacePanel.java

private void btnCheckCertificateActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCheckCertificateActionPerformed
    DefaultMutableTreeNode dtn = (DefaultMutableTreeNode) jtValidation.getLastSelectedPathComponent();
    SignatureValidation sv = null;/*from  www  .  j ava2  s  .  com*/
    if (dtn.isLeaf()) {
        DefaultMutableTreeNode dmtn = (DefaultMutableTreeNode) dtn.getParent();
        sv = (SignatureValidation) dmtn.getUserObject();
    } else {
        sv = (SignatureValidation) dtn.getUserObject();
    }
    CertificatePropertiesDialog cpd = new CertificatePropertiesDialog(mainWindow, true,
            sv.getSignature().getSignCertificateChain());
    cpd.setLocationRelativeTo(null);
    cpd.setVisible(true);
}

From source file:view.WorkspacePanel.java

private void jtValidationValueChanged(javax.swing.event.TreeSelectionEvent evt) {//GEN-FIRST:event_jtValidationValueChanged
    if (jtValidation.getSelectionRows().length == 0) {
        showSignatureValidationDetails(null);
        imagePanel.setSelectedSignature(null);
    } else if (jtValidation.getSelectionRows().length == 1) {
        DefaultMutableTreeNode dtn = (DefaultMutableTreeNode) jtValidation.getLastSelectedPathComponent();
        SignatureValidation sv = null;/*  www  . j  a v  a 2s.co m*/
        if (dtn.isLeaf()) {
            DefaultMutableTreeNode dmtn = (DefaultMutableTreeNode) dtn.getParent();
            sv = (SignatureValidation) dmtn.getUserObject();
        } else {
            sv = (SignatureValidation) dtn.getUserObject();
            jtValidation.expandRow(jtValidation.getSelectionRows()[0]);
        }
        showSignatureValidationDetails(sv);
        imagePanel.setSelectedSignature(sv);
        int pageNumber = sv.getPosList().get(0).page - 1;
        if (imagePanel.getPageNumber() != pageNumber) {
            imagePanel.setPageNumber(pageNumber);
            jsPageNumber.setValue(pageNumber + 1);
        }
    }
}

From source file:view.WorkspacePanel.java

private void lblRevisionMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblRevisionMouseClicked
    if (SwingUtilities.isLeftMouseButton(evt)) {
        DefaultMutableTreeNode dtn = (DefaultMutableTreeNode) jtValidation.getLastSelectedPathComponent();
        SignatureValidation sv = null;/*w  w  w.  j  ava  2 s.  c  o m*/
        if (dtn.isLeaf()) {
            DefaultMutableTreeNode dmtn = (DefaultMutableTreeNode) dtn.getParent();
            sv = (SignatureValidation) dmtn.getUserObject();
        } else {
            sv = (SignatureValidation) dtn.getUserObject();
        }
        try {
            File f = CCInstance.getInstance().extractRevision(document.getDocumentLocation(), sv.getName());
            openPdfReaderFromFile(f);
        } catch (RevisionExtractionException | IOException ex) {
            Logger.getLogger(WorkspacePanel.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
}