Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Hiding child nodes blocks space
Hiding child nodes blocks space [message #714304] Wed, 10 August 2011 09:36 Go to next message
Greg is currently offline GregFriend
Messages: 15
Registered: April 2011
Junior Member
Hi,

after hiding child nodes contained in a compartment programmatically the nodes disappear but the space they used before is blocked and the compartment cannot minimize.

I realized it like:

Figure childFigure, parentFigure;

childFigure.setVisible(false);

parentFigure.revalidate();
parentFigure.repaint();


I have created a workaround but that only causes more problems. I create a list of elements and store the ones I want to hide in them. After that I delete the element from the parents list.

It creates the following warning output to my console:

!ENTRY org.eclipse.gmf.runtime.draw2d.ui 2 2 2011-08-10 11:31:25.964
!MESSAGE MapModeUtil#getMapMode(IFigure fig) fig parameter must be attached to a parent - using default MapMode


Another side effect makes children that are added to a hidden child node of a compartment grow really big once the child nodes are shown again.
Re: Hiding child nodes blocks space [message #714308 is a reply to message #714304] Wed, 10 August 2011 09:38 Go to previous messageGo to next message
Ralph Gerbig is currently offline Ralph GerbigFriend
Messages: 702
Registered: November 2009
Senior Member
Hi,

you should use the view to hide editparts. You can get it via getNotationView(). This resolves your problem.

Ralph
Re: Hiding child nodes blocks space [message #714363 is a reply to message #714308] Wed, 10 August 2011 12:24 Go to previous messageGo to next message
Greg is currently offline GregFriend
Messages: 15
Registered: April 2011
Junior Member
I tried to implement your suggestion like this:

for (GraphicalEditPart ePart : childEPartList)
{
  ePart.getNotationView().setVisible(false);
}


But all I get is:
java.lang.IllegalStateException: Cannot modify resource set without a write transaction
Re: Hiding child nodes blocks space [message #714365 is a reply to message #714363] Wed, 10 August 2011 12:35 Go to previous messageGo to next message
Ralph Gerbig is currently offline Ralph GerbigFriend
Messages: 702
Registered: November 2009
Senior Member
Hi,

try using commands.

CommandParameter parameters = new CommandParameter(...)
Command cmd = getEditingDomain().createCommand(SetCommand.class, parameters);
getEditingDomain().getCommandStack().execute(cmd);


This should help you.

Ralph
Re: Hiding child nodes blocks space [message #714385 is a reply to message #714365] Wed, 10 August 2011 13:15 Go to previous messageGo to next message
Greg is currently offline GregFriend
Messages: 15
Registered: April 2011
Junior Member
It does help me but doesn't solve my issue, yet.

Using a command would've been my next step but I don't know how to write this command and your code is only schematic.

I understand only a little of the whole command framework although I read though all the open documents.

I don't know what command to create here but also am pretty sure that SetCommand is the wrong one. It is an EMF command and here I try to modify a GMF view.

So this is the closest I can get:

GraphicalEditPart gEPart;

SetCommand cmd = new SetCommand(gEPart.getEditingDomain(), gEPart.getNotationView(), _________ , false);

gEPart.getEditingDomain().getCommandStack().execute(cmd);


I'm looking for the precise command and hope to understand a little more about it.
Re: Hiding child nodes blocks space [message #714406 is a reply to message #714385] Wed, 10 August 2011 13:37 Go to previous messageGo to next message
Ralph Gerbig is currently offline Ralph GerbigFriend
Messages: 702
Registered: November 2009
Senior Member
Hi,

the view is in the notational model which is in fact an EMF model. Hence, a EMF command is the right way to manipulate views.

I think in your code all that is missing is the feature you want to set which is returned by

NotationPackageImpl.eINSTANCE.getView_Visible()


Ralph

[Updated on: Wed, 10 August 2011 13:38]

Report message to a moderator

Re: Hiding child nodes blocks space [message #714411 is a reply to message #714385] Wed, 10 August 2011 13:42 Go to previous messageGo to next message
Greg is currently offline GregFriend
Messages: 15
Registered: April 2011
Junior Member
OK I wrote the following:

for (GraphicalEditPart ePart : childEPartList)
{
  SetCommand cmd = new SetCommand(ePart.getEditingDomain(), ePart.getNotationView(), NotationPackage.eINSTANCE.getView_Visible(), false);

  ePart.getEditingDomain().getCommandStack().execute(cmd);
}


and still got :

java.lang.IllegalStateException: Cannot modify resource set without a write transaction
Re: Hiding child nodes blocks space [message #714422 is a reply to message #714411] Wed, 10 August 2011 14:02 Go to previous messageGo to next message
Ralph Gerbig is currently offline Ralph GerbigFriend
Messages: 702
Registered: November 2009
Senior Member
Hi,

when do you want to do this? React on a model change, diagram startup, etc.

Ralph
Re: Hiding child nodes blocks space [message #714485 is a reply to message #714422] Wed, 10 August 2011 16:02 Go to previous messageGo to next message
Greg is currently offline GregFriend
Messages: 15
Registered: April 2011
Junior Member
OK, this might be another issue.

Currently this is invoked by a listener which is attached to a Custom figure that contains an image. It is similar to this example( http://www.eclipse.org/gmt/epsilon/doc/articles/eugenia-nodes-with-images/ ) only my version has an image inside the node.

This image represents a button. On click I react with the MouseListener, change the image and do something. In this case I hide several elements.

I guess I am outside the context to send any command here?

Unfortunately there is no EditPart to this figure so I cannot install an EditPolicy, or can I? What request do I wait for?

This is drifting away from the original topic but do you have any idea how to fix this?
Re: Hiding child nodes blocks space [message #715048 is a reply to message #714485] Fri, 12 August 2011 08:36 Go to previous messageGo to next message
Greg is currently offline GregFriend
Messages: 15
Registered: April 2011
Junior Member
I managed to make it work using your help but have a different effect, again.

Now the top level node can be collapsed and open from outside using the following command:

SetRequest request = new SetRequest(ePart.getNotationView(), NotationPackage.eINSTANCE.getView_Visible(), true);

SetValueCommand cmd = new SetValueCommand(request);


But once I save the diagram with the node in the collapsed status, close it and open it up again, the node cannot be opened again and has lost all its children.

Debugging it I saw that the EditParts of the children vanish from the parent's list with the execution of the SetValueCommand (...getView_Visible, false).

This cannot be right.
Re: Hiding child nodes blocks space [message #715111 is a reply to message #715048] Fri, 12 August 2011 11:56 Go to previous messageGo to next message
Ralph Gerbig is currently offline Ralph GerbigFriend
Messages: 702
Registered: November 2009
Senior Member
Hi,

to get the children again after seting visible to true try this on the editpart:

performRequest(new Request(RequestConstants.REQ_REFRESH));


Ralph
Re: Hiding child nodes blocks space [solved] [message #716125 is a reply to message #714304] Tue, 16 August 2011 13:52 Go to previous message
J.Teutsch  is currently offline J.Teutsch Friend
Messages: 7
Registered: November 2010
Junior Member
I found the solution to the problem Smile

Interesting is that

 editpart.getChildren() 


only returns those editpart that are visible. The invisible editparts are not listed.

So iterating over those children is not helpful.

The solution is
    View notationView = editPart.getNotationView();
    EList<EObject> viewchildren = notationView.getChildren();
    for (EObject object : viewchildren)
    {
      SetRequest request = new SetRequest(object, NotationPackage.eINSTANCE.getView_Visible(), true);

      SetValueCommand cmd = new SetValueCommand(request);
      compositecommand.add(cmd);
    }
Previous Topic:Custom figures creation
Next Topic:Loading external resource
Goto Forum:
  


Current Time: Fri Apr 19 19:55:12 GMT 2024

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

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

Back to the top