Example usage for javax.swing JTree getModel

List of usage examples for javax.swing JTree getModel

Introduction

In this page you can find the example usage for javax.swing JTree getModel.

Prototype

public TreeModel getModel() 

Source Link

Document

Returns the TreeModel that is providing the data.

Usage

From source file:eu.crisis_economics.abm.dashboard.Page_Parameters.java

private JPanel createAParameterBox(final boolean first) {

    final JLabel runLabel = new JLabel("<html><b>Number of runs:</b> 0</html>");
    final JLabel warningLabel = new JLabel();

    final JButton closeButton = new JButton();
    closeButton.setOpaque(false);//from w w  w  . jav a  2 s. c om
    closeButton.setBorder(null);
    closeButton.setFocusable(false);

    if (!first) {
        closeButton.setRolloverIcon(PARAMETER_BOX_REMOVE);
        closeButton.setRolloverEnabled(true);
        closeButton.setIcon(RGBGrayFilter.getDisabledIcon(closeButton, PARAMETER_BOX_REMOVE));
        closeButton.setActionCommand(ACTIONCOMMAND_REMOVE_BOX);
    }

    final JScrollPane treeScrPane = new JScrollPane();
    final DefaultMutableTreeNode treeRoot = new DefaultMutableTreeNode();
    final JTree tree = new JTree(treeRoot);
    ToolTipManager.sharedInstance().registerComponent(tree);

    tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
    tree.setCellRenderer(new ParameterBoxTreeRenderer());
    tree.addTreeSelectionListener(new TreeSelectionListener() {
        public void valueChanged(final TreeSelectionEvent e) {
            final TreePath selectionPath = tree.getSelectionPath();
            boolean success = true;
            if (editedNode != null
                    && (selectionPath == null || !editedNode.equals(selectionPath.getLastPathComponent())))
                success = modify();

            if (success) {
                if (selectionPath != null) {
                    cancelAllSelectionBut(tree);
                    final DefaultMutableTreeNode node = (DefaultMutableTreeNode) selectionPath
                            .getLastPathComponent();
                    if (!node.equals(editedNode)) {
                        ParameterInATree userObj = null;
                        final DefaultTreeModel model = (DefaultTreeModel) tree.getModel();
                        if (!node.isRoot()
                                && selectionPath.getPathCount() == model.getPathToRoot(node).length) {
                            userObj = (ParameterInATree) node.getUserObject();
                            final ParameterInfo info = userObj.info;
                            editedNode = node;
                            editedTree = tree;
                            edit(info);
                        } else {
                            tree.setSelectionPath(null);
                            if (cancelButton.isEnabled())
                                cancelButton.doClick();
                            resetSettings();
                            enableDisableSettings(false);
                            editedNode = null;
                            editedTree = null;
                        }

                        updateDescriptionField(userObj);
                    } else
                        updateDescriptionField();

                } else
                    updateDescriptionField();

                enableDisableParameterCombinationButtons();
            } else {
                final DefaultTreeModel model = (DefaultTreeModel) editedTree.getModel();
                final DefaultMutableTreeNode storedEditedNode = editedNode;
                editedNode = null;
                tree.setSelectionPath(null);
                editedNode = storedEditedNode;
                editedTree.setSelectionPath(new TreePath(model.getPathToRoot(editedNode)));
            }
        }
    });

    treeScrPane.setViewportView(tree);
    treeScrPane.setBorder(null);
    treeScrPane.setViewportBorder(null);
    treeScrPane.setPreferredSize(new Dimension(450, 250));

    final JButton upButton = new JButton();
    upButton.setOpaque(false);
    upButton.setRolloverEnabled(true);
    upButton.setIcon(PARAMETER_UP_ICON);
    upButton.setRolloverIcon(PARAMETER_UP_ICON_RO);
    upButton.setDisabledIcon(PARAMETER_UP_ICON_DIS);
    upButton.setBorder(null);
    upButton.setToolTipText("Move up the selected parameter");
    upButton.setActionCommand(ACTIONCOMMAND_MOVE_UP);

    final JButton downButton = new JButton();
    downButton.setOpaque(false);
    downButton.setRolloverEnabled(true);
    downButton.setIcon(PARAMETER_DOWN_ICON);
    downButton.setRolloverIcon(PARAMETER_DOWN_ICON_RO);
    downButton.setDisabledIcon(PARAMETER_DOWN_ICON_DIS);
    downButton.setBorder(null);
    downButton.setToolTipText("Move down the selected parameter");
    downButton.setActionCommand(ACTIONCOMMAND_MOVE_DOWN);

    final JPanel mainPanel = FormsUtils.build("~ f:p:g ~ p ~ r:p",
            "012||" + "333||" + "44_||" + "445||" + "446||" + "44_ f:p:g", runLabel, first ? "" : warningLabel,
            first ? warningLabel : closeButton, new FormsUtils.Separator(""), treeScrPane, upButton, downButton)
            .getPanel();

    mainPanel.setBorder(BorderFactory.createTitledBorder(""));

    final JButton addButton = new JButton();
    addButton.setOpaque(false);
    addButton.setRolloverEnabled(true);
    addButton.setIcon(PARAMETER_ADD_ICON);
    addButton.setRolloverIcon(PARAMETER_ADD_ICON_RO);
    addButton.setDisabledIcon(PARAMETER_ADD_ICON_DIS);
    addButton.setBorder(null);
    addButton.setToolTipText("Add selected parameter");
    addButton.setActionCommand(ACTIONCOMMAND_ADD_PARAM);

    final JButton removeButton = new JButton();
    removeButton.setOpaque(false);
    removeButton.setRolloverEnabled(true);
    removeButton.setIcon(PARAMETER_REMOVE_ICON);
    removeButton.setRolloverIcon(PARAMETER_REMOVE_ICON_RO);
    removeButton.setDisabledIcon(PARAMETER_REMOVE_ICON_DIS);
    removeButton.setBorder(null);
    removeButton.setToolTipText("Remove selected parameter");
    removeButton.setActionCommand(ACTIONCOMMAND_REMOVE_PARAM);

    final JPanel result = FormsUtils.build("p ~ f:p:g", "_0 f:p:g||" + "10 p ||" + "20 p||" + "_0 f:p:g",
            mainPanel, addButton, removeButton).getPanel();

    Style.registerCssClasses(result, Dashboard.CSS_CLASS_COMMON_PANEL);

    final ParameterCombinationGUI pcGUI = new ParameterCombinationGUI(tree, treeRoot, runLabel, warningLabel,
            addButton, removeButton, upButton, downButton);
    parameterTreeBranches.add(pcGUI);

    final ActionListener boxActionListener = new ActionListener() {

        //====================================================================================================
        // methods

        //----------------------------------------------------------------------------------------------------
        public void actionPerformed(final ActionEvent e) {
            final String cmd = e.getActionCommand();

            if (ACTIONCOMMAND_ADD_PARAM.equals(cmd))
                handleAddParameter(pcGUI);
            else if (ACTIONCOMMAND_REMOVE_PARAM.equals(cmd))
                handleRemoveParameter(tree);
            else if (ACTIONCOMMAND_REMOVE_BOX.equals(cmd))
                handleRemoveBox(tree);
            else if (ACTIONCOMMAND_MOVE_UP.equals(cmd))
                handleMoveUp();
            else if (ACTIONCOMMAND_MOVE_DOWN.equals(cmd))
                handleMoveDown();
        }

        //----------------------------------------------------------------------------------------------------
        private void handleAddParameter(final ParameterCombinationGUI pcGUI) {
            final Object[] selectedValues = parameterList.getSelectedValues();
            if (selectedValues != null && selectedValues.length > 0) {
                final AvailableParameter[] params = new AvailableParameter[selectedValues.length];
                System.arraycopy(selectedValues, 0, params, 0, selectedValues.length);
                addParameterToTree(params, pcGUI);
                enableDisableParameterCombinationButtons();
            }
        }

        //----------------------------------------------------------------------------------------------------
        private void handleRemoveParameter(final JTree tree) {
            final TreePath selectionPath = tree.getSelectionPath();
            if (selectionPath != null) {
                cancelButton.doClick();

                final DefaultMutableTreeNode node = (DefaultMutableTreeNode) selectionPath
                        .getLastPathComponent();
                if (!node.isRoot()) {
                    final DefaultMutableTreeNode parentNode = (DefaultMutableTreeNode) node.getParent();
                    if (parentNode.isRoot()) {
                        removeParameter(tree, node, parentNode);
                        enableDisableParameterCombinationButtons();
                    }
                }
            }
        }

        //----------------------------------------------------------------------------------------------------
        private void handleRemoveBox(final JTree tree) {
            final int answer = Utilities.askUser(dashboard, false, "Comfirmation",
                    "This operation deletes the combination.",
                    "All related parameter returns back to the list on the left side.", "Are you sure?");
            if (answer == 1) {
                final DefaultTreeModel treeModel = (DefaultTreeModel) tree.getModel();

                if (tree.getSelectionCount() > 0) {
                    editedNode = null;
                    tree.setSelectionPath(null);
                    if (cancelButton.isEnabled())
                        cancelButton.doClick();
                }

                final DefaultMutableTreeNode root = (DefaultMutableTreeNode) treeModel.getRoot();
                for (int i = 0; i < root.getChildCount(); ++i) {
                    final DefaultMutableTreeNode node = (DefaultMutableTreeNode) root.getChildAt(i);
                    removeParameter(tree, node, root);
                }

                enableDisableParameterCombinationButtons();

                parameterTreeBranches.remove(pcGUI);
                combinationsPanel.remove(result);
                combinationsPanel.revalidate();

                updateNumberOfRuns();
            }
        }

        //----------------------------------------------------------------------------------------------------
        private void removeParameter(final JTree tree, final DefaultMutableTreeNode node,
                final DefaultMutableTreeNode parentNode) {
            final ParameterInATree userObj = (ParameterInATree) node.getUserObject();
            final ParameterInfo originalInfo = findOriginalInfo(userObj.info);
            if (originalInfo != null) {
                final DefaultListModel model = (DefaultListModel) parameterList.getModel();
                model.addElement(new AvailableParameter(originalInfo, currentModelHandler.getModelClass()));
                final DefaultTreeModel treeModel = (DefaultTreeModel) tree.getModel();
                treeModel.removeNodeFromParent(node);
                updateNumberOfRuns();
                tree.expandPath(new TreePath(treeModel.getPathToRoot(parentNode)));
            } else
                throw new IllegalStateException(
                        "Parameter " + userObj.info.getName() + " is not found in the model.");
        }

        //----------------------------------------------------------------------------------------------------
        private void handleMoveUp() {
            final TreePath selectionPath = tree.getSelectionPath();
            if (selectionPath != null) {
                boolean success = true;
                if (editedNode != null)
                    success = modify();

                if (success) {
                    final DefaultMutableTreeNode node = (DefaultMutableTreeNode) selectionPath
                            .getLastPathComponent();
                    final DefaultMutableTreeNode parent = (DefaultMutableTreeNode) node.getParent();

                    if (parent == null || parent.getFirstChild().equals(node)) {
                        tree.setSelectionPath(null); // we need this to preserve the state of the parameter settings panel
                        tree.setSelectionPath(new TreePath(node.getPath()));
                        return;
                    }

                    final int index = parent.getIndex(node);
                    final DefaultTreeModel treemodel = (DefaultTreeModel) tree.getModel();
                    treemodel.removeNodeFromParent(node);
                    treemodel.insertNodeInto(node, parent, index - 1);
                    tree.setSelectionPath(new TreePath(node.getPath()));
                }

            }
        }

        //----------------------------------------------------------------------------------------------------
        private void handleMoveDown() {
            final TreePath selectionPath = tree.getSelectionPath();
            if (selectionPath != null) {
                boolean success = true;
                if (editedNode != null)
                    success = modify();

                if (success) {
                    final DefaultMutableTreeNode node = (DefaultMutableTreeNode) selectionPath
                            .getLastPathComponent();
                    final DefaultMutableTreeNode parent = (DefaultMutableTreeNode) node.getParent();

                    if (parent == null || parent.getLastChild().equals(node)) {
                        tree.setSelectionPath(null); // we need this to preserve the state of the parameter settings panel
                        tree.setSelectionPath(new TreePath(node.getPath()));
                        return;
                    }

                    final int index = parent.getIndex(node);
                    final DefaultTreeModel treemodel = (DefaultTreeModel) tree.getModel();
                    treemodel.removeNodeFromParent(node);
                    treemodel.insertNodeInto(node, parent, index + 1);
                    tree.setSelectionPath(new TreePath(node.getPath()));
                }
            }
        }
    };

    GUIUtils.addActionListener(boxActionListener, closeButton, upButton, downButton, addButton, removeButton);

    result.setPreferredSize(new Dimension(500, 250));
    enableDisableParameterCombinationButtons();

    Style.apply(result, dashboard.getCssStyle());

    return result;
}

