1 6 7 package org.netbeans.test.editor.app.gui.tree; 8 9 import java.util.HashMap ; 10 import java.util.Iterator ; 11 import java.util.Vector ; 12 import org.netbeans.test.editor.app.gui.actions.TreeNewType; 13 import org.netbeans.test.editor.app.gui.actions.TreeNodeAction; 14 15 19 public class ActionsCache { 20 21 HashMap actions; 22 23 private static ActionsCache instance; 24 25 26 private ActionsCache() { 27 actions=new HashMap (); 28 } 29 30 public static ActionsCache getDefault() { 31 if (instance == null) { 32 instance=new ActionsCache(); 33 } 34 return instance; 35 } 36 37 public void addNodeActions(Class node,Vector acts) { 38 actions.put(node, acts); 39 } 40 41 public void addNodeAction(Class node,TreeNodeAction action) { 42 if (actions.get(node) != null) { 43 ((Vector )(actions.get(node))).add(action); 44 } else { 45 Vector v=new Vector (); 46 addNodeActions(node,v); 47 v.add(action); 48 } 49 } 50 51 public Vector getActions(Class node) { 52 return (Vector )(actions.get(node)); 53 } 54 55 public TreeNodeAction getAction(Class node, Class action) { 56 Vector v=(Vector )(actions.get(node)); 57 Object o; 58 for (Iterator it=v.iterator();it.hasNext();) { 59 o=it.next(); 60 if (o.getClass().equals(action)) { 61 return (TreeNodeAction)o; 62 } 63 } 64 return null; 65 } 66 } 67 | Popular Tags |