Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--plugins/infra/gmfdiag/expansion/org.eclipse.papyrus.infra.gmfdiag.expansion/src/main/java/org/eclipse/papyrus/infra/gmfdiag/expansion/expansionmodel/providers/ExpandEditPartProvider.java29
-rw-r--r--plugins/infra/viewpoints/org.eclipse.papyrus.infra.viewpoints.policy/src/org/eclipse/papyrus/infra/viewpoints/policy/PolicyChecker.java18
2 files changed, 25 insertions, 22 deletions
diff --git a/plugins/infra/gmfdiag/expansion/org.eclipse.papyrus.infra.gmfdiag.expansion/src/main/java/org/eclipse/papyrus/infra/gmfdiag/expansion/expansionmodel/providers/ExpandEditPartProvider.java b/plugins/infra/gmfdiag/expansion/org.eclipse.papyrus.infra.gmfdiag.expansion/src/main/java/org/eclipse/papyrus/infra/gmfdiag/expansion/expansionmodel/providers/ExpandEditPartProvider.java
index 469f19af7ca..877d0972cb9 100644
--- a/plugins/infra/gmfdiag/expansion/org.eclipse.papyrus.infra.gmfdiag.expansion/src/main/java/org/eclipse/papyrus/infra/gmfdiag/expansion/expansionmodel/providers/ExpandEditPartProvider.java
+++ b/plugins/infra/gmfdiag/expansion/org.eclipse.papyrus.infra.gmfdiag.expansion/src/main/java/org/eclipse/papyrus/infra/gmfdiag/expansion/expansionmodel/providers/ExpandEditPartProvider.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2015 CEA LIST.
+ * Copyright (c) 2015, 2018 CEA LIST.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -8,8 +8,8 @@
*
* Contributors:
*
- * CEA LIST - Initial API and implementation
- *
+ * CEA LIST - Initial API and implementation
+ * Benoit Maggi (CEA) - Bug 536581
*****************************************************************************/
package org.eclipse.papyrus.infra.gmfdiag.expansion.expansionmodel.providers;
@@ -52,10 +52,10 @@ public class ExpandEditPartProvider extends AbstractEditPartProvider {
// private static final boolean DEBUG_EXPANSION = "true".equalsIgnoreCase(Platform.getDebugOption(
// "org.eclipse.papyrus.infra.gmfdiag.common/debug/expansion"));
/** Map containing node view types supported by this provider */
- protected Map<String, Class<?>> nodeMap = new HashMap<String, Class<?>>();
+ protected Map<String, Class<?>> nodeMap = new HashMap<>();
/** Map containing edge view types supported by this provider */
- protected Map<String, Class<?>> edgeMap = new HashMap<String, Class<?>>();
+ protected Map<String, Class<?>> edgeMap = new HashMap<>();
private DiagramExpansionsRegistry diagramExpansionRegistry=null;
@@ -67,14 +67,15 @@ public class ExpandEditPartProvider extends AbstractEditPartProvider {
}
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();
+ if (diagram != 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;
}
@@ -123,8 +124,7 @@ public class ExpandEditPartProvider extends AbstractEditPartProvider {
if ((currentDiagramType == null) || (diagramExpansionRegistry.getUsage(currentDiagramType)==null)) {
return null;
}
-
-
+
String graphicalType = view.getType();
Activator.log.trace(Activator.EXPANSION_TRACE,this.getClass().getName()+" view appears with the type "+graphicalType);//$NON-NLS-1$
EObject eObject= diagramExpansionRegistry.mapChildreen.get(currentDiagramType).IDMap.get(graphicalType);
@@ -178,7 +178,6 @@ public class ExpandEditPartProvider extends AbstractEditPartProvider {
private IGraphicalEditPart createNewGraphicEditPart(Class editpartClass, Object[] constructorParams) {
try {
Constructor constructor = getCreationConstructor(editpartClass);
-
return (constructor == null)? null : (IGraphicalEditPart) constructor.newInstance(constructorParams);
}
catch (Throwable e) {
diff --git a/plugins/infra/viewpoints/org.eclipse.papyrus.infra.viewpoints.policy/src/org/eclipse/papyrus/infra/viewpoints/policy/PolicyChecker.java b/plugins/infra/viewpoints/org.eclipse.papyrus.infra.viewpoints.policy/src/org/eclipse/papyrus/infra/viewpoints/policy/PolicyChecker.java
index 408e3c76ac8..6a64edc3e82 100644
--- a/plugins/infra/viewpoints/org.eclipse.papyrus.infra.viewpoints.policy/src/org/eclipse/papyrus/infra/viewpoints/policy/PolicyChecker.java
+++ b/plugins/infra/viewpoints/org.eclipse.papyrus.infra.viewpoints.policy/src/org/eclipse/papyrus/infra/viewpoints/policy/PolicyChecker.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2013, 2017 CEA LIST, Christian W. Damus, and others.
+ * Copyright (c) 2013, 2017, 2018 CEA LIST, Christian W. Damus, and others.
*
*
* All rights reserved. This program and the accompanying materials
@@ -12,6 +12,7 @@
* Christian W. Damus (CEA) - bug 422257
* Christian W. Damus - bugs 463156, 493030
* Thanh Liem PHAN (ALL4TEC) thanhliem.phan@all4tec.net - Bug 519409
+ * Benoit Maggi (CEA) - Bug 536581
*****************************************************************************/
package org.eclipse.papyrus.infra.viewpoints.policy;
@@ -75,30 +76,33 @@ public class PolicyChecker {
* @since 2.0
*/
public static PolicyChecker getFor(EObject object) {
- if (object.eResource() != null)
+ if (object!= null && object.eResource() != null) {
return getFor(object.eResource());
- else
+ } else {
return getFor(ArchitectureDomainManager.getInstance().getDefaultArchitectureContext());
+ }
}
/**
* @since 2.0
*/
public static PolicyChecker getFor(Resource resource) {
- if (resource.getResourceSet() != null)
+ if (resource != null && resource.getResourceSet() != null) {
return getFor(resource.getResourceSet());
- else
+ } else {
return getFor(ArchitectureDomainManager.getInstance().getDefaultArchitectureContext());
+ }
}
/**
* @since 2.0
*/
public static PolicyChecker getFor(ResourceSet resourceSet) {
- if (resourceSet instanceof ModelSet)
+ if (resourceSet instanceof ModelSet) {
return getFor((ModelSet) resourceSet);
- else
+ } else {
return getFor(ArchitectureDomainManager.getInstance().getDefaultArchitectureContext());
+ }
}
/**

Back to the top