From source file:nz.govt.natlib.ndha.manualdeposit.customui.IconRenderer.java

public Component getTreeCellRendererComponent(JTree tree, Object value, boolean sel, boolean expanded,
        boolean leaf, int row, boolean hasFocus) {
    super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus);
    this.setToolTipText("");
    DepositTreeModel model = null;/*from w  w w  . jav  a  2s . c o m*/
    //      MD5Digest digest = null;
    ChecksumDigest digest = null;
    if (tree.getModel() instanceof DepositTreeModel) {
        model = (DepositTreeModel) tree.getModel();
        digest = model.getChecksumDigest();
    }
    DefaultMutableTreeNode node = (DefaultMutableTreeNode) value;
    if ((node.getParent() != null) && (node.getUserObject() instanceof FileGroupCollection)
            && (model.getChecksumDigest() != null) && !(model.getChecksumDigest().isFixitySuccessful(node))) {
        setIcon(folderHomeIcon);
        this.setForeground(java.awt.Color.red);
    } else if (node.getUserObject() instanceof FileSystemObject) {
        FileSystemObject fso = (FileSystemObject) node.getUserObject();
        if (digest != null && fso.getOriginalChecksum() != null) {
            if (!fso.checksumMatches()) {
                this.setForeground(java.awt.Color.red);
                this.setToolTipText("Invalid Fixity value");
            } else {
                this.setForeground(new Color(0, 125, 0));
                this.setToolTipText("File has correct fixity value");
            }
        } else if (digest != null && fso.getIsDuplicate()) {
            this.setForeground(new Color(255, 127, 80));
            this.setToolTipText("Duplicate filename in checksum digest");
        } else if (digest != null && digest.getFileStatus(fso) == null && fso.getIsFile()) {
            this.setForeground(java.awt.Color.blue);
            this.setToolTipText("File is not listed in checksum Digest");
        }
        if (model != null && model.getTreeType() == ETreeType.FileSystemTree) {
            if (fso.getIsFile()) {
                setIcon(getMimeTypeIcon(fso));
            } else {
                setIcon(folderFileSystemIcon);
            }
        } else if (model != null && model.getTreeType() == ETreeType.EntityTree) {
            if (fso.getIsFile()) {
                setIcon(getMimeTypeIcon(fso));
            } else {
                setIcon(folderEntityIcon);
            }
        } else if (model != null && model.getTreeType() == ETreeType.StructMapTree) {
            if (fso.getIsFile()) {
                setIcon(getMimeTypeIcon(fso));
            } else {
                setIcon(folderFileSystemIcon);
            }
        }
    } else if (node.getUserObject() instanceof FileGroup) {
        FileGroup group = (FileGroup) node.getUserObject();
        if (group.getEntityType() == RepresentationTypes.DigitalOriginal) {
            setIcon(digitalOriginalIcon);
        } else if (group.getEntityType() == RepresentationTypes.PreservationMaster) {
            setIcon(preservationCopyIcon);
        } else if (group.getEntityType() == RepresentationTypes.ModifiedMaster) {
            setIcon(modifiedMasterIcon);
        } else if (group.getEntityType() == RepresentationTypes.AccessCopy
                || group.getEntityType() == RepresentationTypes.AccessCopy_High
                || group.getEntityType() == RepresentationTypes.AccessCopy_Medium
                || group.getEntityType() == RepresentationTypes.AccessCopy_Low
                || group.getEntityType() == RepresentationTypes.AccessCopy_Epub
                || group.getEntityType() == RepresentationTypes.AccessCopy_Pdf) {
            setIcon(accessCopyIcon);
        } else {
            setIcon(digitalOriginalIcon);
        }
    } else if (node.getUserObject() instanceof StructMap) {
        setIcon(structMapIcon);
    } else {
        setIcon(folderHomeIcon);

        // Build tooltip at SIP level, to inform user of all colour coded issues with this SIP.
        String toolTipText = "";
        if ((node.getParent() == null) && (node.getUserObject() != null) && (model != null)
                && (model.getChecksumDigest() != null)) {
            if (model.getChecksumDigest().getMissingFiles().size() > 0) {
                toolTipText = "Some files from checksum digest can't be located.";
            }
            if (model.getChecksumDigest().getFilesMissingFromDigest(node).size() > 0) {
                if (toolTipText.isEmpty())
                    toolTipText = "Some files not listed in the checksum digest. (BLUE)";
                else
                    toolTipText = toolTipText + "<br>" + "Some files not listed in the checksum digest. (BLUE)";
            }
            if (model.getChecksumDigest().hasDuplicateFiles(node)) {
                if (toolTipText.isEmpty())
                    toolTipText = "Duplicate files in checksum digest. (ORANGE)";
                else
                    toolTipText = toolTipText + "<br>" + "Duplicate files in checksum digest. (ORANGE)";
            }
            if (!(model.getChecksumDigest().isFixitySuccessful(node))) {
                if (toolTipText.isEmpty())
                    toolTipText = "Files with invalid fixity values. (RED)";
                else
                    toolTipText = toolTipText + "<br>" + "Files with invalid fixity values. (RED)";
            }
        }
        if (!toolTipText.isEmpty()) {
            this.setForeground(java.awt.Color.red);
            toolTipText = "<html>" + toolTipText + "</html>";
            this.setToolTipText(toolTipText);
        }

        // If an IE has customized Metadata then change colour of entity
        if (node.getUserObject() != null) {
            if (node.getUserObject() instanceof FileGroupCollection
                    && (!node.getUserObject().toString().equals("Preservation Master"))) {
                FileGroupCollection entity = (FileGroupCollection) node.getUserObject();
                if (entity.isCustomized()) {
                    this.setForeground(java.awt.Color.MAGENTA);
                    this.setToolTipText("IE has customized Metadata.");
                }
            }
        }
    }
    repaint();
    return this;
}

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

