Java JTree Path checkNode(TreePath path)

Here you can find the source of checkNode(TreePath path)

Description

check Node

License

Open Source License

Declaration

private static String checkNode(TreePath path) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.TreePath;

public class Main {
    private static String REMOVE_OPEN_FLOW = "REMOVE_OPEN_FLOW";
    private static String ADD_FOLDER_NEW_FLOW = "ADD_FOLDER_NEW_FLOW";
    private static String ADD_FOLDER_NEW_FLOW_REMOVE = "ADD_FOLDER_NEW_FLOW_REMOVE";

    private static String checkNode(TreePath path) {
        String type = "";

        if (null != path) {

            TreePath parentPath = path.getParentPath();
            DefaultMutableTreeNode currNode = (DefaultMutableTreeNode) path
                    .getLastPathComponent();
            DefaultMutableTreeNode parentNode = (DefaultMutableTreeNode) parentPath
                    .getLastPathComponent();
            if (("My Flows".equals(currNode.getUserObject()) || "Company Flows"
                    .equals(currNode.getUserObject()))
                    && parentNode.isRoot()) {
                type = ADD_FOLDER_NEW_FLOW;
            } else if (((String) currNode.getUserObject())
                    .endsWith(".rm4es")) {
                type = REMOVE_OPEN_FLOW;
            } else {
                type = ADD_FOLDER_NEW_FLOW_REMOVE;
            }/*w w  w  . jav a 2s. c o  m*/
        }
        return type;
    }
}

Related

  1. createTreePath(TreeNode treeNode)
  2. createTreePathFromTreeNode(TreeNode treeNode)
  3. doNode(JTree tree, TreeNode parentNode, TreePath parentPath)
  4. find2(JTree tree, TreePath parent, Object[] nodes, int depth, boolean byName)