Squiz Matrix  4.12.2
 All Data Structures Namespaces Functions Variables Pages
Selection.java
1 
16 package net.squiz.matrix.matrixtree;
17 
18 import java.util.*;
19 import javax.swing.tree.*;
20 
21 public class Selection {
22 
23  private static List nodes = new ArrayList();
24 
25  // cannot instantiate
26  private Selection() {}
27 
28  public static void setNodes(MatrixTreeNode[] newNodes) {
29  // dont remove the current selection if the specified nodes
30  // is null; keep the current selection
31  if (newNodes == null)
32  return;
34  for (int i = 0; i < newNodes.length; i++) {
35  nodes.add(newNodes[i]);
36  }
37  }
38 
42  public static MatrixTreeNode[] getNodes() {
43  if (nodes != null)
44  return (MatrixTreeNode[]) nodes.toArray(new MatrixTreeNode[nodes.size()]);
45  return null;
46  }
47 
53  public static void removeNode(MatrixTreeNode node) {
54  nodes.remove(node);
55  }
56 
62  public static void removeNodes(TreePath[] paths) {
63  for (int i = 0; i < paths.length; i++) {
64  nodes.remove(paths[i].getLastPathComponent());
65  }
66  }
67 
73  public static void removeNodes(MatrixTreeNode[] removeNodes) {
74  for (int i = 0; i < removeNodes.length; i++) {
75  nodes.remove(removeNodes[i]);
76  }
77  }
78 
84  public static void removeAllNodes() {
85  nodes.clear();
86  }
87 
88  public static void addNode(MatrixTreeNode node) {
89  nodes.add(node);
90  }
91 }