private ETreeType getTreeType(final JTree tree) {
    final DepositTreeModel model = (DepositTreeModel) tree.getModel();
    return model.getTreeType();
}

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

private JTree getTree(final ETreeType treeType) {
    JTree retVal = null;//from  w  w w  . j a v  a  2 s  . co  m
    for (JTree tree : trees) {
        final DepositTreeModel model = (DepositTreeModel) tree.getModel();
        if (model.getTreeType().equals(treeType)) {
            retVal = tree;
            break;
        }
    }
    return retVal;
}

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

private DepositTreeModel getModel(final ETreeType treeType) {
    DepositTreeModel retVal = null;//from w  w  w .  j a  v a 2  s.  co m
    for (JTree tree : trees) {
        DepositTreeModel model = (DepositTreeModel) tree.getModel();
        if (model.getTreeType().equals(treeType)) {
            retVal = model;
            break;
        }
    }
    return retVal;
}

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

public void selectNode(Object nodeObject, ETreeType treeType) {
    JTree tree = getTree(treeType);
    DepositTreeModel model = (DepositTreeModel) tree.getModel();
    DefaultMutableTreeNode rootNode = (DefaultMutableTreeNode) model.getRoot();
    DefaultMutableTreeNode node = findNode(rootNode, nodeObject);
    if (node != null) {
        LOG.debug("selectNode Node object found");
        TreePath path = new TreePath(node.getPath());
        tree.scrollPathToVisible(path);/*from   w  w  w  . ja  v  a2 s . c o  m*/
        tree.setSelectionPath(path);
    } else {
        LOG.debug("selectNode Node object not found");
    }
}

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

