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:nz.govt.natlib.ndha.manualdeposit.ManualDepositPresenter.java

public void setRepresentationCode() {
    JTree tree = theEntityTree;//from  w ww.ja  va 2 s .  c om
    TreePath[] paths = tree.getSelectionPaths();
    for (int i = 0; i < paths.length; i++) {
        DefaultMutableTreeNode node = (DefaultMutableTreeNode) paths[i].getLastPathComponent();
        if ((node.getUserObject() instanceof FileGroup) || (node.getUserObject() instanceof FileSystemObject)
                || ((getEntities().size() > 1) && (node.getUserObject() instanceof FileGroupCollection))) {
            FileGroup group = (FileGroup) node.getUserObject();
            String repCode = manualDepositFrame.getInput("Enter Representation Code",
                    "Enter new representation code", group.getRepresentationCode());
            if (repCode != null) {
                group.setRepresentationCode(repCode);
            }
        }
    }
}

From source file:nz.govt.natlib.ndha.manualdeposit.ManualDepositPresenter.java

public void deleteEntity() {
    if (canDeleteEntityItem()) {
        JTree tree = theEntityTree;
        TreePath[] paths = tree.getSelectionPaths();
        for (int i = 0; i < paths.length; i++) {
            DefaultMutableTreeNode node = (DefaultMutableTreeNode) paths[i].getLastPathComponent();
            if ((node.getUserObject() instanceof FileGroup)
                    || (node.getUserObject() instanceof FileSystemObject)
                    || ((getEntities().size() > 1) && (node.getUserObject() instanceof FileGroupCollection))) {
                deleteEntityNode(node);// w ww. j  a  v a2s. c o m
            }
        }
        ArrayList<FileGroupCollection> entities = getEntities();
        renumberEntityTypes(entities);
        addFileSystemRoot(theFsoRoot, true, false);
        deleteStructMapItemsNotInIE();
        refreshEntityTree();
    }
}

From source file:nz.govt.natlib.ndha.manualdeposit.ManualDepositPresenter.java

private void deleteMapItemIfNotInIE(DefaultMutableTreeNode node) {
    for (int i = 0; i < node.getChildCount(); i++) {
        DefaultMutableTreeNode nodeChild = (DefaultMutableTreeNode) node.getChildAt(i);
        deleteMapItemIfNotInIE(nodeChild);
    }//from  www.  jav a2 s.c  om
    if (node.getUserObject() instanceof FileSystemObject) {
        FileSystemObject fso = (FileSystemObject) node.getUserObject();
        if (!this.fileIsInEntity(fso)) {
            this.deleteStructMapNode(node);
        }
    }
}

From source file:nz.govt.natlib.ndha.manualdeposit.ManualDepositPresenter.java

public boolean canDeleteStructItem() {
    boolean canMove = false;
    JTree tree = this.getTree(ETreeType.StructMapTree);
    if (tree != null) {
        if (tree.getSelectionCount() > 0) {
            TreePath[] paths = tree.getSelectionPaths();
            for (int i = 0; i < paths.length; i++) {
                DefaultMutableTreeNode node = (DefaultMutableTreeNode) paths[i].getLastPathComponent();
                if ((node.getUserObject() instanceof StructMap)
                        || (node.getUserObject() instanceof FileSystemObject)) {
                    canMove = true;/*w w  w  .j  a v a2  s.c  om*/
                    break;
                }
            }
        }
    }
    return canMove;
}

From source file:nz.govt.natlib.ndha.manualdeposit.ManualDepositPresenter.java

public void deleteStructMapItem() {
    if (canDeleteStructItem()) {
        JTree tree = this.getTree(ETreeType.StructMapTree);
        if (tree != null) {
            if (tree.getSelectionCount() > 0) {
                TreePath[] paths = tree.getSelectionPaths();
                for (int i = 0; i < paths.length; i++) {
                    DefaultMutableTreeNode node = (DefaultMutableTreeNode) paths[i].getLastPathComponent();
                    if ((node.getUserObject() instanceof StructMap)
                            || (node.getUserObject() instanceof FileSystemObject)) {
                        deleteStructMapNode(node);
                    }/*  w ww  .  j a v  a2s  .  com*/
                }
            }
        }
    }
}

