Example usage for javax.swing.tree DefaultMutableTreeNode isLeaf

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

Introduction

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

Prototype

public boolean isLeaf() 

Source Link

Document

Returns true if this node has no children.

Usage

From source file:pt.ua.dicoogle.rGUI.client.windows.MainWindow.java

private void jButtonDownloadActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonDownloadActionPerformed

    DefaultMutableTreeNode node = (DefaultMutableTreeNode) jTreeResults.getLastSelectedPathComponent();
    if (node == null) {
        return;//from   w  w  w  .j av a 2 s . c  o m
    }

    Object nodeInfo = node.getUserObject();

    if (node.isLeaf() && SearchResult.class.isInstance(nodeInfo)) {
        try {
            SearchResult temp = (SearchResult) nodeInfo;
            UserRefs.getInstance().getSearch().RequestP2PFile(temp);

        } catch (RemoteException ex) {
            Logger.getLogger(MainWindow.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
}

From source file:pt.ua.dicoogle.rGUI.client.windows.MainWindow.java

/**
 * Checks if the options form is displayed
 * @return true if not displaying, true otherwise
 *//*from w  w w . ja  v  a  2  s  .  c o m*/
private void showMetaData() {
    /**
     * Just show metadata for now
     **/
    DefaultMutableTreeNode node = (DefaultMutableTreeNode) jTreeResults.getLastSelectedPathComponent();

    if (node != null && node.isLeaf() && node.getLevel() > 3) {

        Object nodeInfo = node.getUserObject();
        SearchResult fileInfo = (SearchResult) nodeInfo;

        if (nodeInfo instanceof SearchResult) {
            IndexedMetaData metadataWindow = new IndexedMetaData(fileInfo, this);
            metadataWindow.setVisible(true);
            metadataWindow.toFront();
        }
    }
}

From source file:streamme.visuals.Main.java

public void playNodes() {
    DefaultMutableTreeNode node = (DefaultMutableTreeNode) tree_files.getLastSelectedPathComponent();
    if (node != null && node.isLeaf()) {
        DataNode dn = (DataNode) node.getUserObject();
        if (!dn.isFolder()) {
            PlaylistManager pm = PlaylistManager.get();
            DefaultMutableTreeNode parent = (DefaultMutableTreeNode) node.getParent();
            pm.clearPlaylist(-1);/*from   w  w w.  ja v a 2  s. c o m*/

            // Get Path:
            javax.swing.tree.TreeNode[] tree = parent.getPath();
            String path = StreamMe.OPTIONS.getOutputPath();
            for (int i = 1; i < tree.length; i++) {
                path += "\\" + ((DataNode) ((DefaultMutableTreeNode) tree[i]).getUserObject()).getName();
            }

            Enumeration ch = parent.children();
            DefaultMutableTreeNode child = null;
            while (ch.hasMoreElements()) {
                child = (DefaultMutableTreeNode) ch.nextElement();
                if (child.isLeaf())
                    break;
            }
            int songIdx = 0, i = 0;
            while (child != null) {
                DataNode childnode = (DataNode) child.getUserObject();

                if (child == node) {
                    songIdx = i;
                }
                pm.addToPlaylist(-1, childnode.toFileLink(path + "\\" + childnode.getName()));
                child = child.getNextSibling();
                i++;
            }
            playSong(pm.getDefaultModelIdx(), songIdx);
        }
    }
}

From source file:view.MultipleValidationDialog.java

private void jtValidationValueChanged(javax.swing.event.TreeSelectionEvent evt) {//GEN-FIRST:event_jtValidationValueChanged
    if (jtValidation.getSelectionRows().length == 0) {
        showSignatureValidationDetails(null);
    } else if (jtValidation.getSelectionRows().length == 1) {
        DefaultMutableTreeNode dtn = (DefaultMutableTreeNode) jtValidation.getLastSelectedPathComponent();
        SignatureValidation sv = null;/*from  w  w w. j  a  v  a  2s. com*/
        if (dtn.isLeaf()) {
            DefaultMutableTreeNode dmtn = (DefaultMutableTreeNode) dtn.getParent();
            sv = (SignatureValidation) dmtn.getUserObject();
        } else {
            sv = (SignatureValidation) dtn.getUserObject();
            jtValidation.expandRow(jtValidation.getSelectionRows()[0]);
        }
        showSignatureValidationDetails(sv);
    } else {
        jtValidation.setSelectionPath(evt.getOldLeadSelectionPath());
    }
}

From source file:view.MultipleValidationDialog.java

private void btnShowCertificateDetailsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnShowCertificateDetailsActionPerformed
    DefaultMutableTreeNode dtn = (DefaultMutableTreeNode) jtValidation.getLastSelectedPathComponent();
    SignatureValidation sv = null;//w w  w .  j  av a  2s  .c om
    if (dtn.isLeaf()) {
        DefaultMutableTreeNode dmtn = (DefaultMutableTreeNode) dtn.getParent();
        sv = (SignatureValidation) dmtn.getUserObject();
    } else {
        sv = (SignatureValidation) dtn.getUserObject();
    }
    CertificatePropertiesDialog cpd = new CertificatePropertiesDialog((MainWindow) this.getParent(), true,
            sv.getSignature().getSignCertificateChain());
    cpd.setLocationRelativeTo(null);
    cpd.setVisible(true);
}

From source file:view.MultipleValidationDialog.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;//ww w .  j  a  v  a  2  s .co  m
        if (dtn.isLeaf()) {
            DefaultMutableTreeNode dmtn = (DefaultMutableTreeNode) dtn.getParent();
            sv = (SignatureValidation) dmtn.getUserObject();
        } else {
            sv = (SignatureValidation) dtn.getUserObject();
        }
        try {
            File f = CCInstance.getInstance().extractRevision(sv.getFilename(), sv.getName());
            openPdfReaderFromFile(f);
        } catch (IOException | RevisionExtractionException ex) {
            Logger.getLogger(WorkspacePanel.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
}

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  w  w w .j  a  v  a 2s.  c  om*/
    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;//from  w  w  w. ja  va 2  s  . c o  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;//from w w w  .  j  av  a 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);
        }
    }
}