1 18 19 package org.objectweb.jac.aspects.gui; 20 21 import org.apache.log4j.Logger; 22 import org.objectweb.jac.core.rtti.CollectionItem; 23 import org.objectweb.jac.core.rtti.FieldItem; 24 25 27 28 public class RelationNode extends AbstractNode implements CollectionUpdate { 29 static Logger logger = Logger.getLogger("gui.treeview"); 30 static Logger loggerEvents = Logger.getLogger("gui.events"); 31 32 Object substance; 33 34 40 41 public RelationNode(TreeView model, 42 Object substance, FieldItem relation) { 43 super(model,relation,true); 44 this.substance = substance; 45 rebuildData(); 46 } 47 48 50 51 protected void rebuildData() { 52 Object object = getUserObject(); 53 logger.debug("rebuildData on "+this); 54 if ( object instanceof FieldItem ) { 55 text = ((FieldItem)object).getName(); 56 icon = GuiAC.getIcon((FieldItem)object); 57 } 58 } 59 60 62 public void unregisterEvents() { 63 Utils.unregister(substance,this); 64 } 65 66 68 public void onChange(Object substance, CollectionItem collection, 69 Object value, Object param) { 70 loggerEvents.debug("collectionUpdated"); 71 int[] indices = new int[getChildCount()]; 72 for(int i=0;i<indices.length;i++) { 73 indices[i]=i; 74 } 75 AbstractNode[] removedNodes = new AbstractNode[getChildCount()]; 76 for(int i=0;i<indices.length;i++) { 77 removedNodes[i]=(AbstractNode)getChildAt(i); 78 } 79 removeAllChildren(); 80 model.nodesWereRemoved(this,indices,removedNodes); 81 } 82 83 public void onAdd(Object substance, CollectionItem collection, 84 Object value, Object added, Object param) { 85 onChange(substance,collection,value,param); 86 } 87 88 public void onRemove(Object substance, CollectionItem collection, 89 Object value, Object removed, Object param) { 90 onChange(substance,collection,value,param); 91 } 92 93 public String toString() { 94 return "RelationNode["+getUserObject()+"]"; 95 } 96 } 97 | Popular Tags |