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.Class; 30 import org.objectweb.jac.ide.Diagram; 31 32 public class NewClassFigureCreationTool extends CreationTool { 33 34 DisplayContext context; 35 int count = 0; 36 37 public NewClassFigureCreationTool(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(null, 50 this, 51 ClassRepository.get().getClass(getClass()) 52 .getMethod("createNewClass(java.lang.String)"))); 53 } 55 56 public void mouseUp(MouseEvent e, int x, int y) { 57 } 58 59 public void createNewClass(String name) { 60 if (name!=null) { 61 Class substance = new Class (); 62 substance.setName(name); 63 Diagram diagram = (Diagram)((DiagramView)editor()).getSubstance(); 64 diagram.getContainer().addClass(substance); 66 ((DiagramView)editor()).addClass(substance,anchorPoint); 68 } 69 editor().toolDone(); 70 } 71 } 72 73 | Popular Tags |