Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCamille Letavernier2018-04-18 10:19:03 -0400
committerNicolas FAUVERGUE2018-05-22 11:59:19 -0400
commit9714b7607b138a564456b44221a927faeece9b6e (patch)
tree24baf74e72ae28f54feeccd99f161749910ca76c /plugins/infra
parent35f5a0c41fc41805277fbebfc3a090077e9fd562 (diff)
downloadorg.eclipse.papyrus-9714b7607b138a564456b44221a927faeece9b6e.tar.gz
org.eclipse.papyrus-9714b7607b138a564456b44221a927faeece9b6e.tar.xz
org.eclipse.papyrus-9714b7607b138a564456b44221a927faeece9b6e.zip
Bug 533701: [Sequence Diagram] Stereotype or Shape Compartments should
not be displayed in CombinedFragments https://bugs.eclipse.org/bugs/show_bug.cgi?id=533701 Add 2 services, to support filtering generic Papyrus IViewProviders and IEditPolicyProviders. Also add a simple contribution for the Sequence Diagram, to disable Symbols compartments. Change-Id: I0d6e1af0ad4395daf3170409b5735df36dd02d46 Signed-off-by: Camille Letavernier <cletavernier@eclipsesource.com>
Diffstat (limited to 'plugins/infra')
-rw-r--r--plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/editpolicies/EventListenerEditPolicyProvider.java4
-rw-r--r--plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/editpolicies/MarkerEventListenerEditPolicyProvider.java4
-rw-r--r--plugins/infra/gmfdiag/expansion/org.eclipse.papyrus.infra.gmfdiag.expansion/src/main/java/org/eclipse/papyrus/infra/gmfdiag/expansion/expansionmodel/providers/ExpandViewProvider.java102
-rw-r--r--plugins/infra/gmfdiag/expansion/org.eclipse.papyrus.infra.gmfdiag.expansion/src/main/java/org/eclipse/papyrus/infra/gmfdiag/expansion/expansionmodel/providers/InducedRepresentationPolicyProvider.java31
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/.project5
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/.settings/org.eclipse.pde.ds.annotations.prefs8
-rwxr-xr-xplugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/META-INF/MANIFEST.MF8
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/OSGI-INF/org.eclipse.papyrus.infra.gmfdiag.common.internal.service.EditPolicyProviderServiceImpl.xml8
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/OSGI-INF/org.eclipse.papyrus.infra.gmfdiag.common.internal.service.ViewProviderServiceImpl.xml8
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/build.properties3
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/plugin.xml12
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/internal/service/EditPolicyProviderServiceImpl.java41
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/internal/service/ViewProviderServiceImpl.java40
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/providers/CustomAbstractViewProvider.java12
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/providers/CustomEditPolicyProvider.java6
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/providers/ExternalReferenceEditPolicyProvider.java4
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/service/EditPolicyProviderService.java77
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/service/EditPolicyProviderTester.java39
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/service/ProviderServiceUtil.java130
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/service/ViewProviderService.java78
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/service/ViewProviderTester.java39
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.dnd/src/org/eclipse/papyrus/infra/gmfdiag/dnd/policy/CustomizableDropEditPolicyProvider.java6
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.hyperlink/src/org/eclipse/papyrus/infra/gmfdiag/hyperlink/providers/HyperlinkEditPolicyProvider.java6
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.navigation/src/org/eclipse/papyrus/infra/gmfdiag/navigation/provider/NavigationEditPolicyProvider.java4
24 files changed, 611 insertions, 64 deletions
diff --git a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/editpolicies/EventListenerEditPolicyProvider.java b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/editpolicies/EventListenerEditPolicyProvider.java
index 83e25a9444f..c405b974a4f 100644
--- a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/editpolicies/EventListenerEditPolicyProvider.java
+++ b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/editpolicies/EventListenerEditPolicyProvider.java
@@ -20,6 +20,7 @@ import org.eclipse.gmf.runtime.common.core.service.IOperation;
import org.eclipse.gmf.runtime.diagram.ui.services.editpolicy.CreateEditPoliciesOperation;
import org.eclipse.gmf.runtime.diagram.ui.services.editpolicy.IEditPolicyProvider;
import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
+import org.eclipse.papyrus.infra.gmfdiag.common.service.ProviderServiceUtil;
import org.eclipse.papyrus.infra.gmfdiag.css.helper.CSSHelper;
/**
@@ -35,6 +36,9 @@ public class EventListenerEditPolicyProvider extends AbstractProvider implements
public boolean provides(IOperation operation) {
CreateEditPoliciesOperation epOperation = (CreateEditPoliciesOperation) operation;
EditPart editPart = epOperation.getEditPart();
+ if (!ProviderServiceUtil.isEnabled(this, editPart)) {
+ return false;
+ }
if (!(editPart instanceof GraphicalEditPart)) {
return false;
}
diff --git a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/editpolicies/MarkerEventListenerEditPolicyProvider.java b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/editpolicies/MarkerEventListenerEditPolicyProvider.java
index a8e2bd07abc..e554468228c 100644
--- a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/editpolicies/MarkerEventListenerEditPolicyProvider.java
+++ b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css/src/org/eclipse/papyrus/infra/gmfdiag/css/editpolicies/MarkerEventListenerEditPolicyProvider.java
@@ -20,6 +20,7 @@ import org.eclipse.gmf.runtime.common.core.service.IOperation;
import org.eclipse.gmf.runtime.diagram.ui.services.editpolicy.CreateEditPoliciesOperation;
import org.eclipse.gmf.runtime.diagram.ui.services.editpolicy.IEditPolicyProvider;
import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
+import org.eclipse.papyrus.infra.gmfdiag.common.service.ProviderServiceUtil;
import org.eclipse.papyrus.infra.gmfdiag.css.helper.CSSHelper;
@@ -33,6 +34,9 @@ public class MarkerEventListenerEditPolicyProvider extends AbstractProvider impl
public boolean provides(IOperation operation) {
CreateEditPoliciesOperation epOperation = (CreateEditPoliciesOperation) operation;
EditPart editPart = epOperation.getEditPart();
+ if (!ProviderServiceUtil.isEnabled(this, editPart)) {
+ return false;
+ }
if (!(editPart instanceof GraphicalEditPart)) {
return false;
}
diff --git a/plugins/infra/gmfdiag/expansion/org.eclipse.papyrus.infra.gmfdiag.expansion/src/main/java/org/eclipse/papyrus/infra/gmfdiag/expansion/expansionmodel/providers/ExpandViewProvider.java b/plugins/infra/gmfdiag/expansion/org.eclipse.papyrus.infra.gmfdiag.expansion/src/main/java/org/eclipse/papyrus/infra/gmfdiag/expansion/expansionmodel/providers/ExpandViewProvider.java
index ee2abe66333..f33c8929c8f 100644
--- a/plugins/infra/gmfdiag/expansion/org.eclipse.papyrus.infra.gmfdiag.expansion/src/main/java/org/eclipse/papyrus/infra/gmfdiag/expansion/expansionmodel/providers/ExpandViewProvider.java
+++ b/plugins/infra/gmfdiag/expansion/org.eclipse.papyrus.infra.gmfdiag.expansion/src/main/java/org/eclipse/papyrus/infra/gmfdiag/expansion/expansionmodel/providers/ExpandViewProvider.java
@@ -26,6 +26,7 @@ import org.eclipse.gmf.runtime.notation.Diagram;
import org.eclipse.gmf.runtime.notation.View;
import org.eclipse.papyrus.infra.gmfdiag.common.Activator;
import org.eclipse.papyrus.infra.gmfdiag.common.providers.CustomAbstractViewProvider;
+import org.eclipse.papyrus.infra.gmfdiag.common.service.ProviderServiceUtil;
import org.eclipse.papyrus.infra.gmfdiag.expansion.expansionmodel.AbstractRepresentation;
import org.eclipse.papyrus.infra.gmfdiag.expansion.expansionmodel.RepresentationKind;
import org.eclipse.papyrus.infra.gmfdiag.expansion.expansionmodel.rendering.DiagramExpansionSingleton;
@@ -35,10 +36,10 @@ import org.eclipse.papyrus.infra.tools.util.ClassLoaderHelper;
import org.eclipse.papyrus.infra.viewpoints.policy.ViewPrototype;
/**
- *
+ *
* This class is a generic ViewProvider that is enable to create notation element by reading an expansion model
* See Requirement #Req org.eclipse.papyrus.infra.gmfdiag.expansion.Req_010
- * #Req org.eclipse.papyrus.infra.gmfdiag.expansion.Req_040
+ * #Req org.eclipse.papyrus.infra.gmfdiag.expansion.Req_040
*
*/
public class ExpandViewProvider extends CustomAbstractViewProvider implements IViewProvider {
@@ -76,44 +77,52 @@ public class ExpandViewProvider extends CustomAbstractViewProvider implements IV
@Override
protected boolean provides(CreateNodeViewOperation operation) {
+ if (!ProviderServiceUtil.isEnabled(this, operation.getContainerView())) {
+ return false;
+ }
return providesFromExpansionModel(operation);
}
+
@Override
protected boolean provides(CreateEdgeViewOperation operation) {
+ if (!ProviderServiceUtil.isEnabled(this, operation.getContainerView())) {
+ return false;
+ }
return providesFromExpansionModel(operation);
}
/**
* this method consults the expansion model to know if the view can be created in the current container.
- * @param operation the proposition of creation
+ *
+ * @param operation
+ * the proposition of creation
* @return true if the expansion model declare it, else false
*/
protected boolean providesFromExpansionModel(CreateChildViewOperation operation) {
String currentDiagramType = getDiagramType(operation.getContainerView());
- //this diagram is known as extended?
- if(diagramExpansionRegistry.mapChildreen.get(currentDiagramType)==null){
- Activator.log.trace(Activator.EXPANSION_TRACE,this.getClass().getName()+" " +currentDiagramType+ " not supported by loaded expansion model");
-
- //this diagram is unknown
+ // this diagram is known as extended?
+ if (diagramExpansionRegistry.mapChildreen.get(currentDiagramType) == null) {
+ Activator.log.trace(Activator.EXPANSION_TRACE, this.getClass().getName() + " " + currentDiagramType + " not supported by loaded expansion model");
+
+ // this diagram is unknown
return false;
}
- String graphicalType =operation.getSemanticHint();
+ String graphicalType = operation.getSemanticHint();
String containerType;
- if(operation.getContainerView() instanceof Diagram ){
- containerType=currentDiagramType;
- }
- else{
- containerType = operation.getContainerView().getType();
+ if (operation.getContainerView() instanceof Diagram) {
+ containerType = currentDiagramType;
+ } else {
+ containerType = operation.getContainerView().getType();
}
- Activator.log.trace(Activator.EXPANSION_TRACE,this.getClass().getName()+" try to create view in the container "+containerType+ " the view "+ operation.getSemanticHint()); //$NON-NLS-1$ //$NON-NLS-2$
- //get the list of childreen Id from a parent ID
- List<String> possibleChildreenIDs=diagramExpansionRegistry.mapChildreen.get(currentDiagramType).parentChildrenRelation.get(containerType);
- if(possibleChildreenIDs==null){
+ Activator.log.trace(Activator.EXPANSION_TRACE, this.getClass().getName() + " try to create view in the container " + containerType + " the view " + operation.getSemanticHint()); //$NON-NLS-1$ //$NON-NLS-2$
+ // get the list of childreen Id from a parent ID
+ List<String> possibleChildreenIDs = diagramExpansionRegistry.mapChildreen.get(currentDiagramType).parentChildrenRelation.get(containerType);
+ if (possibleChildreenIDs == null) {
return false;
}
- //the child ID is known?
- if(possibleChildreenIDs.contains(graphicalType)){
+ // the child ID is known?
+ if (possibleChildreenIDs.contains(graphicalType)) {
return true;
}
return false;
@@ -133,21 +142,20 @@ public class ExpandViewProvider extends CustomAbstractViewProvider implements IV
String currentDiagramType = getDiagramType(containerView);
// the map from the diagram ID
- if(diagramExpansionRegistry.mapChildreen.get(currentDiagramType)!=null){
- EObject eObject=diagramExpansionRegistry.mapChildreen.get(currentDiagramType).IDMap.get(graphicalType);
-
- //look for the representation and the view factory path
- if( eObject instanceof AbstractRepresentation){
- String viewFactoryPath=((AbstractRepresentation)eObject).getViewFactory();
- if( viewFactoryPath!=null&& (!"".equals(viewFactoryPath.trim()))){
- return ClassLoaderHelper.loadClass( viewFactoryPath);
- }
- else{
- RepresentationKind representationKind=((AbstractRepresentation)eObject).getKind();
- if(representationKind!=null){
- viewFactoryPath=representationKind.getViewFactory();
- if( viewFactoryPath!=null){
- return ClassLoaderHelper.loadClass( viewFactoryPath);
+ if (diagramExpansionRegistry.mapChildreen.get(currentDiagramType) != null) {
+ EObject eObject = diagramExpansionRegistry.mapChildreen.get(currentDiagramType).IDMap.get(graphicalType);
+
+ // look for the representation and the view factory path
+ if (eObject instanceof AbstractRepresentation) {
+ String viewFactoryPath = ((AbstractRepresentation) eObject).getViewFactory();
+ if (viewFactoryPath != null && (!"".equals(viewFactoryPath.trim()))) {
+ return ClassLoaderHelper.loadClass(viewFactoryPath);
+ } else {
+ RepresentationKind representationKind = ((AbstractRepresentation) eObject).getKind();
+ if (representationKind != null) {
+ viewFactoryPath = representationKind.getViewFactory();
+ if (viewFactoryPath != null) {
+ return ClassLoaderHelper.loadClass(viewFactoryPath);
}
}
}
@@ -158,20 +166,21 @@ public class ExpandViewProvider extends CustomAbstractViewProvider implements IV
/**
* get the diagram type from a view.
- * @param currentView the current view
+ *
+ * @param currentView
+ * the current view
* @return the diagram type it can be also a view point
*/
protected String getDiagramType(View currentView) {
- Diagram diagram=currentView.getDiagram();
- String currentDiagramType=null;
- ViewPrototype viewPrototype=org.eclipse.papyrus.infra.gmfdiag.common.utils.DiagramUtils.getPrototype(diagram);
- if(viewPrototype!=null){
- currentDiagramType=viewPrototype.getLabel();
+ Diagram diagram = currentView.getDiagram();
+ String currentDiagramType = null;
+ ViewPrototype viewPrototype = org.eclipse.papyrus.infra.gmfdiag.common.utils.DiagramUtils.getPrototype(diagram);
+ if (viewPrototype != null) {
+ currentDiagramType = viewPrototype.getLabel();
+ } else {
+ currentDiagramType = diagram.getType();
}
- else{
- currentDiagramType=diagram.getType();
- }
- diagramType=currentDiagramType;
+ diagramType = currentDiagramType;
return currentDiagramType;
}
@@ -182,11 +191,12 @@ public class ExpandViewProvider extends CustomAbstractViewProvider implements IV
protected Class<?> getEdgeViewClass(IAdaptable semanticAdapter, View containerView, String graphicalType) {
return getViewFactory(containerView, graphicalType);
}
+
/**
* {@inheritDoc}
*/
protected void initDiagramType() {
- diagramType=null;
+ diagramType = null;
}
diff --git a/plugins/infra/gmfdiag/expansion/org.eclipse.papyrus.infra.gmfdiag.expansion/src/main/java/org/eclipse/papyrus/infra/gmfdiag/expansion/expansionmodel/providers/InducedRepresentationPolicyProvider.java b/plugins/infra/gmfdiag/expansion/org.eclipse.papyrus.infra.gmfdiag.expansion/src/main/java/org/eclipse/papyrus/infra/gmfdiag/expansion/expansionmodel/providers/InducedRepresentationPolicyProvider.java
index 62548300d7b..0c0fafcb87b 100644
--- a/plugins/infra/gmfdiag/expansion/org.eclipse.papyrus.infra.gmfdiag.expansion/src/main/java/org/eclipse/papyrus/infra/gmfdiag/expansion/expansionmodel/providers/InducedRepresentationPolicyProvider.java
+++ b/plugins/infra/gmfdiag/expansion/org.eclipse.papyrus.infra.gmfdiag.expansion/src/main/java/org/eclipse/papyrus/infra/gmfdiag/expansion/expansionmodel/providers/InducedRepresentationPolicyProvider.java
@@ -21,6 +21,7 @@ import org.eclipse.gmf.runtime.diagram.ui.services.editpolicy.CreateEditPolicies
import org.eclipse.gmf.runtime.diagram.ui.services.editpolicy.IEditPolicyProvider;
import org.eclipse.gmf.runtime.notation.Diagram;
import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.infra.gmfdiag.common.service.ProviderServiceUtil;
import org.eclipse.papyrus.infra.gmfdiag.expansion.expansionmodel.rendering.DiagramExpansionSingleton;
import org.eclipse.papyrus.infra.gmfdiag.expansion.expansionmodel.rendering.DiagramExpansionsRegistry;
import org.eclipse.papyrus.infra.gmfdiag.expansion.expansionmodel.rendering.InducedRepresentationCreationEditPolicy;
@@ -34,7 +35,7 @@ import org.eclipse.papyrus.infra.viewpoints.policy.ViewPrototype;
public class InducedRepresentationPolicyProvider extends AbstractProvider implements IEditPolicyProvider {
- private DiagramExpansionsRegistry diagramExpansionRegistry=null;
+ private DiagramExpansionsRegistry diagramExpansionRegistry = null;
/**
* Constructor.
@@ -46,40 +47,46 @@ public class InducedRepresentationPolicyProvider extends AbstractProvider implem
/**
* get the diagram type from a view.
- * @param currentView the current view
+ *
+ * @param currentView
+ * the current view
* @return the diagram type it can be also a view point
*/
protected String getDiagramType(View currentView) {
- Diagram diagram=currentView.getDiagram();
- String currentDiagramType=null;
- ViewPrototype viewPrototype=org.eclipse.papyrus.infra.gmfdiag.common.utils.DiagramUtils.getPrototype(diagram);
- if(viewPrototype!=null){
- currentDiagramType=viewPrototype.getLabel();
- }
- else{
- currentDiagramType=diagram.getType();
+ Diagram diagram = currentView.getDiagram();
+ String currentDiagramType = null;
+ ViewPrototype viewPrototype = org.eclipse.papyrus.infra.gmfdiag.common.utils.DiagramUtils.getPrototype(diagram);
+ if (viewPrototype != null) {
+ currentDiagramType = viewPrototype.getLabel();
+ } else {
+ currentDiagramType = diagram.getType();
}
return currentDiagramType;
}
+
/**
* {@inheritDoc}
*/
@Override
public boolean provides(IOperation operation) {
CreateEditPoliciesOperation epOperation = (CreateEditPoliciesOperation) operation;
+ if (!ProviderServiceUtil.isEnabled(this, epOperation.getEditPart())) {
+ return false;
+ }
if (!(epOperation.getEditPart() instanceof IGraphicalEditPart)) {
return false;
}
// Make sure this concern Block Definition Diagram only
IGraphicalEditPart gep = (IGraphicalEditPart) epOperation.getEditPart();
- String diagramType=getDiagramType(gep.getNotationView());
- if(diagramExpansionRegistry.mapChildreen.get(diagramType)!=null){
+ String diagramType = getDiagramType(gep.getNotationView());
+ if (diagramExpansionRegistry.mapChildreen.get(diagramType) != null) {
return true;
}
return false;
}
+
/**
* {@inheritDoc}
*/
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/.project b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/.project
index 05fd2ab6c76..74df1fb5be0 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/.project
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/.project
@@ -46,6 +46,11 @@
<arguments>
</arguments>
</buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ds.core.builder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/.settings/org.eclipse.pde.ds.annotations.prefs b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/.settings/org.eclipse.pde.ds.annotations.prefs
new file mode 100644
index 00000000000..73a356b6d05
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/.settings/org.eclipse.pde.ds.annotations.prefs
@@ -0,0 +1,8 @@
+classpath=true
+dsVersion=V1_3
+eclipse.preferences.version=1
+enabled=true
+generateBundleActivationPolicyLazy=true
+path=OSGI-INF
+validationErrorLevel=error
+validationErrorLevel.missingImplicitUnbindMethod=error
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/META-INF/MANIFEST.MF b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/META-INF/MANIFEST.MF
index bef69e99cdd..7fc026b8a63 100755
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/META-INF/MANIFEST.MF
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/META-INF/MANIFEST.MF
@@ -4,8 +4,7 @@ Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.papyrus.infra.gmfdiag.common;singleton:=true
Bundle-Version: 3.100.0.qualifier
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
-Require-Bundle:
- org.eclipse.emf.ecore.edit;bundle-version="[2.9.0,3.0.0)",
+Require-Bundle: org.eclipse.emf.ecore.edit;bundle-version="[2.9.0,3.0.0)",
org.eclipse.gmf.runtime.diagram.ui.resources.editor;bundle-version="[1.7.0,2.0.0)";visibility:=reexport,
org.eclipse.papyrus.infra.emf.appearance;bundle-version="[2.0.0,3.0.0)",
org.eclipse.papyrus.infra.gmfdiag.commands;bundle-version="[3.0.0,4.0.0)";visibility:=reexport,
@@ -89,5 +88,8 @@ Export-Package: org.eclipse.papyrus.infra.gmfdiag.common,
org.eclipse.papyrus.infra.gmfdiag.internal.common.model;x-internal:=true
Import-Package: com.google.common.base;version="21.0.0",
com.google.common.collect;version="21.0.0",
- com.google.common.util.concurrent;version="21.0.0"
+ com.google.common.util.concurrent;version="21.0.0",
+ org.osgi.service.component.annotations;version="1.3.0";resolution:=optional
+Service-Component: OSGI-INF/org.eclipse.papyrus.infra.gmfdiag.common.internal.service.EditPolicyProviderServiceImpl.xml,
+ OSGI-INF/org.eclipse.papyrus.infra.gmfdiag.common.internal.service.ViewProviderServiceImpl.xml
Automatic-Module-Name: org.eclipse.papyrus.infra.gmfdiag.common
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/OSGI-INF/org.eclipse.papyrus.infra.gmfdiag.common.internal.service.EditPolicyProviderServiceImpl.xml b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/OSGI-INF/org.eclipse.papyrus.infra.gmfdiag.common.internal.service.EditPolicyProviderServiceImpl.xml
new file mode 100644
index 00000000000..20616bc68ae
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/OSGI-INF/org.eclipse.papyrus.infra.gmfdiag.common.internal.service.EditPolicyProviderServiceImpl.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="org.eclipse.papyrus.infra.gmfdiag.common.internal.service.EditPolicyProviderServiceImpl">
+ <service>
+ <provide interface="org.eclipse.papyrus.infra.gmfdiag.common.service.EditPolicyProviderService"/>
+ </service>
+ <reference bind="registerTester" interface="org.eclipse.papyrus.infra.gmfdiag.common.service.EditPolicyProviderTester" name="registerTester"/>
+ <implementation class="org.eclipse.papyrus.infra.gmfdiag.common.internal.service.EditPolicyProviderServiceImpl"/>
+</scr:component> \ No newline at end of file
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/OSGI-INF/org.eclipse.papyrus.infra.gmfdiag.common.internal.service.ViewProviderServiceImpl.xml b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/OSGI-INF/org.eclipse.papyrus.infra.gmfdiag.common.internal.service.ViewProviderServiceImpl.xml
new file mode 100644
index 00000000000..f9fb788e860
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/OSGI-INF/org.eclipse.papyrus.infra.gmfdiag.common.internal.service.ViewProviderServiceImpl.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="org.eclipse.papyrus.infra.gmfdiag.common.internal.service.ViewProviderServiceImpl">
+ <service>
+ <provide interface="org.eclipse.papyrus.infra.gmfdiag.common.service.ViewProviderService"/>
+ </service>
+ <reference bind="registerTester" interface="org.eclipse.papyrus.infra.gmfdiag.common.service.ViewProviderTester" name="registerTester"/>
+ <implementation class="org.eclipse.papyrus.infra.gmfdiag.common.internal.service.ViewProviderServiceImpl"/>
+</scr:component> \ No newline at end of file
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/build.properties b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/build.properties
index a1b5cb5e1a2..b9f2a05f653 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/build.properties
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/build.properties
@@ -8,7 +8,8 @@ bin.includes = .options,\
plugin.xml,\
schema/,\
icons/,\
- model/
+ model/,\
+ OSGI-INF/
output.. = bin/
jars.compile.order=.
src.includes = about.html
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/plugin.xml b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/plugin.xml
index c45d6968703..60026473a38 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/plugin.xml
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/plugin.xml
@@ -127,6 +127,18 @@
priority="1"
startKind="lazy">
</service>
+ <serviceFactory
+ classname="org.eclipse.papyrus.infra.gmfdiag.common.service.ViewProviderService$Factory"
+ id="org.eclipse.papyrus.infra.gmfdiag.common.service.ViewProviderService"
+ priority="1"
+ startKind="lazy">
+ </serviceFactory>
+ <serviceFactory
+ classname="org.eclipse.papyrus.infra.gmfdiag.common.service.EditPolicyProviderService$Factory"
+ id="org.eclipse.papyrus.infra.gmfdiag.common.service.EditPolicyProviderService"
+ priority="1"
+ startKind="lazy">
+ </serviceFactory>
</extension>
<extension
point="org.eclipse.papyrus.infra.services.labelprovider.labelProvider">
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/internal/service/EditPolicyProviderServiceImpl.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/internal/service/EditPolicyProviderServiceImpl.java
new file mode 100644
index 00000000000..ad13bf561cc
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/internal/service/EditPolicyProviderServiceImpl.java
@@ -0,0 +1,41 @@
+/*****************************************************************************
+ * Copyright (c) 2018 EclipseSource and others.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * EclipseSource - Initial API and implementation (Bug 533701)
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.gmfdiag.common.internal.service;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.eclipse.gef.EditPart;
+import org.eclipse.gmf.runtime.diagram.ui.services.editpolicy.IEditPolicyProvider;
+import org.eclipse.papyrus.infra.gmfdiag.common.service.EditPolicyProviderService;
+import org.eclipse.papyrus.infra.gmfdiag.common.service.EditPolicyProviderTester;
+import org.osgi.service.component.annotations.Component;
+import org.osgi.service.component.annotations.Reference;
+
+import com.google.common.base.Predicates;
+
+@Component
+public class EditPolicyProviderServiceImpl implements EditPolicyProviderService {
+
+ private Set<EditPolicyProviderTester> testers = new HashSet<>();
+
+ @Override
+ public boolean isEnabled(IEditPolicyProvider provider, EditPart editPart) {
+ return testers.stream().map(tester -> tester.isEnabled(provider, editPart)).noneMatch(Predicates.equalTo(Boolean.FALSE));
+ }
+
+ @Reference
+ public void registerTester(EditPolicyProviderTester tester) {
+ testers.add(tester);
+ }
+}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/internal/service/ViewProviderServiceImpl.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/internal/service/ViewProviderServiceImpl.java
new file mode 100644
index 00000000000..64b6ed738ae
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/internal/service/ViewProviderServiceImpl.java
@@ -0,0 +1,40 @@
+/*****************************************************************************
+ * Copyright (c) 2018 EclipseSource and others.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * EclipseSource - Initial API and implementation (Bug 533701)
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.gmfdiag.common.internal.service;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.eclipse.gmf.runtime.diagram.core.providers.IViewProvider;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.infra.gmfdiag.common.service.ViewProviderService;
+import org.eclipse.papyrus.infra.gmfdiag.common.service.ViewProviderTester;
+import org.osgi.service.component.annotations.Component;
+import org.osgi.service.component.annotations.Reference;
+
+@Component
+public class ViewProviderServiceImpl implements ViewProviderService {
+
+ private Set<ViewProviderTester> testers = new HashSet<>();
+
+ @Override
+ public boolean isEnabled(IViewProvider provider, View view) {
+ return testers.stream().map(tester -> tester.isEnabled(provider, view)).reduce(true, Boolean::logicalAnd);
+ }
+
+ @Reference
+ public void registerTester(ViewProviderTester tester) {
+ testers.add(tester);
+ }
+
+}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/providers/CustomAbstractViewProvider.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/providers/CustomAbstractViewProvider.java
index eb02c910275..055aa16e510 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/providers/CustomAbstractViewProvider.java
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/providers/CustomAbstractViewProvider.java
@@ -24,6 +24,7 @@ import org.eclipse.gmf.runtime.notation.Diagram;
import org.eclipse.gmf.runtime.notation.Edge;
import org.eclipse.gmf.runtime.notation.Node;
import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.infra.gmfdiag.common.service.ProviderServiceUtil;
import org.eclipse.papyrus.infra.viewpoints.policy.ViewPrototype;
/**
@@ -61,6 +62,9 @@ public abstract class CustomAbstractViewProvider extends AbstractViewProvider {
*/
@Override
protected boolean provides(CreateViewForKindOperation op) {
+ if (!ProviderServiceUtil.isEnabled(this, op.getContainerView())) {
+ return false;
+ }
if (!isRelevantDiagram(op.getContainerView().getDiagram())) {
return false;
}
@@ -81,6 +85,9 @@ public abstract class CustomAbstractViewProvider extends AbstractViewProvider {
*/
@Override
protected boolean provides(CreateEdgeViewOperation operation) {
+ if (!ProviderServiceUtil.isEnabled(this, operation.getContainerView())) {
+ return false;
+ }
if (!isRelevantDiagram(operation.getContainerView().getDiagram())) {
return false;
}
@@ -93,6 +100,9 @@ public abstract class CustomAbstractViewProvider extends AbstractViewProvider {
*/
@Override
protected boolean provides(CreateNodeViewOperation operation) {
+ if (!ProviderServiceUtil.isEnabled(this, operation.getContainerView())) {
+ return false;
+ }
if (!isRelevantDiagram(operation.getContainerView().getDiagram())) {
return false;
}
@@ -138,7 +148,7 @@ public abstract class CustomAbstractViewProvider extends AbstractViewProvider {
/**
* This method is used to know id the diagram is conform to type, it may be a prototype view, or a generatedDiagram
- *
+ *
* @param diagram
* @return
*/
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/providers/CustomEditPolicyProvider.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/providers/CustomEditPolicyProvider.java
index d3d717f2201..b3923d22860 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/providers/CustomEditPolicyProvider.java
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/providers/CustomEditPolicyProvider.java
@@ -23,6 +23,7 @@ import org.eclipse.papyrus.infra.core.services.ServiceException;
import org.eclipse.papyrus.infra.core.services.ServicesRegistry;
import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.HighlightEditPolicy;
+import org.eclipse.papyrus.infra.gmfdiag.common.service.ProviderServiceUtil;
import org.eclipse.papyrus.infra.gmfdiag.common.utils.ServiceUtilsForEditPart;
/**
@@ -70,8 +71,11 @@ public class CustomEditPolicyProvider implements IEditPolicyProvider {
* {@inheritDoc}
*/
@Override
- public boolean provides(IOperation operation) {
+ public boolean provides(IOperation operation) {
CreateEditPoliciesOperation epOperation = (CreateEditPoliciesOperation) operation;
+ if (!ProviderServiceUtil.isEnabled(this, epOperation.getEditPart())) {
+ return false;
+ }
try {
EditPart editPart = epOperation.getEditPart();
if (!(editPart instanceof GraphicalEditPart)) {
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/providers/ExternalReferenceEditPolicyProvider.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/providers/ExternalReferenceEditPolicyProvider.java
index 39dd468c4b0..df832001fad 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/providers/ExternalReferenceEditPolicyProvider.java
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/providers/ExternalReferenceEditPolicyProvider.java
@@ -19,6 +19,7 @@ import org.eclipse.gmf.runtime.diagram.ui.services.editpolicy.IEditPolicyProvide
import org.eclipse.gmf.runtime.notation.Node;
import org.eclipse.papyrus.infra.core.services.ServiceException;
import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.ExternalReferenceEditPolicy;
+import org.eclipse.papyrus.infra.gmfdiag.common.service.ProviderServiceUtil;
import org.eclipse.papyrus.infra.gmfdiag.common.utils.ServiceUtilsForEditPart;
/**
@@ -35,6 +36,9 @@ public class ExternalReferenceEditPolicyProvider extends AbstractProvider implem
public boolean provides(IOperation operation) {
if (operation instanceof CreateEditPoliciesOperation) {
CreateEditPoliciesOperation createOperation = (CreateEditPoliciesOperation) operation;
+ if (!ProviderServiceUtil.isEnabled(this, createOperation.getEditPart())) {
+ return false;
+ }
try {
if (ServiceUtilsForEditPart.getInstance().getServiceRegistry(createOperation.getEditPart()) != null) {
return createOperation.getEditPart().getModel() instanceof Node;
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/service/EditPolicyProviderService.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/service/EditPolicyProviderService.java
new file mode 100644
index 00000000000..ed026605c72
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/service/EditPolicyProviderService.java
@@ -0,0 +1,77 @@
+/*****************************************************************************
+ * Copyright (c) 2018 EclipseSource and others.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * EclipseSource - Initial API and implementation (Bug 533701)
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.infra.gmfdiag.common.service;
+
+import org.eclipse.gef.EditPart;
+import org.eclipse.gmf.runtime.diagram.ui.services.editpolicy.IEditPolicyProvider;
+import org.eclipse.papyrus.infra.core.services.IServiceFactory;
+import org.eclipse.papyrus.infra.core.services.ServiceException;
+import org.eclipse.papyrus.infra.core.services.ServicesRegistry;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.FrameworkUtil;
+import org.osgi.framework.ServiceReference;
+
+/**
+ * <p>
+ * A service used to increase the control diagrams have over the {@link IEditPolicyProvider}
+ * that should be enabled in that diagram. All generic Papyrus {@link IEditPolicyProvider} are expected to use this
+ * service before deciding if they should indeed be enabled.
+ * </p>
+ * <p>
+ * Note that this service is here to provide an additional pre-check to determine if a
+ * provider is allowed to work in a specific diagram. However, this service knows nothing
+ * about the internal requirements/dependencies of a specific provider, and should not
+ * <strong>replace</strong> the {@link IEditPolicyProvider#provides(org.eclipse.gmf.runtime.common.core.service.IOperation)}
+ * method (i.e. the actual provider is still expected to run its own checks, in addition
+ * to calling this service).
+ * </p>
+ *
+ * @since 3.100
+ */
+public interface EditPolicyProviderService {
+
+ /**
+ * Tests whether the given provider is allowed in the context of that edit part
+ *
+ * @param provider
+ * @param editPart
+ * @return
+ */
+ boolean isEnabled(IEditPolicyProvider provider, EditPart editPart);
+
+ public static class Factory implements IServiceFactory {
+
+ @Override
+ public void init(ServicesRegistry servicesRegistry) throws ServiceException {
+ // Nothing
+ }
+
+ @Override
+ public void startService() throws ServiceException {
+ // Nothing
+ }
+
+ @Override
+ public void disposeService() throws ServiceException {
+ // Nothing
+ }
+
+ @Override
+ public EditPolicyProviderService createServiceInstance() throws ServiceException {
+ BundleContext bundleContext = FrameworkUtil.getBundle(Factory.class).getBundleContext();
+ ServiceReference<EditPolicyProviderService> serviceReference = bundleContext.getServiceReference(EditPolicyProviderService.class);
+ return bundleContext.getService(serviceReference);
+ }
+ }
+}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/service/EditPolicyProviderTester.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/service/EditPolicyProviderTester.java
new file mode 100644
index 00000000000..7bfd7ad94dc
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/service/EditPolicyProviderTester.java
@@ -0,0 +1,39 @@
+/*****************************************************************************
+ * Copyright (c) 2018 EclipseSource and others.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * EclipseSource - Initial API and implementation (Bug 533701)
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.infra.gmfdiag.common.service;
+
+import org.eclipse.gef.EditPart;
+import org.eclipse.gmf.runtime.diagram.ui.services.editpolicy.IEditPolicyProvider;
+
+/**
+ * <p>
+ * A contribution to the {@link EditPolicyProviderService}
+ * </p>
+ *
+ * @since 3.100
+ */
+public interface EditPolicyProviderTester {
+
+ /**
+ * Tests whether the given provider is allowed in the context of that edit part
+ *
+ * @param provider
+ * @param editPart
+ * @return
+ * <code>false</code> if this tester explicitly rejects this provider in the context of that edit part;
+ * <code>true</code> otherwise.
+ */
+ boolean isEnabled(IEditPolicyProvider provider, EditPart editPart);
+}
+
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/service/ProviderServiceUtil.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/service/ProviderServiceUtil.java
new file mode 100644
index 00000000000..adbbcde0f5e
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/service/ProviderServiceUtil.java
@@ -0,0 +1,130 @@
+/*****************************************************************************
+ * Copyright (c) 2018 EclipseSource and others.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * EclipseSource - Initial API and implementation (Bug 533701)
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.gmfdiag.common.service;
+
+import org.eclipse.gef.EditPart;
+import org.eclipse.gmf.runtime.diagram.core.providers.IViewProvider;
+import org.eclipse.gmf.runtime.diagram.ui.services.editpolicy.IEditPolicyProvider;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.infra.core.services.ServicesRegistry;
+import org.eclipse.papyrus.infra.emf.utils.ServiceUtilsForEObject;
+import org.eclipse.papyrus.infra.gmfdiag.common.utils.ServiceUtilsForEditPart;
+
+/**
+ * <p>
+ * Utility methods to use the {@link ViewProviderService} and {@link EditPolicyProviderService}
+ * </p>
+ *
+ * @since 3.100
+ */
+public class ProviderServiceUtil {
+
+ /**
+ * <p>
+ * Tests if the given edit part is a Papyrus Edit Part, by testing if a Papyrus {@link ServicesRegistry}
+ * is present.
+ * </p>
+ *
+ * @param editPart
+ * The edit part to test
+ * @return
+ * <code>true</code> if this edit part is part of a Papyrus environment (Using a Papyrus {@link ServicesRegistry}), <code>false</code> otherwise
+ */
+ public static boolean isPapyrusPart(EditPart editPart) {
+ try {
+ return ServiceUtilsForEditPart.getInstance().getServiceRegistry(editPart) != null;
+ } catch (Exception ex) {
+ // Ignore & return
+ return false;
+ }
+ }
+
+ /**
+ * <p>
+ * Tests if the given View is a Papyrus View, by testing if a Papyrus {@link ServicesRegistry}
+ * is present.
+ * </p>
+ *
+ * @param view
+ * The view to test
+ * @return
+ * <code>true</code> if this view is part of a Papyrus environment (Using a Papyrus {@link ServicesRegistry}), <code>false</code> otherwise
+ */
+ public static boolean isPapyrusView(View view) {
+ try {
+ return ServiceUtilsForEObject.getInstance().getServiceRegistry(view) != null;
+ } catch (Exception ex) {
+ // Ignore & return
+ return false;
+ }
+ }
+
+ /**
+ * <p>
+ * Helper method to use the {@link ViewProviderService}.
+ * </p>
+ * <p>
+ * This methods verifies that the edit part is a Papyrus Edit Part (Via {@link #isPapyrusPart(EditPart)}),
+ * and then calls {@link ViewProviderService#isEnabled(IViewProvider, EditPart)}
+ * </p>
+ *
+ * @param provider
+ * @param editPart
+ * @return
+ *
+ * @see ViewProviderService#isEnabled(IViewProvider, EditPart)
+ */
+ public static boolean isEnabled(IViewProvider provider, View view) {
+ if (isPapyrusView(view)) {
+ try {
+ ViewProviderService service = ServiceUtilsForEObject.getInstance().getService(ViewProviderService.class, view);
+ return service.isEnabled(provider, view);
+ } catch (Exception ex) {
+ // Ignore & return
+ return false;
+ }
+ }
+
+ return false;
+ }
+
+ /**
+ * <p>
+ * Helper method to use the {@link EditPolicyProviderService}.
+ * </p>
+ * <p>
+ * This methods verifies that the edit part is a Papyrus Edit Part (Via {@link #isPapyrusPart(EditPart)}),
+ * and then calls {@link EditPolicyProviderService#isEnabled(IEditPolicyProvider, EditPart)}
+ * </p>
+ *
+ * @param provider
+ * @param editPart
+ * @return
+ *
+ * @see {@link EditPolicyProviderService#isEnabled(IEditPolicyProvider, EditPart)}
+ */
+ public static boolean isEnabled(IEditPolicyProvider provider, EditPart editPart) {
+ if (isPapyrusPart(editPart)) {
+ try {
+ EditPolicyProviderService service = ServiceUtilsForEditPart.getInstance().getService(EditPolicyProviderService.class, editPart);
+ return service.isEnabled(provider, editPart);
+ } catch (Exception ex) {
+ // Ignore & return
+ return false;
+ }
+ }
+
+ return false;
+ }
+
+}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/service/ViewProviderService.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/service/ViewProviderService.java
new file mode 100644
index 00000000000..7a16c39b72b
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/service/ViewProviderService.java
@@ -0,0 +1,78 @@
+/*****************************************************************************
+ * Copyright (c) 2018 EclipseSource and others.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * EclipseSource - Initial API and implementation (Bug 533701)
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.gmfdiag.common.service;
+
+import org.eclipse.gmf.runtime.diagram.core.providers.IViewProvider;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.infra.core.services.IServiceFactory;
+import org.eclipse.papyrus.infra.core.services.ServiceException;
+import org.eclipse.papyrus.infra.core.services.ServicesRegistry;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.FrameworkUtil;
+import org.osgi.framework.ServiceReference;
+
+/**
+ * <p>
+ * A service used to increase the control diagrams have over the {@link IViewProvider}
+ * that should be enabled in that diagram. All generic Papyrus {@link IViewProvider} are expected to use this
+ * service before deciding if they should indeed be enabled.
+ * </p>
+ * <p>
+ * Note that this service is here to provide an additional pre-check to determine if a
+ * provider is allowed to work in a specific diagram. However, this service knows nothing
+ * about the internal requirements/dependencies of a specific provider, and should not
+ * <strong>replace</strong> the {@link IViewProvider#provides(org.eclipse.gmf.runtime.common.core.service.IOperation)}
+ * method (i.e. the actual provider is still expected to run its own checks, in addition
+ * to calling this service).
+ * </p>
+ *
+ * @since 3.100
+ */
+public interface ViewProviderService {
+ /**
+ * Tests whether the given provider is allowed in the context of that view
+ *
+ * @param provider
+ * @param view
+ * @return
+ */
+ boolean isEnabled(IViewProvider provider, View view);
+
+
+
+ public static class Factory implements IServiceFactory {
+
+ @Override
+ public void init(ServicesRegistry servicesRegistry) throws ServiceException {
+ // Nothing
+ }
+
+ @Override
+ public void startService() throws ServiceException {
+ // Nothing
+ }
+
+ @Override
+ public void disposeService() throws ServiceException {
+ // Nothing
+ }
+
+ @Override
+ public ViewProviderService createServiceInstance() throws ServiceException {
+ BundleContext bundleContext = FrameworkUtil.getBundle(Factory.class).getBundleContext();
+ ServiceReference<ViewProviderService> serviceReference = bundleContext.getServiceReference(ViewProviderService.class);
+ return bundleContext.getService(serviceReference);
+ }
+
+ }
+}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/service/ViewProviderTester.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/service/ViewProviderTester.java
new file mode 100644
index 00000000000..f2928331534
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/service/ViewProviderTester.java
@@ -0,0 +1,39 @@
+/*****************************************************************************
+ * Copyright (c) 2018 EclipseSource and others.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * EclipseSource - Initial API and implementation (Bug 533701)
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.infra.gmfdiag.common.service;
+
+import org.eclipse.gmf.runtime.diagram.core.providers.IViewProvider;
+import org.eclipse.gmf.runtime.notation.View;
+
+/**
+ * <p>
+ * A contribution to the {@link ViewProviderService}
+ * </p>
+ *
+ * @since 3.100
+ */
+public interface ViewProviderTester {
+
+ /**
+ * Tests whether the given provider is allowed in the context of that edit part
+ *
+ * @param provider
+ * @param editPart
+ * @return
+ * <code>false</code> if this tester explicitly rejects this provider in the context of that edit part;
+ * <code>true</code> otherwise.
+ */
+ boolean isEnabled(IViewProvider provider, View view);
+}
+
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.dnd/src/org/eclipse/papyrus/infra/gmfdiag/dnd/policy/CustomizableDropEditPolicyProvider.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.dnd/src/org/eclipse/papyrus/infra/gmfdiag/dnd/policy/CustomizableDropEditPolicyProvider.java
index 117555e8eff..24535b8498a 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.dnd/src/org/eclipse/papyrus/infra/gmfdiag/dnd/policy/CustomizableDropEditPolicyProvider.java
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.dnd/src/org/eclipse/papyrus/infra/gmfdiag/dnd/policy/CustomizableDropEditPolicyProvider.java
@@ -20,13 +20,18 @@ import org.eclipse.gmf.runtime.diagram.ui.services.editpolicy.CreateEditPolicies
import org.eclipse.gmf.runtime.diagram.ui.services.editpolicy.IEditPolicyProvider;
import org.eclipse.papyrus.infra.core.services.ServiceException;
import org.eclipse.papyrus.infra.core.services.ServicesRegistry;
+import org.eclipse.papyrus.infra.gmfdiag.common.service.ProviderServiceUtil;
import org.eclipse.papyrus.infra.gmfdiag.common.utils.ServiceUtilsForEditPart;
public class CustomizableDropEditPolicyProvider extends AbstractProvider implements IEditPolicyProvider {
+ @Override
public boolean provides(IOperation operation) {
CreateEditPoliciesOperation epOperation = (CreateEditPoliciesOperation) operation;
+ if (!ProviderServiceUtil.isEnabled(this, epOperation.getEditPart())) {
+ return false;
+ }
try {
ServicesRegistry registry = ServiceUtilsForEditPart.getInstance().getServiceRegistry(epOperation.getEditPart());
@@ -36,6 +41,7 @@ public class CustomizableDropEditPolicyProvider extends AbstractProvider impleme
}
}
+ @Override
public void createEditPolicies(EditPart editPart) {
EditPolicy defaultDropEditPolicy = editPart.getEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE);
EditPolicy defaultCreationEditPolicy = editPart.getEditPolicy(EditPolicyRoles.CREATION_ROLE);
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.hyperlink/src/org/eclipse/papyrus/infra/gmfdiag/hyperlink/providers/HyperlinkEditPolicyProvider.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.hyperlink/src/org/eclipse/papyrus/infra/gmfdiag/hyperlink/providers/HyperlinkEditPolicyProvider.java
index 10fab80d91b..198f033b389 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.hyperlink/src/org/eclipse/papyrus/infra/gmfdiag/hyperlink/providers/HyperlinkEditPolicyProvider.java
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.hyperlink/src/org/eclipse/papyrus/infra/gmfdiag/hyperlink/providers/HyperlinkEditPolicyProvider.java
@@ -22,6 +22,7 @@ import org.eclipse.gmf.runtime.diagram.ui.services.editpolicy.CreateEditPolicies
import org.eclipse.gmf.runtime.diagram.ui.services.editpolicy.IEditPolicyProvider;
import org.eclipse.papyrus.infra.core.services.ServiceException;
import org.eclipse.papyrus.infra.core.services.ServicesRegistry;
+import org.eclipse.papyrus.infra.gmfdiag.common.service.ProviderServiceUtil;
import org.eclipse.papyrus.infra.gmfdiag.common.utils.ServiceUtilsForEditPart;
import org.eclipse.papyrus.infra.gmfdiag.hyperlink.editpolicies.HyperlinkNavigationMenuEditPolicy;
@@ -38,10 +39,14 @@ public class HyperlinkEditPolicyProvider extends AbstractProvider implements IEd
*
* This provider can handle GraphicalEditParts
*/
+ @Override
public boolean provides(IOperation operation) {
if (operation instanceof CreateEditPoliciesOperation) {
CreateEditPoliciesOperation epOperation = (CreateEditPoliciesOperation) operation;
EditPart editPart = epOperation.getEditPart();
+ if (!ProviderServiceUtil.isEnabled(this, editPart)) {
+ return false;
+ }
try {
ServicesRegistry registry = ServiceUtilsForEditPart.getInstance().getServiceRegistry(editPart);
if (registry == null) {
@@ -63,6 +68,7 @@ public class HyperlinkEditPolicyProvider extends AbstractProvider implements IEd
*
* Installs the Hyperlink and Navigation edit policies
*/
+ @Override
public void createEditPolicies(EditPart editPart) {
editPart.installEditPolicy(org.eclipse.papyrus.infra.gmfdiag.navigation.editpolicy.NavigationEditPolicy.EDIT_POLICY_ID, new HyperlinkNavigationMenuEditPolicy());
editPart.installEditPolicy(org.eclipse.papyrus.infra.gmfdiag.hyperlink.editpolicies.NavigationEditPolicy.NAVIGATION_POLICY, new org.eclipse.papyrus.infra.gmfdiag.hyperlink.editpolicies.NavigationEditPolicy());
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.navigation/src/org/eclipse/papyrus/infra/gmfdiag/navigation/provider/NavigationEditPolicyProvider.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.navigation/src/org/eclipse/papyrus/infra/gmfdiag/navigation/provider/NavigationEditPolicyProvider.java
index 41bb3fce0fa..5526653b7f9 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.navigation/src/org/eclipse/papyrus/infra/gmfdiag/navigation/provider/NavigationEditPolicyProvider.java
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.navigation/src/org/eclipse/papyrus/infra/gmfdiag/navigation/provider/NavigationEditPolicyProvider.java
@@ -16,6 +16,7 @@ import org.eclipse.gmf.runtime.common.core.service.AbstractProvider;
import org.eclipse.gmf.runtime.common.core.service.IOperation;
import org.eclipse.gmf.runtime.diagram.ui.services.editpolicy.CreateEditPoliciesOperation;
import org.eclipse.gmf.runtime.diagram.ui.services.editpolicy.IEditPolicyProvider;
+import org.eclipse.papyrus.infra.gmfdiag.common.service.ProviderServiceUtil;
import org.eclipse.papyrus.infra.gmfdiag.common.utils.ServiceUtilsForEditPart;
import org.eclipse.papyrus.infra.gmfdiag.navigation.editpolicy.NavigationEditPolicy;
import org.eclipse.papyrus.infra.services.navigation.service.NavigationService;
@@ -28,6 +29,9 @@ public class NavigationEditPolicyProvider extends AbstractProvider implements IE
CreateEditPoliciesOperation epOperation = (CreateEditPoliciesOperation) operation;
EditPart editPart = epOperation.getEditPart();
+ if (!ProviderServiceUtil.isEnabled(this, editPart)) {
+ return false;
+ }
try {
NavigationService navigationService = ServiceUtilsForEditPart.getInstance().getService(NavigationService.class, editPart);
return navigationService != null;

Back to the top