From source file:nz.govt.natlib.ndha.manualdeposit.ManualDepositPresenter.java

public void openFile(DefaultMutableTreeNode node) {
    if (node.getUserObject() instanceof FileSystemObject) {
        FileSystemObject fso = (FileSystemObject) node.getUserObject();
        if (fso.getIsFile()) {
            try {
                Runtime.getRuntime()
                        .exec("rundll32 SHELL32.DLL,ShellExec_RunDLL " + fso.getFile().getAbsolutePath());
            } catch (Exception ex) {
                String message = "Could not open file " + fso.getDescription();
                manualDepositFrame.showError("Could not open file", message, ex);
                reportException(ex);//from  w  ww.  j av a2s. c  o m
            }
        }
    }
}

From source file:nz.govt.natlib.ndha.manualdeposit.ManualDepositPresenter.java

public void openFileLocation(DefaultMutableTreeNode node) {
    if (node.getUserObject() instanceof FileSystemObject) {
        FileSystemObject fso = (FileSystemObject) node.getUserObject();
        if (fso.getIsFile()) {
            try {
                Runtime.getRuntime().exec("explorer.exe /select," + fso.getFile().getAbsolutePath());
                //Desktop.getDesktop().open(new File(fso.getFullPathNoFileName()));
            } catch (Exception ex) {
                String message = "Could not open file location " + fso.getDescription();
                manualDepositFrame.showError("Could not open file location", message, ex);
                reportException(ex);//from ww  w  .j a  v  a2s .c  om
            }
        }
    }
}

From source file:nz.govt.natlib.ndha.manualdeposit.ManualDepositPresenter.java

public void refreshFileList() {
    ArrayList<DefaultMutableTreeNode> clipboard = getClipboardCopy();
    for (DefaultMutableTreeNode node : clipboard) {
        if (node.getUserObject() instanceof FileSystemObject) {
            node.removeAllChildren();/* ww  w. ja  v a2  s  .  c o m*/
            FileSystemObject fso = (FileSystemObject) node.getUserObject();
            fso.loadChildren(false);
            DepositTreeModel model = (DepositTreeModel) theFileSystemTree.getModel();
            addChildFiles(node, fso.getChildren(), model, null, theFileSystemTree);
        }
    }
}

From source file:nz.govt.natlib.ndha.manualdeposit.ManualDepositPresenter.java

public JPopupMenu getEntityMenu(DefaultMutableTreeNode node) {
    theNodeInClipboard.clear();/*  ww  w .  j a v a  2  s. c o m*/
    theNodeInClipboard.add(node);
    JPopupMenu menu = null;
    if (node.getUserObject() instanceof FileSystemObject) {
        menu = getEntityMenu((FileSystemObject) node.getUserObject());
    } else if (node.getUserObject() instanceof FileGroupCollection) {
        menu = getEntityMenu((FileGroupCollection) node.getUserObject());
    } else if (node.getUserObject() instanceof FileGroup) {
        menu = getEntityMenu((FileGroup) node.getUserObject());
    }
    return menu;
}

From source file:nz.govt.natlib.ndha.manualdeposit.ManualDepositPresenter.java

public JPopupMenu getStructMapMenu(DefaultMutableTreeNode node) {
    theNodeInClipboard.clear();/*from www .j  a v  a  2 s  .  c  o m*/
    theNodeInClipboard.add(node);
    JPopupMenu menu = null;
    if (node.getUserObject() instanceof String) {
        menu = getStructMapMenu();
    } else if (node.getUserObject() instanceof FileSystemObject) {
        menu = getStructMapMenu((FileSystemObject) node.getUserObject());
    } else if (node.getUserObject() instanceof StructMap) {
        menu = getStructMapMenu((StructMap) node.getUserObject());
    }
    return menu;
}