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 166408 Details for
Bug 309858
Public class BorderedNodeFigure exposes internal interface IExpandableFigure
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
Patch to fix the issue.
patch.txt (text/plain), 36.34 KB, created by
Anthony Hunter
on 2010-04-28 21:04:14 EDT
(
hide
)
Description:
Patch to fix the issue.
Filename:
MIME Type:
Creator:
Anthony Hunter
Created:
2010-04-28 21:04:14 EDT
Size:
36.34 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.gmf.runtime.diagram.ui >Index: src/org/eclipse/gmf/runtime/diagram/ui/figures/BorderItemsAwareFreeFormLayer.java >=================================================================== >RCS file: /cvsroot/modeling/org.eclipse.gmf/plugins/org.eclipse.gmf.runtime.diagram.ui/src/org/eclipse/gmf/runtime/diagram/ui/figures/BorderItemsAwareFreeFormLayer.java,v >retrieving revision 1.4 >diff -u -r1.4 BorderItemsAwareFreeFormLayer.java >--- src/org/eclipse/gmf/runtime/diagram/ui/figures/BorderItemsAwareFreeFormLayer.java 2 Jan 2007 21:57:26 -0000 1.4 >+++ src/org/eclipse/gmf/runtime/diagram/ui/figures/BorderItemsAwareFreeFormLayer.java 29 Apr 2010 00:59:19 -0000 >@@ -1,210 +1,210 @@ >-/****************************************************************************** >- * Copyright (c) 2006, 2006 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * >- * Contributors: >- * IBM Corporation - initial API and implementation >- ****************************************************************************/ >- >-package org.eclipse.gmf.runtime.diagram.ui.figures; >- >-import java.util.Iterator; >-import java.util.List; >- >-import org.eclipse.draw2d.Figure; >-import org.eclipse.draw2d.FigureListener; >-import org.eclipse.draw2d.FreeformFigure; >-import org.eclipse.draw2d.FreeformLayer; >-import org.eclipse.draw2d.FreeformListener; >-import org.eclipse.draw2d.IFigure; >-import org.eclipse.draw2d.geometry.Insets; >-import org.eclipse.draw2d.geometry.Rectangle; >-import org.eclipse.gmf.runtime.diagram.ui.internal.figures.IExpandableFigure; >- >- >-/** >- * a Border item aware implementation for the free form layer >- * This layer will make sure that scroll bars and bounds calculations >- * respect the border items implementation >- * @author mmostafa >- * >- */ >-public class BorderItemsAwareFreeFormLayer >- extends FreeformLayer { >- >- private BorderItemAwareFreeFormHelper _helper = new BorderItemAwareFreeFormHelper(this); >- >- Rectangle extendedBounds = null; >- >- /** >- * The helper class used by the border item aware free form layer >- * This helper class will calculate the correct extent of the layer, considering the >- * border items >- * @author mmostafa >- * >- */ >- public class BorderItemAwareFreeFormHelper implements FreeformListener >- { >- >- class ChildTracker implements FigureListener { >- public void figureMoved(IFigure source) { >- invalidate(); >- } >- } >- >- private FreeformFigure host; >- private Rectangle freeformExtent; >- private FigureListener figureListener = new ChildTracker(); >- >- public BorderItemAwareFreeFormHelper(FreeformFigure host) { >- this.host = host; >- } >- >- public void reset(){ >- freeformExtent = null; >- } >- >- public Rectangle getFreeformExtent() { >- if (freeformExtent != null) >- return freeformExtent; >- Rectangle r; >- List children = host.getChildren(); >- for (int i = 0; i < children.size(); i++) { >- IFigure child = (IFigure)children.get(i); >- if (child instanceof FreeformFigure) >- r = ((FreeformFigure) child).getFreeformExtent(); >- else if (child instanceof IExpandableFigure) >- r = ((IExpandableFigure) child).getExtendedBounds(); >- else >- r = child.getBounds(); >- if (freeformExtent == null) >- freeformExtent = r.getCopy(); >- else >- freeformExtent.union(r); >- } >- Insets insets = host.getInsets(); >- if (freeformExtent == null) >- freeformExtent = new Rectangle(0, 0, insets.getWidth(), insets.getHeight()); >- else { >- host.translateToParent(freeformExtent); >- freeformExtent.expand(insets); >- } >- return freeformExtent; >- } >- >- public void hookChild(IFigure child) { >- invalidate(); >- if (child instanceof FreeformFigure) >- ((FreeformFigure)child).addFreeformListener(this); >- else >- child.addFigureListener(figureListener); >- } >- >- void invalidate() { >- freeformExtent = null; >- host.fireExtentChanged(); >- if (host.getParent() != null) >- host.getParent().revalidate(); >- else >- host.revalidate(); >- } >- >- public void notifyFreeformExtentChanged() { >- //A childs freeform extent has changed, therefore this extent must be recalculated >- invalidate(); >- } >- >- public void setFreeformBounds(Rectangle bounds) { >- host.setBounds(bounds); >- bounds = bounds.getCopy(); >- host.translateFromParent(bounds); >- List children = host.getChildren(); >- for (int i = 0; i < children.size(); i++) { >- IFigure child = (IFigure)children.get(i); >- if (child instanceof FreeformFigure) >- ((FreeformFigure) child).setFreeformBounds(bounds); >- } >- } >- >- public void unhookChild(IFigure child) { >- invalidate(); >- if (child instanceof FreeformFigure) >- ((FreeformFigure)child).removeFreeformListener(this); >- else >- child.removeFigureListener(figureListener); >- } >- >- } >- >- >- public Rectangle getBounds() { >- if (extendedBounds==null){ >- Iterator figuresIter = getChildren().iterator(); >- Rectangle _bounds = super.getBounds().getCopy(); >- while (figuresIter.hasNext()) { >- Figure element = (Figure) figuresIter.next(); >- Rectangle rect = null; >- if (element instanceof IExpandableFigure){ >- rect = ((IExpandableFigure)element).getExtendedBounds(); >- }else { >- rect = element.getBounds(); >- } >- _bounds.union(rect); >- } >- extendedBounds = _bounds; >- } >- return extendedBounds; >- } >- >- public void invalidate() { >- extendedBounds = null; >- super.invalidate(); >- } >- >- public void validate() { >- extendedBounds = null; >- super.validate(); >- } >- >- /** >- * @see IFigure#add(IFigure, Object, int) >- */ >- public void add(IFigure child, Object constraint, int index) { >- super.add(child, constraint, index); >- _helper.hookChild(child); >- } >- >- /** >- * @see FreeformFigure#getFreeformExtent() >- */ >- public Rectangle getFreeformExtent() { >- return _helper.getFreeformExtent(); >- } >- >- /** >- * @see IFigure#remove(IFigure) >- */ >- public void remove(IFigure child) { >- _helper.unhookChild(child); >- super.remove(child); >- } >- >- /** >- * @see FreeformFigure#setFreeformBounds(Rectangle) >- */ >- public void setFreeformBounds(Rectangle bounds) { >- _helper.setFreeformBounds(bounds); >- } >- >- /** >- * will notify the layer that a border item had been moved; which will result in >- * invalidating the layer (recalculating the bounds and extent). >- */ >- public void borderFigureMoved(){ >- _helper.invalidate(); >- } >- >-} >+/****************************************************************************** >+ * Copyright (c) 2006, 2010 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ ****************************************************************************/ >+ >+package org.eclipse.gmf.runtime.diagram.ui.figures; >+ >+import java.util.Iterator; >+import java.util.List; >+ >+import org.eclipse.draw2d.Figure; >+import org.eclipse.draw2d.FigureListener; >+import org.eclipse.draw2d.FreeformFigure; >+import org.eclipse.draw2d.FreeformLayer; >+import org.eclipse.draw2d.FreeformListener; >+import org.eclipse.draw2d.IFigure; >+import org.eclipse.draw2d.geometry.Insets; >+import org.eclipse.draw2d.geometry.Rectangle; >+import org.eclipse.gmf.runtime.diagram.ui.figures.IExpandableFigure; >+ >+ >+/** >+ * a Border item aware implementation for the free form layer >+ * This layer will make sure that scroll bars and bounds calculations >+ * respect the border items implementation >+ * @author mmostafa >+ * >+ */ >+public class BorderItemsAwareFreeFormLayer >+ extends FreeformLayer { >+ >+ private BorderItemAwareFreeFormHelper _helper = new BorderItemAwareFreeFormHelper(this); >+ >+ Rectangle extendedBounds = null; >+ >+ /** >+ * The helper class used by the border item aware free form layer >+ * This helper class will calculate the correct extent of the layer, considering the >+ * border items >+ * @author mmostafa >+ * >+ */ >+ public class BorderItemAwareFreeFormHelper implements FreeformListener >+ { >+ >+ class ChildTracker implements FigureListener { >+ public void figureMoved(IFigure source) { >+ invalidate(); >+ } >+ } >+ >+ private FreeformFigure host; >+ private Rectangle freeformExtent; >+ private FigureListener figureListener = new ChildTracker(); >+ >+ public BorderItemAwareFreeFormHelper(FreeformFigure host) { >+ this.host = host; >+ } >+ >+ public void reset(){ >+ freeformExtent = null; >+ } >+ >+ public Rectangle getFreeformExtent() { >+ if (freeformExtent != null) >+ return freeformExtent; >+ Rectangle r; >+ List children = host.getChildren(); >+ for (int i = 0; i < children.size(); i++) { >+ IFigure child = (IFigure)children.get(i); >+ if (child instanceof FreeformFigure) >+ r = ((FreeformFigure) child).getFreeformExtent(); >+ else if (child instanceof IExpandableFigure) >+ r = ((IExpandableFigure) child).getExtendedBounds(); >+ else >+ r = child.getBounds(); >+ if (freeformExtent == null) >+ freeformExtent = r.getCopy(); >+ else >+ freeformExtent.union(r); >+ } >+ Insets insets = host.getInsets(); >+ if (freeformExtent == null) >+ freeformExtent = new Rectangle(0, 0, insets.getWidth(), insets.getHeight()); >+ else { >+ host.translateToParent(freeformExtent); >+ freeformExtent.expand(insets); >+ } >+ return freeformExtent; >+ } >+ >+ public void hookChild(IFigure child) { >+ invalidate(); >+ if (child instanceof FreeformFigure) >+ ((FreeformFigure)child).addFreeformListener(this); >+ else >+ child.addFigureListener(figureListener); >+ } >+ >+ void invalidate() { >+ freeformExtent = null; >+ host.fireExtentChanged(); >+ if (host.getParent() != null) >+ host.getParent().revalidate(); >+ else >+ host.revalidate(); >+ } >+ >+ public void notifyFreeformExtentChanged() { >+ //A childs freeform extent has changed, therefore this extent must be recalculated >+ invalidate(); >+ } >+ >+ public void setFreeformBounds(Rectangle bounds) { >+ host.setBounds(bounds); >+ bounds = bounds.getCopy(); >+ host.translateFromParent(bounds); >+ List children = host.getChildren(); >+ for (int i = 0; i < children.size(); i++) { >+ IFigure child = (IFigure)children.get(i); >+ if (child instanceof FreeformFigure) >+ ((FreeformFigure) child).setFreeformBounds(bounds); >+ } >+ } >+ >+ public void unhookChild(IFigure child) { >+ invalidate(); >+ if (child instanceof FreeformFigure) >+ ((FreeformFigure)child).removeFreeformListener(this); >+ else >+ child.removeFigureListener(figureListener); >+ } >+ >+ } >+ >+ >+ public Rectangle getBounds() { >+ if (extendedBounds==null){ >+ Iterator figuresIter = getChildren().iterator(); >+ Rectangle _bounds = super.getBounds().getCopy(); >+ while (figuresIter.hasNext()) { >+ Figure element = (Figure) figuresIter.next(); >+ Rectangle rect = null; >+ if (element instanceof IExpandableFigure){ >+ rect = ((IExpandableFigure)element).getExtendedBounds(); >+ }else { >+ rect = element.getBounds(); >+ } >+ _bounds.union(rect); >+ } >+ extendedBounds = _bounds; >+ } >+ return extendedBounds; >+ } >+ >+ public void invalidate() { >+ extendedBounds = null; >+ super.invalidate(); >+ } >+ >+ public void validate() { >+ extendedBounds = null; >+ super.validate(); >+ } >+ >+ /** >+ * @see IFigure#add(IFigure, Object, int) >+ */ >+ public void add(IFigure child, Object constraint, int index) { >+ super.add(child, constraint, index); >+ _helper.hookChild(child); >+ } >+ >+ /** >+ * @see FreeformFigure#getFreeformExtent() >+ */ >+ public Rectangle getFreeformExtent() { >+ return _helper.getFreeformExtent(); >+ } >+ >+ /** >+ * @see IFigure#remove(IFigure) >+ */ >+ public void remove(IFigure child) { >+ _helper.unhookChild(child); >+ super.remove(child); >+ } >+ >+ /** >+ * @see FreeformFigure#setFreeformBounds(Rectangle) >+ */ >+ public void setFreeformBounds(Rectangle bounds) { >+ _helper.setFreeformBounds(bounds); >+ } >+ >+ /** >+ * will notify the layer that a border item had been moved; which will result in >+ * invalidating the layer (recalculating the bounds and extent). >+ */ >+ public void borderFigureMoved(){ >+ _helper.invalidate(); >+ } >+ >+} >Index: src/org/eclipse/gmf/runtime/diagram/ui/figures/BorderedNodeFigure.java >=================================================================== >RCS file: /cvsroot/modeling/org.eclipse.gmf/plugins/org.eclipse.gmf.runtime.diagram.ui/src/org/eclipse/gmf/runtime/diagram/ui/figures/BorderedNodeFigure.java,v >retrieving revision 1.9 >diff -u -r1.9 BorderedNodeFigure.java >--- src/org/eclipse/gmf/runtime/diagram/ui/figures/BorderedNodeFigure.java 14 Jan 2009 15:07:29 -0000 1.9 >+++ src/org/eclipse/gmf/runtime/diagram/ui/figures/BorderedNodeFigure.java 29 Apr 2010 00:59:19 -0000 >@@ -1,269 +1,269 @@ >-/****************************************************************************** >- * Copyright (c) 2003, 2009 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * >- * Contributors: >- * IBM Corporation - initial API and implementation >- * Mariot Chauvin <mariot.chauvin@obeo.fr> - bug 259507 >- ****************************************************************************/ >- >-package org.eclipse.gmf.runtime.diagram.ui.figures; >- >-import org.eclipse.draw2d.ConnectionAnchor; >-import org.eclipse.draw2d.DelegatingLayout; >-import org.eclipse.draw2d.IFigure; >-import org.eclipse.draw2d.LayoutAnimator; >-import org.eclipse.draw2d.TreeSearch; >-import org.eclipse.draw2d.geometry.Dimension; >-import org.eclipse.draw2d.geometry.Point; >-import org.eclipse.draw2d.geometry.Rectangle; >-import org.eclipse.gmf.runtime.diagram.ui.internal.figures.BorderItemContainerFigure; >-import org.eclipse.gmf.runtime.diagram.ui.internal.figures.IExpandableFigure; >-import org.eclipse.gmf.runtime.gef.ui.figures.NodeFigure; >- >-/** >- * Wrapper figure that contains the main figure and the border item figures. >- * This is required to allow the main figure's layout manager to ignore the >- * border items. The border item container applies a delegating layout manager >- * to allow border item children to lay themselves out. >- * >- * @author jbruck, cmahoney, mmostafa >- */ >-public class BorderedNodeFigure >- extends NodeFigure implements IExpandableFigure{ >- >- private BorderItemContainerFigure borderItemContainer; >- >- private IFigure mainFigure; >- >- private Rectangle extendedBounds = new Rectangle(); >- >- /** >- * Creates a new BorderedNodeFigure figure. >- * >- * @param mainFigure >- * the figure to use with this figure >- */ >- public BorderedNodeFigure(IFigure mainFigure) { >- super(); >- setOpaque(false); // set transparent by default >- setBorder(null); >- setLayoutManager(null); >- this.mainFigure = mainFigure; >- >- add(getMainFigure()); >- add(getBorderItemContainer()); >- >- setBounds(getMainFigure().getBounds().getCopy()); >- getBorderItemContainer().setBounds(new Rectangle(0, 0, 1, 1)); >- } >- >- /** >- * Gets the border item container figure to which border item figures can be >- * added with a {@link IBorderItemLocator} as the constraint and then later >- * removed. >- * >- * @return The border item container figure >- */ >- public IFigure getBorderItemContainer() { >- if (borderItemContainer == null) { >- borderItemContainer = new BorderItemContainerFigure(); >- borderItemContainer >- .setLayoutManager(new DelegatingLayout()); >- borderItemContainer.addLayoutListener(LayoutAnimator.getDefault()); >- borderItemContainer.setVisible(true); >- } >- return borderItemContainer; >- } >- >- /** >- * Gets the main figure of this bordered figure. >- * >- * @return The "main" figure >- */ >- public IFigure getMainFigure() { >- return mainFigure; >- } >- >- public Rectangle getClientArea(Rectangle rect) { >- if (getMainFigure() != null) { >- return getMainFigure().getClientArea(rect); >- } >- return super.getClientArea(rect); >- } >- >- /** >- * gets the handle bounds of the main figure >- * >- * @return the hnalde bounds >- */ >- public Rectangle getHandleBounds() { >- if (getMainFigure() instanceof NodeFigure) { >- return ((NodeFigure) getMainFigure()).getHandleBounds().getCopy(); >- } else { >- return getMainFigure().getBounds().getCopy(); >- } >- } >- >- /** >- * Give the main figure the entire bounds of the wrapper. >- */ >- protected void layout() { >- if (!this.getBounds().equals(getMainFigure().getBounds())) { >- getMainFigure().setBounds(this.getBounds().getCopy()); >- getBorderItemContainer().invalidateTree(); >- erase(); >- } >- } >- >- /** >- * We need to override this for smooth painting of border items. >- */ >- public boolean containsPoint(int x, int y) { >- if (borderItemContainer.containsPoint(x, y)) { >- return true; >- } >- return super.containsPoint(x, y); >- } >- >- protected void primTranslate(int dx, int dy) { >- super.primTranslate(dx, dy); >- erase(); >- } >- >- public void erase() { >- super.erase(); >- if (borderItemContainer != null) >- borderItemContainer.erase(); >- } >- >- /** >- * Refresh adornments >- */ >- public void repaint() { >- super.repaint(); >- if (borderItemContainer != null) >- borderItemContainer.repaint(); >- } >- >- public IFigure findFigureAt(int x, int y, TreeSearch search) { >- if (search.prune(this)) >- return null; >- IFigure result = borderItemContainer.findFigureAt(x, y, search); >- if (result != null) { >- return result; >- } >- return getMainFigure().findFigureAt(x, y, search); >- } >- >- public IFigure findMouseEventTargetAt(int x, int y) { >- IFigure borderItemFigure = borderItemContainer.findMouseEventTargetAt( >- x, y); >- if (borderItemFigure != null) >- return borderItemFigure; >- return super.findMouseEventTargetAt(x, y); >- } >- >- public boolean intersects(Rectangle rect) { >- if (getExtendedBounds().intersects(rect)) >- return true; >- return super.intersects(rect); >- } >- >- public Dimension getMinimumSize(int wHint, int hHint) { >- return getMainFigure().getMinimumSize(wHint, hHint); >- } >- >- public Dimension getPreferredSize(int wHint, int hHint) { >- return getMainFigure().getPreferredSize(wHint, hHint); >- } >- >- public IFigure getToolTip() { >- return getMainFigure().getToolTip(); >- } >- >- public void setToolTip(IFigure f) { >- getMainFigure().setToolTip(f); >- } >- >- public ConnectionAnchor getSourceConnectionAnchorAt(Point p) { >- if (getMainFigure() instanceof NodeFigure) >- return ((NodeFigure) getMainFigure()) >- .getSourceConnectionAnchorAt(p); >- return super.getSourceConnectionAnchorAt(p); >- } >- >- public ConnectionAnchor getTargetConnectionAnchorAt(Point p) { >- if (getMainFigure() instanceof NodeFigure) >- return ((NodeFigure) getMainFigure()) >- .getTargetConnectionAnchorAt(p); >- return super.getTargetConnectionAnchorAt(p); >- } >- >- public ConnectionAnchor getConnectionAnchor(String terminal) { >- if (getMainFigure() instanceof NodeFigure) >- return ((NodeFigure) getMainFigure()).getConnectionAnchor(terminal); >- return super.getConnectionAnchor(terminal); >- } >- >- public String getConnectionAnchorTerminal(ConnectionAnchor c) { >- if (getMainFigure() instanceof NodeFigure) >- return ((NodeFigure) getMainFigure()) >- .getConnectionAnchorTerminal(c); >- return super.getConnectionAnchorTerminal(c); >- } >- >- /** >- * This method provides a generic way to get a target figure's parent's main >- * figure where if the target figure is a border item figure, then its >- * parent is considered the figure on which it borders.It is not possible to >- * get a target figure's parent using <code>IFigure#getParent()</code> if >- * the target figure is a border item figure, since this would return the >- * border item container figure. >- * >- * @param target >- * the target figure, may or may not be acting as a border item >- * figure >- * @return the parent figure or if the target figure was on a border item >- * container figure, then the main figure that it borders. >- */ >- public static IFigure getParentFigure(IFigure target) { >- IFigure parent = target.getParent(); >- if (parent instanceof BorderItemContainerFigure) { >- return ((BorderedNodeFigure) parent.getParent()).getMainFigure(); >- } >- return parent; >- } >- >- public Rectangle getExtendedBounds() { >- if (extendedBounds == null) { >- Rectangle rect = getBounds().getCopy(); >- if (borderItemContainer!=null){ >- rect = rect.union(borderItemContainer.getExtendedBounds()); >- } >- extendedBounds = rect; >- } >- return extendedBounds; >- } >- >- @Override >- public void invalidate() { >- extendedBounds = null; >- super.invalidate(); >- } >- >- @Override >- public void validate() { >- extendedBounds = null; >- super.validate(); >- } >- >- @Override >- protected void fireFigureMoved() { >- super.fireFigureMoved(); >- extendedBounds = null; >- } >-} >+/****************************************************************************** >+ * Copyright (c) 2003, 2010 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ * Mariot Chauvin <mariot.chauvin@obeo.fr> - bug 259507 >+ ****************************************************************************/ >+ >+package org.eclipse.gmf.runtime.diagram.ui.figures; >+ >+import org.eclipse.draw2d.ConnectionAnchor; >+import org.eclipse.draw2d.DelegatingLayout; >+import org.eclipse.draw2d.IFigure; >+import org.eclipse.draw2d.LayoutAnimator; >+import org.eclipse.draw2d.TreeSearch; >+import org.eclipse.draw2d.geometry.Dimension; >+import org.eclipse.draw2d.geometry.Point; >+import org.eclipse.draw2d.geometry.Rectangle; >+import org.eclipse.gmf.runtime.diagram.ui.internal.figures.BorderItemContainerFigure; >+import org.eclipse.gmf.runtime.diagram.ui.figures.IExpandableFigure; >+import org.eclipse.gmf.runtime.gef.ui.figures.NodeFigure; >+ >+/** >+ * Wrapper figure that contains the main figure and the border item figures. >+ * This is required to allow the main figure's layout manager to ignore the >+ * border items. The border item container applies a delegating layout manager >+ * to allow border item children to lay themselves out. >+ * >+ * @author jbruck, cmahoney, mmostafa >+ */ >+public class BorderedNodeFigure >+ extends NodeFigure implements IExpandableFigure{ >+ >+ private BorderItemContainerFigure borderItemContainer; >+ >+ private IFigure mainFigure; >+ >+ private Rectangle extendedBounds = new Rectangle(); >+ >+ /** >+ * Creates a new BorderedNodeFigure figure. >+ * >+ * @param mainFigure >+ * the figure to use with this figure >+ */ >+ public BorderedNodeFigure(IFigure mainFigure) { >+ super(); >+ setOpaque(false); // set transparent by default >+ setBorder(null); >+ setLayoutManager(null); >+ this.mainFigure = mainFigure; >+ >+ add(getMainFigure()); >+ add(getBorderItemContainer()); >+ >+ setBounds(getMainFigure().getBounds().getCopy()); >+ getBorderItemContainer().setBounds(new Rectangle(0, 0, 1, 1)); >+ } >+ >+ /** >+ * Gets the border item container figure to which border item figures can be >+ * added with a {@link IBorderItemLocator} as the constraint and then later >+ * removed. >+ * >+ * @return The border item container figure >+ */ >+ public IFigure getBorderItemContainer() { >+ if (borderItemContainer == null) { >+ borderItemContainer = new BorderItemContainerFigure(); >+ borderItemContainer >+ .setLayoutManager(new DelegatingLayout()); >+ borderItemContainer.addLayoutListener(LayoutAnimator.getDefault()); >+ borderItemContainer.setVisible(true); >+ } >+ return borderItemContainer; >+ } >+ >+ /** >+ * Gets the main figure of this bordered figure. >+ * >+ * @return The "main" figure >+ */ >+ public IFigure getMainFigure() { >+ return mainFigure; >+ } >+ >+ public Rectangle getClientArea(Rectangle rect) { >+ if (getMainFigure() != null) { >+ return getMainFigure().getClientArea(rect); >+ } >+ return super.getClientArea(rect); >+ } >+ >+ /** >+ * gets the handle bounds of the main figure >+ * >+ * @return the hnalde bounds >+ */ >+ public Rectangle getHandleBounds() { >+ if (getMainFigure() instanceof NodeFigure) { >+ return ((NodeFigure) getMainFigure()).getHandleBounds().getCopy(); >+ } else { >+ return getMainFigure().getBounds().getCopy(); >+ } >+ } >+ >+ /** >+ * Give the main figure the entire bounds of the wrapper. >+ */ >+ protected void layout() { >+ if (!this.getBounds().equals(getMainFigure().getBounds())) { >+ getMainFigure().setBounds(this.getBounds().getCopy()); >+ getBorderItemContainer().invalidateTree(); >+ erase(); >+ } >+ } >+ >+ /** >+ * We need to override this for smooth painting of border items. >+ */ >+ public boolean containsPoint(int x, int y) { >+ if (borderItemContainer.containsPoint(x, y)) { >+ return true; >+ } >+ return super.containsPoint(x, y); >+ } >+ >+ protected void primTranslate(int dx, int dy) { >+ super.primTranslate(dx, dy); >+ erase(); >+ } >+ >+ public void erase() { >+ super.erase(); >+ if (borderItemContainer != null) >+ borderItemContainer.erase(); >+ } >+ >+ /** >+ * Refresh adornments >+ */ >+ public void repaint() { >+ super.repaint(); >+ if (borderItemContainer != null) >+ borderItemContainer.repaint(); >+ } >+ >+ public IFigure findFigureAt(int x, int y, TreeSearch search) { >+ if (search.prune(this)) >+ return null; >+ IFigure result = borderItemContainer.findFigureAt(x, y, search); >+ if (result != null) { >+ return result; >+ } >+ return getMainFigure().findFigureAt(x, y, search); >+ } >+ >+ public IFigure findMouseEventTargetAt(int x, int y) { >+ IFigure borderItemFigure = borderItemContainer.findMouseEventTargetAt( >+ x, y); >+ if (borderItemFigure != null) >+ return borderItemFigure; >+ return super.findMouseEventTargetAt(x, y); >+ } >+ >+ public boolean intersects(Rectangle rect) { >+ if (getExtendedBounds().intersects(rect)) >+ return true; >+ return super.intersects(rect); >+ } >+ >+ public Dimension getMinimumSize(int wHint, int hHint) { >+ return getMainFigure().getMinimumSize(wHint, hHint); >+ } >+ >+ public Dimension getPreferredSize(int wHint, int hHint) { >+ return getMainFigure().getPreferredSize(wHint, hHint); >+ } >+ >+ public IFigure getToolTip() { >+ return getMainFigure().getToolTip(); >+ } >+ >+ public void setToolTip(IFigure f) { >+ getMainFigure().setToolTip(f); >+ } >+ >+ public ConnectionAnchor getSourceConnectionAnchorAt(Point p) { >+ if (getMainFigure() instanceof NodeFigure) >+ return ((NodeFigure) getMainFigure()) >+ .getSourceConnectionAnchorAt(p); >+ return super.getSourceConnectionAnchorAt(p); >+ } >+ >+ public ConnectionAnchor getTargetConnectionAnchorAt(Point p) { >+ if (getMainFigure() instanceof NodeFigure) >+ return ((NodeFigure) getMainFigure()) >+ .getTargetConnectionAnchorAt(p); >+ return super.getTargetConnectionAnchorAt(p); >+ } >+ >+ public ConnectionAnchor getConnectionAnchor(String terminal) { >+ if (getMainFigure() instanceof NodeFigure) >+ return ((NodeFigure) getMainFigure()).getConnectionAnchor(terminal); >+ return super.getConnectionAnchor(terminal); >+ } >+ >+ public String getConnectionAnchorTerminal(ConnectionAnchor c) { >+ if (getMainFigure() instanceof NodeFigure) >+ return ((NodeFigure) getMainFigure()) >+ .getConnectionAnchorTerminal(c); >+ return super.getConnectionAnchorTerminal(c); >+ } >+ >+ /** >+ * This method provides a generic way to get a target figure's parent's main >+ * figure where if the target figure is a border item figure, then its >+ * parent is considered the figure on which it borders.It is not possible to >+ * get a target figure's parent using <code>IFigure#getParent()</code> if >+ * the target figure is a border item figure, since this would return the >+ * border item container figure. >+ * >+ * @param target >+ * the target figure, may or may not be acting as a border item >+ * figure >+ * @return the parent figure or if the target figure was on a border item >+ * container figure, then the main figure that it borders. >+ */ >+ public static IFigure getParentFigure(IFigure target) { >+ IFigure parent = target.getParent(); >+ if (parent instanceof BorderItemContainerFigure) { >+ return ((BorderedNodeFigure) parent.getParent()).getMainFigure(); >+ } >+ return parent; >+ } >+ >+ public Rectangle getExtendedBounds() { >+ if (extendedBounds == null) { >+ Rectangle rect = getBounds().getCopy(); >+ if (borderItemContainer!=null){ >+ rect = rect.union(borderItemContainer.getExtendedBounds()); >+ } >+ extendedBounds = rect; >+ } >+ return extendedBounds; >+ } >+ >+ @Override >+ public void invalidate() { >+ extendedBounds = null; >+ super.invalidate(); >+ } >+ >+ @Override >+ public void validate() { >+ extendedBounds = null; >+ super.validate(); >+ } >+ >+ @Override >+ protected void fireFigureMoved() { >+ super.fireFigureMoved(); >+ extendedBounds = null; >+ } >+} >Index: src/org/eclipse/gmf/runtime/diagram/ui/figures/IExpandableFigure.java >=================================================================== >RCS file: src/org/eclipse/gmf/runtime/diagram/ui/figures/IExpandableFigure.java >diff -N src/org/eclipse/gmf/runtime/diagram/ui/figures/IExpandableFigure.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/gmf/runtime/diagram/ui/figures/IExpandableFigure.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,26 @@ >+/****************************************************************************** >+ * Copyright (c) 2010 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ ****************************************************************************/ >+ >+package org.eclipse.gmf.runtime.diagram.ui.figures; >+ >+import org.eclipse.draw2d.geometry.Rectangle; >+ >+/** >+ * An Expandable Figure. >+ * >+ * @since 1.4 >+ * @author Anthony Hunter >+ */ >+public interface IExpandableFigure { >+ >+ Rectangle getExtendedBounds(); >+ >+} >Index: src/org/eclipse/gmf/runtime/diagram/ui/internal/figures/IExpandableFigure.java >=================================================================== >RCS file: /cvsroot/modeling/org.eclipse.gmf/plugins/org.eclipse.gmf.runtime.diagram.ui/src/org/eclipse/gmf/runtime/diagram/ui/internal/figures/IExpandableFigure.java,v >retrieving revision 1.2 >diff -u -r1.2 IExpandableFigure.java >--- src/org/eclipse/gmf/runtime/diagram/ui/internal/figures/IExpandableFigure.java 11 Oct 2006 20:46:28 -0000 1.2 >+++ src/org/eclipse/gmf/runtime/diagram/ui/internal/figures/IExpandableFigure.java 29 Apr 2010 00:59:20 -0000 >@@ -1,21 +1,27 @@ >-/****************************************************************************** >- * Copyright (c) 2006 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * >- * Contributors: >- * IBM Corporation - initial API and implementation >- ****************************************************************************/ >- >-package org.eclipse.gmf.runtime.diagram.ui.internal.figures; >- >-import org.eclipse.draw2d.geometry.Rectangle; >- >- >-public interface IExpandableFigure { >- >- Rectangle getExtendedBounds(); >- >-} >+/****************************************************************************** >+ * Copyright (c) 2006, 2010 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ ****************************************************************************/ >+ >+package org.eclipse.gmf.runtime.diagram.ui.internal.figures; >+ >+import org.eclipse.draw2d.geometry.Rectangle; >+ >+/** >+ * An Expandable Figure >+ * >+ * @author mmostafa >+ * @deprecated Use {org.eclipse.gmf.runtime.diagram.ui.figures.IExpandableFigure} >+ */ >+public interface IExpandableFigure extends >+ org.eclipse.gmf.runtime.diagram.ui.figures.IExpandableFigure { >+ >+ Rectangle getExtendedBounds(); >+ >+} >Index: src/org/eclipse/gmf/runtime/diagram/ui/internal/pagesetup/PageInfoHelper.java >=================================================================== >RCS file: /cvsroot/modeling/org.eclipse.gmf/plugins/org.eclipse.gmf.runtime.diagram.ui/src/org/eclipse/gmf/runtime/diagram/ui/internal/pagesetup/PageInfoHelper.java,v >retrieving revision 1.8 >diff -u -r1.8 PageInfoHelper.java >--- src/org/eclipse/gmf/runtime/diagram/ui/internal/pagesetup/PageInfoHelper.java 24 Feb 2010 18:29:00 -0000 1.8 >+++ src/org/eclipse/gmf/runtime/diagram/ui/internal/pagesetup/PageInfoHelper.java 29 Apr 2010 00:59:20 -0000 >@@ -28,7 +28,7 @@ > import org.eclipse.gmf.runtime.diagram.ui.internal.DiagramUIDebugOptions; > import org.eclipse.gmf.runtime.diagram.ui.internal.DiagramUIPlugin; > import org.eclipse.gmf.runtime.diagram.ui.internal.DiagramUIStatusCodes; >-import org.eclipse.gmf.runtime.diagram.ui.internal.figures.IExpandableFigure; >+import org.eclipse.gmf.runtime.diagram.ui.figures.IExpandableFigure; > import org.eclipse.gmf.runtime.diagram.ui.internal.properties.WorkspaceViewerProperties; > import org.eclipse.gmf.runtime.draw2d.ui.mapmode.IMapMode; > import org.eclipse.jface.preference.IPreferenceStore;
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 Raw
Actions:
View
Attachments on
bug 309858
:
166408
|
166409
|
166540