diff options
| author | Laurent Redor | 2016-07-07 16:02:13 +0000 |
|---|---|---|
| committer | Laurent Redor | 2016-07-08 11:19:00 +0000 |
| commit | cbdf959ee962aecbe4f56c6142a37705c2af0522 (patch) | |
| tree | 7ee64b150b4c3fe295f1418dcc47540d0ebc7c52 | |
| parent | 82b5631fe94e15694077427ccfd9c7c87ed93ae8 (diff) | |
| download | org.eclipse.sirius-cbdf959ee962aecbe4f56c6142a37705c2af0522.tar.gz org.eclipse.sirius-cbdf959ee962aecbe4f56c6142a37705c2af0522.tar.xz org.eclipse.sirius-cbdf959ee962aecbe4f56c6142a37705c2af0522.zip | |
[496466] Add Copy/Paste Format feature
* Copy the style and the GMF view during
AbstractSiriusLayoutDataManager.storeLayoutData(IGraphicalEditPart), and
indirectly with LayoutDataHelperImpl.createNodeLayoutData(Node,
IGraphicalEditPart, NodeLayoutData),
LayoutDataHelperImpl.createEdgeLayoutData(Edge, ConnectionEditPart)
* Paste the Sirius style and GMF style attributes during
AbstractSiriusLayoutDataManager.applyFormat(IGraphicalEditPart, boolean,
boolean)
* Add the new actions (copy format, paste format, paste style) and the
associated elements (icons, messages, Ids, ...).
This commit does not cover all the spec [1]. Remaining works:
* Add a drop down menu in the tabbar instead of the current push button
that only calls Paste Format.
* Improvement concerning edge copy/paste style
* Add org.eclipse.sirius.diagram.ui.formatDataManager extension point in
addition to existing one that will be deprecated and removed in Sirius
5.0 (also add corresponding org.eclipse.sirius.diagram.formatdata
plug-in as org.eclipse.sirius.diagram.layoutdata plug-in)
* Update the documentation
* Improve the copy of the GMF style (currently all children of the GMF
node is copied even if they are not necessary)
[1]
http://git.eclipse.org/c/sirius/org.eclipse.sirius.git/plain/plugins/org.eclipse.sirius.doc/specs/proposal/496466_extendCopyPasteLayout/496466.html?id=818037cab466c47e60983061d80246a224d862c0
Bug: 496466
Change-Id: I48f308b0a01cc8e728e7cc1eae204ff109fa7c8f
Signed-off-by: Laurent Redor <laurent.redor@obeo.fr>
32 files changed, 983 insertions, 227 deletions
diff --git a/plugins/org.eclipse.sirius.diagram.sequence.ui/src/org/eclipse/sirius/diagram/sequence/ui/business/api/diagramtype/SequenceDiagramTypeProvider.java b/plugins/org.eclipse.sirius.diagram.sequence.ui/src/org/eclipse/sirius/diagram/sequence/ui/business/api/diagramtype/SequenceDiagramTypeProvider.java index f80250f288..291e93b986 100644 --- a/plugins/org.eclipse.sirius.diagram.sequence.ui/src/org/eclipse/sirius/diagram/sequence/ui/business/api/diagramtype/SequenceDiagramTypeProvider.java +++ b/plugins/org.eclipse.sirius.diagram.sequence.ui/src/org/eclipse/sirius/diagram/sequence/ui/business/api/diagramtype/SequenceDiagramTypeProvider.java @@ -227,6 +227,11 @@ public class SequenceDiagramTypeProvider implements IDiagramDescriptionProvider @Override public boolean allowsCopyPasteLayout(DSemanticDecorator element) { + return allowsCopyPasteFormat(element); + } + + @Override + public boolean allowsCopyPasteFormat(DSemanticDecorator element) { return !isSequenceSemanticDecorator.apply(element); } diff --git a/plugins/org.eclipse.sirius.diagram.ui/icons/copyLayout.gif b/plugins/org.eclipse.sirius.diagram.ui/icons/copyFormat.gif Binary files differindex c350685e97..c350685e97 100644 --- a/plugins/org.eclipse.sirius.diagram.ui/icons/copyLayout.gif +++ b/plugins/org.eclipse.sirius.diagram.ui/icons/copyFormat.gif diff --git a/plugins/org.eclipse.sirius.diagram.ui/icons/copyLayoutDisabled.gif b/plugins/org.eclipse.sirius.diagram.ui/icons/copyFormatDisabled.gif Binary files differindex 3ab2a7c705..3ab2a7c705 100644 --- a/plugins/org.eclipse.sirius.diagram.ui/icons/copyLayoutDisabled.gif +++ b/plugins/org.eclipse.sirius.diagram.ui/icons/copyFormatDisabled.gif diff --git a/plugins/org.eclipse.sirius.diagram.ui/icons/license.txt b/plugins/org.eclipse.sirius.diagram.ui/icons/license.txt index 755a4c586c..2078619a10 100644 --- a/plugins/org.eclipse.sirius.diagram.ui/icons/license.txt +++ b/plugins/org.eclipse.sirius.diagram.ui/icons/license.txt @@ -162,9 +162,13 @@ icons/wizban/NewSiriusWizard.gif - org.eclipse.uml2.diagram.deploy - org.eclipse icons/DDiagram.gif - org.topcased.modeler.uml - org.topcased.modeler.uml/icons/diagram/ClassDiagram.gif icons/HasLink.gif - org.topcased.modeler.uml - org.topcased.modeler.uml/icons/diagram/ClassDiagram.gif icons/Layer.gif - org.eclipse.ui - org.eclipse.ui.cheatsheets/icons/elcl16/collapseall.gif -icons/copyLayout.gif - org.eclipse.ui - org.eclipse.ui/icons/etool16/copy_edit.gif -icons/copyLayoutDisabled.gif - org.eclipse.ui - org.eclipse.ui/icons/etool16/copy_edit.gif +icons/copyFormat.gif - org.eclipse.ui - org.eclipse.ui/icons/etool16/copy_edit.gif +icons/copyFormatDisabled.gif - org.eclipse.ui - org.eclipse.ui/icons/etool16/copy_edit.gif icons/label_obj.gif - org.eclipse.sirius.diagram.ui - org.eclipse.sirius.diagram.ui/icons/obj16/label_obj.gif icons/layoutingMode_activate.png - icons/full/obj16/CompositeLayout.gif - org.eclipse.sirius.ui/icons/full/obj16/CompositeLayout.gif +icons/pasteFormat.gif - org.eclipse.ui - org.eclipse.ui/icons/etool16/paste_edit.gif +icons/pasteFormatDisabled.gif - org.eclipse.ui - org.eclipse.ui/icons/etool16/paste_edit.gif icons/pasteLayout.gif - org.eclipse.ui - org.eclipse.ui/icons/etool16/paste_edit.gif icons/pasteLayoutDisabled.gif - org.eclipse.ui - org.eclipse.ui/icons/etool16/paste_edit.gif +icons/pasteStyle.gif - org.eclipse.ui - org.eclipse.ui/icons/etool16/paste_edit.gif +icons/pasteStyleDisabled.gif - org.eclipse.ui - org.eclipse.ui/icons/etool16/paste_edit.gif diff --git a/plugins/org.eclipse.sirius.diagram.ui/icons/pasteFormat.gif b/plugins/org.eclipse.sirius.diagram.ui/icons/pasteFormat.gif Binary files differnew file mode 100644 index 0000000000..d6d4ac1a70 --- /dev/null +++ b/plugins/org.eclipse.sirius.diagram.ui/icons/pasteFormat.gif diff --git a/plugins/org.eclipse.sirius.diagram.ui/icons/pasteFormatDisabled.gif b/plugins/org.eclipse.sirius.diagram.ui/icons/pasteFormatDisabled.gif Binary files differnew file mode 100644 index 0000000000..055c5bff05 --- /dev/null +++ b/plugins/org.eclipse.sirius.diagram.ui/icons/pasteFormatDisabled.gif diff --git a/plugins/org.eclipse.sirius.diagram.ui/icons/pasteStyle.gif b/plugins/org.eclipse.sirius.diagram.ui/icons/pasteStyle.gif Binary files differnew file mode 100644 index 0000000000..d6d4ac1a70 --- /dev/null +++ b/plugins/org.eclipse.sirius.diagram.ui/icons/pasteStyle.gif diff --git a/plugins/org.eclipse.sirius.diagram.ui/icons/pasteStyleDisabled.gif b/plugins/org.eclipse.sirius.diagram.ui/icons/pasteStyleDisabled.gif Binary files differnew file mode 100644 index 0000000000..055c5bff05 --- /dev/null +++ b/plugins/org.eclipse.sirius.diagram.ui/icons/pasteStyleDisabled.gif diff --git a/plugins/org.eclipse.sirius.diagram.ui/plugin.properties b/plugins/org.eclipse.sirius.diagram.ui/plugin.properties index 9cfed95dd7..8642ce5e13 100644 --- a/plugins/org.eclipse.sirius.diagram.ui/plugin.properties +++ b/plugins/org.eclipse.sirius.diagram.ui/plugin.properties @@ -799,12 +799,12 @@ CommandName_OpenDiagram=Open Diagram CompoundEditPolicy_nullEditPolicyMsg = the edit policy is null ConcernComboContributionItem_tooltip = Current concern ConnectionsFactory_edgeNotCreatedMsg = GMF Edge not created between source element : {0}, and target element : {1} -CopyLayoutAction_clrearPreviousLayoutDateCommandLabel = Clear previous layout data -CopyLayoutAction_commandLabel = Copy layout -CopyLayoutAction_storeLayoutCommandLabel = Store layouts -CopyLayoutAction_text = Copy layout -CopyLayoutAction_toolTipText = Copy the layout of the selected diagram elements -CopyLayoutDataCommand_label = Copy layout data +CopyFormatAction_clearPreviousFormatDateCommandLabel = Clear previous format data +CopyFormatAction_commandLabel = Copy format +CopyFormatAction_storeFormatCommandLabel = Store formats +CopyFormatAction_text = Copy format +CopyFormatAction_toolTipText = Copy the format of the selected diagram elements +CopyFormatDataCommand_label = Copy format data CopyToSiriusClipboardCommand_label = Copy to clipboard CreateAndStoreGMFDiagramCommand_label = Refresh diagram on opening CreateRepresentationFromRepresentationCreationDescription_cmdLabel = Create and open representation @@ -991,11 +991,21 @@ PaletteImageProvider_noIconFor = No icon is available for the tool {0}. A defaul PaletteManagerImpl_alreadyExistingEntry = An existing palette entry with name {0} already exists but it is another kind of entry. PaletteManagerImpl_severalCandidatesInPalette = Several {0}s with identical id ''{1}'' have been found in the palette. Please fix your VSM by whether set a different ID for these Palette entries or ensuring that they cannot be available in the same time. PasteFromSiriusClipboardCommand_label = Generic Paste from clipboard +PasteFormatAction_commandLabel = Paste Format +PasteFormatAction_restoreFormatCommandLabel = Restore formats +PasteFormatAction_text = Paste format +PasteFormatAction_toolTipText = Paste the current recorded format (layout and style) to the selected diagram +PasteFormatDataCommand_label = Paste format data PasteLayoutAction_commandLabel = Paste Layout PasteLayoutAction_restoreLayoutCommandLabel = Restore layouts PasteLayoutAction_text = Paste layout PasteLayoutAction_toolTipText = Paste the current recorded layout to the selected diagram PasteLayoutDataCommand_label = Paste layout data +PasteStyleAction_commandLabel = Paste Style +PasteStyleAction_restoreStyleCommandLabel = Restore styles +PasteStyleAction_text = Paste style +PasteStyleAction_toolTipText = Paste the current recorded style to the selected diagram +PasteStyleDataCommand_label = Paste style data PinElementsEclipseAction_text = Pin selected elements PinnedElementsHandler_notMovableMsg = Pinned elements can not move PinnedElementsHandler_remainOverlapsMsg = solvable but unsolved overlaps remain diff --git a/plugins/org.eclipse.sirius.diagram.ui/plugin.xml b/plugins/org.eclipse.sirius.diagram.ui/plugin.xml index 36e05e527d..3b935f9474 100644 --- a/plugins/org.eclipse.sirius.diagram.ui/plugin.xml +++ b/plugins/org.eclipse.sirius.diagram.ui/plugin.xml @@ -132,9 +132,11 @@ <contributionItemProvider class="org.eclipse.sirius.diagram.ui.internal.providers.SiriusContributionItemProvider"> <Priority name="Low" /> <partContribution id="org.eclipse.sirius.diagram.ui.part.SiriusDiagramEditorID"> - <partMenuGroup menubarPath="/edit/" id="copyLayoutGroup" separator="true" /> - <partAction menubarPath="/edit/copyLayoutGroup" id="copyLayoutAction" /> - <partAction menubarPath="/edit/copyLayoutGroup" id="pasteLayoutAction" /> + <partMenuGroup menubarPath="/edit/" id="copyFormatGroup" separator="true" /> + <partAction menubarPath="/edit/copyFormatGroup" id="copyFormatAction" /> + <partAction menubarPath="/edit/copyFormatGroup" id="pasteFormatAction" /> + <partAction menubarPath="/edit/copyFormatGroup" id="pasteLayoutAction" /> + <partAction menubarPath="/edit/copyFormatGroup" id="pasteStyleAction" /> <partAction menubarPath="/diagramMenu/arrangeMenu/arrangeGroup" id="arrangeBorderNodesAction"/> <!--partAction menubarPath="/diagramMenu/routerMenu/routerGroup" id="treeRoutingStyleAction"/--> <partAction toolbarPath="/arrangeMenu/arrangeGroup" id="arrangeBorderNodesActionToolBar"/> @@ -163,9 +165,11 @@ <popupContribution class="org.eclipse.sirius.diagram.ui.tools.internal.menu.DiagramEditorContextMenuProvider"> <popupStructuredContributionCriteria objectClass="org.eclipse.sirius.diagram.ui.edit.api.part.ISiriusEditPart" /> - <popupMenuGroup path="/editMenu/" id="copyLayoutGroup" separator="true"/> - <popupAction path="/editMenu/copyLayoutGroup" id="copyLayoutAction" /> - <popupAction path="/editMenu/copyLayoutGroup" id="pasteLayoutAction" /> + <popupMenuGroup path="/editMenu/" id="copyFormatGroup" separator="true"/> + <popupAction path="/editMenu/copyFormatGroup" id="copyFormatAction" /> + <popupAction path="/editMenu/copyFormatGroup" id="pasteFormatAction" /> + <popupAction path="/editMenu/copyFormatGroup" id="pasteLayoutAction" /> + <popupAction path="/editMenu/copyFormatGroup" id="pasteStyleAction" /> <popupAction path="/formatMenu/routerMenu/routerGroup" id="treeRoutingStyleAction"/> <popupMenuGroup path="/formatMenu/" id="pinGroup" /> diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/internal/providers/SiriusContributionItemProvider.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/internal/providers/SiriusContributionItemProvider.java index a41645954c..c000e60f0c 100644 --- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/internal/providers/SiriusContributionItemProvider.java +++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/internal/providers/SiriusContributionItemProvider.java @@ -24,8 +24,10 @@ import org.eclipse.sirius.diagram.ui.tools.internal.actions.SizeBothAction; import org.eclipse.sirius.diagram.ui.tools.internal.actions.TabbarRouterAction; import org.eclipse.sirius.diagram.ui.tools.internal.actions.distribute.DistributeAction; import org.eclipse.sirius.diagram.ui.tools.internal.actions.layout.ArrangeBorderNodesAction; -import org.eclipse.sirius.diagram.ui.tools.internal.actions.layout.CopyLayoutAction; +import org.eclipse.sirius.diagram.ui.tools.internal.actions.layout.CopyFormatAction; +import org.eclipse.sirius.diagram.ui.tools.internal.actions.layout.PasteFormatAction; import org.eclipse.sirius.diagram.ui.tools.internal.actions.layout.PasteLayoutAction; +import org.eclipse.sirius.diagram.ui.tools.internal.actions.layout.PasteStyleAction; import org.eclipse.sirius.diagram.ui.tools.internal.actions.pinning.PinElementsEclipseAction; import org.eclipse.sirius.diagram.ui.tools.internal.actions.pinning.UnpinElementsEclipseAction; import org.eclipse.sirius.diagram.ui.tools.internal.editor.tabbar.actions.DistributeMenuManager; @@ -50,8 +52,12 @@ public class SiriusContributionItemProvider extends AbstractContributionItemProv // } else if (actionId.equals(PrintPreviewAction.ID)) { result = new SiriusDiagramPrintPreviewAction(new SiriusEnhancedPrintActionHelper()); - } else if (ActionIds.COPY_LAYOUT.equals(actionId)) { - result = new CopyLayoutAction(workbenchPage); + } else if (ActionIds.COPY_FORMAT.equals(actionId)) { + result = new CopyFormatAction(workbenchPage); + } else if (ActionIds.PASTE_FORMAT.equals(actionId)) { + result = new PasteFormatAction(workbenchPage); + } else if (ActionIds.PASTE_STYLE.equals(actionId)) { + result = new PasteStyleAction(workbenchPage); } else if (ActionIds.PASTE_LAYOUT.equals(actionId)) { result = new PasteLayoutAction(workbenchPage); } else if (ActionIds.PIN_ELEMENTS.equals(actionId)) { diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/part/SiriusDiagramActionBarContributor.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/part/SiriusDiagramActionBarContributor.java index 233807f970..8284e8f3c0 100644 --- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/part/SiriusDiagramActionBarContributor.java +++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/part/SiriusDiagramActionBarContributor.java @@ -33,8 +33,10 @@ import org.eclipse.sirius.diagram.ui.tools.internal.actions.SelectHiddenElements import org.eclipse.sirius.diagram.ui.tools.internal.actions.TabbarRouterAction; import org.eclipse.sirius.diagram.ui.tools.internal.actions.delete.DeleteFromDiagramAction; import org.eclipse.sirius.diagram.ui.tools.internal.actions.delete.DeleteFromModelAction; -import org.eclipse.sirius.diagram.ui.tools.internal.actions.layout.CopyLayoutAction; +import org.eclipse.sirius.diagram.ui.tools.internal.actions.layout.CopyFormatAction; +import org.eclipse.sirius.diagram.ui.tools.internal.actions.layout.PasteFormatAction; import org.eclipse.sirius.diagram.ui.tools.internal.actions.layout.PasteLayoutAction; +import org.eclipse.sirius.diagram.ui.tools.internal.actions.layout.PasteStyleAction; import org.eclipse.sirius.diagram.ui.tools.internal.actions.refresh.RefreshDiagramAction; import org.eclipse.sirius.diagram.ui.tools.internal.actions.style.SetStyleToWorkspaceImageAction; import org.eclipse.sirius.diagram.ui.tools.internal.actions.visibility.HideDDiagramElementAction; @@ -139,15 +141,21 @@ public class SiriusDiagramActionBarContributor extends DiagramActionBarContribut DiagramUIPlugin.Implementation.getBundledImageDescriptor(DiagramImagesPath.DELETE_FROM_MODEL_ICON)); addAction(deleteFromModelAction); - final IAction copyLayoutAction = new CopyLayoutAction(getPage()); + final IAction copyLayoutAction = new CopyFormatAction(getPage()); addAction(copyLayoutAction); final IAction routerAction = TabbarRouterAction.createTreeRouterAction(getPage()); addAction(routerAction); + final IAction pasteFormatAction = new PasteFormatAction(getPage()); + addAction(pasteFormatAction); + final IAction pasteLayoutAction = new PasteLayoutAction(getPage()); addAction(pasteLayoutAction); + final IAction pasteStyleAction = new PasteStyleAction(getPage()); + addAction(pasteStyleAction); + final IAction selectHiddenElementsAction = new SelectHiddenElementsAction(getPage()); addAction(selectHiddenElementsAction); } @@ -171,8 +179,8 @@ public class SiriusDiagramActionBarContributor extends DiagramActionBarContribut toolBarManager.add(getActionRegistry().getAction(HIDE_LABEL)); toolBarManager.add(getActionRegistry().getAction(REVEAL_ELEMENTS)); toolBarManager.add(getActionRegistry().getAction(ActionIds.ACTION_DELETE_FROM_MODEL)); - toolBarManager.add(getActionRegistry().getAction(org.eclipse.sirius.diagram.ui.tools.api.ui.actions.ActionIds.COPY_LAYOUT)); - toolBarManager.add(getActionRegistry().getAction(org.eclipse.sirius.diagram.ui.tools.api.ui.actions.ActionIds.PASTE_LAYOUT)); + toolBarManager.add(getActionRegistry().getAction(org.eclipse.sirius.diagram.ui.tools.api.ui.actions.ActionIds.COPY_FORMAT)); + toolBarManager.add(getActionRegistry().getAction(org.eclipse.sirius.diagram.ui.tools.api.ui.actions.ActionIds.PASTE_FORMAT)); toolBarManager.add(getActionRegistry().getAction(org.eclipse.sirius.diagram.ui.tools.api.ui.actions.ActionIds.SELECT_HIDDEN_ELEMENTS)); toolBarManager.add(getActionRegistry().getAction(org.eclipse.sirius.diagram.ui.tools.api.ui.actions.ActionIds.ROUTING_STYLE)); } diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/api/editor/tabbar/AbstractTabbarContributor.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/api/editor/tabbar/AbstractTabbarContributor.java index 0fe3d591c6..c2c9226174 100644 --- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/api/editor/tabbar/AbstractTabbarContributor.java +++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/api/editor/tabbar/AbstractTabbarContributor.java @@ -400,29 +400,63 @@ public abstract class AbstractTabbarContributor implements ITabbarContributor { } /** - * Creates the copy layout contribution item. This tool can be used to - * duplicate the layout of some diagram elements from this diagram into + * Creates the copy format contribution item. This tool can be used to + * duplicate the format of some diagram elements from this diagram into * another. * * @param part * the current IDiagramWorkbenchPart. * @return the {@link IContributionItem} or null if the workbench part is * being initialized. + * @deprecated since 4.1.0 Use + * {@link #createCopyFormatContribution(IDiagramWorkbenchPart)} + * instead. */ + @Deprecated protected IContributionItem createCopyLayoutContribution(IDiagramWorkbenchPart part) { - return contributorFactory.createCopyLayoutContribution(part); + return createCopyFormatContribution(part); } /** - * Creates the Paste Layout contribution item. + * Creates the copy format contribution item. This tool can be used to + * duplicate the format of some diagram elements from this diagram into + * another. + * + * @param part + * the current IDiagramWorkbenchPart. + * @return the {@link IContributionItem} or null if the workbench part is + * being initialized. + */ + protected IContributionItem createCopyFormatContribution(IDiagramWorkbenchPart part) { + return contributorFactory.createCopyFormatContribution(part); + } + + /** + * Creates the Paste Format contribution item. * * @param part * the current IDiagramWorkbenchPart. * @return the {@link IContributionItem} or null if the workbench part is * being initialized. + * @deprecated since 4.1.0 Use + * {@link #createPasteFormatContribution(IDiagramWorkbenchPart)} + * instead. */ + @Deprecated protected IContributionItem createPasteLayoutContribution(IDiagramWorkbenchPart part) { - return contributorFactory.createPasteLayoutContribution(part); + return createPasteFormatContribution(part); + } + + /** + * Creates the Paste Format contribution item. + * + * @param part + * the current IDiagramWorkbenchPart. + * @return the {@link IContributionItem} or null if the workbench part is + * being initialized. + */ + protected IContributionItem createPasteFormatContribution(IDiagramWorkbenchPart part) { + return contributorFactory.createPasteFormatContribution(part); } /** diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/api/layout/AbstractSiriusLayoutDataManager.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/api/layout/AbstractSiriusLayoutDataManager.java index 5cb1389b74..79f2ef02c9 100644 --- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/api/layout/AbstractSiriusLayoutDataManager.java +++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/api/layout/AbstractSiriusLayoutDataManager.java @@ -27,6 +27,7 @@ import org.eclipse.emf.ecore.EObject; import org.eclipse.gef.ConnectionEditPart; import org.eclipse.gef.EditPartViewer; import org.eclipse.gef.GraphicalEditPart; +import org.eclipse.gmf.runtime.diagram.core.util.ViewRefactorHelper; import org.eclipse.gmf.runtime.diagram.core.util.ViewUtil; import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart; import org.eclipse.gmf.runtime.notation.Bendpoints; @@ -48,15 +49,19 @@ import org.eclipse.gmf.runtime.notation.View; import org.eclipse.gmf.runtime.notation.datatype.RelativeBendpoint; import org.eclipse.sirius.common.tools.api.util.StringUtil; import org.eclipse.sirius.diagram.AbstractDNode; +import org.eclipse.sirius.diagram.ContainerStyle; import org.eclipse.sirius.diagram.DDiagram; import org.eclipse.sirius.diagram.DDiagramElement; +import org.eclipse.sirius.diagram.DDiagramElementContainer; import org.eclipse.sirius.diagram.DEdge; import org.eclipse.sirius.diagram.DNode; import org.eclipse.sirius.diagram.DNodeContainer; import org.eclipse.sirius.diagram.DNodeList; import org.eclipse.sirius.diagram.DNodeListElement; import org.eclipse.sirius.diagram.DiagramPlugin; +import org.eclipse.sirius.diagram.EdgeStyle; import org.eclipse.sirius.diagram.EdgeTarget; +import org.eclipse.sirius.diagram.NodeStyle; import org.eclipse.sirius.diagram.business.api.query.DDiagramElementQuery; import org.eclipse.sirius.diagram.layoutdata.AbstractLayoutData; import org.eclipse.sirius.diagram.layoutdata.EdgeLayoutData; @@ -121,22 +126,60 @@ public abstract class AbstractSiriusLayoutDataManager implements SiriusLayoutDat * org.eclipse.gef.EditPartViewer) */ @Override + public void applyFormat(final IGraphicalEditPart rootEditPart) { + applyFormat(rootEditPart, true, true); + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.sirius.diagram.ui.tools.api.layout.SiriusLayoutDataManager#applyLayout(org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart, + * org.eclipse.gef.EditPartViewer) + */ + @Override public void applyLayout(final IGraphicalEditPart rootEditPart) { + applyFormat(rootEditPart, true, false); + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.sirius.diagram.ui.tools.api.layout.SiriusLayoutDataManager#applyStyle(org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart, + * org.eclipse.gef.EditPartViewer) + */ + @Override + public void applyStyle(final IGraphicalEditPart rootEditPart) { + applyFormat(rootEditPart, false, true); + } + + /** + * Apply the format to the <code>rootEditPart</code>. + * + * @param rootEditPart + * The root edit from which we would try to apply the current + * stored format + * @param applyLayout + * true if the layout must be applied, false otherwise + * @param applyStyle + * true if the layout must be applied, false otherwise + */ + protected void applyFormat(final IGraphicalEditPart rootEditPart, boolean applyLayout, boolean applyStyle) { final EObject semanticElement = rootEditPart.resolveSemanticElement(); final View toStoreView = (View) rootEditPart.getModel(); if (toStoreView instanceof Edge) { - // TODOLRE : Manage the edge as root ? + // TODO LRE : Manage the edge as root ? } else if (toStoreView instanceof Diagram && semanticElement instanceof DDiagram) { - applyLayout((DDiagram) semanticElement, (Diagram) toStoreView, rootEditPart.getRoot().getViewer()); + applyFormat((DDiagram) semanticElement, (Diagram) toStoreView, rootEditPart.getRoot().getViewer(), applyLayout, applyStyle); centerEdgesEnds(toStoreView); } else if (toStoreView instanceof Node) { if (semanticElement instanceof DDiagramElement && semanticElement instanceof DSemanticDecorator) { - applyLayout((DSemanticDecorator) semanticElement, (Node) toStoreView, rootEditPart.getRoot().getViewer(), null); + applyFormat((DSemanticDecorator) semanticElement, (Node) toStoreView, rootEditPart.getRoot().getViewer(), null, applyLayout, applyStyle); } centerEdgesEnds(toStoreView); } } + @SuppressWarnings("unchecked") private void centerEdgesEnds(View view) { Set<Edge> edges = new HashSet<Edge>(); if (view instanceof Diagram) { @@ -157,13 +200,13 @@ public abstract class AbstractSiriusLayoutDataManager implements SiriusLayoutDat * @param editPartViewer * The viewer responsible for the current editparts lifecycle. */ - private void applyLayout(final DDiagram diagram, final Diagram toStoreView, final EditPartViewer editPartViewer) { + private void applyFormat(final DDiagram diagram, final Diagram toStoreView, final EditPartViewer editPartViewer, boolean applyLayout, boolean applyStyle) { // We don't apply layout on diagram but only on its node children (the // edge is applied during source node). for (final AbstractDNode node : Iterables.filter(diagram.getOwnedDiagramElements(), AbstractDNode.class)) { final Node gmfNode = SiriusGMFHelper.getGmfNode(node); if (gmfNode != null) { - applyLayout(node, gmfNode, editPartViewer, null); + applyFormat(node, gmfNode, editPartViewer, null, applyLayout, applyStyle); } } } @@ -172,11 +215,11 @@ public abstract class AbstractSiriusLayoutDataManager implements SiriusLayoutDat * @param sourceNode * @param editPartViewer */ - private void applyLayoutToOutgoingEdge(final EdgeTarget sourceNode, final EditPartViewer editPartViewer) { + private void applyFormatToOutgoingEdge(final EdgeTarget sourceNode, final EditPartViewer editPartViewer, boolean applyLayout, boolean applyStyle) { for (final DEdge edge : sourceNode.getOutgoingEdges()) { final Edge gmfEdge = SiriusGMFHelper.getGmfEdge(edge); if (gmfEdge != null) { - applyLayout(edge, gmfEdge, editPartViewer); + applyFormat(edge, gmfEdge, editPartViewer, applyLayout, applyStyle); } } } @@ -186,63 +229,77 @@ public abstract class AbstractSiriusLayoutDataManager implements SiriusLayoutDat * @param gmfEdge * @param editPartViewer */ - private void applyLayout(final DEdge edge, final Edge gmfEdge, final EditPartViewer editPartViewer) { + private void applyFormat(final DEdge edge, final Edge gmfEdge, final EditPartViewer editPartViewer, boolean applyLayout, boolean applyStyle) { final EdgeLayoutData layoutData = (EdgeLayoutData) getLayoutData(createKey(edge)); if (layoutData != null) { + if (applyLayout) { + final Bendpoints bendpoints = convertPointsToGMFBendpoint(layoutData); + gmfEdge.setBendpoints(bendpoints); - final Bendpoints bendpoints = convertPointsToGMFBendpoint(layoutData); - gmfEdge.setBendpoints(bendpoints); - - if (layoutData.getSourceTerminal() != null) { - if (gmfEdge.getSourceAnchor() == null) { - gmfEdge.setSourceAnchor(NotationFactory.eINSTANCE.createIdentityAnchor()); - } - if (gmfEdge.getSourceAnchor() instanceof IdentityAnchor) { - ((IdentityAnchor) gmfEdge.getSourceAnchor()).setId(layoutData.getSourceTerminal()); + if (layoutData.getSourceTerminal() != null) { + if (gmfEdge.getSourceAnchor() == null) { + gmfEdge.setSourceAnchor(NotationFactory.eINSTANCE.createIdentityAnchor()); + } + if (gmfEdge.getSourceAnchor() instanceof IdentityAnchor) { + ((IdentityAnchor) gmfEdge.getSourceAnchor()).setId(layoutData.getSourceTerminal()); + } + } else if (gmfEdge.getSourceAnchor() instanceof IdentityAnchor) { + gmfEdge.setSourceAnchor(null); } - } else if (gmfEdge.getSourceAnchor() instanceof IdentityAnchor) { - gmfEdge.setSourceAnchor(null); - } - if (layoutData.getTargetTerminal() != null) { - if (gmfEdge.getTargetAnchor() == null) { - gmfEdge.setTargetAnchor(NotationFactory.eINSTANCE.createIdentityAnchor()); + if (layoutData.getTargetTerminal() != null) { + if (gmfEdge.getTargetAnchor() == null) { + gmfEdge.setTargetAnchor(NotationFactory.eINSTANCE.createIdentityAnchor()); + } + if (gmfEdge.getTargetAnchor() instanceof IdentityAnchor) { + ((IdentityAnchor) gmfEdge.getTargetAnchor()).setId(layoutData.getTargetTerminal()); + } + } else if (gmfEdge.getTargetAnchor() instanceof IdentityAnchor) { + gmfEdge.setTargetAnchor(null); } - if (gmfEdge.getTargetAnchor() instanceof IdentityAnchor) { - ((IdentityAnchor) gmfEdge.getTargetAnchor()).setId(layoutData.getTargetTerminal()); + final RoutingStyle routingStyle = (RoutingStyle) gmfEdge.getStyle(NotationPackage.eINSTANCE.getRoutingStyle()); + if (routingStyle != null) { + routingStyle.setRouting(Routing.get(layoutData.getRouting())); + routingStyle.setJumpLinkStatus(JumpLinkStatus.get(layoutData.getJumpLinkStatus())); + routingStyle.setJumpLinkType(JumpLinkType.get(layoutData.getJumpLinkType())); + routingStyle.setJumpLinksReverse(layoutData.isReverseJumpLink()); + routingStyle.setSmoothness(Smoothness.get(layoutData.getSmoothness())); } - } else if (gmfEdge.getTargetAnchor() instanceof IdentityAnchor) { - gmfEdge.setTargetAnchor(null); } - final RoutingStyle routingStyle = (RoutingStyle) gmfEdge.getStyle(NotationPackage.eINSTANCE.getRoutingStyle()); - if (routingStyle != null) { - routingStyle.setRouting(Routing.get(layoutData.getRouting())); - routingStyle.setJumpLinkStatus(JumpLinkStatus.get(layoutData.getJumpLinkStatus())); - routingStyle.setJumpLinkType(JumpLinkType.get(layoutData.getJumpLinkType())); - routingStyle.setJumpLinksReverse(layoutData.isReverseJumpLink()); - routingStyle.setSmoothness(Smoothness.get(layoutData.getSmoothness())); + if (applyStyle) { + // Apply Sirius style properties + applySiriusStyle(edge, layoutData); + // Apply GMF style properties + applyGMFStyle(gmfEdge, layoutData); } - applyLabelLayout(gmfEdge, layoutData); + applyLabelFormat(gmfEdge, layoutData, applyLayout, applyStyle); + } } - private void applyLabelLayout(final View gmfView, final AbstractLayoutData parentLayoutData) { + private void applyLabelFormat(final View gmfView, final AbstractLayoutData parentLayoutData, boolean applyLayout, boolean applyStyle) { if (parentLayoutData != null) { final Node labelNode = SiriusGMFHelper.getLabelNode(gmfView); if (parentLayoutData.getLabel() != null && labelNode != null) { - if (!parentLayoutData.getLabel().eIsSet(LayoutdataPackage.eINSTANCE.getNodeLayoutData_Width()) - && !parentLayoutData.getLabel().eIsSet(LayoutdataPackage.eINSTANCE.getNodeLayoutData_Height())) { - Location location = NotationFactory.eINSTANCE.createLocation(); - location.setX(parentLayoutData.getLabel().getLocation().getX()); - location.setY(parentLayoutData.getLabel().getLocation().getY()); - labelNode.setLayoutConstraint(location); - } else { - Bounds bounds = NotationFactory.eINSTANCE.createBounds(); - bounds.setX(parentLayoutData.getLabel().getLocation().getX()); - bounds.setY(parentLayoutData.getLabel().getLocation().getY()); - bounds.setWidth(parentLayoutData.getLabel().getWidth()); - bounds.setHeight(parentLayoutData.getLabel().getHeight()); - labelNode.setLayoutConstraint(bounds); + if (applyLayout) { + if (!parentLayoutData.getLabel().eIsSet(LayoutdataPackage.eINSTANCE.getNodeLayoutData_Width()) + && !parentLayoutData.getLabel().eIsSet(LayoutdataPackage.eINSTANCE.getNodeLayoutData_Height())) { + Location location = NotationFactory.eINSTANCE.createLocation(); + location.setX(parentLayoutData.getLabel().getLocation().getX()); + location.setY(parentLayoutData.getLabel().getLocation().getY()); + labelNode.setLayoutConstraint(location); + } else { + Bounds bounds = NotationFactory.eINSTANCE.createBounds(); + bounds.setX(parentLayoutData.getLabel().getLocation().getX()); + bounds.setY(parentLayoutData.getLabel().getLocation().getY()); + bounds.setWidth(parentLayoutData.getLabel().getWidth()); + bounds.setHeight(parentLayoutData.getLabel().getHeight()); + labelNode.setLayoutConstraint(bounds); + } + } + if (applyStyle) { + // Apply GMF style properties + applyGMFStyle(labelNode, parentLayoutData.getLabel()); } } } @@ -290,7 +347,8 @@ public abstract class AbstractSiriusLayoutDataManager implements SiriusLayoutDat * The viewer responsible for the current editparts lifecycle. * @parentLayoutData the layout of the parent of <code>toRestoreView<code> */ - private void applyLayout(final DSemanticDecorator semanticDecorator, final Node toRestoreView, final EditPartViewer editPartViewer, final NodeLayoutData parentLayoutData) { + private void applyFormat(final DSemanticDecorator semanticDecorator, final Node toRestoreView, final EditPartViewer editPartViewer, final NodeLayoutData parentLayoutData, boolean applyLayout, + boolean applyStyle) { LayoutDataKey key = createKey(semanticDecorator); NodeLayoutData layoutData = (NodeLayoutData) getLayoutData(key); @@ -313,7 +371,8 @@ public abstract class AbstractSiriusLayoutDataManager implements SiriusLayoutDat } } - if (layoutData != null) { + if (layoutData != null && applyLayout) { + final Bounds bounds = NotationFactory.eINSTANCE.createBounds(); final IGraphicalEditPart graphicalEditPart = (IGraphicalEditPart) editPartViewer.getEditPartRegistry().get(toRestoreView); Point locationToApply; @@ -363,18 +422,81 @@ public abstract class AbstractSiriusLayoutDataManager implements SiriusLayoutDat } toRestoreView.setLayoutConstraint(bounds); } + if (layoutData != null && applyStyle) { + // Apply Sirius style properties + applySiriusStyle(semanticDecorator, layoutData); + // Apply GMF style properties + applyGMFStyle(toRestoreView, layoutData); + } + if (semanticDecorator instanceof DNode) { - applyLayoutToNodeChildren((DNode) semanticDecorator, editPartViewer, layoutData); + applyFormatToNodeChildren((DNode) semanticDecorator, editPartViewer, layoutData, applyLayout, applyStyle); } else if (semanticDecorator instanceof DNodeContainer) { - applyLayoutToNodeContainerChildren((DNodeContainer) semanticDecorator, editPartViewer, layoutData); + applyFormatToNodeContainerChildren((DNodeContainer) semanticDecorator, editPartViewer, layoutData, applyLayout, applyStyle); } else if (semanticDecorator instanceof DNodeList) { - applyLayoutToNodeListChildren((DNodeList) semanticDecorator, editPartViewer, layoutData); + applyFormatToNodeListChildren((DNodeList) semanticDecorator, editPartViewer, layoutData, applyLayout, applyStyle); } else { logWarnMessage(semanticDecorator); } // Deal with the outgoing edges if (semanticDecorator instanceof EdgeTarget) { - applyLayoutToOutgoingEdge((EdgeTarget) semanticDecorator, editPartViewer); + applyFormatToOutgoingEdge((EdgeTarget) semanticDecorator, editPartViewer, applyLayout, applyStyle); + } + } + + /** + * Apply the Sirius style contained in <code>layoutData</code> on the + * <code>semanticDecorator</code>. + * + * @param semanticDecorator + * The {@link DSemanticDecorator} on which to apply the style. + * @param layoutData + * The layout data containing the sirius style + */ + protected void applySiriusStyle(DSemanticDecorator semanticDecorator, AbstractLayoutData layoutData) { + if ((semanticDecorator instanceof DNode || semanticDecorator instanceof DNodeListElement) && layoutData.getSiriusStyle() instanceof NodeStyle) { + NodeStyle style = (NodeStyle) layoutData.getSiriusStyle(); + if (semanticDecorator instanceof DNode) { + DNode node = (DNode) semanticDecorator; + node.setOwnedStyle(style); + } else { + DNodeListElement nodeListElement = (DNodeListElement) semanticDecorator; + nodeListElement.setOwnedStyle(style); + } + } else if (semanticDecorator instanceof DDiagramElementContainer && layoutData.getSiriusStyle() instanceof ContainerStyle) { + final DDiagramElementContainer container = (DDiagramElementContainer) semanticDecorator; + final ContainerStyle style = (ContainerStyle) layoutData.getSiriusStyle(); + container.setOwnedStyle(style); + } else if (semanticDecorator instanceof DEdge && layoutData.getSiriusStyle() instanceof EdgeStyle) { + final DEdge edge = (DEdge) semanticDecorator; + final EdgeStyle style = (EdgeStyle) layoutData.getSiriusStyle(); + edge.setOwnedStyle(style); + } + } + + /** + * Copies the appearance of the old view to the new view. Typically this + * means copying the visibility and the styles of the root and it's + * children. + * + * @param newView + * The new view to copy style features to + * @param layoutData + * The layout data containing the old view to copy style features + * from + */ + @SuppressWarnings("unchecked") + protected void applyGMFStyle(View newView, AbstractLayoutData layoutData) { + if (newView != null && layoutData.getGmfView() != null) { + @SuppressWarnings("rawtypes") + List excludedStyles = Lists.newArrayList(); + if (newView instanceof Edge) { + // The style of RoutingStyle class is considered as layout + // properties. So they have already been pasted during paste + // layout. + excludedStyles.add(NotationPackage.eINSTANCE.getRoutingStyle()); + } + new ViewRefactorHelper().copyViewAppearance(layoutData.getGmfView(), newView, excludedStyles); } } @@ -402,12 +524,12 @@ public abstract class AbstractSiriusLayoutDataManager implements SiriusLayoutDat * @param editPartViewer * The viewer responsible for the current editparts lifecycle. */ - private void applyLayoutToNodeChildren(final DNode parentNode, final EditPartViewer editPartViewer, final NodeLayoutData layoutData) { + private void applyFormatToNodeChildren(final DNode parentNode, final EditPartViewer editPartViewer, final NodeLayoutData layoutData, boolean applyLayout, boolean applyStyle) { // Restore Bordered nodes - applyLayoutForBorderedNodes(parentNode.getOwnedBorderedNodes(), editPartViewer, layoutData); + applyFormatForBorderedNodes(parentNode.getOwnedBorderedNodes(), editPartViewer, layoutData, applyLayout, applyStyle); // Restore label final Node gmfNode = SiriusGMFHelper.getGmfNode(parentNode); - applyLabelLayout(gmfNode, layoutData); + applyLabelFormat(gmfNode, layoutData, applyLayout, applyStyle); } /** @@ -418,22 +540,22 @@ public abstract class AbstractSiriusLayoutDataManager implements SiriusLayoutDat * @param editPartViewer * The viewer responsible for the current editparts lifecycle. */ - private void applyLayoutToNodeContainerChildren(final DNodeContainer container, final EditPartViewer editPartViewer, final NodeLayoutData layoutData) { + private void applyFormatToNodeContainerChildren(final DNodeContainer container, final EditPartViewer editPartViewer, final NodeLayoutData layoutData, boolean applyLayout, boolean applyStyle) { // Restore children for (final DDiagramElement child : container.getOwnedDiagramElements()) { if (child instanceof AbstractDNode) { // Search the GMF node corresponding to the child final Node gmfNode = SiriusGMFHelper.getGmfNode(child); if (gmfNode != null) { - applyLayout(child, gmfNode, editPartViewer, layoutData); + applyFormat(child, gmfNode, editPartViewer, layoutData, applyLayout, applyStyle); } } } // Restore Bordered nodes - applyLayoutForBorderedNodes(container.getOwnedBorderedNodes(), editPartViewer, layoutData); + applyFormatForBorderedNodes(container.getOwnedBorderedNodes(), editPartViewer, layoutData, applyLayout, applyStyle); // Restore label final Node gmfNode = SiriusGMFHelper.getGmfNode(container); - applyLabelLayout(gmfNode, layoutData); + applyLabelFormat(gmfNode, layoutData, applyLayout, applyStyle); } /** @@ -446,7 +568,7 @@ public abstract class AbstractSiriusLayoutDataManager implements SiriusLayoutDat * @param parentLayoutData * The layoutData of the parent of the borderedNodes */ - private void applyLayoutForBorderedNodes(EList<DNode> borderedNodes, EditPartViewer editPartViewer, NodeLayoutData parentLayoutData) { + private void applyFormatForBorderedNodes(EList<DNode> borderedNodes, EditPartViewer editPartViewer, NodeLayoutData parentLayoutData, boolean applyLayout, boolean applyStyle) { HashMap<Node, NodeLayoutData> nodesWithLayoutDataToApply = Maps.newHashMap(); HashMap<Node, DSemanticDecorator> nodesWithCoresspondingDSemanticDecorator = Maps.newHashMap(); // Search each bordered nodes that have layoutData to apply @@ -485,7 +607,7 @@ public abstract class AbstractSiriusLayoutDataManager implements SiriusLayoutDat Set<Node> toIgnore = nodesWithLayoutDataToApply.keySet(); for (Entry<Node, NodeLayoutData> entry : nodesWithLayoutDataToApply.entrySet()) { Node node = entry.getKey(); - applyLayoutForBorderedNode(nodesWithCoresspondingDSemanticDecorator.get(node), node, editPartViewer, entry.getValue(), toIgnore); + applyFormatForBorderedNode(nodesWithCoresspondingDSemanticDecorator.get(node), node, editPartViewer, entry.getValue(), toIgnore, applyLayout, applyStyle); } } @@ -503,88 +625,97 @@ public abstract class AbstractSiriusLayoutDataManager implements SiriusLayoutDat * @param portsNodesToIgnore * The list of bordered nodes to ignore in the conflict detection */ - private void applyLayoutForBorderedNode(final DSemanticDecorator semanticDecorator, final Node toRestoreView, final EditPartViewer editPartViewer, final NodeLayoutData layoutData, - final Set<Node> portsNodesToIgnore) { - final Bounds bounds = NotationFactory.eINSTANCE.createBounds(); - Point locationToApply; - boolean isCollapsed = false; - if (!(toRestoreView.eContainer() instanceof Node)) { - return; - } - Node parentNode = (Node) toRestoreView.eContainer(); - - Object parentGraphicalEditPart = editPartViewer.getEditPartRegistry().get(parentNode); - NodeQuery nodeQuery = new NodeQuery(toRestoreView); - - if (nodeQuery.isBorderedNode() && parentGraphicalEditPart instanceof IGraphicalEditPart) { - // Specific treatment for border node - // Compute absolute location - locationToApply = LayoutDataHelper.INSTANCE.getAbsoluteLocation(layoutData); - // Compute the best location according to other existing - // bordered nodes. - - CanonicalDBorderItemLocator locator = new CanonicalDBorderItemLocator(parentNode, PositionConstants.NSEW); - if (semanticDecorator instanceof DDiagramElement) { - if (new DDiagramElementQuery((DDiagramElement) semanticDecorator).isIndirectlyCollapsed()) { - isCollapsed = true; - locator.setBorderItemOffset(IBorderItemOffsets.COLLAPSE_FILTER_OFFSET); + private void applyFormatForBorderedNode(final DSemanticDecorator semanticDecorator, final Node toRestoreView, final EditPartViewer editPartViewer, final NodeLayoutData layoutData, + final Set<Node> portsNodesToIgnore, boolean applyLayout, boolean applyStyle) { + if (applyLayout) { + final Bounds bounds = NotationFactory.eINSTANCE.createBounds(); + Point locationToApply; + boolean isCollapsed = false; + if (!(toRestoreView.eContainer() instanceof Node)) { + return; + } + Node parentNode = (Node) toRestoreView.eContainer(); + + Object parentGraphicalEditPart = editPartViewer.getEditPartRegistry().get(parentNode); + NodeQuery nodeQuery = new NodeQuery(toRestoreView); + + if (nodeQuery.isBorderedNode() && parentGraphicalEditPart instanceof IGraphicalEditPart) { + // Specific treatment for border node + // Compute absolute location + locationToApply = LayoutDataHelper.INSTANCE.getAbsoluteLocation(layoutData); + // Compute the best location according to other existing + // bordered nodes. + + CanonicalDBorderItemLocator locator = new CanonicalDBorderItemLocator(parentNode, PositionConstants.NSEW); + if (semanticDecorator instanceof DDiagramElement) { + if (new DDiagramElementQuery((DDiagramElement) semanticDecorator).isIndirectlyCollapsed()) { + isCollapsed = true; + locator.setBorderItemOffset(IBorderItemOffsets.COLLAPSE_FILTER_OFFSET); + } else { + locator.setBorderItemOffset(IBorderItemOffsets.DEFAULT_OFFSET); + } } else { locator.setBorderItemOffset(IBorderItemOffsets.DEFAULT_OFFSET); } - } else { - locator.setBorderItemOffset(IBorderItemOffsets.DEFAULT_OFFSET); - } - // CanonicalDBorderItemLocator works with absolute GMF parent - // location so we need to translate BorderedNode absolute location - // from Draw2D to GMF. + // CanonicalDBorderItemLocator works with absolute GMF parent + // location so we need to translate BorderedNode absolute + // location + // from Draw2D to GMF. - Point delta = getGMFDraw2DDelta(parentNode, (IGraphicalEditPart) parentGraphicalEditPart); - final Rectangle rect = new Rectangle(locationToApply.getX() - delta.getX(), locationToApply.getY() - delta.getY(), layoutData.getWidth(), layoutData.getHeight()); + Point delta = getGMFDraw2DDelta(parentNode, (IGraphicalEditPart) parentGraphicalEditPart); + final Rectangle rect = new Rectangle(locationToApply.getX() - delta.getX(), locationToApply.getY() - delta.getY(), layoutData.getWidth(), layoutData.getHeight()); - final org.eclipse.draw2d.geometry.Point realLocation = locator.getValidLocation(rect, toRestoreView, portsNodesToIgnore); + final org.eclipse.draw2d.geometry.Point realLocation = locator.getValidLocation(rect, toRestoreView, portsNodesToIgnore); - // Compute the new relative position to the parent - final org.eclipse.draw2d.geometry.Point parentAbsoluteLocation = GMFHelper.getAbsoluteBounds(parentNode).getTopLeft(); - locationToApply.setX(realLocation.x); - locationToApply.setY(realLocation.y); - locationToApply = LayoutDataHelper.INSTANCE.getTranslated(locationToApply, parentAbsoluteLocation.negate()); + // Compute the new relative position to the parent + final org.eclipse.draw2d.geometry.Point parentAbsoluteLocation = GMFHelper.getAbsoluteBounds(parentNode).getTopLeft(); + locationToApply.setX(realLocation.x); + locationToApply.setY(realLocation.y); + locationToApply = LayoutDataHelper.INSTANCE.getTranslated(locationToApply, parentAbsoluteLocation.negate()); - } else { - Object graphicalEditPart = editPartViewer.getEditPartRegistry().get(toRestoreView); - if (graphicalEditPart instanceof IGraphicalEditPart) { - locationToApply = LayoutDataHelper.INSTANCE.getRelativeLocation(layoutData, (IGraphicalEditPart) graphicalEditPart); - // Apply the location to the figure to, to correctly compute - // the relative location of the children - ((GraphicalEditPart) graphicalEditPart).getFigure().setLocation(new org.eclipse.draw2d.geometry.Point(locationToApply.getX(), locationToApply.getY())); } else { - locationToApply = LayoutdataFactory.eINSTANCE.createPoint(); + Object graphicalEditPart = editPartViewer.getEditPartRegistry().get(toRestoreView); + if (graphicalEditPart instanceof IGraphicalEditPart) { + locationToApply = LayoutDataHelper.INSTANCE.getRelativeLocation(layoutData, (IGraphicalEditPart) graphicalEditPart); + // Apply the location to the figure to, to correctly compute + // the relative location of the children + ((GraphicalEditPart) graphicalEditPart).getFigure().setLocation(new org.eclipse.draw2d.geometry.Point(locationToApply.getX(), locationToApply.getY())); + } else { + locationToApply = LayoutdataFactory.eINSTANCE.createPoint(); + } + } + bounds.setX(locationToApply.getX()); + bounds.setY(locationToApply.getY()); + if (isCollapsed) { + Dimension dim = new NodeQuery(toRestoreView).getCollapsedSize(); + bounds.setHeight(dim.height); + bounds.setWidth(dim.width); + } else { + bounds.setHeight(layoutData.getHeight()); + bounds.setWidth(layoutData.getWidth()); } + + toRestoreView.setLayoutConstraint(bounds); } - bounds.setX(locationToApply.getX()); - bounds.setY(locationToApply.getY()); - if (isCollapsed) { - Dimension dim = new NodeQuery(toRestoreView).getCollapsedSize(); - bounds.setHeight(dim.height); - bounds.setWidth(dim.width); - } else { - bounds.setHeight(layoutData.getHeight()); - bounds.setWidth(layoutData.getWidth()); + if (applyStyle) { + // Apply Sirius style properties + applySiriusStyle(semanticDecorator, layoutData); + // Apply GMF style properties + applyGMFStyle(toRestoreView, layoutData); } - toRestoreView.setLayoutConstraint(bounds); - if (semanticDecorator instanceof DNode) { - applyLayoutToNodeChildren((DNode) semanticDecorator, editPartViewer, layoutData); + applyFormatToNodeChildren((DNode) semanticDecorator, editPartViewer, layoutData, applyLayout, applyStyle); } else if (semanticDecorator instanceof DNodeContainer) { - applyLayoutToNodeContainerChildren((DNodeContainer) semanticDecorator, editPartViewer, layoutData); + applyFormatToNodeContainerChildren((DNodeContainer) semanticDecorator, editPartViewer, layoutData, applyLayout, applyStyle); } else if (semanticDecorator instanceof DNodeList) { - applyLayoutToNodeListChildren((DNodeList) semanticDecorator, editPartViewer, layoutData); + applyFormatToNodeListChildren((DNodeList) semanticDecorator, editPartViewer, layoutData, applyLayout, applyStyle); } else { logWarnMessage(semanticDecorator); } if (semanticDecorator instanceof EdgeTarget) { - applyLayoutToOutgoingEdge((EdgeTarget) semanticDecorator, editPartViewer); + applyFormatToOutgoingEdge((EdgeTarget) semanticDecorator, editPartViewer, applyLayout, applyStyle); } } @@ -610,13 +741,13 @@ public abstract class AbstractSiriusLayoutDataManager implements SiriusLayoutDat * @param editPartViewer * The viewer responsible for the current editparts lifecycle. */ - private void applyLayoutToNodeListChildren(final DNodeList nodeList, final EditPartViewer editPartViewer, final NodeLayoutData layoutData) { + private void applyFormatToNodeListChildren(final DNodeList nodeList, final EditPartViewer editPartViewer, final NodeLayoutData layoutData, boolean applyLayout, boolean applyStyle) { // Restore Bordered nodes - applyLayoutForBorderedNodes(nodeList.getOwnedBorderedNodes(), editPartViewer, layoutData); + applyFormatForBorderedNodes(nodeList.getOwnedBorderedNodes(), editPartViewer, layoutData, applyLayout, applyStyle); // Restore label final Node gmfNode = SiriusGMFHelper.getGmfNode(nodeList); - applyLabelLayout(gmfNode, layoutData); + applyLabelFormat(gmfNode, layoutData, applyLayout, applyStyle); } /** diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/api/layout/SiriusLayoutDataManager.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/api/layout/SiriusLayoutDataManager.java index da82ac967d..9a9c7186ae 100644 --- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/api/layout/SiriusLayoutDataManager.java +++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/api/layout/SiriusLayoutDataManager.java @@ -62,6 +62,16 @@ public interface SiriusLayoutDataManager { void storeLayoutData(IGraphicalEditPart rootEditPart); /** + * Apply the current format data (layout data and style data) to the + * rootEditPart. + * + * @param rootEditPart + * the root edit from which we would try to apply the current + * stored format + */ + void applyFormat(IGraphicalEditPart rootEditPart); + + /** * Apply the current layout data to the rootEditPart. * * @param rootEditPart @@ -71,6 +81,15 @@ public interface SiriusLayoutDataManager { void applyLayout(IGraphicalEditPart rootEditPart); /** + * Apply the current style data to the rootEditPart. + * + * @param rootEditPart + * the root edit from which we would try to apply the current + * stored style + */ + void applyStyle(IGraphicalEditPart rootEditPart); + + /** * Check if the manager contains data. * * @return true if the manager contains data, false otherwise. diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/api/ui/actions/ActionIds.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/api/ui/actions/ActionIds.java index 7eb06090e8..5752a9aba6 100644 --- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/api/ui/actions/ActionIds.java +++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/api/ui/actions/ActionIds.java @@ -26,12 +26,18 @@ import org.eclipse.sirius.diagram.ui.tools.api.requests.RequestConstants; public interface ActionIds { // CHECKSTYLE:ON - /** Action contribution id for the copy layout. */ - String COPY_LAYOUT = "copyLayoutAction"; //$NON-NLS-1$ + /** Action contribution id for the copy format (layout and style). */ + String COPY_FORMAT = "copyFormatAction"; //$NON-NLS-1$ - /** Action contribution id for the paste layout. */ + /** Action contribution id for the paste format (layout and style). */ + String PASTE_FORMAT = "pasteFormatAction"; //$NON-NLS-1$ + + /** Action contribution id for the paste style. */ String PASTE_LAYOUT = "pasteLayoutAction"; //$NON-NLS-1$ + /** Action contribution id for the copy style. */ + String PASTE_STYLE = "pasteStyleAction"; //$NON-NLS-1$ + /** Action id for pin elements action. */ String PIN_ELEMENTS = "pinElementsAction"; //$NON-NLS-1$ diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/actions/layout/AbstractCopyPasteLayoutAction.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/actions/layout/AbstractCopyPasteFormatAction.java index 61dcefe561..291291479b 100644 --- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/actions/layout/AbstractCopyPasteLayoutAction.java +++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/actions/layout/AbstractCopyPasteFormatAction.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2012 THALES GLOBAL SERVICES. + * Copyright (c) 2012, 2016 THALES GLOBAL SERVICES. * 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 @@ -37,7 +37,7 @@ import com.google.common.collect.Lists; * * @author mporhel */ -public abstract class AbstractCopyPasteLayoutAction extends AbstractDiagramAction { +public abstract class AbstractCopyPasteFormatAction extends AbstractDiagramAction { private IWorkbenchPart representationPart; /** @@ -48,7 +48,7 @@ public abstract class AbstractCopyPasteLayoutAction extends AbstractDiagramActio * @param actionWorkbenchPart * the part concerned by this action. Could be null. */ - public AbstractCopyPasteLayoutAction(final IWorkbenchPage workbenchPage, IWorkbenchPart actionWorkbenchPart) { + public AbstractCopyPasteFormatAction(final IWorkbenchPage workbenchPage, IWorkbenchPart actionWorkbenchPart) { super(workbenchPage); this.representationPart = actionWorkbenchPart; @@ -107,8 +107,8 @@ public abstract class AbstractCopyPasteLayoutAction extends AbstractDiagramActio } if (parentDiagram != null) { - Predicate<DSemanticDecorator> allowsPasteLayout = allowsCopyPasteLayout(parentDiagram); - if (Iterables.all(dSelection, allowsPasteLayout)) { + Predicate<DSemanticDecorator> allowsPasteFormat = allowsCopyPasteFormat(parentDiagram); + if (Iterables.all(dSelection, allowsPasteFormat)) { enable = super.calculateEnabled(); } } @@ -139,14 +139,14 @@ public abstract class AbstractCopyPasteLayoutAction extends AbstractDiagramActio } /** - * Indicates if the given ddiagram is allowing copy/paste layout. + * Indicates if the given ddiagram is allowing copy/paste format. * * @param diagram * the diagram to inspect - * @return true if the given ddiagram is allowing copy/paste layout actions, + * @return true if the given ddiagram is allowing copy/paste format actions, * false otherwise */ - public static Predicate<DSemanticDecorator> allowsCopyPasteLayout(DDiagram diagram) { + public static Predicate<DSemanticDecorator> allowsCopyPasteFormat(DDiagram diagram) { // default return value is true (for basic DDiagram that are not handled // by any DiagramDescriptionProvider). Predicate<DSemanticDecorator> result = Predicates.alwaysTrue(); @@ -161,12 +161,12 @@ public abstract class AbstractCopyPasteLayoutAction extends AbstractDiagramActio // DiagramDescriptionProvider handling this type of diagram for (final IDiagramTypeDescriptor diagramTypeDescriptor : DiagramTypeDescriptorRegistry.getInstance().getAllDiagramTypeDescriptors()) { if (diagramTypeDescriptor.getDiagramDescriptionProvider().handles(diagram.getDescription().eClass().getEPackage())) { - // This DiagramDescriptionProvider may forbid copy/paste layout. + // This DiagramDescriptionProvider may forbid copy/paste format. final IDiagramDescriptionProvider provider = diagramTypeDescriptor.getDiagramDescriptionProvider(); result = new Predicate<DSemanticDecorator>() { @Override public boolean apply(DSemanticDecorator input) { - return provider.allowsCopyPasteLayout(input); + return provider.allowsCopyPasteFormat(input); } }; break; diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/actions/layout/CopyLayoutAction.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/actions/layout/CopyFormatAction.java index 78d4fc9e34..3e4c345e99 100644 --- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/actions/layout/CopyLayoutAction.java +++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/actions/layout/CopyFormatAction.java @@ -1,5 +1,5 @@ /****************************************************************************** - * Copyright (c) 2002, 2015 IBM Corporation and others. + * Copyright (c) 2002, 2016 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 @@ -44,11 +44,11 @@ import org.eclipse.ui.IWorkbenchPart; import com.google.common.collect.Lists; /** - * Copy the layout of the selected diagram or of the selected diagram elements. + * Copy the format of the selected diagram or of the selected diagram elements. * * @author <a href="mailto:laurent.redor@obeo.fr">Laurent Redor</a> */ -public class CopyLayoutAction extends AbstractCopyPasteLayoutAction { +public class CopyFormatAction extends AbstractCopyPasteFormatAction { /** * Default constructor. @@ -58,17 +58,17 @@ public class CopyLayoutAction extends AbstractCopyPasteLayoutAction { * @param actionWorkbenchPart * the part concerned by this action. Could be null. */ - public CopyLayoutAction(final IWorkbenchPage workbenchPage, IWorkbenchPart actionWorkbenchPart) { + public CopyFormatAction(final IWorkbenchPage workbenchPage, IWorkbenchPart actionWorkbenchPart) { super(workbenchPage, actionWorkbenchPart); - setText(Messages.CopyLayoutAction_text); + setText(Messages.CopyFormatAction_text); setAccelerator(SWT.CTRL | SWT.SHIFT | SWT.ALT | 'C'); - setId(ActionIds.COPY_LAYOUT); - setToolTipText(Messages.CopyLayoutAction_toolTipText); + setId(ActionIds.COPY_FORMAT); + setToolTipText(Messages.CopyFormatAction_toolTipText); - setImageDescriptor(DiagramUIPlugin.Implementation.getBundledImageDescriptor(DiagramImagesPath.COPY_LAYOUT_ICON)); - setDisabledImageDescriptor(DiagramUIPlugin.Implementation.getBundledImageDescriptor(DiagramImagesPath.COPY_LAYOUT_DISABLED_ICON)); - setHoverImageDescriptor(DiagramUIPlugin.Implementation.getBundledImageDescriptor(DiagramImagesPath.COPY_LAYOUT_ICON)); + setImageDescriptor(DiagramUIPlugin.Implementation.getBundledImageDescriptor(DiagramImagesPath.COPY_FORMAT_ICON)); + setDisabledImageDescriptor(DiagramUIPlugin.Implementation.getBundledImageDescriptor(DiagramImagesPath.COPY_FORMAT_DISABLED_ICON)); + setHoverImageDescriptor(DiagramUIPlugin.Implementation.getBundledImageDescriptor(DiagramImagesPath.COPY_FORMAT_ICON)); } /** @@ -77,7 +77,7 @@ public class CopyLayoutAction extends AbstractCopyPasteLayoutAction { * @param workbenchPage * the active workbench page */ - public CopyLayoutAction(final IWorkbenchPage workbenchPage) { + public CopyFormatAction(final IWorkbenchPage workbenchPage) { this(workbenchPage, null); } @@ -88,7 +88,7 @@ public class CopyLayoutAction extends AbstractCopyPasteLayoutAction { */ @Override protected String getCommandLabel() { - return Messages.CopyLayoutAction_commandLabel; + return Messages.CopyFormatAction_commandLabel; } /** @@ -98,9 +98,9 @@ public class CopyLayoutAction extends AbstractCopyPasteLayoutAction { */ @Override protected Command getCommand() { - // Create a compound command to hold the store layout commands - final CompoundCommand doStoreLayoutsCmd = new CompoundCommand(Messages.CopyLayoutAction_storeLayoutCommandLabel); - doStoreLayoutsCmd.add(new Command(Messages.CopyLayoutAction_clrearPreviousLayoutDateCommandLabel) { + // Create a compound command to hold the store format commands + final CompoundCommand doStoreFormatsCmd = new CompoundCommand(Messages.CopyFormatAction_storeFormatCommandLabel); + doStoreFormatsCmd.add(new Command(Messages.CopyFormatAction_clearPreviousFormatDateCommandLabel) { /** * {@inheritDoc} * @@ -142,13 +142,13 @@ public class CopyLayoutAction extends AbstractCopyPasteLayoutAction { // Clean the selection to keep only one data if both node and // its label are selected. List<IGraphicalEditPart> selectedEditParts = cleanSelectedObjects(getSelectedObjects()); - // For each selected edit part, store its layout. + // For each selected edit part, store its format. for (final IGraphicalEditPart toStore : selectedEditParts) { - doStoreLayoutsCmd.add(new ICommandProxy(new CopyLayoutDataCommand(toStore.getEditingDomain(), diagram.get(), toStore))); + doStoreFormatsCmd.add(new ICommandProxy(new CopyFormatDataCommand(toStore.getEditingDomain(), diagram.get(), toStore))); } } } - return doStoreLayoutsCmd.unwrap(); + return doStoreFormatsCmd.unwrap(); } /** @@ -173,9 +173,9 @@ public class CopyLayoutAction extends AbstractCopyPasteLayoutAction { } /** - * A command allowing to copy layout data. + * A command allowing to copy format data. */ - private final class CopyLayoutDataCommand extends AbstractTransactionalCommand { + private final class CopyFormatDataCommand extends AbstractTransactionalCommand { private IGraphicalEditPart toStore; @@ -187,12 +187,12 @@ public class CopyLayoutAction extends AbstractCopyPasteLayoutAction { * @param domain * the editing domain on which this command will be executed * @param dDiagram - * the {@link DDiagram} on which layout will be pasted + * the {@link DDiagram} on which format will be pasted * @param editPartToStore * the edit part to store */ - public CopyLayoutDataCommand(TransactionalEditingDomain domain, DDiagram dDiagram, IGraphicalEditPart editPartToStore) { - super(domain, Messages.CopyLayoutDataCommand_label, null); + public CopyFormatDataCommand(TransactionalEditingDomain domain, DDiagram dDiagram, IGraphicalEditPart editPartToStore) { + super(domain, Messages.CopyFormatDataCommand_label, null); this.dDiagram = dDiagram; this.toStore = editPartToStore; } diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/actions/layout/PasteFormatAction.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/actions/layout/PasteFormatAction.java new file mode 100644 index 0000000000..54fd74bb66 --- /dev/null +++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/actions/layout/PasteFormatAction.java @@ -0,0 +1,174 @@ +/******************************************************************************* + * Copyright (c) 2016 THALES GLOBAL SERVICES. + * 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: + * Obeo - initial API and implementation + *******************************************************************************/ +package org.eclipse.sirius.diagram.ui.tools.internal.actions.layout; + +import java.util.Iterator; +import java.util.List; + +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.core.runtime.IAdaptable; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.emf.transaction.TransactionalEditingDomain; +import org.eclipse.gef.commands.Command; +import org.eclipse.gef.commands.CompoundCommand; +import org.eclipse.gef.commands.UnexecutableCommand; +import org.eclipse.gmf.runtime.common.core.command.CommandResult; +import org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy; +import org.eclipse.gmf.runtime.diagram.ui.editparts.DiagramEditPart; +import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart; +import org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand; +import org.eclipse.sirius.diagram.DDiagram; +import org.eclipse.sirius.diagram.ui.edit.api.part.IDDiagramEditPart; +import org.eclipse.sirius.diagram.ui.provider.DiagramUIPlugin; +import org.eclipse.sirius.diagram.ui.provider.Messages; +import org.eclipse.sirius.diagram.ui.tools.api.image.DiagramImagesPath; +import org.eclipse.sirius.diagram.ui.tools.api.layout.SiriusLayoutDataManager; +import org.eclipse.sirius.diagram.ui.tools.api.layout.SiriusLayoutDataManagerForSemanticElementsFactory; +import org.eclipse.sirius.diagram.ui.tools.api.ui.actions.ActionIds; +import org.eclipse.sirius.diagram.ui.tools.internal.layout.data.extension.LayoutDataManagerRegistry; +import org.eclipse.sirius.ecore.extender.business.api.permission.PermissionAuthorityRegistry; +import org.eclipse.sirius.ext.base.Option; +import org.eclipse.swt.SWT; +import org.eclipse.ui.IWorkbenchPage; +import org.eclipse.ui.IWorkbenchPart; + +/** + * Paste the format on the selected diagram or on the selected container. + * + * @author <a href="mailto:laurent.redor@obeo.fr">Laurent Redor</a> + */ +public class PasteFormatAction extends AbstractCopyPasteFormatAction { + + /** + * Default constructor. + * + * @param workbenchPage + * the active workbench page + * @param actionWorkbenchPart + * the part concerned by this action. Could be null. + */ + public PasteFormatAction(final IWorkbenchPage workbenchPage, IWorkbenchPart actionWorkbenchPart) { + super(workbenchPage, actionWorkbenchPart); + + setText(Messages.PasteFormatAction_text); + setAccelerator(SWT.CTRL | SWT.SHIFT | SWT.ALT | 'V'); + setId(ActionIds.PASTE_FORMAT); + setToolTipText(Messages.PasteFormatAction_toolTipText); + + setImageDescriptor(DiagramUIPlugin.Implementation.getBundledImageDescriptor(DiagramImagesPath.PASTE_FORMAT_ICON)); + setDisabledImageDescriptor(DiagramUIPlugin.Implementation.getBundledImageDescriptor(DiagramImagesPath.PASTE_FORMAT_DISABLED_ICON)); + setHoverImageDescriptor(DiagramUIPlugin.Implementation.getBundledImageDescriptor(DiagramImagesPath.PASTE_FORMAT_ICON)); + } + + /** + * Default constructor. + * + * @param workbenchPage + * the active workbench page + */ + public PasteFormatAction(final IWorkbenchPage workbenchPage) { + this(workbenchPage, null); + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.gmf.runtime.diagram.ui.actions.DiagramAction#getCommandLabel() + */ + @Override + protected String getCommandLabel() { + return Messages.PasteFormatAction_commandLabel; + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.gmf.runtime.diagram.ui.actions.DiagramAction#getCommand() + */ + @Override + protected Command getCommand() { + Command pasteFormatCommand = UnexecutableCommand.INSTANCE; + if (SiriusLayoutDataManagerForSemanticElementsFactory.getInstance().getSiriusLayoutDataManager().containsData()) { + + // Create a compound command to hold the resize commands + CompoundCommand doStoreFormatsCmd = new CompoundCommand(Messages.PasteFormatAction_restoreFormatCommandLabel); + + // Create an iterator for the selection + final Iterator<?> iter = getSelectedObjects().iterator(); + DiagramEditPart diagramEditPart = getDiagramEditPart(); + if (diagramEditPart instanceof IDDiagramEditPart) { + final Option<DDiagram> diagram = ((IDDiagramEditPart) diagramEditPart).resolveDDiagram(); + + // If ddiagram is locked, we will return an unexecutableCommand + // so that action is disabled + if (diagram.some() && PermissionAuthorityRegistry.getDefault().getPermissionAuthority(diagram.get()).canEditInstance(diagram.get())) { + while (iter.hasNext()) { + final Object next = iter.next(); + if (next instanceof IGraphicalEditPart) { + final IGraphicalEditPart torestore = (IGraphicalEditPart) next; + doStoreFormatsCmd.add(new ICommandProxy(new PasteFormatDataCommand(torestore.getEditingDomain(), diagram.get(), torestore))); + } + } + } + } + pasteFormatCommand = doStoreFormatsCmd.unwrap(); + } + return pasteFormatCommand; + } + + /** + * A command allowing to paste format data. + * + * @author <a href="mailto:alex.lagarde@obeo.fr">Alex Lagarde</a> + * + */ + private final class PasteFormatDataCommand extends AbstractTransactionalCommand { + + private IGraphicalEditPart editPartToRestore; + + private DDiagram dDiagram; + + /** + * Default constructor. + * + * @param domain + * the editing domain on which this command will be executed + * @param dDiagram + * the {@link DDiagram} on which format will be pasted + * @param editPartToRestore + * the edit part to restore + */ + public PasteFormatDataCommand(TransactionalEditingDomain domain, DDiagram dDiagram, IGraphicalEditPart editPartToRestore) { + super(domain, Messages.PasteFormatDataCommand_label, null); + this.dDiagram = dDiagram; + this.editPartToRestore = editPartToRestore; + } + + /** + * + * {@inheritDoc} + * + * @see org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand#doExecuteWithResult(org.eclipse.core.runtime.IProgressMonitor, + * org.eclipse.core.runtime.IAdaptable) + */ + @Override + protected CommandResult doExecuteWithResult(final IProgressMonitor monitor, final IAdaptable info) throws ExecutionException { + List<SiriusLayoutDataManager> layoutDataManagers = LayoutDataManagerRegistry.getSiriusLayoutDataManagers(dDiagram); + + if (!layoutDataManagers.isEmpty()) { + layoutDataManagers.get(0).applyFormat(editPartToRestore); + } + + return CommandResult.newOKCommandResult(); + } + + } +} diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/actions/layout/PasteLayoutAction.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/actions/layout/PasteLayoutAction.java index 776f8aa6a4..836c020532 100644 --- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/actions/layout/PasteLayoutAction.java +++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/actions/layout/PasteLayoutAction.java @@ -1,5 +1,5 @@ /****************************************************************************** - * Copyright (c) 2002, 2015 IBM Corporation and others. + * Copyright (c) 2002, 2016 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 @@ -37,7 +37,6 @@ import org.eclipse.sirius.diagram.ui.tools.api.ui.actions.ActionIds; import org.eclipse.sirius.diagram.ui.tools.internal.layout.data.extension.LayoutDataManagerRegistry; import org.eclipse.sirius.ecore.extender.business.api.permission.PermissionAuthorityRegistry; import org.eclipse.sirius.ext.base.Option; -import org.eclipse.swt.SWT; import org.eclipse.ui.IWorkbenchPage; import org.eclipse.ui.IWorkbenchPart; @@ -46,7 +45,7 @@ import org.eclipse.ui.IWorkbenchPart; * * @author <a href="mailto:laurent.redor@obeo.fr">Laurent Redor</a> */ -public class PasteLayoutAction extends AbstractCopyPasteLayoutAction { +public class PasteLayoutAction extends AbstractCopyPasteFormatAction { /** * Default constructor. @@ -60,7 +59,6 @@ public class PasteLayoutAction extends AbstractCopyPasteLayoutAction { super(workbenchPage, actionWorkbenchPart); setText(Messages.PasteLayoutAction_text); - setAccelerator(SWT.CTRL | SWT.SHIFT | SWT.ALT | 'V'); setId(ActionIds.PASTE_LAYOUT); setToolTipText(Messages.PasteLayoutAction_toolTipText); diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/actions/layout/PasteStyleAction.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/actions/layout/PasteStyleAction.java new file mode 100644 index 0000000000..44e0c6d3da --- /dev/null +++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/actions/layout/PasteStyleAction.java @@ -0,0 +1,171 @@ +/******************************************************************************* + * Copyright (c) 2016 THALES GLOBAL SERVICES. + * 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: + * Obeo - initial API and implementation + *******************************************************************************/ +package org.eclipse.sirius.diagram.ui.tools.internal.actions.layout; + +import java.util.Iterator; +import java.util.List; + +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.core.runtime.IAdaptable; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.emf.transaction.TransactionalEditingDomain; +import org.eclipse.gef.commands.Command; +import org.eclipse.gef.commands.CompoundCommand; +import org.eclipse.gef.commands.UnexecutableCommand; +import org.eclipse.gmf.runtime.common.core.command.CommandResult; +import org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy; +import org.eclipse.gmf.runtime.diagram.ui.editparts.DiagramEditPart; +import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart; +import org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand; +import org.eclipse.sirius.diagram.DDiagram; +import org.eclipse.sirius.diagram.ui.edit.api.part.IDDiagramEditPart; +import org.eclipse.sirius.diagram.ui.provider.DiagramUIPlugin; +import org.eclipse.sirius.diagram.ui.provider.Messages; +import org.eclipse.sirius.diagram.ui.tools.api.image.DiagramImagesPath; +import org.eclipse.sirius.diagram.ui.tools.api.layout.SiriusLayoutDataManager; +import org.eclipse.sirius.diagram.ui.tools.api.layout.SiriusLayoutDataManagerForSemanticElementsFactory; +import org.eclipse.sirius.diagram.ui.tools.api.ui.actions.ActionIds; +import org.eclipse.sirius.diagram.ui.tools.internal.layout.data.extension.LayoutDataManagerRegistry; +import org.eclipse.sirius.ecore.extender.business.api.permission.PermissionAuthorityRegistry; +import org.eclipse.sirius.ext.base.Option; +import org.eclipse.ui.IWorkbenchPage; +import org.eclipse.ui.IWorkbenchPart; + +/** + * Paste the style on the selected diagram or on the selected container. + * + * @author <a href="mailto:laurent.redor@obeo.fr">Laurent Redor</a> + */ +public class PasteStyleAction extends AbstractCopyPasteFormatAction { + + /** + * Default constructor. + * + * @param workbenchPage + * the active workbench page + * @param actionWorkbenchPart + * the part concerned by this action. Could be null. + */ + public PasteStyleAction(final IWorkbenchPage workbenchPage, IWorkbenchPart actionWorkbenchPart) { + super(workbenchPage, actionWorkbenchPart); + + setText(Messages.PasteStyleAction_text); + setId(ActionIds.PASTE_STYLE); + setToolTipText(Messages.PasteStyleAction_toolTipText); + + setImageDescriptor(DiagramUIPlugin.Implementation.getBundledImageDescriptor(DiagramImagesPath.PASTE_STYLE_ICON)); + setDisabledImageDescriptor(DiagramUIPlugin.Implementation.getBundledImageDescriptor(DiagramImagesPath.PASTE_STYLE_DISABLED_ICON)); + setHoverImageDescriptor(DiagramUIPlugin.Implementation.getBundledImageDescriptor(DiagramImagesPath.PASTE_STYLE_ICON)); + } + + /** + * Default constructor. + * + * @param workbenchPage + * the active workbench page + */ + public PasteStyleAction(final IWorkbenchPage workbenchPage) { + this(workbenchPage, null); + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.gmf.runtime.diagram.ui.actions.DiagramAction#getCommandLabel() + */ + @Override + protected String getCommandLabel() { + return Messages.PasteStyleAction_commandLabel; + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.gmf.runtime.diagram.ui.actions.DiagramAction#getCommand() + */ + @Override + protected Command getCommand() { + Command pasteStyleCommand = UnexecutableCommand.INSTANCE; + if (SiriusLayoutDataManagerForSemanticElementsFactory.getInstance().getSiriusLayoutDataManager().containsData()) { + + // Create a compound command to hold the resize commands + CompoundCommand doStoreStylesCmd = new CompoundCommand(Messages.PasteStyleAction_restoreStyleCommandLabel); + + // Create an iterator for the selection + final Iterator<?> iter = getSelectedObjects().iterator(); + DiagramEditPart diagramEditPart = getDiagramEditPart(); + if (diagramEditPart instanceof IDDiagramEditPart) { + final Option<DDiagram> diagram = ((IDDiagramEditPart) diagramEditPart).resolveDDiagram(); + + // If ddiagram is locked, we will return an unexecutableCommand + // so that action is disabled + if (diagram.some() && PermissionAuthorityRegistry.getDefault().getPermissionAuthority(diagram.get()).canEditInstance(diagram.get())) { + while (iter.hasNext()) { + final Object next = iter.next(); + if (next instanceof IGraphicalEditPart) { + final IGraphicalEditPart torestore = (IGraphicalEditPart) next; + doStoreStylesCmd.add(new ICommandProxy(new PasteStyleDataCommand(torestore.getEditingDomain(), diagram.get(), torestore))); + } + } + } + } + pasteStyleCommand = doStoreStylesCmd.unwrap(); + } + return pasteStyleCommand; + } + + /** + * A command allowing to paste style data. + * + * @author <a href="mailto:alex.lagarde@obeo.fr">Alex Lagarde</a> + */ + private final class PasteStyleDataCommand extends AbstractTransactionalCommand { + + private IGraphicalEditPart editPartToRestore; + + private DDiagram dDiagram; + + /** + * Default constructor. + * + * @param domain + * the editing domain on which this command will be executed + * @param dDiagram + * the {@link DDiagram} on which style will be pasted + * @param editPartToRestore + * the edit part to restore + */ + public PasteStyleDataCommand(TransactionalEditingDomain domain, DDiagram dDiagram, IGraphicalEditPart editPartToRestore) { + super(domain, Messages.PasteStyleDataCommand_label, null); + this.dDiagram = dDiagram; + this.editPartToRestore = editPartToRestore; + } + + /** + * + * {@inheritDoc} + * + * @see org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand#doExecuteWithResult(org.eclipse.core.runtime.IProgressMonitor, + * org.eclipse.core.runtime.IAdaptable) + */ + @Override + protected CommandResult doExecuteWithResult(final IProgressMonitor monitor, final IAdaptable info) throws ExecutionException { + List<SiriusLayoutDataManager> layoutDataManagers = LayoutDataManagerRegistry.getSiriusLayoutDataManagers(dDiagram); + + if (!layoutDataManagers.isEmpty()) { + layoutDataManagers.get(0).applyStyle(editPartToRestore); + } + + return CommandResult.newOKCommandResult(); + } + + } +} diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/editor/tabbar/TabbarFillerWithContributions.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/editor/tabbar/TabbarFillerWithContributions.java index 78c107b113..b6c85c7207 100644 --- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/editor/tabbar/TabbarFillerWithContributions.java +++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/editor/tabbar/TabbarFillerWithContributions.java @@ -160,7 +160,7 @@ public class TabbarFillerWithContributions extends AbstractTabbarFiller { addContributionItem(diagramContributionItems, HIDE_PIN, contributionFactory.createSelectPinnedElementsContribution(part)); addContributionItem(diagramContributionItems, HIDE_PIN, contributionFactory.createSelectHiddenElementsContribution(part)); - addContributionItem(diagramContributionItems, PAST, contributionFactory.createPasteLayoutContribution(part)); + addContributionItem(diagramContributionItems, PAST, contributionFactory.createPasteFormatContribution(part)); addContributionItem(diagramContributionItems, ZOOM, contributionFactory.createZoomContribution(part)); addContributionItem(diagramContributionItems, ZOOM, contributionFactory.createZoomOutContribution(part)); @@ -186,7 +186,7 @@ public class TabbarFillerWithContributions extends AbstractTabbarFiller { addContributionItem(diagramElementContributionItems, HIDE_PIN, contributionFactory.createUnPinElementContribution(part, pinElementContributionItem)); addContributionItem(diagramElementContributionItems, HIDE_PIN, pinElementContributionItem); - addContributionItem(diagramElementContributionItems, PAST, contributionFactory.createCopyLayoutContribution(part)); + addContributionItem(diagramElementContributionItems, PAST, contributionFactory.createCopyFormatContribution(part)); addContributionItem(diagramElementContributionItems, HIDE_DELETE, contributionFactory.createDeleteFromModelContribution(part)); addContributionItem(diagramElementContributionItems, HIDE_DELETE, contributionFactory.createDeleteFromDiagramContribution(part)); diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/editor/tabbar/contributions/TabbarContributionFactory.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/editor/tabbar/contributions/TabbarContributionFactory.java index 9610b3a9b4..f3339d1e1b 100644 --- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/editor/tabbar/contributions/TabbarContributionFactory.java +++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/editor/tabbar/contributions/TabbarContributionFactory.java @@ -37,8 +37,8 @@ import org.eclipse.sirius.diagram.ui.tools.internal.actions.SiriusCopyAppearance import org.eclipse.sirius.diagram.ui.tools.internal.actions.SizeBothAction; import org.eclipse.sirius.diagram.ui.tools.internal.actions.delete.DeleteFromDiagramAction; import org.eclipse.sirius.diagram.ui.tools.internal.actions.delete.DeleteFromModelWithHookAction; -import org.eclipse.sirius.diagram.ui.tools.internal.actions.layout.CopyLayoutAction; -import org.eclipse.sirius.diagram.ui.tools.internal.actions.layout.PasteLayoutAction; +import org.eclipse.sirius.diagram.ui.tools.internal.actions.layout.CopyFormatAction; +import org.eclipse.sirius.diagram.ui.tools.internal.actions.layout.PasteFormatAction; import org.eclipse.sirius.diagram.ui.tools.internal.actions.refresh.RefreshDiagramAction; import org.eclipse.sirius.diagram.ui.tools.internal.actions.style.ResetStylePropertiesToDefaultValuesAction; import org.eclipse.sirius.diagram.ui.tools.internal.actions.style.SetStyleToWorkspaceImageAction; @@ -601,8 +601,8 @@ public class TabbarContributionFactory { } /** - * Creates the copy layout contribution item. This tool can be used to - * duplicate the layout of some diagram elements from this diagram into + * Creates the copy format contribution item. This tool can be used to + * duplicate the format of some diagram elements from this diagram into * another. * * @param part @@ -610,28 +610,28 @@ public class TabbarContributionFactory { * @return the {@link IContributionItem} or null if the workbench part is * being initialized. */ - public IContributionItem createCopyLayoutContribution(IDiagramWorkbenchPart part) { + public IContributionItem createCopyFormatContribution(IDiagramWorkbenchPart part) { IWorkbenchPartSite site = part.getSite(); if (site != null) { - CopyLayoutAction copyLayoutAction = new CopyLayoutAction(site.getPage(), part); + CopyFormatAction copyLayoutAction = new CopyFormatAction(site.getPage(), part); return new ActionContributionItem(copyLayoutAction); } return null; } /** - * Creates the Paste Layout contribution item. + * Creates the Paste Format contribution item. * * @param part * the current IDiagramWorkbenchPart. * @return the {@link IContributionItem} or null if the workbench part is * being initialized. */ - public IContributionItem createPasteLayoutContribution(IDiagramWorkbenchPart part) { + public IContributionItem createPasteFormatContribution(IDiagramWorkbenchPart part) { IWorkbenchPartSite site = part.getSite(); if (site != null) { - PasteLayoutAction pasteLayoutAction = new PasteLayoutAction(site.getPage(), part); - return new ActionContributionItem(pasteLayoutAction); + PasteFormatAction pasteFormatAction = new PasteFormatAction(site.getPage(), part); + return new ActionContributionItem(pasteFormatAction); } return null; } diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/layout/LayoutDataHelperImpl.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/layout/LayoutDataHelperImpl.java index 129ea046bc..12a544ff83 100644 --- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/layout/LayoutDataHelperImpl.java +++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/layout/LayoutDataHelperImpl.java @@ -17,6 +17,7 @@ import org.eclipse.draw2d.geometry.Dimension; import org.eclipse.draw2d.geometry.PointList; import org.eclipse.emf.common.util.EList; import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.util.EcoreUtil; import org.eclipse.gef.ConnectionEditPart; import org.eclipse.gmf.runtime.diagram.core.util.ViewUtil; import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart; @@ -29,6 +30,7 @@ import org.eclipse.gmf.runtime.notation.LayoutConstraint; import org.eclipse.gmf.runtime.notation.Node; import org.eclipse.gmf.runtime.notation.NotationPackage; import org.eclipse.gmf.runtime.notation.Size; +import org.eclipse.gmf.runtime.notation.View; import org.eclipse.sirius.diagram.DDiagramElement; import org.eclipse.sirius.diagram.business.api.query.DDiagramElementQuery; import org.eclipse.sirius.diagram.layoutdata.AbstractLayoutData; @@ -44,6 +46,7 @@ import org.eclipse.sirius.diagram.ui.tools.internal.layout.semantic.SemanticEdge import org.eclipse.sirius.diagram.ui.tools.internal.layout.semantic.SemanticNodeLayoutDataKey; import org.eclipse.sirius.ext.base.Option; import org.eclipse.sirius.ext.draw2d.figure.FigureUtilities; +import org.eclipse.sirius.viewpoint.DStylizable; import com.google.common.base.Predicate; import com.google.common.collect.Maps; @@ -131,9 +134,24 @@ public class LayoutDataHelperImpl implements LayoutDataHelper { location.setY(relativeLocation.y); result.setLocation(location); + // 4-Copy Sirius and GMF styles + copyNodeStyleInLayoutData(result, node); + return result; } + private void copyNodeStyleInLayoutData(AbstractLayoutData layoutData, View view) { + // 1-Copy Sirius Style + if (view.getElement() instanceof DStylizable) { + layoutData.setSiriusStyle(EcoreUtil.copy(((DStylizable) view.getElement()).getStyle())); + } + + // 2-Copy GMF view to retrieve GMF style + EcoreUtil.Copier copierWithoutElementRef = new EcoreUtil.Copier(false, false); + View viewCopy = (View) copierWithoutElementRef.copy(view); + layoutData.setGmfView(viewCopy); + } + /** * {@inheritDoc} * @@ -170,6 +188,9 @@ public class LayoutDataHelperImpl implements LayoutDataHelper { result.setTargetTerminal(((IdentityAnchor) gmfEdge.getTargetAnchor()).getId()); } + // 4-Copy Sirius and GMF styles + copyNodeStyleInLayoutData(result, gmfEdge); + return result; } diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/layout/diagram/SiriusLayoutDataManagerForDDiagram.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/layout/diagram/SiriusLayoutDataManagerForDDiagram.java index 5f003b3d11..26c421dca2 100644 --- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/layout/diagram/SiriusLayoutDataManagerForDDiagram.java +++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/layout/diagram/SiriusLayoutDataManagerForDDiagram.java @@ -22,8 +22,8 @@ import org.eclipse.sirius.diagram.ui.tools.api.layout.SiriusLayoutDataManager; import org.eclipse.sirius.viewpoint.DSemanticDecorator; /** - * SiriusLayoutDataManager drives by the DDiagram (DNode, DEdge, ...). Use - * for drag'n'drop and creation process. + * SiriusLayoutDataManager drives by the DDiagram (DNode, DEdge, ...). Use for + * drag'n'drop and creation process. * * @author <a href="mailto:laurent.redor@obeo.fr">Laurent Redor</a> * @@ -39,6 +39,7 @@ public class SiriusLayoutDataManagerForDDiagram implements SiriusLayoutDataManag * @see org.eclipse.sirius.diagram.ui.tools.api.layout.SiriusLayoutDataManager#addLayoutData(org.eclipse.sirius.diagram.ui.tools.api.layout.LayoutDataKey, * org.eclipse.sirius.diagram.layoutdata.AbstractLayoutData) */ + @Override public void addLayoutData(final LayoutDataKey key, final AbstractLayoutData layoutData) { if (!checkKeyType(key)) { // Kind of key not manage @@ -64,6 +65,7 @@ public class SiriusLayoutDataManagerForDDiagram implements SiriusLayoutDataManag * * @see org.eclipse.sirius.diagram.ui.tools.api.layout.SiriusLayoutDataManager#getLayoutData(org.eclipse.sirius.diagram.ui.tools.api.layout.LayoutDataKey) */ + @Override public AbstractLayoutData getLayoutData(final LayoutDataKey key) { AbstractLayoutData result = null; if (checkKeyType(key)) { @@ -90,8 +92,20 @@ public class SiriusLayoutDataManagerForDDiagram implements SiriusLayoutDataManag /** * {@inheritDoc} * + * @see org.eclipse.sirius.diagram.ui.tools.api.layout.SiriusLayoutDataManager#applyFormat(org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart) + */ + @Override + public void applyFormat(final IGraphicalEditPart rootEditPart) { + // TODO Auto-generated method stub + + } + + /** + * {@inheritDoc} + * * @see org.eclipse.sirius.diagram.ui.tools.api.layout.SiriusLayoutDataManager#applyLayout(org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart) */ + @Override public void applyLayout(final IGraphicalEditPart rootEditPart) { // TODO Auto-generated method stub @@ -100,8 +114,20 @@ public class SiriusLayoutDataManagerForDDiagram implements SiriusLayoutDataManag /** * {@inheritDoc} * + * @see org.eclipse.sirius.diagram.ui.tools.api.layout.SiriusLayoutDataManager#applyStyle(org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart) + */ + @Override + public void applyStyle(final IGraphicalEditPart rootEditPart) { + // TODO Auto-generated method stub + + } + + /** + * {@inheritDoc} + * * @see org.eclipse.sirius.diagram.ui.tools.api.layout.SiriusLayoutDataManager#clearLayoutData() */ + @Override public void clearLayoutData() { // TODO Auto-generated method stub @@ -112,6 +138,7 @@ public class SiriusLayoutDataManagerForDDiagram implements SiriusLayoutDataManag * * @see org.eclipse.sirius.diagram.ui.tools.api.layout.SiriusLayoutDataManager#containsData() */ + @Override public boolean containsData() { // TODO Auto-generated method stub return false; @@ -122,6 +149,7 @@ public class SiriusLayoutDataManagerForDDiagram implements SiriusLayoutDataManag * * @see org.eclipse.sirius.diagram.ui.tools.api.layout.SiriusLayoutDataManager#createKey(org.eclipse.sirius.viewpoint.DSemanticDecorator) */ + @Override public LayoutDataKey createKey(final DSemanticDecorator semanticDecorator) { // TODO Auto-generated method stub return null; @@ -142,6 +170,7 @@ public class SiriusLayoutDataManagerForDDiagram implements SiriusLayoutDataManag * * @see org.eclipse.sirius.diagram.ui.tools.api.layout.SiriusLayoutDataManager#storeLayoutData(org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart) */ + @Override public void storeLayoutData(final IGraphicalEditPart rootEditPart) { // TODO Auto-generated method stub diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/layout/semantic/SiriusLayoutDataManagerForSemanticElements.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/layout/semantic/SiriusLayoutDataManagerForSemanticElements.java index 862071caae..4c48f173e0 100644 --- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/layout/semantic/SiriusLayoutDataManagerForSemanticElements.java +++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/layout/semantic/SiriusLayoutDataManagerForSemanticElements.java @@ -55,6 +55,7 @@ public class SiriusLayoutDataManagerForSemanticElements extends AbstractSiriusLa * @see org.eclipse.sirius.diagram.ui.tools.api.layout.SiriusLayoutDataManager#addLayoutData(org.eclipse.sirius.diagram.ui.tools.api.layout.LayoutDataKey, * org.eclipse.sirius.diagram.layoutdata.AbstractLayoutData) */ + @Override public void addLayoutData(final LayoutDataKey key, final AbstractLayoutData layoutData) { if (!checkKeyType(key)) { // Kind of key not manage @@ -82,6 +83,7 @@ public class SiriusLayoutDataManagerForSemanticElements extends AbstractSiriusLa * * @see org.eclipse.sirius.diagram.ui.tools.api.layout.SiriusLayoutDataManager#getLayoutData(org.eclipse.sirius.diagram.ui.tools.api.layout.LayoutDataKey) */ + @Override public AbstractLayoutData getLayoutData(final LayoutDataKey key) { AbstractLayoutData result = null; if (checkKeyType(key)) { @@ -119,6 +121,7 @@ public class SiriusLayoutDataManagerForSemanticElements extends AbstractSiriusLa * * @see org.eclipse.sirius.diagram.ui.tools.api.layout.SiriusLayoutDataManager#createKey(org.eclipse.sirius.viewpoint.DSemanticDecorator) */ + @Override public LayoutDataKey createKey(final DSemanticDecorator semanticDecorator) { LayoutDataKey result = null; final EObject realSemanticElement = semanticDecorator.getTarget(); @@ -135,6 +138,7 @@ public class SiriusLayoutDataManagerForSemanticElements extends AbstractSiriusLa * * @see org.eclipse.sirius.diagram.ui.tools.api.layout.SiriusLayoutDataManager#containsData() */ + @Override public boolean containsData() { return !nodeLayoutDataMap.isEmpty() || !edgeLayoutDataMap.isEmpty(); } @@ -144,6 +148,7 @@ public class SiriusLayoutDataManagerForSemanticElements extends AbstractSiriusLa * * @see org.eclipse.sirius.diagram.ui.tools.api.layout.SiriusLayoutDataManager#clearLayoutData() */ + @Override public void clearLayoutData() { nodeLayoutDataMap.clear(); edgeLayoutDataMap.clear(); @@ -152,6 +157,7 @@ public class SiriusLayoutDataManagerForSemanticElements extends AbstractSiriusLa /** * {@inheritDoc} */ + @Override public Map<SemanticEdgeLayoutDataKey, EdgeLayoutData> getEdgeLayoutData() { return edgeLayoutDataMap; } @@ -159,6 +165,7 @@ public class SiriusLayoutDataManagerForSemanticElements extends AbstractSiriusLa /** * {@inheritDoc} */ + @Override public Map<? extends LayoutDataKey, ? extends NodeLayoutData> getRootNodeLayoutData() { return (Map<? extends LayoutDataKey, ? extends NodeLayoutData>) LayoutDataHelper.INSTANCE.getRootLayoutData(nodeLayoutDataMap); } @@ -166,6 +173,7 @@ public class SiriusLayoutDataManagerForSemanticElements extends AbstractSiriusLa /** * {@inheritDoc} */ + @Override public Map<SemanticNodeLayoutDataKey, NodeLayoutData> getNodeLayoutData() { return nodeLayoutDataMap; } diff --git a/plugins/org.eclipse.sirius.diagram.ui/src/org/eclipse/sirius/diagram/ui/provider/Messages.java b/plugins/org.eclipse.sirius.diagram.ui/src/org/eclipse/sirius/diagram/ui/provider/Messages.java index 643ae79d87..e5cf2eb136 100644 --- a/plugins/org.eclipse.sirius.diagram.ui/src/org/eclipse/sirius/diagram/ui/provider/Messages.java +++ b/plugins/org.eclipse.sirius.diagram.ui/src/org/eclipse/sirius/diagram/ui/provider/Messages.java @@ -183,22 +183,22 @@ public final class Messages { public static String ConnectionsFactory_edgeNotCreatedMsg; @TranslatableMessage - public static String CopyLayoutAction_clrearPreviousLayoutDateCommandLabel; + public static String CopyFormatAction_clearPreviousFormatDateCommandLabel; @TranslatableMessage - public static String CopyLayoutAction_commandLabel; + public static String CopyFormatAction_commandLabel; @TranslatableMessage - public static String CopyLayoutAction_storeLayoutCommandLabel; + public static String CopyFormatAction_storeFormatCommandLabel; @TranslatableMessage - public static String CopyLayoutAction_text; + public static String CopyFormatAction_text; @TranslatableMessage - public static String CopyLayoutAction_toolTipText; + public static String CopyFormatAction_toolTipText; @TranslatableMessage - public static String CopyLayoutDataCommand_label; + public static String CopyFormatDataCommand_label; @TranslatableMessage public static String CopyToSiriusClipboardCommand_label; @@ -759,6 +759,21 @@ public final class Messages { public static String PasteFromSiriusClipboardCommand_label; @TranslatableMessage + public static String PasteFormatAction_commandLabel; + + @TranslatableMessage + public static String PasteFormatAction_restoreFormatCommandLabel; + + @TranslatableMessage + public static String PasteFormatAction_text; + + @TranslatableMessage + public static String PasteFormatAction_toolTipText; + + @TranslatableMessage + public static String PasteFormatDataCommand_label; + + @TranslatableMessage public static String PasteLayoutAction_commandLabel; @TranslatableMessage @@ -774,6 +789,21 @@ public final class Messages { public static String PasteLayoutDataCommand_label; @TranslatableMessage + public static String PasteStyleAction_commandLabel; + + @TranslatableMessage + public static String PasteStyleAction_restoreStyleCommandLabel; + + @TranslatableMessage + public static String PasteStyleAction_text; + + @TranslatableMessage + public static String PasteStyleAction_toolTipText; + + @TranslatableMessage + public static String PasteStyleDataCommand_label; + + @TranslatableMessage public static String PinElementsEclipseAction_text; @TranslatableMessage diff --git a/plugins/org.eclipse.sirius.diagram.ui/src/org/eclipse/sirius/diagram/ui/tools/api/image/DiagramImagesPath.java b/plugins/org.eclipse.sirius.diagram.ui/src/org/eclipse/sirius/diagram/ui/tools/api/image/DiagramImagesPath.java index 9c505e1a0c..f2c094d1c5 100644 --- a/plugins/org.eclipse.sirius.diagram.ui/src/org/eclipse/sirius/diagram/ui/tools/api/image/DiagramImagesPath.java +++ b/plugins/org.eclipse.sirius.diagram.ui/src/org/eclipse/sirius/diagram/ui/tools/api/image/DiagramImagesPath.java @@ -81,10 +81,16 @@ public interface DiagramImagesPath { String DELETE_FROM_MODEL_ICON = "icons/deleteModel.gif"; //$NON-NLS-1$ /** path of the copy layout icon image. */ - String COPY_LAYOUT_ICON = "icons/copyLayout.gif"; //$NON-NLS-1$ + String COPY_FORMAT_ICON = "icons/copyFormat.gif"; //$NON-NLS-1$ /** path of the copy layout icon image. */ - String COPY_LAYOUT_DISABLED_ICON = "icons/copyLayoutDisabled.gif"; //$NON-NLS-1$ + String COPY_FORMAT_DISABLED_ICON = "icons/copyFormatDisabled.gif"; //$NON-NLS-1$ + + /** paste format icon. */ + String PASTE_FORMAT_ICON = "icons/pasteFormat.gif"; //$NON-NLS-1$ + + /** paste format disabled icon. */ + String PASTE_FORMAT_DISABLED_ICON = "icons/pasteFormatDisabled.gif"; //$NON-NLS-1$ /** paste layout icon. */ String PASTE_LAYOUT_ICON = "icons/pasteLayout.gif"; //$NON-NLS-1$ @@ -92,6 +98,12 @@ public interface DiagramImagesPath { /** paste layout disabled icon. */ String PASTE_LAYOUT_DISABLED_ICON = "icons/pasteLayoutDisabled.gif"; //$NON-NLS-1$ + /** paste style icon. */ + String PASTE_STYLE_ICON = "icons/pasteStyle.gif"; //$NON-NLS-1$ + + /** paste style disabled icon. */ + String PASTE_STYLE_DISABLED_ICON = "icons/pasteStyleDisabled.gif"; //$NON-NLS-1$ + /** pin elements icon. */ String PIN_ELEMENTS_ICON = "icons/pin.gif"; //$NON-NLS-1$ @@ -164,6 +176,8 @@ public interface DiagramImagesPath { */ String DISTRIBUTE_CENTERS_VERTICALLY = "icons/distributeCentersVertical.gif"; //$NON-NLS-1$ - /** Path of the action's image to distribute with uniform gaps vertically. */ + /** + * Path of the action's image to distribute with uniform gaps vertically. + */ String DISTRIBUTE_WITH_UNIFORM_GAPS_VERTICALLY = "icons/distributeWithUniformGapVertical.gif"; //$NON-NLS-1$ } diff --git a/plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/business/api/diagramtype/IDiagramDescriptionProvider.java b/plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/business/api/diagramtype/IDiagramDescriptionProvider.java index 274cc91aa7..b349545f25 100644 --- a/plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/business/api/diagramtype/IDiagramDescriptionProvider.java +++ b/plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/business/api/diagramtype/IDiagramDescriptionProvider.java @@ -145,14 +145,32 @@ public interface IDiagramDescriptionProvider { * @param element * the element to check. * - * @return true if this provider allows the Copy/Paster Layout actions on - * the specified element, false otherwise. + * @return true if this provider allows the Copy/Paste Layout actions on the + * specified element, false otherwise. * * @since 1.0.0M7 + * @deprecated since 4.1.0 Use + * {@link #allowsCopyPasteFormat(DSemanticDecorator)} instead */ + @Deprecated boolean allowsCopyPasteLayout(DSemanticDecorator element); /** + * Indicates if this Diagram description provider allows the Copy/Paste + * Format actions on the specified element (including paste style and paste + * layout). + * + * @param element + * the element to check. + * + * @return true if this provider allows the Copy/Paster Layout actions on + * the specified element, false otherwise. + * + * @since 4.1.0 + */ + boolean allowsCopyPasteFormat(DSemanticDecorator element); + + /** * Indicates if the given Diagram description provider support the header * section in diagram to display header datas. This header section is * displayed between the tabbar and the diagram (just above the ruler if @@ -222,5 +240,6 @@ public interface IDiagramDescriptionProvider { * .IDiagramDescriptionProvider.completeToolTipText(String, * EObject, EStructuralFeature) */ + @Deprecated String completeToolTipText(String toolTipText, EObject eObject); } diff --git a/plugins/org.eclipse.sirius.doc/doc/Release_Notes.html b/plugins/org.eclipse.sirius.doc/doc/Release_Notes.html index 68923f33ad..f2d39d8c64 100644 --- a/plugins/org.eclipse.sirius.doc/doc/Release_Notes.html +++ b/plugins/org.eclipse.sirius.doc/doc/Release_Notes.html @@ -125,10 +125,61 @@ <code>UICallBack.askSessionReopeningWithResourceVersionMismatch()</code> method to give feedback about version mismatch and give the choice to reopen session despite a potential corruption. </li> </ul> + <h4 id="Changesinorg.eclipse.sirius.diagram">Changes in + <code>org.eclipse.sirius.diagram</code> + </h4> + <ul> + <li><span class="label label-success">Added</span> + <code>org.eclipse.sirius.diagram.business.api.diagramtype.IDiagramDescriptionProvider.allowsCopyPasteFormat(DSemanticDecorator)</code> has been added in replacement of + <code>allowsCopyPasteLayout(DSemanticDecorator)</code> that is now deprecated. This 2 methods must return the same result. + <code>allowsCopyPasteLayout(DSemanticDecorator)</code> will be removed in the new major version. + </li> + </ul> <h4 id="Changesinorg.eclipse.sirius.diagram.ui">Changes in <code>org.eclipse.sirius.diagram.ui</code> </h4> <ul> + <li><span class="label label-success">Added</span> 2 methods are added in + <code>org.eclipse.sirius.diagram.ui.tools.api.layout.SiriusLayoutDataManager</code> (and also in + <code>org.eclipse.sirius.diagram.ui.tools.api.layout.AbstractSiriusLayoutDataManager</code>): + <ul> + <li> + <code>applyFormat(IGraphicalEditPart)</code>: Apply the current format data (layout data and style data) to the given edit part. + </li> + <li> + <code>applyStyle(IGraphicalEditPart)</code>: Apply the current style data to the give edit part. + </li> + </ul> + </li> + <li><span class="label label-success">Added</span> 2 methods are added in + <code>org.eclipse.sirius.diagram.ui.tools.api.editor.tabbar.AbstractTabbarContributor</code>: + <ul> + <li> + <code>createCopyFormatContribution(IDiagramWorkbenchPart)</code>: In replacement of + <code>createCopyLayoutContribution(IDiagramWorkbenchPart)</code> that is now deprecated. + </li> + <li> + <code>createPasteFormatContribution(IDiagramWorkbenchPart)</code>: In replacement of + <code>createPasteLayoutContribution(IDiagramWorkbenchPart)</code> that is now deprecated. + </li> + </ul> + </li> + <li><span class="label label-success">Added</span> New action ids have been added in + <code>org.eclipse.sirius.diagram.ui.tools.api.ui.actions.ActionIds</code>: + <ul> + <li> + <code>COPY_FORMAT</code>: Action contribution id for the copy format. It replaces the old + <code>COPY_LAYOUT</code>. + </li> + <li> + <code>PASTE_FORMAT</code>: Action contribution id for the paste format. It does not replace the old + <code>PASTE_LAYOUT</code>. The paste format paste the layout and the style. The paste layout only paste layout. + </li> + <li> + <code>PASTE_STYLE</code>: Action contribution id for the paste style. + </li> + </ul> + </li> <li><span class="label label-success">Added</span> <code>org.eclipse.sirius.diagram.ui.business.api.query.NodeQuery.isDescendantOf(View)</code> has been added to know if a view is a descendant of another view. </li> @@ -362,7 +413,7 @@ <code>org.eclipse.sirius.common.tools.api.interpreter.IInterpreterStatus</code> to reflect all kind of language validation severity (of AQL for example). </li> </ul> - <h4 id="Changesinorg.eclipse.sirius.diagram">Changes in + <h4 id="Changesinorg.eclipse.sirius.diagram2">Changes in <code>org.eclipse.sirius.diagram</code> </h4> <ul> @@ -1665,7 +1716,7 @@ <code>org.eclipse.sirius.editor.tools.api.assist.TypeContentProposalProvider.bindCompletionProcessor(AbstractPropertySection, Text)</code>, the difference is that it binds the completion processors available in plugins to the text. </li> </ul> - <h4 id="Changesinorg.eclipse.sirius.diagram2">Changes in + <h4 id="Changesinorg.eclipse.sirius.diagram3">Changes in <code>org.eclipse.sirius.diagram</code> </h4> <ul> @@ -2307,7 +2358,7 @@ <code>IServiceLocator.getService()</code> on the site. </li> </ul> - <h4 id="Changesinorg.eclipse.sirius.diagram3">Changes in + <h4 id="Changesinorg.eclipse.sirius.diagram4">Changes in <code>org.eclipse.sirius.diagram</code> </h4> <ul> diff --git a/plugins/org.eclipse.sirius.doc/doc/Release_Notes.textile b/plugins/org.eclipse.sirius.doc/doc/Release_Notes.textile index 2a388bda12..7a81b688eb 100644 --- a/plugins/org.eclipse.sirius.doc/doc/Release_Notes.textile +++ b/plugins/org.eclipse.sirius.doc/doc/Release_Notes.textile @@ -26,8 +26,22 @@ h4. Changes in @org.eclipse.sirius.ui@ * <span class="label label-info">Modified</span> @AbstractSWTCallback@ provides a default implementation of @UICallBack.askSessionReopeningWithResourceVersionMismatch()@ method to give feedback about version mismatch and give the choice to reopen session despite a potential corruption. +h4. Changes in @org.eclipse.sirius.diagram@ + +* <span class="label label-success">Added</span> @org.eclipse.sirius.diagram.business.api.diagramtype.IDiagramDescriptionProvider.allowsCopyPasteFormat(DSemanticDecorator)@ has been added in replacement of @allowsCopyPasteLayout(DSemanticDecorator)@ that is now deprecated. This 2 methods must return the same result. @allowsCopyPasteLayout(DSemanticDecorator)@ will be removed in the new major version. + h4. Changes in @org.eclipse.sirius.diagram.ui@ +* <span class="label label-success">Added</span> 2 methods are added in @org.eclipse.sirius.diagram.ui.tools.api.layout.SiriusLayoutDataManager@ (and also in @org.eclipse.sirius.diagram.ui.tools.api.layout.AbstractSiriusLayoutDataManager@): +** @applyFormat(IGraphicalEditPart)@: Apply the current format data (layout data and style data) to the given edit part. +** @applyStyle(IGraphicalEditPart)@: Apply the current style data to the give edit part. +* <span class="label label-success">Added</span> 2 methods are added in @org.eclipse.sirius.diagram.ui.tools.api.editor.tabbar.AbstractTabbarContributor@: +** @createCopyFormatContribution(IDiagramWorkbenchPart)@: In replacement of @createCopyLayoutContribution(IDiagramWorkbenchPart)@ that is now deprecated. +** @createPasteFormatContribution(IDiagramWorkbenchPart)@: In replacement of @createPasteLayoutContribution(IDiagramWorkbenchPart)@ that is now deprecated. +* <span class="label label-success">Added</span> New action ids have been added in @org.eclipse.sirius.diagram.ui.tools.api.ui.actions.ActionIds@: +** @COPY_FORMAT@: Action contribution id for the copy format. It replaces the old @COPY_LAYOUT@. +** @PASTE_FORMAT@: Action contribution id for the paste format. It does not replace the old @PASTE_LAYOUT@. The paste format paste the layout and the style. The paste layout only paste layout. +** @PASTE_STYLE@: Action contribution id for the paste style. * <span class="label label-success">Added</span> @org.eclipse.sirius.diagram.ui.business.api.query.NodeQuery.isDescendantOf(View)@ has been added to know if a view is a descendant of another view. * <span class="label label-success">Added</span> @org.eclipse.sirius.diagram.ui.business.api.query.ViewQuery.getAncestor(int...)@ has been added to retrieve the first ancestor of the view, or itself, that has at least one of the visualID passed as parameter. diff --git a/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/tabbar/TabbarContributorSample.java b/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/tabbar/TabbarContributorSample.java index 7d310e5e6e..9cd1eb5217 100644 --- a/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/tabbar/TabbarContributorSample.java +++ b/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/tabbar/TabbarContributorSample.java @@ -79,12 +79,12 @@ public class TabbarContributorSample extends AbstractTabbarContributor { diagramContributionItems.add(createSelectPinnedElementsContribution(part)); diagramContributionItems.add(createSelectHiddenElementsContribution(part)); diagramContributionItems.add(createFilterContribution(part, manager)); - diagramContributionItems.add(createPasteLayoutContribution(part)); + diagramContributionItems.add(createPasteFormatContribution(part)); diagramContributionItems.add(createRefreshContribution()); diagramContributionItems.add(createSaveAsImageContributionItem()); diagramContributionItems.add(createLayoutingModeContributionItem(part)); diagramContributionItems.add(createCopyAppearancePropertiesContribution(part)); - diagramContributionItems.add(createCopyLayoutContribution(part)); + diagramContributionItems.add(createCopyFormatContribution(part)); } return diagramContributionItems; } @@ -102,7 +102,7 @@ public class TabbarContributorSample extends AbstractTabbarContributor { diagramElementContributionItems.add(pinElementContributionItem); diagramElementContributionItems.add(createUnPinElementContribution(part, pinElementContributionItem)); diagramElementContributionItems.add(createFontColorContribution(part)); - diagramElementContributionItems.add(createPasteLayoutContribution(part)); + diagramElementContributionItems.add(createPasteFormatContribution(part)); diagramElementContributionItems.add(createBoldFontStyleContribution(part)); diagramElementContributionItems.add(createItalicFontStyleContribution(part)); diagramElementContributionItems.add(createFontDialogContribution(part)); @@ -115,7 +115,7 @@ public class TabbarContributorSample extends AbstractTabbarContributor { diagramElementContributionItems.add(createLayoutingModeContributionItem(part)); diagramElementContributionItems.add(createRouterContribution()); diagramElementContributionItems.add(createCopyAppearancePropertiesContribution(part)); - diagramElementContributionItems.add(createCopyLayoutContribution(part)); + diagramElementContributionItems.add(createCopyFormatContribution(part)); diagramElementContributionItems.add(createSizeBothContribution(part)); diagramElementContributionItems.add(createAutoSizeContribution(part)); } |
