Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » How to make a Compartment become invisible when it is empty?
How to make a Compartment become invisible when it is empty? [message #232483] Fri, 05 June 2009 06:08 Go to next message
Alessander Botti Benevides is currently offline Alessander Botti BenevidesFriend
Messages: 20
Registered: July 2009
Junior Member
Hi people,
is there a way to make a Compartment become invisible when it is empty?

Thanks for all the help I'm getting here!
Best regards,
Alessander
Re: How to make a Compartment become invisible when it is empty? [message #232683 is a reply to message #232483] Fri, 05 June 2009 11:43 Go to previous messageGo to next message
No real name is currently offline No real nameFriend
Messages: 62
Registered: July 2009
Member
Hi Alessander,

I don't know how other's do it, but I gave the figure that contains the
compartment a custom layout, which sets the compartment's size to 0 if
it is empty. However, for this I always check the model element to see
if it contains elements in that compartment. To do this I had to pass
the edit part that corresponds to the laid out figure to the very same
when it is created. Maybe there is an easier way to check if a
compartment is empty.

Regards,
Matthias

Alessander Botti Benevides wrote:
> Hi people,
> is there a way to make a Compartment become invisible when it is empty?
>
> Thanks for all the help I'm getting here!
> Best regards,
> Alessander
>
Re: How to make a Compartment become invisible when it is empty? [message #232826 is a reply to message #232483] Sun, 07 June 2009 10:55 Go to previous messageGo to next message
mohammad  is currently offline mohammad Friend
Messages: 2
Registered: July 2009
Junior Member
Hi
I have never done it on my own but in gmfgen ,find your gen compartment
,find the "Hide If Empty" property and simply set it true.
It may work.
Re: How to make a Compartment become invisible when it is empty? [message #233128 is a reply to message #232826] Tue, 09 June 2009 15:34 Go to previous messageGo to next message
Alessander Botti Benevides is currently offline Alessander Botti BenevidesFriend
Messages: 20
Registered: July 2009
Junior Member
Thanks for the suggestion,
"Hide If Empty" was set true, but it don't makes the compartment invisible.

Best regards,
Alessander Botti Benevides
Re: How to make a Compartment become invisible when it is empty? [message #233136 is a reply to message #232683] Tue, 09 June 2009 15:44 Go to previous messageGo to next message
Alessander Botti Benevides is currently offline Alessander Botti BenevidesFriend
Messages: 20
Registered: July 2009
Junior Member
Hi Matthias, thank you very much!
But setting the compartment's size to 0 does not makes it totally
invisible in my case, maybe because it has a Stack Layout...
So, I have a different solution: Suppose my metamodel has an EClass named
"C" having an EReference named "attribute" which is the Containemnt
Feature of the compartment named "AttributeCompartment" in the gmfgraph
file:

(i) add "view.setVisible(false);" in the end of the method
decorateView(...) in CAttributeCompartmentViewFactory.java:
protected void decorateView(View containerView, View view, IAdaptable
semanticAdapter, String semanticHint, int index, boolean persisted) {
...
view.setVisible(false);
}

(ii) create a method handleNotificationEvent(Notification event) in
CEdidPart.java:
protected void handleNotificationEvent(Notification event) {
getPrimaryShape().updateContents();
super.handleNotificationEvent(event);
}

(iii) create the method updateContents() inside the class CFigure in
CEdidPart.java (substitute "???" for the name of your GMF project):
private void updateContents() {
CEditPart ceditpart = CEditPart.this;
C element = (C) ceditpart.resolveSemanticElement();
EditPart compartmentEditPart =
getChildBySemanticHint(???.diagram.part.???VisualIDRegistry. getType(???.diagram.edit.parts.CAttributeCompartmentEditPart .VISUAL_ID));
if (compartmentEditPart != null) {
if (element.getAttribute().size() == 0) \\ where getAttribute() refers to
EReference "attribute".
((View) compartmentEditPart.getModel()).setVisible(false);
else
((View) compartmentEditPart.getModel()).setVisible(true);
}
}

Best regards
Alessander Botti Benevides
Re: How to make a Compartment become invisible when it is empty? [message #233152 is a reply to message #232483] Tue, 09 June 2009 16:28 Go to previous message
Alex Boyko is currently offline Alex BoykoFriend
Messages: 200
Registered: July 2009
Senior Member
Hi,

You could try overriding the figure for compartment. Override isVisible()
method on the figure. Make it return false if children are empty. Children
of the compartment, however, won't be direct children... you'd have to go
down a couple of levels to reach them.

Cheers,
Alex
Previous Topic:Context Menu entry does not work when plug-in downloaded and installed
Next Topic:How to set Avoid obstructions and Closest distance on my connections by default.
Goto Forum:
  


Current Time: Mon Mar 30 17:39:57 GMT 2020

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

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

Back to the top