Skip to content

Commit

Permalink
#116 Requirement Preference page and Diagram display update
Browse files Browse the repository at this point in the history
- Update the Requirement Preference page
- Update documentation
- Increase the Requirement content default display size in diagrams
- Fix broken Requirement content display for model link elements

Fixes #116

Change-Id: I7add5d4de1c07ef3e482679178e8f30df640ef86
Signed-off-by: Sandu Postaru <sandu.postaru@thalesgroup.com>
  • Loading branch information
sandupostaru authored and pdulth committed Jan 19, 2021
1 parent f94800a commit 9c8d04c
Show file tree
Hide file tree
Showing 11 changed files with 275 additions and 252 deletions.

Large diffs are not rendered by default.

Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public static List<AttributeSet> loadPropertiesFileAttributes(List<URI> properti

public static List<URI> getPropertyFilesFromPreferences() {
IPreferenceStore store = RequirementsPreferencesPlugin.getDefault().getPreferenceStore();
String values = store.getString(RequirementsPreferencesConstants.REQUIREMENT_PROPERTIES_FILES);
String values = store.getString(RequirementsPreferencesConstants.REQUIREMENT_PROPERTIES_FILES_KEY);
return deserializePropertyFilesPreference(values);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,15 @@
*/
public class RequirementsPreferencesConstants {

public static final String REQUIREMENT_LABEL_EXPRESSION = "requirement.label.expression";

public static final String REQUIREMENT_DEFAULT_LABEL_EXPRESSION = "aql:let puid = self.ownedAttributes->any(a | a.definition.ReqIFLongName == 'IE PUID')->collect(a | '['+a.value+']')->first() in let name = OrderedSet{self.ReqIFText, self.ReqIFName, self.ReqIFChapterName, self.ReqIFLongName}->any(s | s != null and s.size() > 0)->first() in OrderedSet{puid, name}->select(s | s != null)->sep(' ')->toString()";
public static final String REQUIREMENT_PROPERTIES_FILES_KEY = "requirement.properties.files";

public static final String REQUIREMENT_PROPERTIES_FILES = "requirement.properties.files";

public static final String REQUIREMENT_LABEL_MAX_LEN = "requirement.label.max.len";

public static final String REQUIREMENT_LABEL_EXPRESSION_KEY = "requirement.label.expression";
public static final String REQUIREMENT_DEFAULT_LABEL_EXPRESSION = "aql:let puid = self.ownedAttributes->any(a | a.definition.ReqIFLongName == 'IE PUID')->collect(a | '['+a.value+']')->first() in let name = OrderedSet{self.ReqIFText, self.ReqIFName, self.ReqIFChapterName, self.ReqIFLongName}->any(s | s != null and s.size() > 0)->first() in OrderedSet{puid, name}->select(s | s != null)->sep(' ')->toString()";
public static final String REQUIREMENT_LABEL_MAX_LEN_KEY = "requirement.label.max.len";
public static final String REQUIREMENT_DEFAULT_LABEL_MAX_LEN = "80";

public static final String VALUE_LABEL_MAX_LEN = "value.label.max.len";

public static final String VALUE_DEFAULT_LABEL_MAX_LEN = "80";
public static final String ENUMERATION_VALUE_ATTRIBUTE_LABEL_MAX_LEN_KEY = "value.label.max.len";
public static final String ENUMERATION_VALUE_ATTRIBUTE_DEFAULT_LABEL_MAX_LEN = "80";
/**
* Preference used to enforce requirements check with Doors and RMF plugin
*/
Expand All @@ -38,5 +34,5 @@ public class RequirementsPreferencesConstants {
* Default value
*/
public static final String DEFAULT_VALUE_FORCE_DOORS_RMF_USAGE = "false";

}
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ public class RequirementsPreferencesInitializer extends AbstractPreferenceInitia
@Override
public void initializeDefaultPreferences() {
IPreferenceStore store = RequirementsPreferencesPlugin.getDefault().getPreferenceStore();
store.setDefault(RequirementsPreferencesConstants.REQUIREMENT_LABEL_EXPRESSION,
store.setDefault(RequirementsPreferencesConstants.REQUIREMENT_LABEL_EXPRESSION_KEY,
RequirementsPreferencesConstants.REQUIREMENT_DEFAULT_LABEL_EXPRESSION);
store.setDefault(RequirementsPreferencesConstants.REQUIREMENT_LABEL_MAX_LEN,
store.setDefault(RequirementsPreferencesConstants.REQUIREMENT_LABEL_MAX_LEN_KEY,
RequirementsPreferencesConstants.REQUIREMENT_DEFAULT_LABEL_MAX_LEN);
store.setDefault(RequirementsPreferencesConstants.VALUE_LABEL_MAX_LEN,
RequirementsPreferencesConstants.VALUE_DEFAULT_LABEL_MAX_LEN);
store.setDefault(RequirementsPreferencesConstants.ENUMERATION_VALUE_ATTRIBUTE_LABEL_MAX_LEN_KEY,
RequirementsPreferencesConstants.ENUMERATION_VALUE_ATTRIBUTE_DEFAULT_LABEL_MAX_LEN);
store.setDefault(RequirementsPreferencesConstants.PREFERENCE_FORCE_DOORS_RMF_USAGE,
RequirementsPreferencesConstants.DEFAULT_VALUE_FORCE_DOORS_RMF_USAGE);
RequirementsPreferencesConstants.DEFAULT_VALUE_FORCE_DOORS_RMF_USAGE);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ GROUP_TITLE_FOR_CONTENT_AREA=Requirement's content
EXPRESSION_LABEL_TEXT=Expression
LENGTH_LABEL_TEXT=Length (put nothing to display full text):
DefaultValueOfLabelExpression=aql:self.ownedAttributes->select( a | a.definition.ReqIFLongName == 'IE PUID').value
DefaultValueOfContentExpression=aql:OrderedSet{self.ReqIFLongName, self.ReqIFName, self.ReqIFChapterName, self.ReqIFText}->select(s | s != 'null' and s.size() > 0).prefix('- ')->sep('\n')
DefaultValueOfContentExpression=aql:OrderedSet{self.ReqIFLongName, self.ReqIFName, self.ReqIFChapterName, self.ReqIFText}->select(s | s != 'null' and s.size() > 0).prefix('- ')->sep('\\n')
DefaultValueOfLabelMaxLength=80
DefaultValueOfContentMaxLength=80
DefaultValueOfContentMaxLength=300
ReqVPConfigureDialog_Title=Configure Requirements' Labels In Diagram
ReqVPConfigureDialog_Message=Configure queries for computing the label and content of each requirement displayed in a diagram
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ protected void performApply() {
try {
// Write property files list in preferences.
String value = ReqImporterPreferencesUtil.serializePropertyFilesPreference(model.getPropertiesFiles());
preferenceStore.setValue(RequirementsPreferencesConstants.REQUIREMENT_PROPERTIES_FILES, value);
preferenceStore.setValue(RequirementsPreferencesConstants.REQUIREMENT_PROPERTIES_FILES_KEY, value);

// Write selected attributes in preferences.
for (AttributeSet category : model.getCategories()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,34 +66,50 @@ protected void createFieldEditors() {
Composite parentGroup = new Composite(getFieldEditorParent(), SWT.NONE);
parentGroup.setLayout(new GridLayout(1, false));

final Composite grp = createGroup("Requirement's label",
"Insert here an interpreted expression that will be evaluated to show the requirement's label", parentGroup);

StringFieldEditor _delayFieldEditor = new StringFieldEditor(
RequirementsPreferencesConstants.REQUIREMENT_LABEL_EXPRESSION, "Expression", grp);

addField(_delayFieldEditor);

final StringFieldEditor maxLenFieldEditor = new StringFieldEditor(
RequirementsPreferencesConstants.REQUIREMENT_LABEL_MAX_LEN, "Length (put nothing to display full text):", grp);
maxLenFieldEditor.getTextControl(grp)
.addModifyListener(new NumberFieldModifyListener(maxLenFieldEditor.getTextControl(grp)));
addField(maxLenFieldEditor);

final Composite grpValue = createGroup("Attribute Value's label",
"Insert here the maximum length of an attribute value's label", parentGroup);
final StringFieldEditor maxValueLenFieldEditor = new StringFieldEditor(
RequirementsPreferencesConstants.VALUE_LABEL_MAX_LEN, "Length (put nothing to display full text):", grpValue);
maxValueLenFieldEditor.getTextControl(grpValue)
.addModifyListener(new NumberFieldModifyListener(maxValueLenFieldEditor.getTextControl(grpValue)));
addField(maxValueLenFieldEditor);

final Composite grpOther = createGroup("Other configuration items",
"", parentGroup);
final BooleanFieldEditor forceDoorsRmfUsageBooleanEditor = new BooleanFieldEditor(
RequirementsPreferencesConstants.PREFERENCE_FORCE_DOORS_RMF_USAGE, "Force DOORS RMF usage check while importing requirements", grpOther);
addField(forceDoorsRmfUsageBooleanEditor);
createRequirementFieldEditors(parentGroup);
createEnumerationValueFieldEditors(parentGroup);
createOtherFieldEditors(parentGroup);
}

private void createRequirementFieldEditors(Composite parentGroup) {
Composite reqGroup = createGroup("Requirements", "Requirement Preferences", parentGroup);

StringFieldEditor reqLabelExpressionEditor = new StringFieldEditor(
RequirementsPreferencesConstants.REQUIREMENT_LABEL_EXPRESSION_KEY, "Label Expression", 80, 4,
StringFieldEditor.VALIDATE_ON_KEY_STROKE, reqGroup);

addField(reqLabelExpressionEditor);

StringFieldEditor reqLabelMaxLenEditor = new StringFieldEditor(
RequirementsPreferencesConstants.REQUIREMENT_LABEL_MAX_LEN_KEY, "Label Max Length (leave empty for full text)",
reqGroup);
reqLabelMaxLenEditor.getTextControl(reqGroup)
.addModifyListener(new NumberFieldModifyListener(reqLabelMaxLenEditor.getTextControl(reqGroup)));

addField(reqLabelMaxLenEditor);
}

private void createEnumerationValueFieldEditors(Composite parentGroup) {
Composite enumGroup = createGroup("Enumeration Value Attributes", "Enumeration Value Attribute Preferences",
parentGroup);

StringFieldEditor enumValueLabelMaxLenEditor = new StringFieldEditor(
RequirementsPreferencesConstants.ENUMERATION_VALUE_ATTRIBUTE_LABEL_MAX_LEN_KEY,
"Label Max Length (leave empty for full text)", enumGroup);
enumValueLabelMaxLenEditor.getTextControl(enumGroup)
.addModifyListener(new NumberFieldModifyListener(enumValueLabelMaxLenEditor.getTextControl(enumGroup)));

addField(enumValueLabelMaxLenEditor);
}

private void createOtherFieldEditors(Composite parentGroup) {
Composite otherGroup = createGroup("Other configuration items", "", parentGroup);

BooleanFieldEditor forceDoorsRmfUsageEditor = new BooleanFieldEditor(
RequirementsPreferencesConstants.PREFERENCE_FORCE_DOORS_RMF_USAGE,
"Force DOORS RMF usage check while importing requirements", otherGroup);

addField(forceDoorsRmfUsageEditor);
}

@Override
Expand All @@ -103,7 +119,7 @@ protected String getPageTitle() {

@Override
protected String getPageDescription() {
return "Capella requirements preference page";
return "Preferences related to Requirements";
}

class NumberFieldModifyListener implements ModifyListener {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public String getText(Object object) {

return reduceValueLabelLen(result.toString(),
RequirementsPreferencesPlugin.getDefault().getPreferenceStore()
.getString(RequirementsPreferencesConstants.VALUE_LABEL_MAX_LEN));
.getString(RequirementsPreferencesConstants.ENUMERATION_VALUE_ATTRIBUTE_LABEL_MAX_LEN_KEY));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public String getText(Object object) {
interpreter = CompoundInterpreter.INSTANCE;
if (interpreter != null) {
String expression = RequirementsPreferencesPlugin.getDefault().getPreferenceStore()
.getString(RequirementsPreferencesConstants.REQUIREMENT_LABEL_EXPRESSION);
.getString(RequirementsPreferencesConstants.REQUIREMENT_LABEL_EXPRESSION_KEY);
Object value = interpreter.evaluate(requirement, expression);
String result = "";
if (value instanceof List<?>) {
Expand All @@ -92,7 +92,7 @@ public String getText(Object object) {
}
result = LabelHelper.transformHTMLToText(result);
return reduceReqNameLen(result, RequirementsPreferencesPlugin.getDefault().getPreferenceStore()
.getString(RequirementsPreferencesConstants.REQUIREMENT_LABEL_MAX_LEN));
.getString(RequirementsPreferencesConstants.REQUIREMENT_LABEL_MAX_LEN_KEY));
}
} catch (EvaluationException ex) {
return "[Error in label expression] " + super.getText(object);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public void test() throws Exception {
propertiesFileURIs.add(URI.createFileURI(classicFile.getAbsolutePath()));
// Write property files list in preferences.
String value = ReqImporterPreferencesUtil.serializePropertyFilesPreference(propertiesFileURIs);
preferenceStore.setValue(RequirementsPreferencesConstants.REQUIREMENT_PROPERTIES_FILES, value);
preferenceStore.setValue(RequirementsPreferencesConstants.REQUIREMENT_PROPERTIES_FILES_KEY, value);

//
// Perform tests
Expand Down

0 comments on commit 9c8d04c

Please sign in to comment.