Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLaurent Redor2017-10-25 16:35:19 +0000
committerLaurent Redor2017-10-26 14:01:20 +0000
commit812c25564d28ca486f73d5e0ca7a4b2714822148 (patch)
tree52f48cd4b167be1f92f44e35c4dd0dc58d51cf25
parent506aa8f3fdabb04ad31c8a783abbd388c5714798 (diff)
downloadorg.eclipse.sirius-812c25564d28ca486f73d5e0ca7a4b2714822148.tar.gz
org.eclipse.sirius-812c25564d28ca486f73d5e0ca7a4b2714822148.tar.xz
org.eclipse.sirius-812c25564d28ca486f73d5e0ca7a4b2714822148.zip
[525933] Complete getActivatedLayers with getActivatedTransientLayers
Some calls to DDiagram.getActivatedLayers() is not enough and must be completed with DDiagram.getActivatedTransientLayers(). Here is the list of cases fixed by this commit: * Outline view in oldUI mode (no longer used except in tests) * Contextual menu provided by tool sections of VSM * Label of ChangeLayerActivation (visible in Undo/Redo menu) * Drop tool * Detection of target for paste tool * Update of an existing diagram using a newly activated diagram extension * Checked decorator on Layers icon of tabbar after transient layer activation Tests scenario have been added in bug 525933 comment 7 to details the above cases. Bug: 525933 Change-Id: I3700ba8ee41cc4fea56c93043c5a75563a9db8e4 Signed-off-by: Laurent Redor <laurent.redor@obeo.fr>
-rw-r--r--plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/editor/tabbar/LayersContribution.java15
-rw-r--r--plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/editor/tabbar/TabbarRefresher.java46
-rw-r--r--plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/menu/PopupMenuContribution.java6
-rw-r--r--plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/views/providers/layers/LayersActivationAdapter.java13
-rw-r--r--plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/views/providers/layers/LayersCellModifier.java5
-rw-r--r--plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/views/providers/layers/LayersLabelProvider.java5
-rw-r--r--plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/business/internal/dialect/DiagramDialectServices.java15
-rw-r--r--plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/business/internal/metamodel/operations/DDiagramElementContainerSpecOperations.java5
-rw-r--r--plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/business/internal/query/PasteTargetQuery.java5
-rw-r--r--plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/tools/api/command/ChangeLayerActivationCommand.java3
10 files changed, 69 insertions, 49 deletions
diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/editor/tabbar/LayersContribution.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/editor/tabbar/LayersContribution.java
index 67faec4553..80091db9f8 100644
--- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/editor/tabbar/LayersContribution.java
+++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/editor/tabbar/LayersContribution.java
@@ -13,6 +13,7 @@ package org.eclipse.sirius.diagram.ui.tools.internal.editor.tabbar;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
+import java.util.stream.Collectors;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.gmf.runtime.notation.Diagram;
@@ -27,6 +28,7 @@ import org.eclipse.sirius.common.tools.api.util.StringUtil;
import org.eclipse.sirius.common.ui.tools.api.util.ImageProvider;
import org.eclipse.sirius.diagram.DDiagram;
import org.eclipse.sirius.diagram.business.api.componentization.DiagramComponentizationManager;
+import org.eclipse.sirius.diagram.business.api.query.DDiagramQuery;
import org.eclipse.sirius.diagram.business.internal.metamodel.helper.LayerHelper;
import org.eclipse.sirius.diagram.description.AdditionalLayer;
import org.eclipse.sirius.diagram.description.DiagramDescription;
@@ -66,7 +68,7 @@ public class LayersContribution extends AbstractMenuContributionItem {
EObject diagram = gmfDiagram.getElement();
if (diagram instanceof DDiagram) {
super.setDiagram((DDiagram) diagram);
- if (!getActivatedLayers().isEmpty()) {
+ if (!getActivatedOptionalLayers().isEmpty()) {
return DiagramUIPlugin.Implementation.getDecoratedCheckedImage(DESC_LAYER);
}
}
@@ -140,10 +142,13 @@ public class LayersContribution extends AbstractMenuContributionItem {
return allLayers;
}
- private Collection<Layer> getActivatedLayers() {
- DiagramDescription diagramDesc = diagram.getDescription();
- Collection<Layer> allLayers = new ArrayList<Layer>(diagram.getActivatedLayers());
- allLayers.remove(diagramDesc.getDefaultLayer());
+ private Collection<Layer> getActivatedOptionalLayers() {
+ Collection<Layer> allLayers = new ArrayList<Layer>(new DDiagramQuery(diagram).getAllActivatedLayers()).stream().filter(layer -> {
+ if (layer instanceof AdditionalLayer) {
+ return ((AdditionalLayer) layer).isOptional();
+ }
+ return false;
+ }).collect(Collectors.toList());
return allLayers;
}
diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/editor/tabbar/TabbarRefresher.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/editor/tabbar/TabbarRefresher.java
index 445fead1c6..84f5d16613 100644
--- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/editor/tabbar/TabbarRefresher.java
+++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/editor/tabbar/TabbarRefresher.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010 THALES GLOBAL SERVICES.
+ * Copyright (c) 2010, 2017 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
@@ -27,6 +27,7 @@ import org.eclipse.ui.PlatformUI;
* @author nlepine
*/
public class TabbarRefresher extends ResourceSetListenerImpl {
+
/**
* Default constructor.
*
@@ -38,6 +39,27 @@ public class TabbarRefresher extends ResourceSetListenerImpl {
domain.addResourceSetListener(this);
}
+ /**
+ * Reinit the toolbar.
+ */
+ public static void reinitToolbar() {
+ EclipseUIUtil.displayAsyncExec(new Runnable() {
+ @Override
+ public void run() {
+ IWorkbenchWindow activeWorkbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+ if (activeWorkbenchWindow != null) {
+ IWorkbenchPage activePage = activeWorkbenchWindow.getActivePage();
+ if (activePage != null) {
+ IEditorPart activeEditor = activePage.getActiveEditor();
+ if (activeEditor instanceof DDiagramEditorImpl && ((DDiagramEditorImpl) activeEditor).getTabbar() != null) {
+ ((DDiagramEditorImpl) activeEditor).getTabbar().reinitToolBar(((DDiagramEditorImpl) activeEditor).getDiagramGraphicalViewer().getSelection());
+ }
+ }
+ }
+ }
+ });
+ }
+
@Override
public boolean isPrecommitOnly() {
return false;
@@ -55,27 +77,7 @@ public class TabbarRefresher extends ResourceSetListenerImpl {
*/
@Override
public void resourceSetChanged(ResourceSetChangeEvent event) {
- reinitToolbar();
- }
-
- /**
- * Reinit the toolbar
- */
- private void reinitToolbar() {
- EclipseUIUtil.displayAsyncExec(new Runnable() {
- public void run() {
- IWorkbenchWindow activeWorkbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
- if (activeWorkbenchWindow != null) {
- IWorkbenchPage activePage = activeWorkbenchWindow.getActivePage();
- if (activePage != null) {
- IEditorPart activeEditor = activePage.getActiveEditor();
- if (activeEditor instanceof DDiagramEditorImpl && ((DDiagramEditorImpl) activeEditor).getTabbar() != null) {
- ((DDiagramEditorImpl) activeEditor).getTabbar().reinitToolBar(((DDiagramEditorImpl) activeEditor).getDiagramGraphicalViewer().getSelection());
- }
- }
- }
- }
- });
+ TabbarRefresher.reinitToolbar();
}
/**
diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/menu/PopupMenuContribution.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/menu/PopupMenuContribution.java
index 06e79dd6d5..2a9943396d 100644
--- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/menu/PopupMenuContribution.java
+++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/menu/PopupMenuContribution.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2016 THALES GLOBAL SERVICES and others.
+ * Copyright (c) 2008, 2017 THALES GLOBAL SERVICES 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
@@ -15,6 +15,7 @@ import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
import java.util.LinkedHashSet;
+import java.util.List;
import org.eclipse.draw2d.FigureCanvas;
import org.eclipse.draw2d.IFigure;
@@ -51,6 +52,7 @@ import org.eclipse.sirius.common.tools.api.interpreter.IInterpreter;
import org.eclipse.sirius.common.tools.api.util.MessageTranslator;
import org.eclipse.sirius.common.tools.api.util.StringUtil;
import org.eclipse.sirius.diagram.DSemanticDiagram;
+import org.eclipse.sirius.diagram.business.api.query.DDiagramQuery;
import org.eclipse.sirius.diagram.business.api.query.ToolSectionQuery;
import org.eclipse.sirius.diagram.description.Layer;
import org.eclipse.sirius.diagram.description.tool.ToolSection;
@@ -115,7 +117,7 @@ public class PopupMenuContribution implements IContributionItemProvider {
final EObject element = diagrampart.getDiagramEditPart().resolveSemanticElement();
if (element instanceof DSemanticDiagram) {
final DSemanticDiagram designerDiag = (DSemanticDiagram) element;
- final EList<Layer> layers = designerDiag.getActivatedLayers();
+ final List<Layer> layers = new DDiagramQuery(designerDiag).getAllActivatedLayers();
final Session session = SessionManager.INSTANCE.getSession(designerDiag.getTarget());
diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/views/providers/layers/LayersActivationAdapter.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/views/providers/layers/LayersActivationAdapter.java
index d6cecc3b15..c106f6fa1b 100644
--- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/views/providers/layers/LayersActivationAdapter.java
+++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/views/providers/layers/LayersActivationAdapter.java
@@ -19,6 +19,7 @@ import org.eclipse.sirius.diagram.DDiagram;
import org.eclipse.sirius.diagram.DiagramPackage;
import org.eclipse.sirius.diagram.description.Layer;
import org.eclipse.sirius.diagram.ui.tools.api.graphical.edit.palette.PaletteManager;
+import org.eclipse.sirius.diagram.ui.tools.internal.editor.tabbar.TabbarRefresher;
/**
* An adapter to listen layer activation change.
@@ -55,7 +56,7 @@ public class LayersActivationAdapter extends AdapterImpl {
this.paletteManager = paletteManager;
}
- private void update(final DDiagram diagram, final Layer layer, final boolean activate) {
+ private void update(final DDiagram diagram, final Layer layer, final boolean activate, final boolean isTransient) {
EclipseUIUtil.displayAsyncExec(new Runnable() {
@Override
public void run() {
@@ -72,6 +73,12 @@ public class LayersActivationAdapter extends AdapterImpl {
}
}
+ if (isTransient) {
+ // This change is a transient change and does not trigger a postCommit
+ // (TabbarRefresher.resourceSetChanged is not called as for other kind of layer). So
+ // reinitialisation of the tabbar is directly called to refresh the Layers icon in the tabbar.
+ TabbarRefresher.reinitToolbar();
+ }
}
});
}
@@ -92,11 +99,11 @@ public class LayersActivationAdapter extends AdapterImpl {
case Notification.ADD:
final Layer layerToAdd = (Layer) msg.getNewValue();
- update((DDiagram) notifier, layerToAdd, true);
+ update((DDiagram) notifier, layerToAdd, true, featureID == DiagramPackage.DDIAGRAM__ACTIVATED_TRANSIENT_LAYERS);
break;
case Notification.REMOVE:
final Layer layerToRemove = (Layer) msg.getOldValue();
- update((DDiagram) notifier, layerToRemove, false);
+ update((DDiagram) notifier, layerToRemove, false, featureID == DiagramPackage.DDIAGRAM__ACTIVATED_TRANSIENT_LAYERS);
break;
default:
break;
diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/views/providers/layers/LayersCellModifier.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/views/providers/layers/LayersCellModifier.java
index 4fba1c065e..0f54e375bd 100644
--- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/views/providers/layers/LayersCellModifier.java
+++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/views/providers/layers/LayersCellModifier.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009, 2015 THALES GLOBAL SERVICES and others.
+ * Copyright (c) 2009, 2017 THALES GLOBAL SERVICES 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
@@ -26,6 +26,7 @@ import org.eclipse.jface.viewers.ICellModifier;
import org.eclipse.sirius.business.api.query.IdentifiedElementQuery;
import org.eclipse.sirius.common.tools.api.util.EqualityHelper;
import org.eclipse.sirius.diagram.DDiagram;
+import org.eclipse.sirius.diagram.business.api.query.DDiagramQuery;
import org.eclipse.sirius.diagram.description.Layer;
import org.eclipse.sirius.diagram.tools.api.command.ChangeLayerActivationCommand;
import org.eclipse.sirius.diagram.ui.provider.Messages;
@@ -100,7 +101,7 @@ public class LayersCellModifier implements ICellModifier {
if (obj instanceof View) {
final EObject designerElement = ((View) obj).getElement();
if (designerElement instanceof DDiagram) {
- final List<Layer> activatedLayers = ((DDiagram) designerElement).getActivatedLayers();
+ final List<Layer> activatedLayers = new DDiagramQuery((DDiagram) designerElement).getAllActivatedLayers();
if (EqualityHelper.contains(activatedLayers, (EObject) element)) {
result = Boolean.TRUE;
} else {
diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/views/providers/layers/LayersLabelProvider.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/views/providers/layers/LayersLabelProvider.java
index fc00becd04..edb5d28dd8 100644
--- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/views/providers/layers/LayersLabelProvider.java
+++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/views/providers/layers/LayersLabelProvider.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009 THALES GLOBAL SERVICES.
+ * Copyright (c) 2009, 2017 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
@@ -23,6 +23,7 @@ import org.eclipse.sirius.common.tools.api.util.EqualityHelper;
import org.eclipse.sirius.common.tools.api.util.StringUtil;
import org.eclipse.sirius.common.ui.tools.api.util.ImageProvider;
import org.eclipse.sirius.diagram.DDiagram;
+import org.eclipse.sirius.diagram.business.api.query.DDiagramQuery;
import org.eclipse.sirius.diagram.description.Layer;
import org.eclipse.sirius.diagram.ui.provider.DiagramUIPlugin;
import org.eclipse.sirius.diagram.ui.tools.api.image.DiagramImagesPath;
@@ -65,7 +66,7 @@ public class LayersLabelProvider extends ColumnLabelProvider {
if (obj instanceof View) {
final EObject designerElement = ((View) obj).getElement();
if (designerElement instanceof DDiagram) {
- final List<Layer> activatedLayers = ((DDiagram) designerElement).getActivatedLayers();
+ final List<Layer> activatedLayers = new DDiagramQuery((DDiagram) designerElement).getAllActivatedLayers();
Image img = null;
if (EqualityHelper.contains(activatedLayers, (EObject) element)) {
img = DiagramUIPlugin.getPlugin().getBundledImage(DiagramImagesPath.ACTIVE_LAYER_ICON);
diff --git a/plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/business/internal/dialect/DiagramDialectServices.java b/plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/business/internal/dialect/DiagramDialectServices.java
index 250be1a2fa..9b7fd8b0c4 100644
--- a/plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/business/internal/dialect/DiagramDialectServices.java
+++ b/plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/business/internal/dialect/DiagramDialectServices.java
@@ -48,6 +48,7 @@ import org.eclipse.sirius.diagram.Messages;
import org.eclipse.sirius.diagram.business.api.componentization.DiagramDescriptionMappingsRegistry;
import org.eclipse.sirius.diagram.business.api.helper.display.DisplayMode;
import org.eclipse.sirius.diagram.business.api.helper.display.DisplayServiceManager;
+import org.eclipse.sirius.diagram.business.api.query.DDiagramQuery;
import org.eclipse.sirius.diagram.business.api.query.EObjectQuery;
import org.eclipse.sirius.diagram.business.api.refresh.CanonicalSynchronizer;
import org.eclipse.sirius.diagram.business.api.refresh.CanonicalSynchronizerFactory;
@@ -365,14 +366,12 @@ public class DiagramDialectServices extends AbstractRepresentationDialectService
if (layer instanceof AdditionalLayer) {
AdditionalLayer additionalLayer = (AdditionalLayer) layer;
- // Change Layer Activation if the Sirius is activated and
- // layer deactivated
- Boolean shouldChangeLayerActivation = activated && !diagram.getActivatedLayers().contains(additionalLayer);
- // Change Layer Activation if the Sirius is deactivated and
- // layer activated
- shouldChangeLayerActivation = shouldChangeLayerActivation || (!activated && diagram.getActivatedLayers().contains(additionalLayer));
- // Change Layer Activation if the layer is mandatory or active
- // by default
+ List<Layer> allActivatedLayers = new DDiagramQuery(diagram).getAllActivatedLayers();
+ // Change Layer Activation if the Viewpoint is activated and layer deactivated
+ Boolean shouldChangeLayerActivation = activated && !allActivatedLayers.contains(additionalLayer);
+ // Change Layer Activation if the Viewpoint is deactivated and layer activated
+ shouldChangeLayerActivation = shouldChangeLayerActivation || (!activated && allActivatedLayers.contains(additionalLayer));
+ // Change Layer Activation if the layer is mandatory or active by default
shouldChangeLayerActivation = shouldChangeLayerActivation && (!additionalLayer.isOptional() || additionalLayer.isActiveByDefault());
if (shouldChangeLayerActivation) {
diff --git a/plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/business/internal/metamodel/operations/DDiagramElementContainerSpecOperations.java b/plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/business/internal/metamodel/operations/DDiagramElementContainerSpecOperations.java
index bd200d4f7c..03c1fdd3f7 100644
--- a/plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/business/internal/metamodel/operations/DDiagramElementContainerSpecOperations.java
+++ b/plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/business/internal/metamodel/operations/DDiagramElementContainerSpecOperations.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2016 THALES GLOBAL SERVICES.
+ * Copyright (c) 2007, 2017 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
@@ -33,6 +33,7 @@ import org.eclipse.sirius.diagram.DNodeListElement;
import org.eclipse.sirius.diagram.DSemanticDiagram;
import org.eclipse.sirius.diagram.DragAndDropTarget;
import org.eclipse.sirius.diagram.Messages;
+import org.eclipse.sirius.diagram.business.api.query.DDiagramQuery;
import org.eclipse.sirius.diagram.business.api.query.DiagramElementMappingQuery;
import org.eclipse.sirius.diagram.business.internal.metamodel.description.extensions.IContainerMappingExt;
import org.eclipse.sirius.diagram.business.internal.metamodel.helper.ContainerMappingHelper;
@@ -379,7 +380,7 @@ public final class DDiagramElementContainerSpecOperations {
if (diagram.getDescription().getDefaultLayer() != null) {
final Collection<AbstractToolDescription> allActivatedTools = Sets.newHashSet();
allActivatedTools.addAll(diagram.getDescription().getDefaultLayer().getAllTools());
- for (Layer layer : diagram.getActivatedLayers()) {
+ for (Layer layer : new DDiagramQuery(diagram).getAllActivatedLayers()) {
allActivatedTools.addAll(layer.getAllTools());
}
Collection<ContainerDropDescription> dropTools = DDiagramElementContainerSpecOperations.getDropTools(mapping);
diff --git a/plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/business/internal/query/PasteTargetQuery.java b/plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/business/internal/query/PasteTargetQuery.java
index e76d890bbb..8e53452bc5 100644
--- a/plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/business/internal/query/PasteTargetQuery.java
+++ b/plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/business/internal/query/PasteTargetQuery.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011 THALES GLOBAL SERVICES.
+ * Copyright (c) 2011, 2017 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
@@ -14,6 +14,7 @@ import java.util.Collection;
import org.eclipse.sirius.diagram.DDiagram;
import org.eclipse.sirius.diagram.DDiagramElement;
+import org.eclipse.sirius.diagram.business.api.query.DDiagramQuery;
import org.eclipse.sirius.diagram.business.api.query.DiagramDescriptionQuery;
import org.eclipse.sirius.diagram.business.api.query.DiagramElementMappingQuery;
import org.eclipse.sirius.diagram.description.DiagramDescription;
@@ -73,7 +74,7 @@ public class PasteTargetQuery {
if (dDiagram.getDescription().getDefaultLayer() != null) {
final Collection<AbstractToolDescription> allActivatedTools = Sets.newHashSet();
allActivatedTools.addAll(dDiagram.getDescription().getDefaultLayer().getAllTools());
- for (Layer layer : dDiagram.getActivatedLayers()) {
+ for (Layer layer : new DDiagramQuery(dDiagram).getAllActivatedLayers()) {
allActivatedTools.addAll(layer.getAllTools());
}
Collection<PasteDescription> pasteTools = getAllPasteTools(pasteTargetDescription);
diff --git a/plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/tools/api/command/ChangeLayerActivationCommand.java b/plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/tools/api/command/ChangeLayerActivationCommand.java
index 1e141b2373..3a98536c3c 100644
--- a/plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/tools/api/command/ChangeLayerActivationCommand.java
+++ b/plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/tools/api/command/ChangeLayerActivationCommand.java
@@ -24,6 +24,7 @@ import org.eclipse.sirius.common.tools.api.listener.NotificationUtil;
import org.eclipse.sirius.diagram.DDiagram;
import org.eclipse.sirius.diagram.Messages;
import org.eclipse.sirius.diagram.business.api.helper.decoration.DecorationHelper;
+import org.eclipse.sirius.diagram.business.api.query.DDiagramQuery;
import org.eclipse.sirius.diagram.business.internal.metamodel.helper.LayerHelper;
import org.eclipse.sirius.diagram.description.AdditionalLayer;
import org.eclipse.sirius.diagram.description.Layer;
@@ -57,7 +58,7 @@ public final class ChangeLayerActivationCommand extends RecordingCommand {
* activation changes
*/
public ChangeLayerActivationCommand(TransactionalEditingDomain domain, DDiagram dDiagram, Layer layer, IProgressMonitor monitor) {
- super(domain, dDiagram.getActivatedLayers().contains(layer) ? Messages.ChangeLayerActivationCommand_hideLabel
+ super(domain, new DDiagramQuery(dDiagram).getAllActivatedLayers().contains(layer) ? Messages.ChangeLayerActivationCommand_hideLabel
: MessageFormat.format(Messages.ChangeLayerActivationCommand_showLabel, new IdentifiedElementQuery(layer).getLabel()));
this.dDiagram = dDiagram;
this.layer = layer;

Back to the top