1 18 19 package org.objectweb.jac.ide.diagrams; 20 21 22 import CH.ifa.draw.framework.DrawingEditor; 23 import CH.ifa.draw.framework.Figure; 24 import CH.ifa.draw.standard.ActionTool; 25 import org.objectweb.jac.aspects.gui.DisplayContext; 26 import org.objectweb.jac.core.Wrapping; 27 import org.objectweb.jac.core.rtti.ClassRepository; 28 import java.util.List ; 29 30 public class PointcutLinkShowTool extends ActionTool { 31 DisplayContext context; 32 public PointcutLinkShowTool(DrawingEditor newDrawingEditor, 33 DisplayContext context) { 34 super(newDrawingEditor); 35 this.context = context; 36 } 37 38 40 static org.objectweb.jac.ide.Aspect curAspect=null; 41 42 public static List pointcuts(Object o) { 43 if(curAspect!=null) { 44 return curAspect.getPointcutLinks(); 45 } else { 46 return null; 47 } 48 } 49 50 public void choosePointcut(org.objectweb.jac.ide.PointcutLink pointcut) { 51 } 52 53 public void action(Figure figure) { 54 if(! (figure instanceof AspectFigure) ) return; 55 56 curAspect=(org.objectweb.jac.ide.Aspect)((AspectFigure)figure).getSubstance(); 57 Object [] parameters = new Object [] {null}; 58 boolean result = context.getDisplay().showInput( 59 this,ClassRepository.get().getClass(getClass()).getMethod("choosePointcut"), 60 parameters); 61 Figure cf = null; 62 if( result ) { 63 org.objectweb.jac.ide.PointcutLink rel = (org.objectweb.jac.ide.PointcutLink)parameters[0]; 64 if( rel == null || rel.getEnd() == null ) return; 65 66 if( rel.getEnd() instanceof org.objectweb.jac.ide.TypedElement ) { 67 cf = ((DiagramView)editor()).findElement((org.objectweb.jac.ide.TypedElement)rel.getEnd()); 68 } 69 if( cf == null ) { 70 context.getDisplay().showMessage( 72 "You must import '"+ 73 rel.getEnd()+ 74 "' before this action.", 75 "Error",false,false,true); 76 } else { 77 78 PointcutLinkFigure relf = new PointcutLinkFigure(); 79 relf.startPoint(figure.center().x,figure.center().y); 80 relf.endPoint(cf.center().x,cf.center().y); 81 relf.connectStart(figure.connectorAt(figure.center().x,figure.center().y)); 82 relf.connectEnd(cf.connectorAt(cf.center().x,cf.center().y)); 83 84 86 view().add(relf); 87 88 view().add(relf.createAttachedFigure( 89 AttachedTextFigure.NAME)); 90 view().add(relf.createAttachedFigure( 91 AttachedTextFigure.START_ROLE)); 92 view().add(relf.createAttachedFigure( 93 AttachedTextFigure.END_ROLE)); 94 view().add(relf.createAttachedFigure( 95 AttachedTextFigure.START_CARDINALITY)); 96 view().add(relf.createAttachedFigure( 97 AttachedTextFigure.END_CARDINALITY)); 98 99 relf.updateConnection(); 100 Wrapping.invokeRoleMethod((org.objectweb.jac.core.Wrappee)rel,"addView",new Object []{relf}); 101 102 editor().toolDone(); 103 } 104 } 105 } 106 107 } 108 109 | Popular Tags |