Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Collapsible Label(Need to know how to build a collapsible label with GMF)
Collapsible Label [message #671902] Thu, 19 May 2011 10:06 Go to next message
Dominic S. is currently offline Dominic S.
Messages: 11
Registered: May 2011
Junior Member
Hello eclipse community!

I've been trying for hours now to create a collapsible label with the GMF framework. The result shall look like this:

+--------------------------+
| Title Label              |
+--------------------------+
| ^ collapsible multiline  |
| label.....               |
+--------------------------+
| ^                        |
|    (collapsible drag'n'  |
|     drop compartment)    |
|                          |
+--------------------------+


I have a rounded rectangle with border layout, the title label at the BEGINNING, then a nested rectangle containing the (should-be) collapsible label and a compartment (which contains other elements and is collapsible, this works).

So far, I tried to map the label to an own compartment to use the built-in collapse functionality, but this does not work (although the +/- signs are being displayed and are clickable) - the label text is always visible.
Then I tried to add a custom MouseListener to the Label EditPart, with which I did not succeed either.

I would highly appreciate any help regarding this issue! Google search did not bring any usable results, unfortunately. Given the case that I solve this problem, I'll go and publish the result in my blog to help other people avoid time-consuming work on such stuff.

Thanks!
Dominic.

[Updated on: Fri, 20 May 2011 15:52]

Report message to a moderator

Re: Collapsible Label [message #672307 is a reply to message #671902] Fri, 20 May 2011 16:03 Go to previous messageGo to next message
Dominic S. is currently offline Dominic S.
Messages: 11
Registered: May 2011
Junior Member
Hey!

I solved the problem.
For those who're interested in the solution:

I have a Rectangle with a border layout in which I nested my label. The rectangle was made a collapsible compartment. In the compartment's EditPart class, the handleNotificationEvent methos is overidden:

	@Override
	protected void handleNotificationEvent(Notification event) {
		super.handleNotificationEvent(event);
		if (NotationPackage.eINSTANCE.getDrawerStyle_Collapsed().equals(
				event.getFeature())) {
			//TODO: Improve child selection
			DescriptionEditPart descriptionLabel = ((DescriptionEditPart) this
					.getParent().getChildren().get(1));

			descriptionLabel.getFigure().setVisible(
					getCompartmentFigure().isExpanded());
		}
	}


To be able to store the label collapse state, I added the very same code snippet in the overidden "public void activate()" method in the same class. Now it works - when the compartment collapses, the label is hidden, too. Because of the BorderLayout of the compartment rectangle, it automatically resizes after the collapse (the label is set at the BEGINNING of the border layout).

Best regards,
Dominic
Re: Collapsible Label [message #757671 is a reply to message #672307] Mon, 21 November 2011 08:47 Go to previous message
Chris B. is currently offline Chris B.
Messages: 37
Registered: November 2011
Member
Hello Dominic,

i have the same issue and i'll try out your solution but i need some clarification about the steps you've applied. You said that you made the rectangle a collapsible compartment. Did you change the ecore model to achieve that? As far as i know, one can not create a compartment with nested elements without having a class in the model which is declared as a containment. Could you please explain your approach in more details? My problem is that the diagram doesn't resize automatically when hiding the label. It seems that the label still requires the space in the diagram, although it is invisible. Can you clarify that?

thx & regards
bj
Previous Topic:How to use constructor of xxxItemProvider.java in other class in GMF
Next Topic:Event Notification
Goto Forum:
  


Current Time: Thu Oct 23 08:02:34 GMT 2014

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

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