Commit cf95dbba authored by Vivek Nigam's avatar Vivek Nigam
Browse files

<mira> Safety Aspects


* Implemented the Hazard editor
* corrected bug in model

Issue-Ref: 3418
Signed-off-by: Vivek Nigam's avatarVivek Nigam <nigam@fortiss.org>
parent 7ba7d840
......@@ -15,22 +15,31 @@
+--------------------------------------------------------------------------*/
package org.fortiss.af3.mira.ui.editor;
import static org.eclipse.jface.databinding.viewers.ViewersObservables.observeSinglePostSelection;
import static org.fortiss.af3.mira.model.safety.SafetyPackage.Literals.HAZARD_REQUIREMENT_SPECIFICATION__HAZARD_IMPACT;
import static org.fortiss.af3.mira.ui.utils.HighlightUtils.createSourceViewer;
import static org.fortiss.af3.mira.ui.utils.MiraLayoutUtils.singleLineInputFactory;
import static org.fortiss.af3.mira.ui.utils.MiraLayoutUtils.singleLineLabelFactory;
import static org.fortiss.tooling.kernel.model.FortissToolingKernelPackage.Literals.INAMED_ELEMENT__NAME;
import static org.fortiss.tooling.kernel.ui.util.DataBindingUtils.bind;
import static org.fortiss.tooling.kernel.ui.util.ObservableUtils.observeValue;
import static org.fortiss.tooling.kernel.utils.EcoreUtils.pickInstanceOf;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.jface.text.source.SourceViewer;
import org.eclipse.jface.viewers.ArrayContentProvider;
import org.eclipse.jface.viewers.ComboViewer;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.fortiss.af3.mira.model.Requirement;
import org.fortiss.af3.mira.model.safety.HazardImpact;
import org.fortiss.af3.mira.model.safety.HazardRequirementSpecification;
import org.fortiss.tooling.base.model.element.IModelElementSpecification;
......@@ -66,6 +75,11 @@ public class HazardRequirementEditor<T extends Requirement> extends AspectEditor
singleLineInputFactory.applyTo(inputName.getControl());
bind(dbc, inputName.getTextWidget(), spec, INAMED_ELEMENT__NAME);
ComboViewer standardInput =
createSingleLineFixedInputRequirementField(hazardSection, "Hazard Impact",
HazardImpact.values(), spec,
HAZARD_REQUIREMENT_SPECIFICATION__HAZARD_IMPACT);
}
/** {@inheritDoc} */
......@@ -76,4 +90,25 @@ public class HazardRequirementEditor<T extends Requirement> extends AspectEditor
editedObject.getSpecifications()));
return res;
}
/** Create a single line field of a requirement with given input. */
private ComboViewer createSingleLineFixedInputRequirementField(Composite composite,
String labelName, Object inputValues, EObject object,
EStructuralFeature observedStructuralFeature) {
Label label = toolkit.createLabel(composite, labelName + " ", SWT.READ_ONLY);
singleLineLabelFactory.applyTo(label);
ComboViewer comboViewer = new ComboViewer(composite, SWT.READ_ONLY);
singleLineInputFactory.applyTo(comboViewer.getCombo());
toolkit.adapt(comboViewer.getCombo());
comboViewer.setContentProvider(new ArrayContentProvider());
comboViewer.setLabelProvider(new LabelProvider());
comboViewer.setInput(inputValues);
dbc.bindValue(observeSinglePostSelection(comboViewer),
observeValue(object, observedStructuralFeature));
comboViewer.getControl().setEnabled(true);
return comboViewer;
}
}
This diff is collapsed.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment