Bug 566659 - [Robotics, OCL] Apply workaround for OCL issues
- Load robotics library into resource set, if patterns are not found
- Add RoboticsLibResource with information about robotics library URIs
- Use URIs defined in xxxResource classes in BTML model command
- [not directly related] code cleanup in RoboticsParser
Change-Id: Ia89bba14ce6cf977ffa94d26d1ed81d689f6d3f3
Signed-off-by: Ansgar Radermacher <ansgar.radermacher@cea.fr>
diff --git a/plugins/bt/org.eclipse.papyrus.robotics.bt.architecture/META-INF/MANIFEST.MF b/plugins/bt/org.eclipse.papyrus.robotics.bt.architecture/META-INF/MANIFEST.MF
index 0e2eb5b..5d64e39 100644
--- a/plugins/bt/org.eclipse.papyrus.robotics.bt.architecture/META-INF/MANIFEST.MF
+++ b/plugins/bt/org.eclipse.papyrus.robotics.bt.architecture/META-INF/MANIFEST.MF
@@ -12,7 +12,8 @@
org.eclipse.papyrus.uml.diagram.activity;bundle-version="[3.0.0,4.0.0)",
org.eclipse.papyrus.uml.tools;bundle-version="4.1.0",
org.eclipse.papyrus.robotics.core;bundle-version="0.7.0",
- org.eclipse.papyrus.robotics.bt.profile;bundle-version="0.7.0"
+ org.eclipse.papyrus.robotics.bt.profile;bundle-version="0.7.0",
+ org.eclipse.papyrus.robotics.library;bundle-version="0.7.0"
Automatic-Module-Name: org.eclipse.papyrus.robotics.bt.architecture
Bundle-ActivationPolicy: lazy
Bundle-Localization: plugin
diff --git a/plugins/bt/org.eclipse.papyrus.robotics.bt.architecture/src/org/eclipse/papyrus/robotics/bt/architecture/commands/CreateBTMLModelCommand.java b/plugins/bt/org.eclipse.papyrus.robotics.bt.architecture/src/org/eclipse/papyrus/robotics/bt/architecture/commands/CreateBTMLModelCommand.java
index 1574523..0d26df8 100644
--- a/plugins/bt/org.eclipse.papyrus.robotics.bt.architecture/src/org/eclipse/papyrus/robotics/bt/architecture/commands/CreateBTMLModelCommand.java
+++ b/plugins/bt/org.eclipse.papyrus.robotics.bt.architecture/src/org/eclipse/papyrus/robotics/bt/architecture/commands/CreateBTMLModelCommand.java
@@ -31,8 +31,11 @@
import org.eclipse.papyrus.infra.architecture.commands.IModelCreationCommand;
import org.eclipse.papyrus.infra.core.resource.ModelSet;
import org.eclipse.papyrus.infra.emf.gmf.command.GMFtoEMFCommandWrapper;
+import org.eclipse.papyrus.robotics.bpc.profile.util.BPCResource;
import org.eclipse.papyrus.robotics.bt.architecture.Activator;
+import org.eclipse.papyrus.robotics.library.util.RoboticsLibResource;
import org.eclipse.papyrus.robotics.profile.robotics.generics.Package;
+import org.eclipse.papyrus.robotics.profile.util.RoboticsResource;
import org.eclipse.papyrus.uml.tools.model.UmlUtils;
import org.eclipse.papyrus.uml.tools.utils.PackageUtil;
import org.eclipse.papyrus.uml.tools.utils.StereotypeUtil;
@@ -107,11 +110,11 @@
org.eclipse.uml2.uml.Package packageOwner = (org.eclipse.uml2.uml.Package) owner;
// Retrieve profiles and apply
- Profile bpc = (Profile) PackageUtil.loadPackage(URI.createURI("pathmap://ROBOTICS_BPC_PROFILES/bpc.profile.uml"), owner.eResource().getResourceSet());
+ Profile bpc = (Profile) PackageUtil.loadPackage(BPCResource.PROFILE_PATH_URI, owner.eResource().getResourceSet());
if (bpc != null) {
PackageUtil.applyProfile(packageOwner, bpc, true);
}
- Profile robotics = (Profile) PackageUtil.loadPackage(URI.createURI("pathmap://ROBOTICS_PROFILES/robotics.profile.uml"), owner.eResource().getResourceSet());
+ Profile robotics = (Profile) PackageUtil.loadPackage(RoboticsResource.PROFILE_PATH_URI, owner.eResource().getResourceSet());
if (robotics != null) {
List<String> profileNames = Arrays.asList("generics", "skills", "behavior");
for(String name : profileNames) {
@@ -126,7 +129,7 @@
PackageUtil.applyProfile(packageOwner, bt, true);
}
- org.eclipse.uml2.uml.Package roboticsLib = PackageUtil.loadPackage(URI.createURI("pathmap://ROBOTICS_LIBRARIES/robotics.library.uml"), owner.eResource().getResourceSet());
+ org.eclipse.uml2.uml.Package roboticsLib = PackageUtil.loadPackage(RoboticsLibResource.ROBOTICS_LIB_URI, owner.eResource().getResourceSet());
if (roboticsLib != null) {
org.eclipse.uml2.uml.Package skillLib = (org.eclipse.uml2.uml.Package) roboticsLib.getOwnedMember("skills");
if (roboticsLib != null) {
diff --git a/plugins/customization/org.eclipse.papyrus.robotics.library/META-INF/MANIFEST.MF b/plugins/customization/org.eclipse.papyrus.robotics.library/META-INF/MANIFEST.MF
index 9b4c905..51108b3 100644
--- a/plugins/customization/org.eclipse.papyrus.robotics.library/META-INF/MANIFEST.MF
+++ b/plugins/customization/org.eclipse.papyrus.robotics.library/META-INF/MANIFEST.MF
@@ -24,5 +24,6 @@
Bundle-SymbolicName: org.eclipse.papyrus.robotics.library;singleton:=true
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Export-Package: org.eclipse.papyrus.robotics.library.advice,
- org.eclipse.papyrus.robotics.library.matcher
+ org.eclipse.papyrus.robotics.library.matcher,
+ org.eclipse.papyrus.robotics.library.util
Automatic-Module-Name: org.eclipse.papyrus.robotics.library
diff --git a/plugins/customization/org.eclipse.papyrus.robotics.library/src/org/eclipse/papyrus/robotics/library/advice/AdviceUtil.java b/plugins/customization/org.eclipse.papyrus.robotics.library/src/org/eclipse/papyrus/robotics/library/advice/AdviceUtil.java
index 9b7c2e2..9815b25 100644
--- a/plugins/customization/org.eclipse.papyrus.robotics.library/src/org/eclipse/papyrus/robotics/library/advice/AdviceUtil.java
+++ b/plugins/customization/org.eclipse.papyrus.robotics.library/src/org/eclipse/papyrus/robotics/library/advice/AdviceUtil.java
@@ -18,6 +18,8 @@
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.papyrus.designer.languages.common.base.ElementUtils;
+import org.eclipse.papyrus.robotics.library.util.RoboticsLibResource;
+import org.eclipse.papyrus.uml.tools.utils.PackageUtil;
import org.eclipse.swt.widgets.Display;
import org.eclipse.uml2.uml.Classifier;
import org.eclipse.uml2.uml.Element;
@@ -38,15 +40,19 @@
if (pattern instanceof Classifier) {
return (Classifier) pattern;
} else {
- Display.getDefault().syncExec(new Runnable() {
+ PackageUtil.loadPackage(RoboticsLibResource.ROBOTICS_LIB_URI, anElement.eResource().getResourceSet());
+ pattern = ElementUtils.getQualifiedElementFromRS(anElement, patternQN);
+ if (pattern != null) {
+ Display.getDefault().syncExec(new Runnable() {
- @Override
- public void run() {
- MessageDialog.openWarning(Display.getCurrent().getActiveShell(),
- "Can not find communication pattern",
- String.format("Cannot find communication pattern %s. Please import the RobMoSys library", patternQN));
- }
- });
+ @Override
+ public void run() {
+ MessageDialog.openWarning(Display.getCurrent().getActiveShell(),
+ "Can not find communication pattern",
+ String.format("Cannot find communication pattern %s.", patternQN));
+ }
+ });
+ }
}
return null;
}
diff --git a/plugins/customization/org.eclipse.papyrus.robotics.library/src/org/eclipse/papyrus/robotics/library/util/RoboticsLibResource.java b/plugins/customization/org.eclipse.papyrus.robotics.library/src/org/eclipse/papyrus/robotics/library/util/RoboticsLibResource.java
new file mode 100644
index 0000000..cee954c
--- /dev/null
+++ b/plugins/customization/org.eclipse.papyrus.robotics.library/src/org/eclipse/papyrus/robotics/library/util/RoboticsLibResource.java
@@ -0,0 +1,30 @@
+/*****************************************************************************
+ * Copyright (c) 2020 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * Ansgar Radermacher (inspired from SysML variant of this file)
+ * - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.robotics.library.util;
+
+import org.eclipse.emf.common.util.URI;
+
+/**
+ * Utility class to get informations about robotics library resources
+ *
+ */
+public final class RoboticsLibResource {
+
+ public static final String ROBOTICS_LIB_PATHMAP = "pathmap://ROBOTICS_LIBRARIES/"; //$NON-NLS-1$
+
+ public static final String ROBOTICS_LIB_PATH = ROBOTICS_LIB_PATHMAP + "robotics.library.uml"; //$NON-NLS-1$
+
+ public static final URI ROBOTICS_LIB_URI = URI.createURI(ROBOTICS_LIB_PATH);
+}
diff --git a/plugins/customization/org.eclipse.papyrus.robotics.simplifiedui/src/org/eclipse/papyrus/robotics/simplifiedui/parsers/RoboticsParser.java b/plugins/customization/org.eclipse.papyrus.robotics.simplifiedui/src/org/eclipse/papyrus/robotics/simplifiedui/parsers/RoboticsParser.java
index 0e5c497..8c02e16 100644
--- a/plugins/customization/org.eclipse.papyrus.robotics.simplifiedui/src/org/eclipse/papyrus/robotics/simplifiedui/parsers/RoboticsParser.java
+++ b/plugins/customization/org.eclipse.papyrus.robotics.simplifiedui/src/org/eclipse/papyrus/robotics/simplifiedui/parsers/RoboticsParser.java
@@ -36,44 +36,12 @@
public RoboticsParser() {
super(new EAttribute[] { UMLPackage.eINSTANCE.getNamedElement_Name() });
- // TODO Auto-generated constructor stub
}
@Override
public IContentAssistProcessor getCompletionProcessor(IAdaptable element) {
return null;
}
-
- /*
- @Override
- public String getEditString(IAdaptable element, int flags) {
- EObject eObj = element.getAdapter(EObject.class);
- if (eObj instanceof NamedElement) {
- return ((NamedElement) eObj).getName();
- }
- return null;
- }
- */
- /*
- @Override
- public ICommand getParseCommand(IAdaptable element, String name, int flags) {
- EObject eObj = element.getAdapter(EObject.class);
- if (eObj instanceof NamedElement) {
- AbstractCommand cmd = new SetCommand(TransactionUtil.getEditingDomain(eObj),
- eObj, UMLPackage.eINSTANCE.getNamedElement_Name(), name);
- cmd = new RecordingCommand(TransactionUtil.getEditingDomain(eObj), "rename") {
-
- @Override
- protected void doExecute() {
- ((NamedElement) eObj).setName(name);
-
- }
- };
- return EMFtoGMFCommandWrapper.wrap(cmd);
- }
- return null;
- }
- */
@Override
public String getPrintString(IAdaptable element, int flags) {