]> git.proxmox.com Git - mirror_edk2.git/blobdiff - Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/ui/ITree.java
1. Fix EDKT193 "Provide a Module tree when platform/package are open"
[mirror_edk2.git] / Tools / Source / FrameworkWizard / src / org / tianocore / frameworkwizard / common / ui / ITree.java
index 5b7ea5900c1c13ec55db54f22d79827faf25be97..252c34ff72a1e754572dc62850377420261bede1 100644 (file)
@@ -26,8 +26,6 @@ import org.tianocore.frameworkwizard.common.Identifications.Identification;
 /**\r
  The class is used to override JTree to provides customized interfaces \r
  It extends JTree\r
\r
-\r
 \r
  **/\r
 public class ITree extends JTree {\r
@@ -35,7 +33,7 @@ public class ITree extends JTree {
     /// Define class Serial Version UID\r
     ///\r
     private static final long serialVersionUID = -7907086164518295327L;\r
-    \r
+\r
     //\r
     // Define class members\r
     //\r
@@ -58,7 +56,7 @@ public class ITree extends JTree {
      **/\r
     public ITree(IDefaultMutableTreeNode iDmtRoot) {\r
         super(iDmtRoot);\r
-        treeModel = (DefaultTreeModel)this.getModel();\r
+        treeModel = (DefaultTreeModel) this.getModel();\r
     }\r
 \r
     /**\r
@@ -75,44 +73,6 @@ public class ITree extends JTree {
         return intCategory;\r
     }\r
 \r
-    /**\r
-     Get operation of selected node\r
-     \r
-     @return The operation of selected node\r
-     \r
-     **/\r
-    public int getSelectOperation() {\r
-        int intOperation = 0;\r
-        TreePath path = this.getSelectionPath();\r
-        IDefaultMutableTreeNode node = (IDefaultMutableTreeNode) path.getLastPathComponent();\r
-        intOperation = node.getOperation();\r
-        return intOperation;\r
-    }\r
-\r
-    /**\r
-     Get selectLoaction of selected node\r
-     \r
-     @return The selectLoaction of selected node\r
-     \r
-     **/\r
-    public int getSelectLoaction() {\r
-        int intLocation = 0;\r
-        TreePath path = this.getSelectionPath();\r
-        IDefaultMutableTreeNode node = (IDefaultMutableTreeNode) path.getLastPathComponent();\r
-        intLocation = node.getLocation();\r
-        return intLocation;\r
-    }\r
-\r
-    /**\r
-     Main class, reserved for test\r
-     \r
-     @param args\r
-     \r
-     **/\r
-    public static void main(String[] args) {\r
-        // TODO Auto-generated method stub\r
-    }\r
-\r
     /**\r
      Add input node as child node for current selected node\r
      \r
@@ -151,17 +111,17 @@ public class ITree extends JTree {
         treeModel.insertNodeInto(newNode, parentNode, parentNode.getChildCount());\r
         this.scrollPathToVisible(new TreePath(newNode.getPath()));\r
     }\r
-    \r
+\r
     /**\r
-    Add input node as child node for current selected node\r
-    \r
-    @param newNode The node need be added\r
-    \r
-    **/\r
-   public void addNode(IDefaultMutableTreeNode parentNode, IDefaultMutableTreeNode newNode) {\r
-       treeModel.insertNodeInto(newNode, parentNode, parentNode.getChildCount());\r
-       this.scrollPathToVisible(new TreePath(newNode.getPath()));\r
-   }\r
+     Add input node as child node for current selected node\r
+     \r
+     @param newNode The node need be added\r
+     \r
+     **/\r
+    public void addNode(IDefaultMutableTreeNode parentNode, IDefaultMutableTreeNode newNode) {\r
+        treeModel.insertNodeInto(newNode, parentNode, parentNode.getChildCount());\r
+        this.scrollPathToVisible(new TreePath(newNode.getPath()));\r
+    }\r
 \r
     /**\r
      Remove the selected node\r
@@ -173,13 +133,13 @@ public class ITree extends JTree {
         TreePath treePath = this.getSelectionPath();\r
         removeNodeByPath(treePath);\r
     }\r
-    \r
+\r
     /**\r
-    Remove the node by tree path\r
-    \r
-    @param strRemovedNode\r
-    \r
-    **/\r
+     Remove the node by tree path\r
+     \r
+     @param strRemovedNode\r
+     \r
+     **/\r
     public void removeNodeByPath(TreePath treePath) {\r
         if (treePath != null) {\r
             DefaultMutableTreeNode selectionNode = (DefaultMutableTreeNode) treePath.getLastPathComponent();\r
@@ -191,14 +151,29 @@ public class ITree extends JTree {
     }\r
     \r
     /**\r
-    Remove all child nodes under current node\r
+     Return a node by input tree path\r
+    \r
+     @param treePath\r
+     @return\r
     \r
     **/\r
+    public IDefaultMutableTreeNode getNodeByPath(TreePath treePath) {\r
+        if (treePath != null) {\r
+            IDefaultMutableTreeNode selectionNode = (IDefaultMutableTreeNode) treePath.getLastPathComponent();\r
+            return selectionNode;\r
+        }\r
+        return null;\r
+    }\r
+\r
+    /**\r
+     Remove all child nodes under current node\r
+     \r
+     **/\r
     public void removeNodeChildrenByPath(TreePath treePath) {\r
         if (treePath != null) {\r
             DefaultMutableTreeNode currentNode = (DefaultMutableTreeNode) treePath.getLastPathComponent();\r
             for (int index = currentNode.getChildCount() - 1; index > -1; index--) {\r
-                treeModel.removeNodeFromParent((DefaultMutableTreeNode)currentNode.getChildAt(index));\r
+                treeModel.removeNodeFromParent((DefaultMutableTreeNode) currentNode.getChildAt(index));\r
             }\r
         }\r
     }\r
@@ -212,7 +187,7 @@ public class ITree extends JTree {
         rootNode.removeAllChildren();\r
         treeModel.reload();\r
     }\r
-    \r
+\r
     public IDefaultMutableTreeNode getSelectNode() {\r
         TreePath treepath = this.getSelectionPath();\r
         IDefaultMutableTreeNode selectionNode = null;\r
@@ -221,7 +196,7 @@ public class ITree extends JTree {
         }\r
         return selectionNode;\r
     }\r
-    \r
+\r
     public IDefaultMutableTreeNode getNodeById(IDefaultMutableTreeNode node, Identification id) {\r
         for (int index = 0; index < node.getChildCount(); index++) {\r
             IDefaultMutableTreeNode iNode = (IDefaultMutableTreeNode) node.getChildAt(index);\r
@@ -231,7 +206,7 @@ public class ITree extends JTree {
         }\r
         return null;\r
     }\r
-    \r
+\r
     public IDefaultMutableTreeNode getNodeById(IDefaultMutableTreeNode node, Identification id, int category) {\r
         for (int index = 0; index < node.getChildCount(); index++) {\r
             IDefaultMutableTreeNode iNode = (IDefaultMutableTreeNode) node.getChildAt(index);\r
@@ -245,11 +220,11 @@ public class ITree extends JTree {
         }\r
         return null;\r
     }\r
-    \r
+\r
     public TreePath getPathOfNode(IDefaultMutableTreeNode node) {\r
         if (node != null) {\r
             TreePath treePath = new TreePath(treeModel.getPathToRoot(node));\r
-            return treePath;    \r
+            return treePath;\r
         }\r
         return null;\r
     }\r