1 10 11 package org.enhydra.jawe; 12 13 import org.enhydra.jawe.graph.*; 14 15 import org.jgraph.graph.*; 16 17 import java.util.*; 18 import javax.swing.tree.TreeNode ; 19 20 24 public class JaWEParentMap extends ParentMap { 25 26 30 public ArrayList emptyParentList() { 31 ArrayList list = new ArrayList(); 32 Iterator it = childCount.entrySet().iterator(); 33 while (it.hasNext()) { 34 Map.Entry entry = (Map.Entry) it.next(); 35 if (entry.getValue() instanceof Integer ) { 36 if (((Integer ) entry.getValue()).intValue()==0) 37 list.add(entry.getKey()); 38 } 39 } 40 return list; 41 } 42 43 48 public boolean hasAnyParticipant (Object p) { 49 if ((p==null) || !(p instanceof Participant)) { 50 return false; 51 } 52 Set childParticipants=new HashSet(((Participant)p).getChildParticipants()); 54 childParticipants.removeAll(changedNodes); 57 58 return (childParticipants.size()>0); 59 60 } 61 62 63 67 public ArrayList getNewChildren (Object parent) { 68 ArrayList list = new ArrayList(); 69 if (parent!= null) { 70 Iterator it = entries.iterator(); 71 while (it.hasNext()) { 72 Entry entry = (Entry)it.next(); 73 Object parentFromEntry=entry.getParent(); 74 if (parentFromEntry != null && parentFromEntry.equals(parent)) { 75 list.add(entry.getChild()); 76 } 77 } 78 } 79 return list; 80 } 81 82 86 public Object getNewParent (Object child) { 87 Object parent=null; 88 if (child !=null) { 89 Iterator it = entries.iterator(); 90 while (it.hasNext()) { 91 Entry entry = (Entry)it.next(); 92 Object childFromEntry=entry.getChild(); 93 if (childFromEntry!=null && childFromEntry.equals(child)) { 94 parent=entry.getParent(); 95 break; 96 } 97 } 98 } 99 return parent; 100 } 101 102 106 public ArrayList getRemovedNodes () { 107 ArrayList list = new ArrayList(); 108 Iterator it = entries.iterator(); 109 while (it.hasNext()) { 110 Entry entry = (Entry)it.next(); 111 Object parentFromEntry=entry.getParent(); 112 if (parentFromEntry == null) { 113 list.add(entry.getChild()); 114 } 115 } 116 return list; 117 } 118 119 122 public int entryCount () { 123 return entries.size(); 124 } 125 126 } 127 128 129 | Popular Tags |