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 83456 Details for
Bug 119252
[RulersGrid] Useability: diagram arrange all should snap to grid if snap to grid is on
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Proposed Patch _ Updated
119252.txt (text/plain), 7.38 KB, created by
Carson Li
on 2007-11-21 13:10:29 EST
(
hide
)
Description:
Proposed Patch _ Updated
Filename:
MIME Type:
Creator:
Carson Li
Created:
2007-11-21 13:10:29 EST
Size:
7.38 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.gmf.runtime.diagram.ui >Index: src/org/eclipse/gmf/runtime/diagram/ui/editpolicies/ContainerEditPolicy.java >=================================================================== >RCS file: /cvsroot/modeling/org.eclipse.gmf/plugins/org.eclipse.gmf.runtime.diagram.ui/src/org/eclipse/gmf/runtime/diagram/ui/editpolicies/ContainerEditPolicy.java,v >retrieving revision 1.20 >diff -u -r1.20 ContainerEditPolicy.java >--- src/org/eclipse/gmf/runtime/diagram/ui/editpolicies/ContainerEditPolicy.java 2 Nov 2007 21:03:36 -0000 1.20 >+++ src/org/eclipse/gmf/runtime/diagram/ui/editpolicies/ContainerEditPolicy.java 21 Nov 2007 18:06:20 -0000 >@@ -30,6 +30,7 @@ > import org.eclipse.gef.EditPart; > import org.eclipse.gef.Request; > import org.eclipse.gef.commands.Command; >+import org.eclipse.gef.commands.CompoundCommand; > import org.eclipse.gef.requests.CreateRequest; > import org.eclipse.gef.requests.GroupRequest; > import org.eclipse.gmf.runtime.common.core.command.CommandResult; >@@ -52,11 +53,14 @@ > import org.eclipse.gmf.runtime.diagram.ui.internal.commands.DuplicateViewsCommand; > import org.eclipse.gmf.runtime.diagram.ui.internal.commands.PasteCommand; > import org.eclipse.gmf.runtime.diagram.ui.internal.commands.RefreshEditPartCommand; >+import org.eclipse.gmf.runtime.diagram.ui.internal.commands.SnapCommand; > import org.eclipse.gmf.runtime.diagram.ui.internal.editparts.ISurfaceEditPart; >+import org.eclipse.gmf.runtime.diagram.ui.internal.properties.WorkspaceViewerProperties; > import org.eclipse.gmf.runtime.diagram.ui.internal.requests.PasteViewRequest; > import org.eclipse.gmf.runtime.diagram.ui.internal.services.layout.IInternalLayoutRunnable; > import org.eclipse.gmf.runtime.diagram.ui.internal.services.layout.LayoutNode; > import org.eclipse.gmf.runtime.diagram.ui.l10n.DiagramUIMessages; >+import org.eclipse.gmf.runtime.diagram.ui.parts.DiagramGraphicalViewer; > import org.eclipse.gmf.runtime.diagram.ui.requests.ArrangeRequest; > import org.eclipse.gmf.runtime.diagram.ui.requests.DuplicateRequest; > import org.eclipse.gmf.runtime.diagram.ui.requests.EditCommandRequestWrapper; >@@ -72,6 +76,7 @@ > import org.eclipse.gmf.runtime.notation.Edge; > import org.eclipse.gmf.runtime.notation.Node; > import org.eclipse.gmf.runtime.notation.View; >+import org.eclipse.jface.preference.IPreferenceStore; > > /** > * the container edit policy >@@ -275,7 +280,8 @@ > > if ( (ActionIds.ACTION_ARRANGE_ALL.equals(request.getType())) || > (ActionIds.ACTION_TOOLBAR_ARRANGE_ALL.equals(request.getType()))) { >- editparts = ((IGraphicalEditPart)getHost()).getChildren(); >+ editparts = ((IGraphicalEditPart)getHost()).getChildren(); >+ request.setPartsToArrange(editparts); > } > if ( (ActionIds.ACTION_ARRANGE_SELECTION.equals(request.getType())) || > (ActionIds.ACTION_TOOLBAR_ARRANGE_SELECTION.equals(request.getType()))) { >@@ -290,9 +296,9 @@ > if (editparts.isEmpty()) > return null; > List nodes = new ArrayList(editparts.size()); >- ListIterator li = editparts.listIterator(); >+ ListIterator li = editparts.listIterator(); > while (li.hasNext()) { >- IGraphicalEditPart ep = (IGraphicalEditPart)li.next(); >+ IGraphicalEditPart ep = (IGraphicalEditPart)li.next(); > View view = ep.getNotationView(); > if (view != null && view instanceof Node) { > Rectangle bounds = ep.getFigure().getBounds(); >@@ -305,23 +311,43 @@ > hints.add(getHost()); > IAdaptable layoutHint = new ObjectAdapter(hints); > final Runnable layoutRun = layoutNodes(nodes, offsetFromBoundingBox, layoutHint); >+ >+ boolean isSnap = true; >+ //retrieves the preference store from the first edit part >+ IGraphicalEditPart firstEditPart = (IGraphicalEditPart)editparts.get(0); >+ if (firstEditPart.getViewer() != null){ >+ if (firstEditPart.getViewer() instanceof DiagramGraphicalViewer){ >+ IPreferenceStore preferenceStore = ((DiagramGraphicalViewer)firstEditPart.getViewer()) >+ .getWorkspaceViewerPreferenceStore(); >+ if (preferenceStore != null){ >+ isSnap = preferenceStore.getBoolean(WorkspaceViewerProperties.SNAPTOGRID); >+ } >+ } >+ } > >+ //the snapCommand still invokes proper calculations if snap to grid is turned off, this additional check >+ //is intended to make the code more appear more logical >+ >+ CompoundCommand cmd = new CompoundCommand(); > if (layoutRun instanceof IInternalLayoutRunnable) { >- return ((IInternalLayoutRunnable)layoutRun).getCommand(); >+ cmd.add(((IInternalLayoutRunnable) layoutRun).getCommand()); > } > else { > TransactionalEditingDomain editingDomain = ((IGraphicalEditPart) getHost()) >- .getEditingDomain(); >- >- return new ICommandProxy(new AbstractTransactionalCommand(editingDomain, "", null) {//$NON-NLS-1$ >+ .getEditingDomain(); >+ cmd.add(new ICommandProxy(new AbstractTransactionalCommand(editingDomain, "", null) {//$NON-NLS-1$ > protected CommandResult doExecuteWithResult( > IProgressMonitor progressMonitor, IAdaptable info) > throws ExecutionException { > layoutRun.run(); > return CommandResult.newOKCommandResult(); > } >- }); >+ })); >+ } >+ if (isSnap) { >+ cmd.add(getSnapCommand(request)); > } >+ return cmd; > } > > /** >@@ -433,6 +459,24 @@ > return new Point(offset, offset); > } > >+ private Command getSnapCommand(Request request){ >+ >+ List editparts = null; >+ if (request instanceof GroupRequest){ >+ editparts = ((GroupRequest)request).getEditParts(); >+ } >+ else if (request instanceof ArrangeRequest){ >+ editparts = ((ArrangeRequest)request).getPartsToArrange(); >+ } >+ >+ TransactionalEditingDomain editingDomain = ((IGraphicalEditPart) getHost()) >+ .getEditingDomain(); >+ if (editparts != null){ >+ return new ICommandProxy(new SnapCommand(editingDomain, editparts)); >+ } >+ return null; >+ } >+ > /** > * @see org.eclipse.gef.EditPolicy#getCommand(Request) > */ >@@ -440,8 +484,12 @@ > > if (request instanceof ArrangeRequest) { > return getArrangeCommand((ArrangeRequest)request); >+ } >+ >+ if (RequestConstants.REQ_SNAP_TO_GRID.equals(request.getType())){ >+ return getSnapCommand(request); > } >- >+ > if (RequestConstants.REQ_REFRESH.equals(request.getType())) { > IGraphicalEditPart containerEP = (IGraphicalEditPart) getHost(); > >@@ -503,12 +551,13 @@ > ActionIds.ACTION_ARRANGE_ALL.equals(request.getType()) > || ActionIds.ACTION_TOOLBAR_ARRANGE_ALL.equals(request.getType()) > || ActionIds.ACTION_ARRANGE_SELECTION.equals(request.getType()) >- || ActionIds.ACTION_TOOLBAR_ARRANGE_SELECTION.equals(request.getType()) >+ || ActionIds.ACTION_TOOLBAR_ARRANGE_SELECTION.equals(request.getType()) > || RequestConstants.REQ_ARRANGE_RADIAL.equals(request.getType()) > || RequestConstants.REQ_ARRANGE_DEFERRED.equals(request.getType()) > || RequestConstants.REQ_REFRESH.equals(request.getType()) > || RequestConstants.REQ_PASTE.equals(request.getType()) > || RequestConstants.REQ_DUPLICATE.equals(request.getType()) >+ || RequestConstants.REQ_SNAP_TO_GRID.equals(request.getType()) > || ZOrderRequest.REQ_BRING_TO_FRONT.equals(request.getType()) > || ZOrderRequest.REQ_BRING_FORWARD.equals(request.getType()) > || ZOrderRequest.REQ_SEND_TO_BACK.equals(request.getType())
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 119252
:
83283
| 83456