Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMauricio Alferez2016-06-03 14:02:07 +0000
committerGerrit Code Review @ Eclipse.org2016-06-06 13:59:08 +0000
commitf644f4332850b0561fcc8ac3870106add9adac2c (patch)
tree014b243a0750b3264eca54950df6359675f596f3 /extraplugins/requirements
parent4b2ef6429fc6889e633fe2617b80d2b705f862f7 (diff)
downloadorg.eclipse.papyrus-f644f4332850b0561fcc8ac3870106add9adac2c.tar.gz
org.eclipse.papyrus-f644f4332850b0561fcc8ac3870106add9adac2c.tar.xz
org.eclipse.papyrus-f644f4332850b0561fcc8ac3870106add9adac2c.zip
Bug 480505 - [Extra Plugin][Req] requirement identififer should be
unique not only for the package but also for the model - I added the Boolean option "ID must be unique in the entire model?" in the Papyrus for Requirements page. Therefore, users can decide if they want the ID to be unique only in the package or also in the entire model. The default value for the option is "true" in the preferences initializer. - Change the getNewIDReq implementation Change-Id: I7927028c7f43f14f6ae03af47fe034af41740c67 Signed-off-by: Mauricio Alferez <mauricio.alferez@cea.fr>
Diffstat (limited to 'extraplugins/requirements')
-rw-r--r--extraplugins/requirements/org.eclipse.papyrus.requirements.preferences/META-INF/MANIFEST.MF21
-rw-r--r--extraplugins/requirements/org.eclipse.papyrus.requirements.preferences/build.properties5
-rw-r--r--extraplugins/requirements/org.eclipse.papyrus.requirements.preferences/bundle.properties (renamed from extraplugins/requirements/org.eclipse.papyrus.requirements.preferences/plugin.properties)2
-rw-r--r--extraplugins/requirements/org.eclipse.papyrus.requirements.preferences/plugin.xml2
-rw-r--r--extraplugins/requirements/org.eclipse.papyrus.requirements.preferences/src/org/eclipse/papyrus/requirements/preferences/PreferenceConstants.java1
-rw-r--r--extraplugins/requirements/org.eclipse.papyrus.requirements.preferences/src/org/eclipse/papyrus/requirements/preferences/PreferenceInitializer.java10
-rw-r--r--extraplugins/requirements/org.eclipse.papyrus.requirements.preferences/src/org/eclipse/papyrus/requirements/preferences/PreferencePage.java4
-rw-r--r--extraplugins/requirements/org.eclipse.papyrus.requirements.sysml.assistant.commands/META-INF/MANIFEST.MF14
-rw-r--r--extraplugins/requirements/org.eclipse.papyrus.requirements.sysml.assistant.commands/src/org/eclipse/papyrus/requirements/sysml/assistant/commands/InitDecomposeReqCommand.java50
9 files changed, 59 insertions, 50 deletions
diff --git a/extraplugins/requirements/org.eclipse.papyrus.requirements.preferences/META-INF/MANIFEST.MF b/extraplugins/requirements/org.eclipse.papyrus.requirements.preferences/META-INF/MANIFEST.MF
index da3d8ceb5ae..d583ada9de7 100644
--- a/extraplugins/requirements/org.eclipse.papyrus.requirements.preferences/META-INF/MANIFEST.MF
+++ b/extraplugins/requirements/org.eclipse.papyrus.requirements.preferences/META-INF/MANIFEST.MF
@@ -1,13 +1,18 @@
Manifest-Version: 1.0
-Require-Bundle: org.eclipse.ui;bundle-version="3.107.0",
- org.eclipse.core.runtime;bundle-version="3.12.0"
-Export-Package: org.eclipse.papyrus.requirements.preferences
+Bundle-ManifestVersion: 2
+Bundle-Name: %Bundle-Name
Bundle-Vendor: %Bundle-Vendor
-Bundle-ActivationPolicy: lazy
+Bundle-SymbolicName: org.eclipse.papyrus.requirements.preferences;singleton:=true
Bundle-Version: 0.7.0.qualifier
-Bundle-Name: %Bundle-Name
-Bundle-Localization: plugin
-Bundle-ManifestVersion: 2
Bundle-Activator: org.eclipse.papyrus.requirements.preferences.Activator
-Bundle-SymbolicName: org.eclipse.papyrus.requirements.preferences;singleton:=true
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
+Bundle-ActivationPolicy: lazy
+Export-Package: org.eclipse.papyrus.requirements.preferences;
+ uses:="org.osgi.framework,
+ org.eclipse.ui,
+ org.eclipse.jface.preference,
+ org.eclipse.core.runtime.preferences,
+ org.eclipse.ui.plugin"
+Bundle-Localization: bundle
diff --git a/extraplugins/requirements/org.eclipse.papyrus.requirements.preferences/build.properties b/extraplugins/requirements/org.eclipse.papyrus.requirements.preferences/build.properties
index 653ec3c3daf..d45a00fecd7 100644
--- a/extraplugins/requirements/org.eclipse.papyrus.requirements.preferences/build.properties
+++ b/extraplugins/requirements/org.eclipse.papyrus.requirements.preferences/build.properties
@@ -4,5 +4,6 @@ bin.includes = META-INF/,\
.,\
plugin.xml,\
about.html,\
- plugin.properties
-src.includes = about.html
+ bundle.properties
+src.includes = about.html,\
+ bundle.properties
diff --git a/extraplugins/requirements/org.eclipse.papyrus.requirements.preferences/plugin.properties b/extraplugins/requirements/org.eclipse.papyrus.requirements.preferences/bundle.properties
index 8e8d174ccba..adb42f1ab59 100644
--- a/extraplugins/requirements/org.eclipse.papyrus.requirements.preferences/plugin.properties
+++ b/extraplugins/requirements/org.eclipse.papyrus.requirements.preferences/bundle.properties
@@ -1,4 +1,4 @@
#Properties file for org.eclipse.papyrus.requirements.preferences
Bundle-Vendor = Eclipse Modeling Project
Bundle-Name = Papyrus for Requirements - Preferences (Incubation)
-page.name = Papyrus for Requirements
+page.name = Papyrus for Requirements \ No newline at end of file
diff --git a/extraplugins/requirements/org.eclipse.papyrus.requirements.preferences/plugin.xml b/extraplugins/requirements/org.eclipse.papyrus.requirements.preferences/plugin.xml
index f7f8c2a46ce..ecf5cafa86c 100644
--- a/extraplugins/requirements/org.eclipse.papyrus.requirements.preferences/plugin.xml
+++ b/extraplugins/requirements/org.eclipse.papyrus.requirements.preferences/plugin.xml
@@ -6,7 +6,7 @@
<page
category="org.eclipse.papyrus.infra.core.sasheditor.preferences.generalcategory"
class="org.eclipse.papyrus.requirements.preferences.PreferencePage"
- id="org.eclipse.papyrus.requirements.sysml.preferences.PreferencePage"
+ id="org.eclipse.papyrus.requirements.preferences.PreferencePage"
name="%page.name">
</page>
</extension>
diff --git a/extraplugins/requirements/org.eclipse.papyrus.requirements.preferences/src/org/eclipse/papyrus/requirements/preferences/PreferenceConstants.java b/extraplugins/requirements/org.eclipse.papyrus.requirements.preferences/src/org/eclipse/papyrus/requirements/preferences/PreferenceConstants.java
index 277aa7af3a3..2dccba0e22c 100644
--- a/extraplugins/requirements/org.eclipse.papyrus.requirements.preferences/src/org/eclipse/papyrus/requirements/preferences/PreferenceConstants.java
+++ b/extraplugins/requirements/org.eclipse.papyrus.requirements.preferences/src/org/eclipse/papyrus/requirements/preferences/PreferenceConstants.java
@@ -22,6 +22,7 @@ public class PreferenceConstants {
public static final String REQUIREMENT_ID_PREFIX = "REQUIREMENT_ID_PREFIX";
public static final String REQUIREMENT_ID_DIGIT = "REQUIREMENT_ID_DIGIT";
public static final String CHILD_REQUIREMENTS_SEPARATOR = "CHILD_REQUIREMENTS_SEPARATOR";
+ public static final String REQUIREMENT_ID_UNIQUE_IN_ENTIRE_MODEL = "REQUIREMENT_ID_UNIQUE_IN_ENTIRE_MODEL";
//Options for the generation of a profile based on a domain model
public static final String NSURI_PREFIX = "NSURI_PREFIX";
public static final String GENERATE_ABSTRACTIONS_MODEL = "GENERATE_ABSTRACTIONS_MODEL";
diff --git a/extraplugins/requirements/org.eclipse.papyrus.requirements.preferences/src/org/eclipse/papyrus/requirements/preferences/PreferenceInitializer.java b/extraplugins/requirements/org.eclipse.papyrus.requirements.preferences/src/org/eclipse/papyrus/requirements/preferences/PreferenceInitializer.java
index 5a9859faf18..1519cbaf230 100644
--- a/extraplugins/requirements/org.eclipse.papyrus.requirements.preferences/src/org/eclipse/papyrus/requirements/preferences/PreferenceInitializer.java
+++ b/extraplugins/requirements/org.eclipse.papyrus.requirements.preferences/src/org/eclipse/papyrus/requirements/preferences/PreferenceInitializer.java
@@ -18,7 +18,7 @@ import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
import org.eclipse.jface.preference.IPreferenceStore;
/**
- * Initializes the preferences for the creation of Papyrus REQ SysML
+ * Initializes the preferences for the creation of Papyrus for Requirements SysML
* requirements
*
*/
@@ -29,10 +29,10 @@ public class PreferenceInitializer extends AbstractPreferenceInitializer {
IPreferenceStore store = Activator.getDefault().getPreferenceStore();
// Options for requirements creation
- store.setDefault(PreferenceConstants.REQUIREMENT_ID_PREFIX, "REQ_");
- store.setDefault(PreferenceConstants.REQUIREMENT_ID_DIGIT, 3);
- store.setDefault(PreferenceConstants.CHILD_REQUIREMENTS_SEPARATOR, "_");
-
+ store.setDefault(PreferenceConstants.REQUIREMENT_ID_PREFIX, "R-");
+ store.setDefault(PreferenceConstants.REQUIREMENT_ID_DIGIT, 2);
+ store.setDefault(PreferenceConstants.CHILD_REQUIREMENTS_SEPARATOR, "-");
+ store.setDefault(PreferenceConstants.REQUIREMENT_ID_UNIQUE_IN_ENTIRE_MODEL, true);
// Options for the generation of a profile based on a domain model
store.setDefault(PreferenceConstants.NSURI_PREFIX, "https://www.eclipse.org/papyrus/");
store.setDefault(PreferenceConstants.GENERATE_ABSTRACTIONS_MODEL, false);
diff --git a/extraplugins/requirements/org.eclipse.papyrus.requirements.preferences/src/org/eclipse/papyrus/requirements/preferences/PreferencePage.java b/extraplugins/requirements/org.eclipse.papyrus.requirements.preferences/src/org/eclipse/papyrus/requirements/preferences/PreferencePage.java
index 2832f6c0976..095dfeb1754 100644
--- a/extraplugins/requirements/org.eclipse.papyrus.requirements.preferences/src/org/eclipse/papyrus/requirements/preferences/PreferencePage.java
+++ b/extraplugins/requirements/org.eclipse.papyrus.requirements.preferences/src/org/eclipse/papyrus/requirements/preferences/PreferencePage.java
@@ -27,7 +27,7 @@ import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPreferencePage;
/**
- * Preference page related to SysML Papyrus REQ
+ * Preference page related to SysML Papyrus for Requirements
*
*/
public class PreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage {
@@ -52,6 +52,8 @@ public class PreferencePage extends FieldEditorPreferencePage implements IWorkbe
reqCreationOptions));
addField(new StringFieldEditor(PreferenceConstants.CHILD_REQUIREMENTS_SEPARATOR,
"Separator between parent and child requirements IDs", reqCreationOptions));
+ addField(new BooleanFieldEditor(PreferenceConstants.REQUIREMENT_ID_UNIQUE_IN_ENTIRE_MODEL,
+ "ID must be unique in the entire model?", reqCreationOptions));
Group profileCreationOptions = createGroup("Generation of a profile based on a domain model");
addField(new StringFieldEditor(PreferenceConstants.NSURI_PREFIX, "Ns URI prefix for new profile",
diff --git a/extraplugins/requirements/org.eclipse.papyrus.requirements.sysml.assistant.commands/META-INF/MANIFEST.MF b/extraplugins/requirements/org.eclipse.papyrus.requirements.sysml.assistant.commands/META-INF/MANIFEST.MF
index 34e39b92c1b..97ffad177f7 100644
--- a/extraplugins/requirements/org.eclipse.papyrus.requirements.sysml.assistant.commands/META-INF/MANIFEST.MF
+++ b/extraplugins/requirements/org.eclipse.papyrus.requirements.sysml.assistant.commands/META-INF/MANIFEST.MF
@@ -5,14 +5,14 @@ Bundle-SymbolicName: org.eclipse.papyrus.requirements.sysml.assistant.commands;s
Bundle-Version: 0.7.0.qualifier
Bundle-Activator: org.eclipse.papyrus.requirements.sysml.assistant.commands.Activator
Bundle-Vendor: %Bundle-Vendor
-Require-Bundle: org.eclipse.gmf.runtime.diagram.ui;bundle-version="1.6.0",
- org.eclipse.papyrus.infra.widgets;bundle-version="1.2.0";resolution:=optional,
- org.eclipse.papyrus.requirements.preferences;bundle-version="0.7.0",
- org.eclipse.papyrus.requirements.sysml.common;bundle-version="0.7.0",
- org.eclipse.papyrus.uml.tools;bundle-version="1.2.0",
- org.eclipse.papyrus.infra.ui.emf;bundle-version="1.2.0"
+Require-Bundle: org.eclipse.papyrus.requirements.preferences;bundle-version="0.7.0",
+ org.eclipse.gmf.runtime.diagram.ui,
+ org.eclipse.papyrus.infra.ui.emf,
+ org.eclipse.papyrus.infra.widgets,
+ org.eclipse.papyrus.requirements.sysml.common,
+ org.eclipse.papyrus.uml.tools,
+ org.eclipse.papyrus.requirements.preferences
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Bundle-ActivationPolicy: lazy
Export-Package: org.eclipse.papyrus.requirements.sysml.assistant.commands
Bundle-Localization: plugin
-Import-Package: org.eclipse.papyrus.requirements.sysml.common
diff --git a/extraplugins/requirements/org.eclipse.papyrus.requirements.sysml.assistant.commands/src/org/eclipse/papyrus/requirements/sysml/assistant/commands/InitDecomposeReqCommand.java b/extraplugins/requirements/org.eclipse.papyrus.requirements.sysml.assistant.commands/src/org/eclipse/papyrus/requirements/sysml/assistant/commands/InitDecomposeReqCommand.java
index 28caec8cbf8..479f0f466a7 100644
--- a/extraplugins/requirements/org.eclipse.papyrus.requirements.sysml.assistant.commands/src/org/eclipse/papyrus/requirements/sysml/assistant/commands/InitDecomposeReqCommand.java
+++ b/extraplugins/requirements/org.eclipse.papyrus.requirements.sysml.assistant.commands/src/org/eclipse/papyrus/requirements/sysml/assistant/commands/InitDecomposeReqCommand.java
@@ -16,7 +16,6 @@ package org.eclipse.papyrus.requirements.sysml.assistant.commands;
import java.text.DecimalFormat;
import java.util.Iterator;
-
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.transaction.RecordingCommand;
import org.eclipse.emf.transaction.TransactionalEditingDomain;
@@ -24,13 +23,13 @@ import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.papyrus.requirements.preferences.PreferenceConstants;
import org.eclipse.papyrus.requirements.sysml.common.I_SysMLStereotype;
import org.eclipse.uml2.uml.Class;
-import org.eclipse.uml2.uml.Classifier;
import org.eclipse.uml2.uml.Element;
import org.eclipse.uml2.uml.Stereotype;
+import org.eclipse.uml2.uml.util.UMLUtil;
/**
* Creates a requirement and adds a decomposition link from the selected
- * requirement to the new requirement. The names are based on the Papyrus Req
+ * requirement to the new requirement. The names are based on the Papyrus for Requirements
* preferences.
*
*/
@@ -50,8 +49,7 @@ public class InitDecomposeReqCommand extends RecordingCommand {
org.eclipse.uml2.uml.Package owner = null;
if (selectedElement.getAppliedStereotype(I_SysMLStereotype.REQUIREMENT_STEREOTYPE) != null) {
Stereotype stereotype = selectedElement.getAppliedStereotype(I_SysMLStereotype.REQUIREMENT_STEREOTYPE);
- concatenedString = concatenedString + "\n"
- + selectedElement.getValue(stereotype, I_SysMLStereotype.REQUIREMENT_TEXT_ATT);
+ concatenedString = concatenedString + selectedElement.getValue(stereotype, I_SysMLStereotype.REQUIREMENT_TEXT_ATT);
owner = selectedElement.getNearestPackage();
String id = getNewIDReq((Class) selectedElement, stereotype);
Class req = owner.createOwnedClass(id, false);
@@ -74,19 +72,21 @@ public class InitDecomposeReqCommand extends RecordingCommand {
* @return the name for a potential requirement
*/
public static String getNewIDReq(org.eclipse.uml2.uml.Class parent, Stereotype stereotype) {
- IPreferenceStore store = Activator.getDefault().getPreferenceStore();
+ IPreferenceStore store = org.eclipse.papyrus.requirements.preferences.Activator.getDefault().getPreferenceStore();
+
String prefix = store.getString(PreferenceConstants.REQUIREMENT_ID_PREFIX);// by
// default
- // "REQ_"
+ // "R-"
String separator = store.getString(PreferenceConstants.CHILD_REQUIREMENTS_SEPARATOR); // by
// default
- // "_"
+ // "-"
+ boolean idUniqueInModel = store.getBoolean(PreferenceConstants.REQUIREMENT_ID_UNIQUE_IN_ENTIRE_MODEL); // by default true
String parentRequirementId = (String) parent.getValue(stereotype, I_SysMLStereotype.REQUIREMENT_ID_ATT);
+
String parentRequirementIdSuffix = parentRequirementId.replaceAll(prefix, "");
int digit = store.getInt(PreferenceConstants.REQUIREMENT_ID_DIGIT);// by
- // default
- // 3
+ // default 2
int i = 0;
DecimalFormat df = new DecimalFormat();
df.setMinimumIntegerDigits(digit);
@@ -96,24 +96,24 @@ public class InitDecomposeReqCommand extends RecordingCommand {
IDexist = false;
i++;
value = (df.format(i));
- EList<Classifier> classifiers = parent.getNestedClassifiers();
- for (Iterator<Classifier> iterator = classifiers.iterator(); iterator.hasNext() && (!IDexist);) {
- Classifier classifier = (Classifier) iterator.next();
- // current element is a Req?
- Stereotype reqStereotype = classifier.getAppliedStereotype(I_SysMLStereotype.REQUIREMENT_STEREOTYPE);
- if (reqStereotype != null) {
- if (classifier.getValue(reqStereotype, I_SysMLStereotype.REQUIREMENT_ID_ATT) != null) {
- String existedID = (String) classifier.getValue(reqStereotype,
- I_SysMLStereotype.REQUIREMENT_ID_ATT);
- String newID = prefix + parentRequirementIdSuffix + separator + value;
- // id already exists so increment suffix
- if (newID.equals(existedID)) {
- IDexist = true;
- }
+ EList<Element> elements = null;
+ if (idUniqueInModel) {
+ elements = parent.getModel().allOwnedElements();
+ } else {
+ elements = parent.allOwnedElements();
+ }
+ for (Iterator<Element> iterator = elements.iterator(); iterator.hasNext() && (!IDexist);) {
+ Element element = (Element) iterator.next();
+ Object reqIdObject = UMLUtil.getTaggedValue(element, I_SysMLStereotype.REQUIREMENT_STEREOTYPE, I_SysMLStereotype.REQUIREMENT_ID_ATT);
+ if (reqIdObject != null) {
+ String existedID = (String) reqIdObject;
+ String newID = prefix + parentRequirementIdSuffix + separator + value;
+ // id already exists so increment suffix
+ if (newID.equals(existedID)) {
+ IDexist = true;
}
}
}
-
}
return prefix + parentRequirementIdSuffix + separator + value;
}

Back to the top