1 18 19 package org.objectweb.jac.ide.diagrams; 20 21 import CH.ifa.draw.framework.DrawingEditor; 22 import CH.ifa.draw.framework.Figure; 23 import java.util.List ; 24 import java.util.Vector ; 25 import org.objectweb.jac.aspects.gui.DisplayContext; 26 import org.objectweb.jac.aspects.gui.EventHandler; 27 import org.objectweb.jac.aspects.gui.InvokeEvent; 28 import org.objectweb.jac.core.rtti.ClassRepository; 29 import org.objectweb.jac.ide.Class; 30 import org.objectweb.jac.ide.InheritanceLink; 31 import org.objectweb.jac.ide.Link; 32 import org.objectweb.jac.ide.RelationLink; 33 import org.objectweb.jac.util.Log; 34 35 38 public class RelationLinkShowTool extends AbstractActionTool { 39 40 public RelationLinkShowTool(DrawingEditor newDrawingEditor, 41 DisplayContext context) throws ClassNotFoundException { 42 super(newDrawingEditor,context,java.lang.Class.forName("org.objectweb.jac.ide.diagrams.ClassFigure")); 43 } 44 45 47 Class curClass = null; 48 ClassFigure startFig = null; 49 50 55 public List relations() { 56 Log.trace("figures","getting relations for class "+curClass); 57 List relations = new Vector (); 58 if (curClass!=null) { 59 return ((DiagramView)editor()).getDiagram().getMissingRelations(curClass); 60 } else { 61 return null; 62 } 63 } 64 65 public void showRelation(Link link) throws Exception { 66 if (link==null || link.getStart()==null || link.getEnd()==null) 68 return; 69 if (link instanceof RelationLink) 70 ((DiagramView)editor()).importRelation((RelationLink)link); 71 else if (link instanceof InheritanceLink) 72 ((DiagramView)editor()).importInheritance((InheritanceLink)link); 73 view().repairDamage(); 74 editor().toolDone(); 75 } 76 77 public void action(Figure figure) { 78 startFig = (ClassFigure)figure; 79 curClass = startFig.getClassElement(); 80 EventHandler.get().onInvoke( 81 context, 82 new InvokeEvent( 83 null, 84 this, 85 ClassRepository.get().getClass(getClass()) 86 .getMethod("showRelation"))); 87 88 } 89 90 } 91 92 | Popular Tags |