1 18 19 package org.objectweb.jac.ide.diagrams; 20 21 22 import CH.ifa.draw.framework.DrawingEditor; 23 import java.awt.Point ; 24 import java.awt.event.MouseEvent ; 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.Aspect; 30 import org.objectweb.jac.ide.Diagram; 31 import org.objectweb.jac.util.Log; 32 33 public class AspectFigureCreationTool extends CreationTool { 34 35 DisplayContext context; 36 37 public AspectFigureCreationTool(DrawingEditor newDrawingEditor, 38 DisplayContext context) { 39 super(newDrawingEditor); 40 this.context = context; 41 } 42 43 Point anchorPoint; 44 45 48 public void mouseDown(MouseEvent e, int x, int y) { 49 anchorPoint = new Point (x,y); 50 EventHandler.get().onInvoke( 51 context, 52 new InvokeEvent( 53 null, 54 this, 55 ClassRepository.get().getClass(getClass()) 56 .getMethod("importAspect(org.objectweb.jac.ide.Aspect)"))); 57 } 59 60 public void mouseUp(MouseEvent e, int x, int y) { 61 } 62 63 public void importAspect(Aspect cl) { 64 Log.trace("figures","createFigure for "+cl); 65 if (cl!=null) { 66 AspectFigure cf = null; 67 org.objectweb.jac.ide.ClassFigure figure = 68 new org.objectweb.jac.ide.ClassFigure(cl); 69 Diagram diagram = (Diagram)((DiagramView)editor()).getSubstance(); 70 diagram.addFigure(figure); 71 Log.trace("diagram","creating new figure "+figure+","+ 72 diagram.getContainer()); 73 cf = new AspectFigure(figure,diagram.getContainer(), 74 ((DiagramView)editor()).view()); 75 (view().add(cf)).displayBox(anchorPoint, anchorPoint); 76 } 77 editor().toolDone(); 78 } 79 80 } 81 82 83 | Popular Tags |