Example usage for javax.swing.event TreeSelectionEvent getPath

List of usage examples for javax.swing.event TreeSelectionEvent getPath

Introduction

In this page you can find the example usage for javax.swing.event TreeSelectionEvent getPath.

Prototype

public TreePath getPath() 

Source Link

Document

Returns the first path element.

Usage

From source file:org.photovault.swingui.volumetree.VolumeTreeController.java

public void valueChanged(TreeSelectionEvent e) {
    DefaultMutableTreeNode node = (DefaultMutableTreeNode) e.getPath().getLastPathComponent();
    VolumeTreeNode dir = (VolumeTreeNode) node.getUserObject();

    // Test/*from  www.j a  va2 s  . c  o  m*/
    ExtDirPhotos photoQuery = new ExtDirPhotos(dir.volId, dir.path);
    fireEvent(new PhotoFolderTreeEvent(this, photoQuery));
    List<PhotoInfo> photos = photoQuery.queryPhotos(getPersistenceContext());
    log.debug("Directory " + dir.volId + ":" + dir.path + " selected. " + photos.size() + " photos.");
}

From source file:view.MultipleValidationDialog.java

private void jtFilesValueChanged(javax.swing.event.TreeSelectionEvent evt) {//GEN-FIRST:event_jtFilesValueChanged
    jtValidation.setModel(null);/*from   ww w .ja  va2  s  . c o m*/
    ArrayList<SignatureValidation> svList = null;

    if (jtFiles.getSelectionRows().length > 1) {
        jtFiles.setSelectionPath(evt.getOldLeadSelectionPath());
        return;
    }

    if (evt.getNewLeadSelectionPath() == null) {
        panelSignatureDetails.setVisible(false);
        return;
    }

    for (Map.Entry<ValidationFileListEntry, ArrayList<SignatureValidation>> entry : hmValidation.entrySet()) {
        int numSigs = CCInstance.getInstance().getNumberOfSignatures(entry.getKey().getFilename());
        if (String.valueOf(evt.getPath().getLastPathComponent())
                .equals("(" + numSigs + ") " + entry.getKey().getFilename())) {
            svList = entry.getValue();
            break;
        }
    }

    final DefaultMutableTreeNode top = new DefaultMutableTreeNode(null);

    if (svList == null) {
        return;
    }
    if (svList.isEmpty()) {
        panelSignatureDetails.setVisible(false);
        DefaultMutableTreeNode noSignatures = new TreeNodeWithState(Bundle.getBundle().getString("notSigned"),
                TreeNodeWithState.State.NOT_SIGNED);
        top.add(noSignatures);
        TreeModel tm = new DefaultTreeModel(top);
        jtValidation.setModel(tm);
        return;
    }

    for (SignatureValidation sv : svList) {
        DefaultMutableTreeNode sig = new DefaultMutableTreeNode(sv);

        TreeNodeWithState childChanged = null;
        if (sv.isCertification()) {
            if (sv.isValid()) {
                if (sv.isChanged() || !sv.isCoversEntireDocument()) {
                    childChanged = new TreeNodeWithState(
                            "<html>" + Bundle.getBundle().getString("tn.1") + "<br>"
                                    + Bundle.getBundle().getString("tn.2") + "</html>",
                            TreeNodeWithState.State.CERTIFIED_WARNING);
                } else {
                    childChanged = new TreeNodeWithState(Bundle.getBundle().getString("certifiedOk"),
                            TreeNodeWithState.State.CERTIFIED);
                }
            } else {
                childChanged = new TreeNodeWithState(Bundle.getBundle().getString("changedAfterCertified"),
                        TreeNodeWithState.State.INVALID);
            }
        } else if (sv.isValid()) {
            if (sv.isChanged()) {
                childChanged = new TreeNodeWithState(
                        "<html>" + Bundle.getBundle().getString("tn.3") + "<br>"
                                + Bundle.getBundle().getString("tn.4") + "</html>",
                        TreeNodeWithState.State.VALID_WARNING);
            } else {
                childChanged = new TreeNodeWithState(Bundle.getBundle().getString("signedOk"),
                        TreeNodeWithState.State.VALID);
            }
        } else {
            childChanged = new TreeNodeWithState(Bundle.getBundle().getString("signedChangedOrCorrupted"),
                    TreeNodeWithState.State.INVALID);
        }

        TreeNodeWithState childVerified = null;
        if (sv.getOcspCertificateStatus().equals(CertificateStatus.OK)
                || sv.getCrlCertificateStatus().equals(CertificateStatus.OK)) {
            childVerified = new TreeNodeWithState(Bundle.getBundle().getString("certOK"),
                    TreeNodeWithState.State.VALID);
        } else if (sv.getOcspCertificateStatus().equals(CertificateStatus.REVOKED)
                || sv.getCrlCertificateStatus().equals(CertificateStatus.REVOKED)) {
            childVerified = new TreeNodeWithState(Bundle.getBundle().getString("certRevoked"),
                    TreeNodeWithState.State.INVALID);
        } else if (sv.getOcspCertificateStatus().equals(CertificateStatus.UNCHECKED)
                && sv.getCrlCertificateStatus().equals(CertificateStatus.UNCHECKED)) {
            childVerified = new TreeNodeWithState(Bundle.getBundle().getString("certNotVerified"),
                    TreeNodeWithState.State.WARNING);
        } else if (sv.getOcspCertificateStatus().equals(CertificateStatus.UNCHAINED)) {
            childVerified = new TreeNodeWithState(Bundle.getBundle().getString("certNotChained"),
                    TreeNodeWithState.State.WARNING);
        } else if (sv.getOcspCertificateStatus().equals(CertificateStatus.EXPIRED)) {
            childVerified = new TreeNodeWithState(Bundle.getBundle().getString("certExpired"),
                    TreeNodeWithState.State.WARNING);
        } else if (sv.getOcspCertificateStatus().equals(CertificateStatus.CHAINED_LOCALLY)) {
            childVerified = new TreeNodeWithState(
                    "<html>" + Bundle.getBundle().getString("tn.5") + "<br>"
                            + Bundle.getBundle().getString("tn.6") + "</html>",
                    TreeNodeWithState.State.VALID_WARNING);
        }

        TreeNodeWithState childTimestamp = null;
        if (sv.isValidTimeStamp()) {
            childTimestamp = new TreeNodeWithState(Bundle.getBundle().getString("validTimestamp"),
                    TreeNodeWithState.State.VALID);
        } else {
            childTimestamp = new TreeNodeWithState(Bundle.getBundle().getString("signerDateTime"),
                    TreeNodeWithState.State.WARNING);
        }

        sig.add(childChanged);
        sig.add(childVerified);
        sig.add(childTimestamp);
        top.add(sig);
    }
    TreeModel tm = new DefaultTreeModel(top);
    jtValidation.setModel(tm);

    if (jtValidation.getRowCount() > 0) {
        jtValidation.setSelectionRow(jtValidation.getRowCount() - 1);
    }
}