Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMaged Elaasar2018-05-24 10:41:42 -0400
committerBenoit Maggi2018-05-25 03:47:39 -0400
commite2a420c06ffe82d452498710211c5c25e64d2466 (patch)
tree8d70962a358f92e058658f52f6627af231d98756
parente7097d28fc7e706fa2097b8620b6c41f029e6f62 (diff)
downloadorg.eclipse.papyrus-e2a420c06ffe82d452498710211c5c25e64d2466.tar.gz
org.eclipse.papyrus-e2a420c06ffe82d452498710211c5c25e64d2466.tar.xz
org.eclipse.papyrus-e2a420c06ffe82d452498710211c5c25e64d2466.zip
Bug 535098 - [AFViewpoints] Validation not working with junit.
Fix the case of validating class names specified in architecture models that are deployed in the platform as opposed to loaded in the workspace. Change-Id: I644c6d2141d9424372014c3c05f84640fbbe47c3 Signed-off-by: Maged Elaasar <melaasar@gmail.com>
-rw-r--r--plugins/infra/core/org.eclipse.papyrus.infra.core.architecture/src-gen/org/eclipse/papyrus/infra/core/architecture/impl/ArchitectureContextImpl.java68
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.representation/src-gen/org/eclipse/papyrus/infra/gmfdiag/representation/impl/PapyrusDiagramImpl.java33
2 files changed, 67 insertions, 34 deletions
diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.architecture/src-gen/org/eclipse/papyrus/infra/core/architecture/impl/ArchitectureContextImpl.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.architecture/src-gen/org/eclipse/papyrus/infra/core/architecture/impl/ArchitectureContextImpl.java
index 22c68cecdab..6c9cc8c9d47 100644
--- a/plugins/infra/core/org.eclipse.papyrus.infra.core.architecture/src-gen/org/eclipse/papyrus/infra/core/architecture/impl/ArchitectureContextImpl.java
+++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.architecture/src-gen/org/eclipse/papyrus/infra/core/architecture/impl/ArchitectureContextImpl.java
@@ -17,11 +17,9 @@ import java.lang.reflect.InvocationTargetException;
import java.util.Collection;
import java.util.Map;
-import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Platform;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;
import org.eclipse.emf.common.util.BasicDiagnostic;
@@ -39,7 +37,6 @@ import org.eclipse.emf.ecore.util.EObjectValidator;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.emf.ecore.util.InternalEList;
import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.papyrus.infra.core.architecture.ArchitectureContext;
@@ -48,6 +45,7 @@ import org.eclipse.papyrus.infra.core.architecture.ArchitecturePackage;
import org.eclipse.papyrus.infra.core.architecture.ArchitectureViewpoint;
import org.eclipse.papyrus.infra.core.architecture.util.ArchitectureValidator;
import org.eclipse.papyrus.infra.types.ElementTypeSetConfiguration;
+import org.osgi.framework.Bundle;
/**
* <!-- begin-user-doc -->
@@ -286,18 +284,29 @@ public abstract class ArchitectureContextImpl extends ADElementImpl implements A
*/
public boolean ceationCommandClassExists(DiagnosticChain diagnostics, Map<Object, Object> context) {
if (creationCommandClass != null) {
+ boolean exists = false;
+
URI uri = eResource().getURI();
- IWorkspace workspace = ResourcesPlugin.getWorkspace();
- IFile file = workspace.getRoot().getFile(new Path(uri.toPlatformString(false)));
- IProject project = file.getProject();
- IJavaProject javaProject = JavaCore.create(project);
- IType type = null;
- try {
- type = javaProject.findType(creationCommandClass);
- } catch (JavaModelException e) {
- /* ignore */
+ if (uri.isPlatformPlugin()) {
+ String bundleName = uri.segment(1);
+ Bundle bundle = Platform.getBundle(bundleName);
+ try {
+ exists = bundle.loadClass(creationCommandClass) != null;
+ } catch (ClassNotFoundException e) {
+ /* ignore */
+ }
+ } else if (uri.isPlatformResource()) {
+ String projectName = uri.segment(1);
+ IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
+ IJavaProject javaProject = JavaCore.create(project);
+ try {
+ exists = javaProject.findType(creationCommandClass) != null;
+ } catch (JavaModelException e) {
+ /* ignore */
+ }
}
- if (type == null) {
+
+ if (!exists) {
if (diagnostics != null) {
diagnostics.add
(new BasicDiagnostic
@@ -320,18 +329,29 @@ public abstract class ArchitectureContextImpl extends ADElementImpl implements A
*/
public boolean conversionCommandClassExists(DiagnosticChain diagnostics, Map<Object, Object> context) {
if (conversionCommandClass != null) {
+ boolean exists = false;
+
URI uri = eResource().getURI();
- IWorkspace workspace = ResourcesPlugin.getWorkspace();
- IFile file = workspace.getRoot().getFile(new Path(uri.toPlatformString(false)));
- IProject project = file.getProject();
- IJavaProject javaProject = JavaCore.create(project);
- IType type = null;
- try {
- type = javaProject.findType(conversionCommandClass);
- } catch (JavaModelException e) {
- /* ignore */
+ if (uri.isPlatformPlugin()) {
+ String bundleName = uri.segment(1);
+ Bundle bundle = Platform.getBundle(bundleName);
+ try {
+ exists = bundle.loadClass(conversionCommandClass) != null;
+ } catch (ClassNotFoundException e) {
+ /* ignore */
+ }
+ } else if (uri.isPlatformResource()) {
+ String projectName = uri.segment(1);
+ IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
+ IJavaProject javaProject = JavaCore.create(project);
+ try {
+ exists = javaProject.findType(conversionCommandClass) != null;
+ } catch (JavaModelException e) {
+ /* ignore */
+ }
}
- if (type == null) {
+
+ if (!exists) {
if (diagnostics != null) {
diagnostics.add
(new BasicDiagnostic
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.representation/src-gen/org/eclipse/papyrus/infra/gmfdiag/representation/impl/PapyrusDiagramImpl.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.representation/src-gen/org/eclipse/papyrus/infra/gmfdiag/representation/impl/PapyrusDiagramImpl.java
index 5272d4dcddd..98b60662aea 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.representation/src-gen/org/eclipse/papyrus/infra/gmfdiag/representation/impl/PapyrusDiagramImpl.java
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.representation/src-gen/org/eclipse/papyrus/infra/gmfdiag/representation/impl/PapyrusDiagramImpl.java
@@ -23,6 +23,7 @@ import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Platform;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;
import org.eclipse.emf.common.util.BasicDiagnostic;
@@ -50,6 +51,7 @@ import org.eclipse.papyrus.infra.gmfdiag.representation.PaletteRule;
import org.eclipse.papyrus.infra.gmfdiag.representation.PapyrusDiagram;
import org.eclipse.papyrus.infra.gmfdiag.representation.RepresentationPackage;
import org.eclipse.papyrus.infra.gmfdiag.representation.util.RepresentationValidator;
+import org.osgi.framework.Bundle;
/**
* <!-- begin-user-doc --> An implementation of the model object '<em><b>Papyrus
@@ -254,18 +256,29 @@ public class PapyrusDiagramImpl extends PapyrusRepresentationKindImpl implements
*/
public boolean ceationCommandClassExists(DiagnosticChain diagnostics, Map<Object, Object> context) {
if (creationCommandClass != null) {
+ boolean exists = false;
+
URI uri = eResource().getURI();
- IWorkspace workspace = ResourcesPlugin.getWorkspace();
- IFile file = workspace.getRoot().getFile(new Path(uri.toPlatformString(false)));
- IProject project = file.getProject();
- IJavaProject javaProject = JavaCore.create(project);
- IType type = null;
- try {
- type = javaProject.findType(creationCommandClass);
- } catch (JavaModelException e) {
- /* ignore */
+ if (uri.isPlatformPlugin()) {
+ String bundleName = uri.segment(1);
+ Bundle bundle = Platform.getBundle(bundleName);
+ try {
+ exists = bundle.loadClass(creationCommandClass) != null;
+ } catch (ClassNotFoundException e) {
+ /* ignore */
+ }
+ } else if (uri.isPlatformResource()) {
+ String projectName = uri.segment(1);
+ IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
+ IJavaProject javaProject = JavaCore.create(project);
+ try {
+ exists = javaProject.findType(creationCommandClass) != null;
+ } catch (JavaModelException e) {
+ /* ignore */
+ }
}
- if (type == null) {
+
+ if (!exists) {
if (diagnostics != null) {
diagnostics.add
(new BasicDiagnostic

Back to the top