Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[jwt-dev] Links from Figures to Model elements

I have actions that I want to remain action objects, but I want them to appear differently, based on their aspects, or other model features.

I don't know if there is an easier path to get to the details, but I customized ActionFigure and RoundedRectangleBorder.  I added a constructor to RoundedRectangleBorder, so I could get the "parent" ActionFigure.

Then, while painting in the border class:

 private NamedElementFigure parentFigure = null; 
 private ActionImpl parentModelImpl = null; 
 private String shapeType = "";  //TODO: use enum
...
 public void paint(IFigure figure, Graphics graphics, Insets insets)  { 
if (this.parentFigure != null && this.parentModelImpl==null) {
WEEditor editor = GeneralHelper.getActiveInstance();
for (ActivityNode an : editor.getCurrentActivitySheet().getActivityModel().getNodes()) {
for (Adapter eAdapters : an.eAdapters()) {
if (eAdapters instanceof EditPartAdapter) {
EditPartAdapter epa = (EditPartAdapter) eAdapters;
if (epa != null && epa.getEditPart() instanceof ActionEditPart) {
ActionEditPart aep = (ActionEditPart) epa.getEditPart();
if (this.parentFigure==aep.getFigure()) {
this.parentModelImpl = (ActionImpl) aep.getModel();
//figure out what type of aspect this shape has
for (Aspect aspect : AspectManager.INSTANCE.getAspects(this.parentModelImpl)) {
if ("Callflow VUI".equals(aspect.getId())) {
if (AspectManager.INSTANCE.getAspectInstance(parentModelImpl, aspect)!=null)
shapeType = "tel";
}
}
}
}
}
}
}
}
...
graphics.setBackgroundColor(shapeType.equals("tel")?dialogColor: plainColor);
...

Now is the perfect time for someone to say, "why didn't you use x - it's one line of code?"  ;-)

Eric





Back to the top