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.Diagram; 30 import org.objectweb.jac.ide.Instance; 31 32 public class NewInstanceFigureCreationTool extends CreationTool { 33 34 DisplayContext context; 35 int count=0; 36 37 public NewInstanceFigureCreationTool(DrawingEditor newDrawingEditor, 38 DisplayContext context) { 39 super(newDrawingEditor); 40 this.context = context; 41 } 42 43 Point anchorPoint; 44 45 public void mouseDown(MouseEvent e, int x, int y) { 46 anchorPoint = new Point (x,y); 47 EventHandler.get().onInvoke( 48 context, 49 new InvokeEvent( 50 null, 51 this, 52 ClassRepository.get().getClass(getClass()) 53 .getMethod("createNewInstance(java.lang.String)"))); 54 } 56 57 public void mouseUp(MouseEvent e, int x, int y) { 58 } 59 60 public void createNewInstance(String name) { 61 if(name!=null) { 62 GenericObjectFigure cf = null; 63 Instance substance = new Instance(); 64 org.objectweb.jac.ide.GenericFigure figure = new org.objectweb.jac.ide.GenericFigure(substance); 65 substance.setName(name); 66 Diagram diagram = (Diagram)((DiagramView)editor()).getSubstance(); 67 diagram.addFigure(figure); 68 diagram.getContainer().addInstance(substance); 69 cf = new GenericObjectFigure(figure,diagram.getContainer(), 70 ((DiagramView)editor()).view()); 71 (view().add(cf)).displayBox(anchorPoint, anchorPoint); 72 } 73 editor().toolDone(); 74 } 75 76 } 77 78 79 | Popular Tags |