collapsing a figure [message #195246] |
Thu, 08 September 2005 20:30 |
Eclipse User |
|
|
|
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 #195371 is a reply to message #195327] |
Fri, 09 September 2005 16:02 |
Eclipse User |
|
|
|
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 #195440 is a reply to message #195396] |
Fri, 09 September 2005 18:31 |
Eclipse User |
|
|
|
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'?
|
|
|
Powered by
FUDForum. Page generated in 0.04366 seconds