Commit 23f89f9a authored by Saad bin Abid's avatar Saad bin Abid
Browse files

Added Initial-Value field in the Signal Editor. To achieve this I extended the...

Added Initial-Value field in the Signal Editor. To achieve this I extended the mira.ecore model-> regenerated the model code. Put more code in the SignalViewer.java.
parent 6bf8a4c2
......@@ -53,7 +53,7 @@ import org.fortiss.tooling.kernel.utils.EcoreUtils;
* @author saadbinabid
* @author $Author$
* @version $Rev$
* @ConQAT.Rating YELLOW Hash: BFF6930804F28A8F172BBB86BC4E14BE
* @ConQAT.Rating YELLOW Hash: 1F07F0458A0971F76B39791B5D3D84D8
*/
public class MultipleAspectsConstraintUI extends ConstraintUIBases.ConstraintUIBaseAutocheck {
......@@ -160,7 +160,6 @@ public class MultipleAspectsConstraintUI extends ConstraintUIBases.ConstraintUIB
newReqFormalSpec.setPriority(RequirementPriority.NORMAL);
// CreateFormalSpecRequirement(newReqFormalSpec, req);
CopyRequirementProperties(newReqFormalSpec, req, spec);
// add formal specification contained elements
formalSpec.getContainedElements().addAll(
((FormalSpecification)spec).getContainedElements());
......
......@@ -138,6 +138,21 @@ public class SignalsViewer extends FilteredTree {
});
ioColumn.setEditingSupport(createIOEditingSupport(top, viewer, ioColumn));
// adding InitialValueColumn
TreeViewerColumn initialValueColumn = new TreeViewerColumn(viewer, SWT.NONE);
TreeColumn initValColType = initialValueColumn.getColumn();
initValColType.setWidth(120);
initValColType.setText("Initial-Value");
initialValueColumn.setLabelProvider(new ColumnLabelProvider() {
/** {@inheritDoc} */
@Override
public String getText(Object element) {
return getInitialValue(element);
}
});
initialValueColumn.setEditingSupport(createInitialValueEditingSupport(top, viewer,
initialValueColumn));
TreeViewerColumn typeColumn = new TreeViewerColumn(viewer, SWT.NONE);
TreeColumn trColType = typeColumn.getColumn();
trColType.setWidth(100);
......@@ -280,6 +295,44 @@ public class SignalsViewer extends FilteredTree {
};
}
/** {@link EditingSupport} for the initial-value column. */
private EditingSupport createInitialValueEditingSupport(ITopLevelElement top,
TreeViewer viewer, TreeViewerColumn initValColumn) {
return new EditingSupport(initValColumn.getViewer()) {
@Override
protected void setValue(Object element, Object value) {
if(element instanceof Signal) {
Signal config = (Signal)element;
if(config.getInitialValue().equals(value)) {
return;
}
top.runAsCommand(() -> {
((Signal)element).setInitialValue((String)value);
viewer.refresh();
});
}
}
@Override
protected Object getValue(Object element) {
return element instanceof Signal ? ((Signal)element).getInitialValue() : "";
}
@Override
protected CellEditor getCellEditor(Object element) {
return new TextCellEditorWithTextStyledTextActionHandler(
getTextStyledTextActionHandler.get(), (Composite)getViewer().getControl());
}
@Override
protected boolean canEdit(Object element) {
return true;
}
};
}
/** {@link EditingSupport} for the I/O column. */
private EditingSupport createIOEditingSupport(ITopLevelElement top, TreeViewer viewer,
TreeViewerColumn ioColumn) {
......@@ -383,6 +436,15 @@ public class SignalsViewer extends FilteredTree {
return txt;
}
/** Gets the string representation of the initial value displayed in the table. */
private String getInitialValue(Object element) {
String txt = "";
if(element instanceof Signal) {
txt = ((Signal)element).getInitialValue().toString();
}
return txt;
}
/**
* Checks if the name is empty or already exists among current signals, if so displays an error
* message and return true, otherwise returns false.
......
......@@ -505,6 +505,8 @@
<eStructuralFeatures xsi:type="ecore:EAttribute" name="input" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EBoolean"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="updateRate" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="unit" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="initialValue" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"
defaultValueLiteral=""/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="ISignalsContainer" abstract="true"
interface="true" eSuperTypes="platform:/resource/org.fortiss.tooling.kernel/model/kernel.ecore#//constraints/IConstrained">
......
......@@ -263,6 +263,7 @@
<genFeatures createChild="false" ecoreFeature="ecore:EAttribute mira.ecore#//functional/Signal/input"/>
<genFeatures createChild="false" ecoreFeature="ecore:EAttribute mira.ecore#//functional/Signal/updateRate"/>
<genFeatures createChild="false" ecoreFeature="ecore:EAttribute mira.ecore#//functional/Signal/unit"/>
<genFeatures createChild="false" ecoreFeature="ecore:EAttribute mira.ecore#//functional/Signal/initialValue"/>
</genClasses>
<genClasses image="false" ecoreClass="mira.ecore#//functional/ISignalsContainer">
<genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference mira.ecore#//functional/ISignalsContainer/signals"/>
......
......@@ -40,7 +40,7 @@ import org.fortiss.tooling.kernel.model.constraints.IConstraintInstanceStatus;
* @author abid
* @author $Author$
* @version $Rev$
* @ConQAT.Rating YELLOW Hash: 75E1971AE604133D4BBC4F2D3B499F32
* @ConQAT.Rating YELLOW Hash: 9CE8DF220B610CD284ED85A95685E5EA
*/
public class MultipleAspectsConstraint extends AF3ProjectConstraintCheckerBase {
......
......@@ -38,6 +38,7 @@ public class NameConstraint extends AF3ProjectConstraintCheckerBase {
@Override
public IConstraintInstanceStatus verify(IConstrained constrained) {
Requirement req = (Requirement)constrained;
return successIfTrue(!(req.getName() == null || req.getName().trim().isEmpty()));
}
......
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