Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » collapsing a figure
collapsing a figure [message #195246] Thu, 08 September 2005 20:30 Go to next message
Eclipse UserFriend
Originally posted by: pbeagan.yahoo_dontspamme_.com

I want to implement windowshades like functionality in my editor, that is ,
have a toggle that lets me collapse or expand the figure. I am
accomplishing this by returning an empty list in the figure's
getModelChildren() depending on a setting in the model.

I want to have an expand/collapse Label on the figure which the user would
click on to trigger this. I added a MouseListener to the Label and can
capture the mouse down event. How do I determine which EditPart is being
clicked? Figures don't know about EditParts. Am I going about this the
wrong way?
Re: collapsing a figure [message #195281 is a reply to message #195246] Fri, 09 September 2005 06:54 Go to previous messageGo to next message
Pasi Lehtimäki is currently offline Pasi LehtimäkiFriend
Messages: 9
Registered: July 2009
Junior Member
Patrick wrote:
> I want to implement windowshades like functionality in my editor, that is ,
> have a toggle that lets me collapse or expand the figure. I am
> accomplishing this by returning an empty list in the figure's
> getModelChildren() depending on a setting in the model.
>
> I want to have an expand/collapse Label on the figure which the user would
> click on to trigger this. I added a MouseListener to the Label and can
> capture the mouse down event. How do I determine which EditPart is being
> clicked? Figures don't know about EditParts. Am I going about this the
> wrong way?
>


If you add mouse listener to the image this way in EditPart's
createFigure() or refreshVisuals() (or where ever you create the for
collapsing)method:

collapseThisImage.addMouseListener(new MouseListener(){

public void mousePressed(MouseEvent me) {
//Here you have acces to this current edit part

((RealModelClass)getModel()).setCollapsionState(true); //this is your
code to set the model's status beingcollapsed. Could also //just set
some flag to edit part.
}

public void mouseReleased(MouseEvent me) {}
public void mouseDoubleClicked(MouseEvent me) {}

});
Re: collapsing a figure [message #195327 is a reply to message #195281] Fri, 09 September 2005 13:56 Go to previous messageGo to next message
Sapna George is currently offline Sapna GeorgeFriend
Messages: 76
Registered: July 2009
Member
I implemented this functionality completely in the Figure itself. My
parent figure has a Label, which when clicked either expands or collapses
the figure to show/hide child figures, whcih are also Labels. My parent
Figure has a List of childFigures into which the parent EditPart adds the
Child figures in addChildVisual method of the parent EditPart.

Now the parent figure has all the child figures. The Expand Label has a
MouseListener. When the mouse is clicked, depending on the state of an
expand toggle flag, the child figures are added or removed from the parent
figure.

The Parent EditPart's method is :

protected void addChildVisual(EditPart childEditPart, int index) {
ClassFigure classFigure = (ClassFigure)getFigure();
IFigure childFigure = ((GraphicalEditPart)childEditPart).getFigure();
if (childEditPart instanceof AttributeEditPart ) {
if (classFigure.isShowCompartments()) {
AttributeEditPart attrPart = (AttributeEditPart)childEditPart;
int attrIndex =
getClassData().getIndexOfAttribute(attrPart.getAttribute());
classFigure.getAttributesCompartment().addChildFigure(childF igure,
attrIndex);

}
}
Re: collapsing a figure [message #195371 is a reply to message #195327] Fri, 09 September 2005 16:02 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: none.unknown.com

Sapna, what Pasi suggested is the recommended way of doing this.

"Sapna George" <sgeorge@vt.edu> wrote in message
news:74c6dd611430732452e34beb4b5d2dd7$1@www.eclipse.org...
> I implemented this functionality completely in the Figure itself. My
> parent figure has a Label, which when clicked either expands or collapses
> the figure to show/hide child figures, whcih are also Labels. My parent
> Figure has a List of childFigures into which the parent EditPart adds the
> Child figures in addChildVisual method of the parent EditPart.
>
> Now the parent figure has all the child figures. The Expand Label has a
> MouseListener. When the mouse is clicked, depending on the state of an
> expand toggle flag, the child figures are added or removed from the parent
> figure.
>
> The Parent EditPart's method is :
>
> protected void addChildVisual(EditPart childEditPart, int index) {
> ClassFigure classFigure = (ClassFigure)getFigure();
> IFigure childFigure = ((GraphicalEditPart)childEditPart).getFigure();
> if (childEditPart instanceof AttributeEditPart ) {
> if (classFigure.isShowCompartments()) {
> AttributeEditPart attrPart = (AttributeEditPart)childEditPart;
> int attrIndex =
> getClassData().getIndexOfAttribute(attrPart.getAttribute());
> classFigure.getAttributesCompartment().addChildFigure(childF igure,
> attrIndex);
>
> }
> }
>
Re: collapsing a figure [message #195396 is a reply to message #195371] Fri, 09 September 2005 17:45 Go to previous messageGo to next message
Sapna George is currently offline Sapna GeorgeFriend
Messages: 76
Registered: July 2009
Member
Hmmm... But, wouldn't that be a violation of MVC? Shouldn't the view be
responsible for displaying the figures whichever way it wants and the
Controller be responsible for creation of the View and passing on the
appropriate 'data'?
Re: collapsing a figure [message #195440 is a reply to message #195396] Fri, 09 September 2005 18:31 Go to previous message
Eclipse UserFriend
Originally posted by: none.us.ibm.com

The only difficulty in figure collapse is that editparts aren't very smart
about their figures being hidden, and they may remain selected even though
the figure is clipped or hidden.

It's still MVC, the view is displaying a toggle button, which flips a bit in
the controller, which owns the view, so it can do whatever it wants. Some
applications may save expansion state in the model, but without the use of a
command, or at least without dirtying the command stack.

"Sapna George" <sgeorge@vt.edu> wrote in message
news:2f9762d57d542d5b47d6ef0f1d6dd593$1@www.eclipse.org...
> Hmmm... But, wouldn't that be a violation of MVC? Shouldn't the view be
> responsible for displaying the figures whichever way it wants and the
> Controller be responsible for creation of the View and passing on the
> appropriate 'data'?
Previous Topic:Draw2d Label bounds
Next Topic:TemplateTransferDropTargetListener & CombinedTemplateCreationEntry - Problem
Goto Forum:
  


Current Time: Wed May 08 14:13:47 GMT 2024

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

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

Back to the top