Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Laying out optional visual elements
Laying out optional visual elements [message #484310] Sun, 06 September 2009 09:04 Go to next message
Indigo Mising name is currently offline Indigo Mising nameFriend
Messages: 14
Registered: August 2009
Junior Member
Hi,

I a node where the model elements (FirstName, MiddleName, LastName) are displayed using labels, for example:

John
Joseph
Smith

But if the model element behind any of the labels has no content, I don't want display that label at all. For example, if there is no middle name, I would like to see:

John
Smith

But not:

John
<blank>
Smith

This seems like a pretty simple requirement, but I'm struggling.

Any suggestions would be appreciated. Thanks.
Re: Laying out optional visual elements [message #484364 is a reply to message #484310] Mon, 07 September 2009 08:47 Go to previous message
Indigo Mising name is currently offline Indigo Mising nameFriend
Messages: 14
Registered: August 2009
Junior Member
I'd like to take a shot at answering my own question, but I'd still appreciate any feedback as to whether this is a good approach or not.

Here's what I did (real class names this time, the earlier post was a simplified example):

The EditPart for the node is FeatureEditPart, and this class contains a WrappingLabel member for each label. The first label is fFigureFeatureNameFigure. The corresponding EditPart for this label is FeatureNameEditPart.

I added two methods to FeatureEditPart, removeName and addName. Each method simply removes the label from the figure, but does not destroy it:

public void removeName(){			
    this.remove(fFigureFeatureNameFigure);
}
		
public void addName(){
   if(!this.getChildren().contains(fFigureFeatureNameFigure)){
      this.add(fFigureFeatureNameFigure,0);	
   }
}


In FeatureNameEditPart.refreshLabel, I added a check to see if the label text is blank and call the parent class (FeatureEditPart) removeName or addName accordingly.

It would be preferable to do this without coding (e.g. via gmfgraph/gmfmap), but I presume that's not an option.

Any feedback or alternatives appreciated.
Previous Topic:Discovering referenced models
Next Topic:syncronisation error with diag partitioning?
Goto Forum:
  


Current Time: Thu Apr 25 10:11:11 GMT 2024

Powered by FUDForum. Page generated in 0.03376 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top