Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 49110 Details for
Bug 115905
ShapeCompartment collapse handle drawn outside shapecomartment figure
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
fix for ResizableCompartmentEditPolicy
Patch_115905_attempt1 (text/plain), 9.06 KB, created by
Alex Boyko
on 2006-08-30 18:29:32 EDT
(
hide
)
Description:
fix for ResizableCompartmentEditPolicy
Filename:
MIME Type:
Creator:
Alex Boyko
Created:
2006-08-30 18:29:32 EDT
Size:
9.06 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.gmf.runtime.diagram.ui >Index: src/org/eclipse/gmf/runtime/diagram/ui/editpolicies/ResizableCompartmentEditPolicy.java >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.gmf/plugins/org.eclipse.gmf.runtime.diagram.ui/src/org/eclipse/gmf/runtime/diagram/ui/editpolicies/ResizableCompartmentEditPolicy.java,v >retrieving revision 1.9 >diff -u -r1.9 ResizableCompartmentEditPolicy.java >--- src/org/eclipse/gmf/runtime/diagram/ui/editpolicies/ResizableCompartmentEditPolicy.java 6 Apr 2006 20:04:27 -0000 1.9 >+++ src/org/eclipse/gmf/runtime/diagram/ui/editpolicies/ResizableCompartmentEditPolicy.java 30 Aug 2006 22:30:09 -0000 >@@ -13,7 +13,9 @@ > > import java.util.ArrayList; > import java.util.List; >+import java.util.ListIterator; > >+import org.eclipse.draw2d.FigureListener; > import org.eclipse.draw2d.IFigure; > import org.eclipse.draw2d.PositionConstants; > import org.eclipse.draw2d.geometry.Dimension; >@@ -22,6 +24,7 @@ > import org.eclipse.emf.transaction.TransactionalEditingDomain; > import org.eclipse.gef.EditPart; > import org.eclipse.gef.EditPartListener; >+import org.eclipse.gef.LayerConstants; > import org.eclipse.gef.commands.Command; > import org.eclipse.gef.requests.ChangeBoundsRequest; > import org.eclipse.gmf.runtime.diagram.core.listener.DiagramEventBroker; >@@ -29,11 +32,13 @@ > import org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart; > import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart; > import org.eclipse.gmf.runtime.diagram.ui.editparts.ResizableCompartmentEditPart; >+import org.eclipse.gmf.runtime.diagram.ui.editparts.TopGraphicEditPart; > import org.eclipse.gmf.runtime.diagram.ui.figures.BorderedNodeFigure; > import org.eclipse.gmf.runtime.diagram.ui.figures.ResizableCompartmentFigure; > import org.eclipse.gmf.runtime.diagram.ui.handles.CompartmentCollapseHandle; > import org.eclipse.gmf.runtime.diagram.ui.internal.handles.CompartmentResizeHandle; > import org.eclipse.gmf.runtime.notation.NotationPackage; >+import org.eclipse.jface.util.Assert; > > /** > * A resizable editpolicy for resizable compartments. The editpolicy could be >@@ -45,6 +50,36 @@ > extends ResizableEditPolicyEx { > > private boolean horizontal; >+ >+ /** >+ * Listener to determine bounds changes of compartment figure and/or its container >+ * to display or hide collapse handles accordingly (Bugzilla #115905) >+ */ >+ private FigureListener figureListener = new FigureListener() { >+ public void figureMoved(IFigure source) { >+ if (handles != null) { >+ ResizableCompartmentFigure compartment = getCompartmentFigure(); >+ if (source.equals(compartment)) >+ { >+ refreshCollapseHandles(getGraphicalEditPart() >+ .getTopGraphicEditPart().getFigure().getBounds() >+ .contains(source.getBounds())); >+ Dimension minClientDimension = compartment.getMinClientDimension(); >+ >+ /* If compartment size cannot become smaller, we'll be looking at its >+ * container figure bounds changes. If compartment can decrease its size >+ * we don't need to look at its container figure bounds changes */ >+ if (compartment.getBounds().width <= minClientDimension.width+1 >+ || compartment.getBounds().height <= minClientDimension.height+1) >+ getGraphicalEditPart().getTopGraphicEditPart().getFigure().addFigureListener(this); >+ else >+ getGraphicalEditPart().getTopGraphicEditPart().getFigure().removeFigureListener(this); >+ } >+ else if (source.equals(getGraphicalEditPart().getTopGraphicEditPart().getFigure())) >+ refreshCollapseHandles(source.getBounds().contains(compartment.getBounds())); >+ } >+ } >+ }; > > /** > * Creates a new vertical ResizableCompartmentEditPolicy >@@ -79,10 +114,11 @@ > IGraphicalEditPart part = (IGraphicalEditPart) getHost(); > > List collapseHandles = new ArrayList(); >+ > collapseHandles.add(new CompartmentCollapseHandle(part)); > return collapseHandles; > } >- >+ > /** > * @see org.eclipse.gef.editpolicies.SelectionHandlesEditPolicy#createSelectionHandles() > */ >@@ -93,7 +129,11 @@ > int d2 = isHorizontal() ? PositionConstants.EAST > : PositionConstants.SOUTH; > List selectionHandles = new ArrayList(); >- selectionHandles.addAll(createCollapseHandles()); >+ >+ TopGraphicEditPart wrapper = part.getTopGraphicEditPart(); >+ if ( wrapper == null || wrapper.getFigure().getBounds().contains(getCompartmentFigure().getBounds()) ) >+ selectionHandles.addAll(createCollapseHandles()); >+ > selectionHandles.add(new CompartmentResizeHandle(part, d1)); > selectionHandles.add(new CompartmentResizeHandle(part, d2)); > return selectionHandles; >@@ -133,9 +173,12 @@ > */ > protected void showSelection() { > super.showSelection(); >- if (getHost().getSelected() != EditPart.SELECTED_NONE) { >- ResizableCompartmentFigure compartmentFigure = getCompartmentFigure(); >- if (compartmentFigure != null) { >+ if (getGraphicalEditPart().getTopGraphicEditPart() != null) >+ getGraphicalEditPart().getTopGraphicEditPart().getFigure().addFigureListener(figureListener); >+ ResizableCompartmentFigure compartmentFigure = getCompartmentFigure(); >+ if (compartmentFigure != null) { >+ compartmentFigure.addFigureListener(figureListener); >+ if (getHost().getSelected() != EditPart.SELECTED_NONE) { > compartmentFigure.setSelected(true); > } > } >@@ -146,9 +189,12 @@ > */ > protected void hideSelection() { > super.hideSelection(); >- if (getHost().getSelected() == EditPart.SELECTED_NONE) { >- ResizableCompartmentFigure compartmentFigure = getCompartmentFigure(); >- if (compartmentFigure != null) { >+ if (getGraphicalEditPart().getTopGraphicEditPart() != null) >+ getGraphicalEditPart().getTopGraphicEditPart().getFigure().removeFigureListener(figureListener); >+ ResizableCompartmentFigure compartmentFigure = getCompartmentFigure(); >+ if (compartmentFigure != null) { >+ compartmentFigure.removeFigureListener(figureListener); >+ if (getHost().getSelected() == EditPart.SELECTED_NONE) { > compartmentFigure.setSelected(false); > } > } >@@ -185,10 +231,11 @@ > > public void notifyChanged(Notification notification) { > if (NotationPackage.eINSTANCE.getView_Visible().equals( >- notification.getFeature())) >+ notification.getFeature())) > setSelectedState(); > } > }; >+ > getDiagramEventBroker().addNotificationListener( > getGraphicalEditPart().getNotationView(), propertyListener); > } >@@ -291,4 +338,75 @@ > } > return null; > } >+ >+ /** >+ * Refreshes collapse handles - displays them if they need to be displayed but not displaying >+ * and removes them if they shouldn't be displayed, but are displayed. >+ * Method assumes that handles are not <code>null</code>, i.e. handles are being displayed >+ * >+ * @param shouldHaveHandles <code>true</code> if collapse handles need to be displayed >+ */ >+ private void refreshCollapseHandles(boolean shouldHaveHandles) >+ { >+ Assert.isTrue(handles!=null); >+ >+ boolean hasHandles = dispalyingCollapseHandles(); >+ >+ if (shouldHaveHandles && !hasHandles) >+ addCollapseHandles(); >+ else if (!shouldHaveHandles && hasHandles) >+ removeCollapseHandles(); >+ } >+ >+ /** >+ * Adds collapse handles to the list of handles and displays them >+ * Method assumes that handles are not <code>null</code>, i.e. handles are being displayed >+ */ >+ private void addCollapseHandles() >+ { >+ Assert.isTrue(handles!=null); >+ List collapseHandles = createCollapseHandles(); >+ IFigure layer = getLayer(LayerConstants.HANDLE_LAYER); >+ handles.addAll(collapseHandles); >+ for (ListIterator handlesIterator = collapseHandles >+ .listIterator(); handlesIterator.hasNext();) >+ layer.add((IFigure) handlesIterator.next()); >+ } >+ >+ /** >+ * Tries to remove collapse handles if any displayed >+ * Method assumes that handles are not <code>null</code>, i.e. handles are being displayed >+ * >+ */ >+ private void removeCollapseHandles() >+ { >+ Assert.isTrue(handles!=null); >+ IFigure layer = getLayer(LayerConstants.HANDLE_LAYER); >+ for (ListIterator handlesIterator = handles.listIterator(); handlesIterator.hasNext();) >+ { >+ IFigure handle = (IFigure) handlesIterator.next(); >+ if (handle instanceof CompartmentCollapseHandle) { >+ layer.remove(handle); >+ handlesIterator.remove(); >+ } >+ } >+ } >+ >+ /** >+ * Checks whether connection handles are being displayed. >+ * Method assumes that handles are not <code>null</code>, i.e. handles are being displayed >+ * >+ * @return <code>true</code> if collapse handles are being displayed >+ */ >+ private boolean dispalyingCollapseHandles() >+ { >+ Assert.isTrue(handles!=null); >+ for (ListIterator handlesIterator = handles.listIterator(); handlesIterator.hasNext();) >+ { >+ if (handlesIterator.next() instanceof CompartmentCollapseHandle) >+ return true; >+ } >+ return false; >+ } >+ > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 115905
:
49110
|
49217
|
49495
|
50315
|
50393
|
50436