diff options
5 files changed, 47 insertions, 20 deletions
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 2dccba0e22c..94a91acb412 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 @@ -23,6 +23,12 @@ public class PreferenceConstants { 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 command "Extract annotations as comments" + public static final String INITIAL_CHAR = "INITIAL_CHAR"; + public static final String FINAL_CHAR = "FINAL_CHAR"; + public static final String MEANING_OF_TEXT_BETWEEN_CHARS = "MEANING_OF_TEXT_BETWEEN_CHARS"; + //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 1519cbaf230..9fdd6a61999 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 @@ -33,6 +33,11 @@ public class PreferenceInitializer extends AbstractPreferenceInitializer { store.setDefault(PreferenceConstants.REQUIREMENT_ID_DIGIT, 2);
store.setDefault(PreferenceConstants.CHILD_REQUIREMENTS_SEPARATOR, "-");
store.setDefault(PreferenceConstants.REQUIREMENT_ID_UNIQUE_IN_ENTIRE_MODEL, true);
+
+ store.setDefault(PreferenceConstants.INITIAL_CHAR, "[");
+ store.setDefault(PreferenceConstants.FINAL_CHAR, "]");
+ store.setDefault(PreferenceConstants.MEANING_OF_TEXT_BETWEEN_CHARS, "Stakeholder: ");
+
// 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 095dfeb1754..80673ddbdd6 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 @@ -54,7 +54,16 @@ public class PreferencePage extends FieldEditorPreferencePage implements IWorkbe "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 annotationsOptions = createGroup("Requirements extract annotations as comments");
+ addField(new StringFieldEditor(PreferenceConstants.INITIAL_CHAR, "Initial character",
+ annotationsOptions));
+ addField(new StringFieldEditor(PreferenceConstants.FINAL_CHAR, "Final character",
+ annotationsOptions));
+ addField(new StringFieldEditor(PreferenceConstants.MEANING_OF_TEXT_BETWEEN_CHARS, "Label to identify what is between the initial and characters",
+ annotationsOptions));
+
+
Group profileCreationOptions = createGroup("Generation of a profile based on a domain model");
addField(new StringFieldEditor(PreferenceConstants.NSURI_PREFIX, "Ns URI prefix for new profile",
profileCreationOptions));
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 97ffad177f7..3329dd33ba0 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 @@ -7,8 +7,6 @@ Bundle-Activator: org.eclipse.papyrus.requirements.sysml.assistant.commands.Acti Bundle-Vendor: %Bundle-Vendor 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 diff --git a/extraplugins/requirements/org.eclipse.papyrus.requirements.sysml.assistant.commands/src/org/eclipse/papyrus/requirements/sysml/assistant/commands/ExtractCommentCommand.java b/extraplugins/requirements/org.eclipse.papyrus.requirements.sysml.assistant.commands/src/org/eclipse/papyrus/requirements/sysml/assistant/commands/ExtractCommentCommand.java index 08c7854b00d..7f5329a295f 100644 --- a/extraplugins/requirements/org.eclipse.papyrus.requirements.sysml.assistant.commands/src/org/eclipse/papyrus/requirements/sysml/assistant/commands/ExtractCommentCommand.java +++ b/extraplugins/requirements/org.eclipse.papyrus.requirements.sysml.assistant.commands/src/org/eclipse/papyrus/requirements/sysml/assistant/commands/ExtractCommentCommand.java @@ -17,11 +17,14 @@ import java.util.Iterator; import org.eclipse.emf.transaction.RecordingCommand;
import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.papyrus.requirements.sysml.common.I_SysMLStereotype;
+import org.eclipse.papyrus.requirements.preferences.PreferenceConstants;
import org.eclipse.uml2.uml.Class;
import org.eclipse.uml2.uml.Comment;
import org.eclipse.uml2.uml.Element;
import org.eclipse.uml2.uml.Stereotype;
+
/**
*
* Parses the text of the requirement and move some parts as comments
@@ -29,36 +32,44 @@ import org.eclipse.uml2.uml.Stereotype; */
public class ExtractCommentCommand extends RecordingCommand {
protected ArrayList<Element> selectedElements;
+
public ExtractCommentCommand(TransactionalEditingDomain domain, ArrayList<Element> selectedElements) {
- super(domain,"ExtractCommentCommand" );
- this.selectedElements=selectedElements;
+ super(domain, "ExtractCommentCommand");
+ this.selectedElements = selectedElements;
}
- protected void createAnnotatedComment(Element owner,String text){
- Comment comment=owner.createOwnedComment();
+ protected void createAnnotatedComment(Element owner, String text) {
+ Comment comment = owner.createOwnedComment();
comment.getAnnotatedElements().add(owner);
comment.setBody(text);
}
/**
- * example [stakeHolder1, stakeHolder2]
*
- * @param req
+ * Example: "[stakeHolder1, stakeHolder2] some text" in the text attribute of a requirement,
+ * becomes the text "Stakeholders:[stakeHolder1, stakeHolder2]" in the body of a new comment
+ * of the requirement received as input.
+ *
+ * @param requirement
*/
- protected void parseAndExecute(Class req) {
- Stereotype reqStereotype = req.getAppliedStereotype(I_SysMLStereotype.REQUIREMENT_STEREOTYPE);
- String text = (String) req.getValue(reqStereotype, I_SysMLStereotype.REQUIREMENT_TEXT_ATT);
+ protected void parseAndExecute(Class requirement) {
+ IPreferenceStore store = org.eclipse.papyrus.requirements.preferences.Activator.getDefault().getPreferenceStore();
+ String initialChar = store.getString(PreferenceConstants.INITIAL_CHAR);
+ String finalChar = store.getString(PreferenceConstants.FINAL_CHAR);
+ String meaningOfTextBetweenChars = store.getString(PreferenceConstants.MEANING_OF_TEXT_BETWEEN_CHARS);
+
+ Stereotype reqStereotype = requirement.getAppliedStereotype(I_SysMLStereotype.REQUIREMENT_STEREOTYPE);
+ String text = (String) requirement.getValue(reqStereotype, I_SysMLStereotype.REQUIREMENT_TEXT_ATT);
if (text == null)
return;
text = text.trim();
- if (text.startsWith("[")) {
- // stakeholders detected
- int index = text.indexOf("]");
- String stakeholders = text.substring(0, index + 1);
+ if (text.startsWith(initialChar)) {
+ int index = text.indexOf(finalChar);
+ String extractedText = text.substring(0, index + 1);
text = text.substring(index + 1);
text = text.trim();
- createAnnotatedComment(req, "Stakeholders:" + stakeholders);
- req.setValue(reqStereotype, I_SysMLStereotype.REQUIREMENT_TEXT_ATT, text);
+ createAnnotatedComment(requirement, meaningOfTextBetweenChars + extractedText);
+ requirement.setValue(reqStereotype, I_SysMLStereotype.REQUIREMENT_TEXT_ATT, text);
}
}
@@ -69,9 +80,7 @@ public class ExtractCommentCommand extends RecordingCommand { if (currentElement.getAppliedStereotype(I_SysMLStereotype.REQUIREMENT_STEREOTYPE) != null) {
parseAndExecute((Class) currentElement);
}
-
}
-
}
}
|