Skip to main content

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

Exactly, why didn't you use...
Just kidding, the real GEF expert here is Chris.

Chris, maybe that rings a bell to you ?


Le 27/07/2011 22:48, Eric Phetteplace a écrit :
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?"  ;-)


jwt-dev mailing list

Back to the top