public void createAutoStructItem(boolean fromSingleFile) {
    if (canCreateAutoStructItem()) {
        JTree tree = getTree(ETreeType.EntityTree);
        if ((tree != null) && (tree.getSelectionCount() > 0)) {
            String structNodeName = getNewStructNodeName();
            if (structNodeName == null) {
                return;
            }/* w  ww.  ja va 2s  .co  m*/
            StructMapCollection structure = getStructures();
            FSOCollection files = new FSOCollection();
            if (fromSingleFile) {
                // Complex one - need to recurse through tree & get all
                // matching files
                TreePath[] paths = tree.getSelectionPaths();
                DefaultMutableTreeNode nodeSource = null;
                for (int i = 0; i < paths.length; i++) {
                    DefaultMutableTreeNode node = (DefaultMutableTreeNode) paths[i].getLastPathComponent();
                    if (node.getUserObject() instanceof FileSystemObject) {
                        nodeSource = node;
                        break;
                    }
                }
                if (nodeSource != null) {
                    DepositTreeModel model = (DepositTreeModel) tree.getModel();
                    DefaultMutableTreeNode rootNode = (DefaultMutableTreeNode) model.getRoot();
                    FileSystemObject fso = (FileSystemObject) nodeSource.getUserObject();
                    String baseFileName = fso.getFileNameWithoutRepTypeOrSuffix();
                    getMatchingFiles(baseFileName, rootNode, files);
                }
            } else {
                TreePath[] paths = tree.getSelectionPaths();
                for (int i = 0; i < paths.length; i++) {
                    DefaultMutableTreeNode node = (DefaultMutableTreeNode) paths[i].getLastPathComponent();
                    if (node.getUserObject() instanceof FileSystemObject) {
                        FileSystemObject fso = (FileSystemObject) node.getUserObject();
                        files.add(fso);
                    }
                }
            }

            files.setSortBy(manualDepositFrame.getCurrentSortBy());
            files.reSortList();
            int structSortOrder = 0;
            for (FileSystemObject fso : files) {
                fso.setStructSortOrder(structSortOrder);
                structSortOrder++;
            }
            StructMap map = StructMap.create(structNodeName, null, files, 0);
            structure.add(map);
            addStructMap(structure);
        }
    }
}

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

