1 18 19 package org.objectweb.jac.ide.diagrams; 20 21 import CH.ifa.draw.framework.DrawingEditor; 22 import java.awt.Point ; 23 import java.awt.event.MouseEvent ; 24 import java.util.Collection ; 25 import java.util.Iterator ; 26 import java.util.List ; 27 import java.util.Vector ; 28 import org.objectweb.jac.aspects.gui.DisplayContext; 29 import org.objectweb.jac.aspects.gui.EventHandler; 30 import org.objectweb.jac.aspects.gui.InvokeEvent; 31 import org.objectweb.jac.core.rtti.ClassRepository; 32 import org.objectweb.jac.ide.Class; 33 import org.objectweb.jac.ide.Diagram; 34 import org.objectweb.jac.ide.Project; 35 import org.objectweb.jac.util.Log; 36 37 public class ClassFigureCreationTool extends CreationTool { 38 39 DisplayContext context; 40 41 public ClassFigureCreationTool(DrawingEditor newDrawingEditor, 42 DisplayContext context) { 43 super(newDrawingEditor); 44 this.context = context; 45 } 46 47 Point anchorPoint; 48 49 52 public void mouseDown(MouseEvent e, int x, int y) { 53 anchorPoint = new Point (x,y); 54 EventHandler.get().onInvoke( 55 context, 56 new InvokeEvent( 57 null, 58 this, 59 ClassRepository.get().getClass(getClass()) 60 .getMethod("importClass(org.objectweb.jac.ide.Class,boolean)"))); 61 } 63 64 public void mouseUp(MouseEvent e, int x, int y) { 65 } 66 67 73 public void importClass(Class cl, boolean importRelations) { 74 Log.trace("figures","createFigure for "+cl); 75 if (cl!=null) { 76 DiagramView diagram = ((DiagramView)editor()); 77 diagram.addClass(cl,anchorPoint); 78 79 if (importRelations) { 80 diagram.importRelations(cl); 81 } 82 } 83 editor().toolDone(); 84 } 85 86 public Collection importClassChoice() { 87 List result = new Vector (); 88 Diagram diagram = (Diagram)((DiagramView)editor()).getSubstance(); 89 Project project = diagram.getContainer().getProject(); 90 Iterator it = project.getClasses().iterator(); 91 while (it.hasNext()) { 92 Class cl = (Class )it.next(); 93 if (!diagram.contains(cl)) 94 result.add(cl); 95 } 96 return result; 97 } 98 } 99 | Popular Tags |