1 18 19 package org.objectweb.jac.ide.diagrams; 20 21 import org.objectweb.jac.aspects.gui.DisplayContext; 22 import org.objectweb.jac.aspects.gui.EventHandler; 23 import org.objectweb.jac.aspects.gui.GuiAC; 24 import org.objectweb.jac.aspects.gui.ObjectUpdate; 25 import org.objectweb.jac.aspects.gui.Utils; 26 import org.objectweb.jac.core.rtti.ClassRepository; 27 import org.objectweb.jac.core.rtti.CollectionItem; 28 import org.objectweb.jac.ide.Class; 29 import org.objectweb.jac.ide.Field; 30 import org.objectweb.jac.ide.ModelElement; 31 32 public class FieldFigure extends MemberFigure 33 implements ModelElementFigure, ObjectUpdate, Selectable 34 { 35 Field field; 36 37 public FieldFigure(Field field, ClassFigure parentFigure) { 38 super(parentFigure); 39 this.field = field; 40 super.setText(GuiAC.toString(field)); 41 Utils.registerObject(field,this); 42 } 43 44 public void close() { 45 Utils.unregisterObject(field,this); 46 } 47 48 public ModelElement getSubstance() { 49 return field; 50 } 51 52 public void linkToField(Class cl) { 53 field = cl.findField(getName()); 54 } 55 56 boolean updating = false; 57 58 public void setText(String s) { 59 super.setText(s); 60 if (field != null && !DiagramView.init) { 61 updating=true; 62 field.setName(getName()); 63 field.setType(org.objectweb.jac.ide.Projects.types.resolveType(getType())); 64 updating=false; 65 } 66 } 67 68 public void objectUpdated(Object object, Object extra) { 70 if (!updating) { 71 super.setText(GuiAC.toString(field)); 72 } 73 } 74 75 public void onSelect(DisplayContext context) { 77 CollectionItem coll = ClassRepository.get().getClass(Class .class) 78 .getCollection("fields"); 79 EventHandler.get().onSelection( 80 context,coll,getSubstance(),null,null); 81 } 82 } 83 | Popular Tags |