Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEsteban Dugueperoux2016-02-02 14:44:44 +0000
committerEsteban Dugueperoux2016-02-11 13:50:49 +0000
commitd462f5445529a04e9f33e9631a029cb4021b20c5 (patch)
tree58800e219f2367742bd024ff1bca413842fae407
parent3dbdc21d199b8d98e00bfa83dccb62b7637beded (diff)
downloadorg.eclipse.sirius-d462f5445529a04e9f33e9631a029cb4021b20c5.tar.gz
org.eclipse.sirius-d462f5445529a04e9f33e9631a029cb4021b20c5.tar.xz
org.eclipse.sirius-d462f5445529a04e9f33e9631a029cb4021b20c5.zip
[486330] Don't create/refresh a DRepresentation without needed viewpoint
- Don't create/refresh a DRepresentation if some required viewpoints are missing. - For tree/table it is simply the viewpoint containing the related RepresentationDescription, for diagram it is all viewpoints owning RepresentationDescription providing layer to the diagram to refresh. - Consequently DialectServices.getRequiredViewpoints(DRepresentation) API method has been added to know the required viewpoints to refresh a representation. And AbstractRepresentationDialectServices. Bug: 486330 Change-Id: Ifd679f690647842a06b43d64d95c2dcb67992614 Signed-off-by: Esteban Dugueperoux <esteban.dugueperoux@obeo.fr>
-rw-r--r--plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/business/internal/dialect/DiagramDialectUIServices.java12
-rw-r--r--plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/business/internal/dialect/DiagramDialectServices.java61
-rw-r--r--plugins/org.eclipse.sirius.doc/doc/Release_Notes.html11
-rw-r--r--plugins/org.eclipse.sirius.doc/doc/Release_Notes.textile3
-rw-r--r--plugins/org.eclipse.sirius.table/src/org/eclipse/sirius/table/business/internal/dialect/TableDialectServices.java18
-rw-r--r--plugins/org.eclipse.sirius.tree/src/org/eclipse/sirius/tree/business/internal/dialect/TreeDialectServices.java17
-rw-r--r--plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/api/dialect/AbstractRepresentationDialectServices.java61
-rw-r--r--plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/api/dialect/DialectServices.java24
-rw-r--r--plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/internal/dialect/DialectManagerImpl.java15
9 files changed, 177 insertions, 45 deletions
diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/business/internal/dialect/DiagramDialectUIServices.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/business/internal/dialect/DiagramDialectUIServices.java
index abfffd8b7d..f0efdbb7d1 100644
--- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/business/internal/dialect/DiagramDialectUIServices.java
+++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/business/internal/dialect/DiagramDialectUIServices.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2015 THALES GLOBAL SERVICES and others.
+ * Copyright (c) 2007, 2016 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
@@ -55,6 +55,7 @@ import org.eclipse.gmf.runtime.notation.View;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.sirius.business.api.dialect.DialectManager;
import org.eclipse.sirius.business.api.helper.SiriusResourceHelper;
import org.eclipse.sirius.business.api.query.EObjectQuery;
import org.eclipse.sirius.business.api.query.URIQuery;
@@ -222,14 +223,7 @@ public class DiagramDialectUIServices implements DialectUIServices {
}
private Set<Viewpoint> activateNeededViewpoints(Session session, DDiagram dDiagram, IProgressMonitor monitor) {
- List<Layer> activatedLayers = dDiagram.getActivatedLayers();
- Set<Viewpoint> neededViewpoints = new LinkedHashSet<Viewpoint>();
- for (Layer activatedLayer : activatedLayers) {
- if (!activatedLayer.eIsProxy() && activatedLayer.eContainer() != null) {
- Viewpoint viewpoint = (Viewpoint) activatedLayer.eContainer().eContainer();
- neededViewpoints.add(viewpoint);
- }
- }
+ Set<Viewpoint> neededViewpoints = DialectManager.INSTANCE.getRequiredViewpoints(dDiagram);
Set<Viewpoint> selectedViewpoints = new LinkedHashSet<Viewpoint>();
for (Viewpoint viewpoint : session.getSelectedViewpoints(false)) {
selectedViewpoints.add(SiriusResourceHelper.getCorrespondingViewpoint(session, viewpoint));
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 ff3d6636af..5cef32dcf8 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
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2015 THALES GLOBAL SERVICES.
+ * Copyright (c) 2007, 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
@@ -12,6 +12,7 @@ package org.eclipse.sirius.diagram.business.internal.dialect;
import java.text.MessageFormat;
import java.util.Collection;
+import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -121,27 +122,31 @@ public class DiagramDialectServices extends AbstractRepresentationDialectService
public boolean canCreate(final EObject semantic, final RepresentationDescription desc) {
boolean result = false;
if (semantic != null && isSupported(desc)) {
- DiagramDescription diagDesc = (DiagramDescription) desc;
- ModelAccessor accessor = SiriusPlugin.getDefault().getModelAccessorRegistry().getModelAccessor(semantic);
- if (accessor != null) {
- result = checkDomainClass(accessor, semantic, diagDesc.getDomainClass());
-
- // If the representation is a diagram description
- boolean needsToCheckSemanticElement = true;
- // We first check if the diagram description has a non null
- // initial operation
- if ((diagDesc.getInit() == null) || (diagDesc.getInit().getInitialOperation() == null) || (diagDesc.getInit().getInitialOperation().getFirstModelOperations() == null)) {
- // If the diagram description has no initial operation
- // we do not need to check the semantic element
- // => true will be returned
- needsToCheckSemanticElement = false;
- }
+ Session session = new EObjectQuery(semantic).getSession();
+ // If the semantic doesn't belong to a session we don't check
+ // viewpoint selection but only others things like domainClass
+ if (session == null || isRelatedViewpointSelected(session, desc)) {
+ DiagramDescription diagDesc = (DiagramDescription) desc;
+ ModelAccessor accessor = SiriusPlugin.getDefault().getModelAccessorRegistry().getModelAccessor(semantic);
+ if (accessor != null) {
+ result = checkDomainClass(accessor, semantic, diagDesc.getDomainClass());
+ // If the representation is a diagram description
+ boolean needsToCheckSemanticElement = true;
+ // We first check if the diagram description has a non null
+ // initial operation
+ if ((diagDesc.getInit() == null) || (diagDesc.getInit().getInitialOperation() == null) || (diagDesc.getInit().getInitialOperation().getFirstModelOperations() == null)) {
+ // If the diagram description has no initial operation
+ // we do not need to check the semantic element
+ // => true will be returned
+ needsToCheckSemanticElement = false;
+ }
- if (needsToCheckSemanticElement) {
- result = result && checkSemanticElementCanBeFilled(accessor, semantic);
+ if (needsToCheckSemanticElement) {
+ result = result && checkSemanticElementCanBeFilled(accessor, semantic);
+ }
}
+ result = result && checkPrecondition(semantic, diagDesc.getPreconditionExpression());
}
- result = result && checkPrecondition(semantic, diagDesc.getPreconditionExpression());
}
return result;
}
@@ -173,7 +178,7 @@ public class DiagramDialectServices extends AbstractRepresentationDialectService
monitor.subTask(MessageFormat.format(Messages.DiagramDialectServices_createDiagramMsg, name));
diagram = createRepresentation(name, semantic, description, new SubProgressMonitor(monitor, 2));
if (diagram != null) {
- refresh(diagram, new SubProgressMonitor(monitor, 26));
+ DialectManager.INSTANCE.refresh(diagram, new SubProgressMonitor(monitor, 26));
if (DisplayMode.NORMAL.equals(DisplayServiceManager.INSTANCE.getMode())) {
DisplayServiceManager.INSTANCE.getDisplayService().refreshAllElementsVisibility((DDiagram) diagram);
monitor.worked(1);
@@ -263,6 +268,22 @@ public class DiagramDialectServices extends AbstractRepresentationDialectService
}
}
+ @Override
+ public Set<Viewpoint> getRequiredViewpoints(DRepresentation representation) {
+ Set<Viewpoint> requiredViewpoints = super.getRequiredViewpoints(representation);
+ if (representation instanceof DDiagram) {
+ DDiagram dDiagram = (DDiagram) representation;
+ List<Layer> activatedLayers = dDiagram.getActivatedLayers();
+ for (Layer activatedLayer : activatedLayers) {
+ if (!activatedLayer.eIsProxy() && activatedLayer.eContainer() != null) {
+ Viewpoint viewpoint = (Viewpoint) activatedLayer.eContainer().eContainer();
+ requiredViewpoints.add(viewpoint);
+ }
+ }
+ }
+ return requiredViewpoints;
+ }
+
/**
* {@inheritDoc}
*/
diff --git a/plugins/org.eclipse.sirius.doc/doc/Release_Notes.html b/plugins/org.eclipse.sirius.doc/doc/Release_Notes.html
index 0df94a3b04..615f0dd68c 100644
--- a/plugins/org.eclipse.sirius.doc/doc/Release_Notes.html
+++ b/plugins/org.eclipse.sirius.doc/doc/Release_Notes.html
@@ -134,6 +134,17 @@
<li><span class="label label-success">Added</span>
<code>org.eclipse.sirius.tools.api.command.ui.NoUICallback.askForTypedVariable(List&lt;TypedVariable&gt;, List&lt;String&gt;)</code> has been created.
</li>
+ <li><span class="label label-success">Added</span>
+ <code>org.eclipse.sirius.business.api.dialect.DialectServices.getRequiredViewpoints(DRepresentation)</code> has been added to have mean to get required viewpoints to use a representation.
+ </li>
+ <li><span class="label label-success">Added</span>
+ <code>org.eclipse.sirius.business.api.dialect.AbstractRepresentationDialectServices.getRequiredViewpoints(DRepresentation)</code> has been added to have a default implementation of
+ <code>DialectServices.getRequiredViewpoints(DRepresentation)</code> method.
+ </li>
+ <li><span class="label label-success">Added</span>
+ <code>org.eclipse.sirius.business.api.dialect.AbstractRepresentationDialectServices.isRelatedViewpointSelected(Session, RepresentationDescription)</code> protected method has been added to check if a
+ <code>RepresentationDescription</code> is usable in the context of the specified session.
+ </li>
<li><span class="label label-info">Modified</span>
<code>org.eclipse.sirius.viewpoint.description.tool.SelectModelElementVariable</code> now implements
<code>org.eclipse.sirius.viewpoint.description.InteractiveVariableDescription</code>.
diff --git a/plugins/org.eclipse.sirius.doc/doc/Release_Notes.textile b/plugins/org.eclipse.sirius.doc/doc/Release_Notes.textile
index a4bb19fac4..34172051e0 100644
--- a/plugins/org.eclipse.sirius.doc/doc/Release_Notes.textile
+++ b/plugins/org.eclipse.sirius.doc/doc/Release_Notes.textile
@@ -30,6 +30,9 @@ h4. Changes in @org.eclipse.sirius@
* <span class="label label-success">Added</span> @org.eclipse.sirius.viewpoint.description.InteractiveVariableDescription@ has been created as tag interface for variables that require user interaction to be valued.
* <span class="label label-success">Added</span> @org.eclipse.sirius.tools.api.command.ui.UICallBack.askForTypedVariable(List<TypedVariable>, List<String>)@ has been created.
* <span class="label label-success">Added</span> @org.eclipse.sirius.tools.api.command.ui.NoUICallback.askForTypedVariable(List<TypedVariable>, List<String>)@ has been created.
+* <span class="label label-success">Added</span> @org.eclipse.sirius.business.api.dialect.DialectServices.getRequiredViewpoints(DRepresentation)@ has been added to have mean to get required viewpoints to use a representation.
+* <span class="label label-success">Added</span> @org.eclipse.sirius.business.api.dialect.AbstractRepresentationDialectServices.getRequiredViewpoints(DRepresentation)@ has been added to have a default implementation of @DialectServices.getRequiredViewpoints(DRepresentation)@ method.
+* <span class="label label-success">Added</span> @org.eclipse.sirius.business.api.dialect.AbstractRepresentationDialectServices.isRelatedViewpointSelected(Session, RepresentationDescription)@ protected method has been added to check if a @RepresentationDescription@ is usable in the context of the specified session.
* <span class="label label-info">Modified</span> @org.eclipse.sirius.viewpoint.description.tool.SelectModelElementVariable@ now implements @org.eclipse.sirius.viewpoint.description.InteractiveVariableDescription@.
* <span class="label label-info">Modified</span> @org.eclipse.sirius.viewpoint.description.tool.AbstractVariable@ has been moved to @org.eclipse.sirius.viewpoint.description.AbstractVariable@.
* <span class="label label-info">Modified</span> @org.eclipse.sirius.viewpoint.description.tool.SubVariable@ has been moved to @org.eclipse.sirius.viewpoint.description.SubVariable@.
diff --git a/plugins/org.eclipse.sirius.table/src/org/eclipse/sirius/table/business/internal/dialect/TableDialectServices.java b/plugins/org.eclipse.sirius.table/src/org/eclipse/sirius/table/business/internal/dialect/TableDialectServices.java
index 5c3c021470..3249c983e2 100644
--- a/plugins/org.eclipse.sirius.table/src/org/eclipse/sirius/table/business/internal/dialect/TableDialectServices.java
+++ b/plugins/org.eclipse.sirius.table/src/org/eclipse/sirius/table/business/internal/dialect/TableDialectServices.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2015 THALES GLOBAL SERVICES and others.
+ * Copyright (c) 2007, 2016 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
@@ -29,6 +29,7 @@ import org.eclipse.emf.transaction.util.TransactionUtil;
import org.eclipse.sirius.business.api.dialect.AbstractRepresentationDialectServices;
import org.eclipse.sirius.business.api.dialect.description.IInterpretedExpressionQuery;
import org.eclipse.sirius.business.api.query.DRepresentationElementQuery;
+import org.eclipse.sirius.business.api.query.EObjectQuery;
import org.eclipse.sirius.business.api.query.IdentifiedElementQuery;
import org.eclipse.sirius.business.api.session.CustomDataConstants;
import org.eclipse.sirius.business.api.session.Session;
@@ -112,12 +113,17 @@ public class TableDialectServices extends AbstractRepresentationDialectServices
public boolean canCreate(final EObject semantic, final RepresentationDescription desc) {
boolean result = false;
if (semantic != null && isSupported(desc)) {
- TableDescription tableDesc = (TableDescription) desc;
- ModelAccessor accessor = SiriusPlugin.getDefault().getModelAccessorRegistry().getModelAccessor(semantic);
- if (accessor != null) {
- result = checkDomainClass(accessor, semantic, tableDesc.getDomainClass());
+ Session session = new EObjectQuery(semantic).getSession();
+ // If the semantic doesn't belong to a session we don't check
+ // viewpoint selection but only others things like domainClass
+ if (session == null || isRelatedViewpointSelected(session, desc)) {
+ TableDescription tableDesc = (TableDescription) desc;
+ ModelAccessor accessor = SiriusPlugin.getDefault().getModelAccessorRegistry().getModelAccessor(semantic);
+ if (accessor != null) {
+ result = checkDomainClass(accessor, semantic, tableDesc.getDomainClass());
+ }
+ result = result && checkPrecondition(semantic, tableDesc.getPreconditionExpression());
}
- result = result && checkPrecondition(semantic, tableDesc.getPreconditionExpression());
}
return result;
}
diff --git a/plugins/org.eclipse.sirius.tree/src/org/eclipse/sirius/tree/business/internal/dialect/TreeDialectServices.java b/plugins/org.eclipse.sirius.tree/src/org/eclipse/sirius/tree/business/internal/dialect/TreeDialectServices.java
index f5d3340b15..1b721258bc 100644
--- a/plugins/org.eclipse.sirius.tree/src/org/eclipse/sirius/tree/business/internal/dialect/TreeDialectServices.java
+++ b/plugins/org.eclipse.sirius.tree/src/org/eclipse/sirius/tree/business/internal/dialect/TreeDialectServices.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010, 2015 THALES GLOBAL SERVICES and others.
+ * Copyright (c) 2010, 2016 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
@@ -216,12 +216,17 @@ public class TreeDialectServices extends AbstractRepresentationDialectServices {
public boolean canCreate(EObject semantic, RepresentationDescription desc) {
boolean result = false;
if (semantic != null && isSupported(desc)) {
- TreeDescription treeDesc = (TreeDescription) desc;
- ModelAccessor accessor = SiriusPlugin.getDefault().getModelAccessorRegistry().getModelAccessor(semantic);
- if (accessor != null) {
- result = checkDomainClass(accessor, semantic, treeDesc.getDomainClass());
+ Session session = new EObjectQuery(semantic).getSession();
+ // If the semantic doesn't belong to a session we don't check
+ // viewpoint selection but only others things like domainClass
+ if (session == null || isRelatedViewpointSelected(session, desc)) {
+ TreeDescription treeDesc = (TreeDescription) desc;
+ ModelAccessor accessor = SiriusPlugin.getDefault().getModelAccessorRegistry().getModelAccessor(semantic);
+ if (accessor != null) {
+ result = checkDomainClass(accessor, semantic, treeDesc.getDomainClass());
+ }
+ result = result && checkPrecondition(semantic, treeDesc.getPreconditionExpression());
}
- result = result && checkPrecondition(semantic, treeDesc.getPreconditionExpression());
}
return result;
}
diff --git a/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/api/dialect/AbstractRepresentationDialectServices.java b/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/api/dialect/AbstractRepresentationDialectServices.java
index e603fedb9b..b824a8b6af 100644
--- a/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/api/dialect/AbstractRepresentationDialectServices.java
+++ b/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/api/dialect/AbstractRepresentationDialectServices.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009, 2015 THALES GLOBAL SERVICES and others.
+ * Copyright (c) 2009, 2016 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
@@ -14,6 +14,7 @@ import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
+import java.util.LinkedHashSet;
import java.util.Map;
import java.util.Set;
@@ -27,6 +28,8 @@ import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.sirius.business.api.dialect.identifier.RepresentationElementIdentifier;
import org.eclipse.sirius.business.api.helper.SiriusUtil;
import org.eclipse.sirius.business.api.helper.task.AbstractCommandTask;
+import org.eclipse.sirius.business.api.query.EObjectQuery;
+import org.eclipse.sirius.business.api.query.RepresentationDescriptionQuery;
import org.eclipse.sirius.business.api.query.ViewpointQuery;
import org.eclipse.sirius.business.api.session.CustomDataConstants;
import org.eclipse.sirius.business.api.session.Session;
@@ -40,6 +43,7 @@ import org.eclipse.sirius.tools.api.command.CommandContext;
import org.eclipse.sirius.tools.api.command.ui.UICallBack;
import org.eclipse.sirius.tools.api.interpreter.InterpreterUtil;
import org.eclipse.sirius.viewpoint.DRepresentation;
+import org.eclipse.sirius.viewpoint.DSemanticDecorator;
import org.eclipse.sirius.viewpoint.Messages;
import org.eclipse.sirius.viewpoint.ViewpointPackage;
import org.eclipse.sirius.viewpoint.description.RepresentationDescription;
@@ -176,7 +180,60 @@ public abstract class AbstractRepresentationDialectServices implements DialectSe
*/
@Override
public boolean canRefresh(DRepresentation representation) {
- return isSupported(representation);
+ return isSupported(representation) && areRequiredViewpointsSelected(representation);
+ }
+
+ private boolean areRequiredViewpointsSelected(DRepresentation representation) {
+ boolean areRequiredViewpointsSelected = false;
+ if (representation != null) {
+ Collection<Viewpoint> requiredViewpoints = getRequiredViewpoints(representation);
+ if (!requiredViewpoints.isEmpty()) {
+ Session session = new EObjectQuery(representation).getSession();
+ if (session == null) {
+ // To manage case representation is in creation then not yet
+ // added to session, for example on viewpoint first
+ // selection
+ EObject target = ((DSemanticDecorator) representation).getTarget();
+ session = new EObjectQuery(target).getSession();
+ }
+ if (session != null) {
+ areRequiredViewpointsSelected = session.getSelectedViewpoints(false).containsAll(requiredViewpoints);
+ }
+ }
+ }
+ return areRequiredViewpointsSelected;
+ }
+
+ /**
+ * Tell if the {@link Viewpoint} owner of the
+ * {@link RepresentationDescription} is enabled on {@link Session}.
+ *
+ * @param session
+ * the {@link Session}
+ * @param representationDescription
+ * a {@link RepresentationDescription} in the context of the
+ * {@link Session}
+ * @return true if the {@link Viewpoint} owner of the
+ * {@link RepresentationDescription} is enabled on {@link Session}
+ */
+ protected boolean isRelatedViewpointSelected(Session session, RepresentationDescription representationDescription) {
+ boolean isRelatedViewpointSelected = false;
+ Viewpoint parentViewpoint = new RepresentationDescriptionQuery(representationDescription).getParentViewpoint();
+ isRelatedViewpointSelected = session != null && parentViewpoint != null && session.getSelectedViewpoints(false).contains(parentViewpoint);
+ return isRelatedViewpointSelected;
+ }
+
+ @Override
+ public Set<Viewpoint> getRequiredViewpoints(DRepresentation representation) {
+ Set<Viewpoint> requiredViewpoints = new LinkedHashSet<Viewpoint>();
+ RepresentationDescription representationDescription = getDescription(representation);
+ if (representationDescription != null) {
+ Viewpoint parentViewpoint = new RepresentationDescriptionQuery(representationDescription).getParentViewpoint();
+ if (parentViewpoint != null) {
+ requiredViewpoints.add(parentViewpoint);
+ }
+ }
+ return requiredViewpoints;
}
/**
diff --git a/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/api/dialect/DialectServices.java b/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/api/dialect/DialectServices.java
index f527947fea..c1d9bfe94e 100644
--- a/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/api/dialect/DialectServices.java
+++ b/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/api/dialect/DialectServices.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2014 THALES GLOBAL SERVICES.
+ * Copyright (c) 2007, 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
@@ -12,6 +12,7 @@ package org.eclipse.sirius.business.api.dialect;
import java.util.Collection;
import java.util.Map;
+import java.util.Set;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.emf.common.notify.Notification;
@@ -176,10 +177,14 @@ public interface DialectServices {
/**
* Tell whether the dialect is able to refresh the given representation.
*
+ * NOTE: a prerequisite to have a {@link DRepresentation} refreshable is to
+ * have its required viewpoints selected in the current session.
+ *
* @param representation
* representation to refresh.
* @return true if the dialect can refresh the representation, false
* otherwise.
+ * @see DialectServices#getRequiredViewpoints(DRepresentation)
*/
boolean canRefresh(DRepresentation representation);
@@ -187,6 +192,9 @@ public interface DialectServices {
* Tell whether the dialect is able to create a representation from the
* given representation description and the semantic object.
*
+ * NOTE: If the semantic does not belong to a session we do not check that
+ * required viewpoint is selected but only others things like domainClass
+ *
* @param semantic
* semantic object used to create the representation.
* @param desc
@@ -354,4 +362,18 @@ public interface DialectServices {
* @since 1.0.0 M6
*/
boolean allowsEStructuralFeatureCustomization(EObject element);
+
+ /**
+ * Tell which {@link Viewpoint viewpoints} are required to do a refresh of
+ * the specified <code>representation</code>.
+ *
+ * NOTE: only available viewpoints are returned. In some cases, the
+ * Viewpoint of a selected layer might not be available: for example if it
+ * is not installed.
+ *
+ * @param representation
+ * the specified {@link DRepresentation}
+ * @return the collection of required {@link Viewpoint viewpoints}
+ */
+ Set<Viewpoint> getRequiredViewpoints(DRepresentation representation);
}
diff --git a/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/internal/dialect/DialectManagerImpl.java b/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/internal/dialect/DialectManagerImpl.java
index f8fbb32703..d2121dbb9d 100644
--- a/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/internal/dialect/DialectManagerImpl.java
+++ b/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/internal/dialect/DialectManagerImpl.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2015 THALES GLOBAL SERVICES and others.
+ * Copyright (c) 2007, 2016 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
@@ -17,6 +17,7 @@ import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
@@ -592,4 +593,16 @@ public class DialectManagerImpl implements DialectManager {
}
return customizationAllowed;
}
+
+ @Override
+ public Set<Viewpoint> getRequiredViewpoints(DRepresentation representation) {
+ Set<Viewpoint> requiredViewpoints = null;
+ for (Dialect dialect : dialects.values()) {
+ if (dialect.getServices().handles(getDescription(representation))) {
+ requiredViewpoints = dialect.getServices().getRequiredViewpoints(representation);
+ break;
+ }
+ }
+ return requiredViewpoints;
+ }
}

Back to the top