private void putIERootInClipboard() {
    for (JTree tree : trees) {
        DepositTreeModel model = (DepositTreeModel) tree.getModel();
        if (model.getTreeType() == ETreeType.EntityTree) {
            theNodeInClipboard.clear();//from w w w .  jav  a 2  s .  c o m
            theNodeInClipboard.add((DefaultMutableTreeNode) model.getRoot());
            break;
        }
    }
}

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

private boolean dropOK(DefaultMutableTreeNode destinationNode, JTree destinationTree) {
    boolean canDrop = false;
    if (droppingDoesntMakeSense(theNodeInClipboard, destinationNode)) {
        return false;
    }//w  w w  .  j ava2s  . co  m

    if (dragFromTreeType.equals(ETreeType.FileSystemTree)) {
        for (DefaultMutableTreeNode node : theNodeInClipboard) {
            if (node.getUserObject() instanceof FileSystemObject) {
                if (entityRootSet) {
                    if (destinationNode.getUserObject() instanceof FileGroup) {
                        canDrop = true;
                    } else if (destinationNode.getUserObject() instanceof FileSystemObject) {
                        canDrop = true;
                    }
                } else {
                    canDrop = true;
                }
            }
            if (!canDrop) {
                break;
            }
        }
    } else if (dragFromTreeType.equals(ETreeType.EntityTree)) {
        // If we have a multiple entity structure, can't drop at all
        if (getEntities().size() == 1) {
            // Can drop onto the Entity Tree or the StructMap tree
            DepositTreeModel model = (DepositTreeModel) destinationTree.getModel();
            if (model.getTreeType().equals(ETreeType.EntityTree)) {
                // Dragging to itself
                // Can drop a FileSystemObject or a StructMap onto a
                // StructMap
                // Can only drop a FileSystemObject onto a FileSystemObject
                for (DefaultMutableTreeNode node : theNodeInClipboard) {
                    if ((node.getUserObject() instanceof FileSystemObject)
                            && ((destinationNode.getUserObject() instanceof FileSystemObject)
                                    || (destinationNode.getUserObject() instanceof FileGroup))) {
                        canDrop = true;
                        break;
                    }
                }
            } else { // Dragging to StructMap
                // Can only drop a FileSystemObject
                // Can drop onto a FileSystemObject or a StructMap
                for (DefaultMutableTreeNode node : theNodeInClipboard) {
                    if ((node.getUserObject() instanceof FileSystemObject)
                            && ((destinationNode.getUserObject() instanceof StructMap)
                                    || (destinationNode.getUserObject() instanceof FileSystemObject))) {
                        FileSystemObject fso = (FileSystemObject) node.getUserObject();
                        canDrop = !fileIsInStructMap(fso) || isCopying;
                        if (canDrop) {
                            break;
                        }
                    }
                }
            }
        }
    } else { // Dragging from StructMap
        // Can only drop onto the StructMap tree
        // Can drop a FileSystemObject or a StructMap onto a StructMap
        // Can only drop a FileSystemObject onto a FileSystemObject
        DepositTreeModel model = (DepositTreeModel) destinationTree.getModel();
        if (model.getTreeType().equals(ETreeType.StructMapTree)) {
            for (DefaultMutableTreeNode node : theNodeInClipboard) {
                if ((node.getUserObject() instanceof FileSystemObject)
                        || (node.getUserObject() instanceof StructMap)) {
                    if (destinationNode.getUserObject() instanceof StructMap) {
                        canDrop = true;
                    } else if (node.getUserObject() instanceof FileSystemObject) {
                        canDrop = true;
                    }
                }
                if (canDrop) {
                    break;
                }
            }
        }
    }
    return canDrop;
}

From source file:org.csml.tommo.sugar.modules.TileTree.java

@Override
public void makeReport(HTMLReportArchive report) throws IOException {
    JTree tileTree = new JTree(createTileTree());
    String list = TreeUtils.listTree((TreeNode) tileTree.getModel().getRoot(), "", "<br/>");
    StringBuffer sb = report.htmlDocument();
    sb.append(list);//from  ww  w .  ja v  a2  s.  co m
}