Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Compartment expand/collapse programmatically (Starter for a toolbar of grouping nodes in GMF)
Compartment expand/collapse programmatically [message #1451062] Thu, 23 October 2014 09:19 Go to next message
Nikos Margaritis is currently offline Nikos MargaritisFriend
Messages: 65
Registered: September 2014
Member

Hello everyone,

I have a class called EntitiesContainer that holds multiple compartments.

What I did is basically, when you right click on the compartment or compartmentName to listen to this event through a double click listener that is applied to both the compartmentXEditpart and compartmentXNameEditpart.

Now, I would like to achieve something like expanding or collapsing this compartment based on the double click but I havent found any way to do this. How can I approach it through the EditPart of this compartment?

Also would it be possible to close all other compartments when one opens, and if so this has to be done with AddSemanticListeners-listenerFilters ?

Any clues will be appreciated.


Kind Regards,

[Updated on: Thu, 23 October 2014 09:57]

Report message to a moderator

Re: Compartment expand/collapse programmatically [message #1453776 is a reply to message #1451062] Mon, 27 October 2014 13:12 Go to previous message
Nikos Margaritis is currently offline Nikos MargaritisFriend
Messages: 65
Registered: September 2014
Member

Hey there, I have resolved this.

If anyone is interested you will need to apply a double click listener in both the xxxEditPart and xxxNameEditPart (if you have a node that holds a compartment and you want it to open either by double clicking on it or its name)

// this goes in the xxxEditPart
@Override
public void performRequest(Request req) {
	if (req.getType() == RequestConstants.REQ_OPEN) {
         // create your compartment edit part and get it from the children of the xxxEditPart,    mine is second in the list, thus i call get(1), you might need to change this
	    FolderFaultsFolderFaultsFaultCompartmentEditPart test = (FolderFaultsFolderFaultsFaultCompartmentEditPart) this.getChildren().get(1);
        // call the method that you will create in the xxxCompartmentEditPart (e.g FolderFaultsFolderFaultsFaultCompartmentEditPart for me)
	    test.collapseCompartment(test.getCompartmentFigure().isExpanded());
	}
}


// this goes in the xxxNameEditPart (if you wish also to collapse/expand when you click in the name of the node, if not is not needed)
@Override
public void performRequest(Request req) {
	if (req.getType() == RequestConstants.REQ_OPEN) {
                // create your compartment edit part and get it from the children of the xxxEditPart, but first you will need to get the xxxEditPart (that's why I call get parent(), as before mine is second in the list, thus i call get(1), you might need to change this
		FolderFaultsFolderFaultsFaultCompartmentEditPart test = (FolderFaultsFolderFaultsFaultCompartmentEditPart) this.getParent().getChildren().get(1);
                 // call the method that you will create in the xxxCompartmentEditPart (e.g FolderFaultsFolderFaultsFaultCompartmentEditPart for me)
		test.collapseCompartment(test.getCompartmentFigure().isExpanded());
	}
}


finally create the method in the xxxCompartmentEditPart, for me it is FolderFaultsFolderFaultsFaultCompartmentEditPart
public void collapseCompartment(boolean collapse) {
		ChangePropertyValueRequest request = new ChangePropertyValueRequest(
		DiagramUIMessages.PropertyDescriptorFactory_CollapseCompartment,
	    Properties.ID_COLLAPSED, collapse);
		getEditDomain().getCommandStack().execute(getCommand(request)); 
}


Kind Regards,
Previous Topic:Generate GMF-Generators headless?
Next Topic:exception when creating a connection via a command
Goto Forum:
  


Current Time: Wed Jan 17 18:28:10 GMT 2018

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

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