use of org.osate.aadl2.impl.SystemTypeImpl in project VERDICT by ge-high-assurance.
the class WzrdDashboard method checkIfSystem.
// check if component corr. to selected button is "top-level" (i.e. invoking .aadl contains a corresponding .impl element)
private boolean checkIfSystem(SystemTypeImpl sys) {
boolean sysLevel = false;
String systemName;
TreeIterator<EObject> tree = sys.eResource().getAllContents();
while (tree.hasNext()) {
EObject tmp = tree.next();
if (tmp instanceof SystemImplementationImpl) {
systemName = ((SystemImplementationImpl) tmp).getTypeName();
if (sys.getName().equals(systemName)) {
sysLevel = true;
break;
}
}
}
return sysLevel;
}
use of org.osate.aadl2.impl.SystemTypeImpl in project VERDICT by ge-high-assurance.
the class WzrdDashboard method loadSystems.
// reloads .aadl resource after modification of script content by Wizard
private void loadSystems(Resource oldResource) throws Exception {
ResourceSetImpl resourceSet = new ResourceSetImpl();
resourceSet.getResourceFactoryRegistry();
Resource resource = resourceSet.createResource(oldResource.getURI());
resource.load(null);
systems.clear();
TreeIterator<EObject> tree = resource.getAllContents();
while (tree.hasNext()) {
EObject anObject = tree.next();
if (anObject instanceof SystemTypeImpl) {
systems.add((SystemTypeImpl) anObject);
}
}
}
use of org.osate.aadl2.impl.SystemTypeImpl in project VERDICT by ge-high-assurance.
the class WzrdDashboard method createContents.
@Override
protected Control createContents(Composite parent) {
try {
// re-extract SystemTypeImpl instances from the current (possibly modified) resource
loadSystems(resource);
} catch (Exception e) {
e.printStackTrace();
}
Composite composite = new Composite(parent, SWT.NONE);
composite.setLayout(new GridLayout(4, false));
Composite childComposite = new Composite(composite, SWT.NONE);
GridData gridData = new GridData();
gridData.horizontalAlignment = GridData.FILL;
gridData.horizontalSpan = 4;
childComposite.setLayout(new GridLayout(1, false));
childComposite.setLayoutData(gridData);
// the following clabels define the color legends appearing at the top of dashboard
CLabel labelFirstLegend = new CLabel(childComposite, SWT.NONE);
labelFirstLegend.setText("Component with no Cyber-relation Defined");
labelFirstLegend.setImage(images[0]);
CLabel labelSecondLegend = new CLabel(childComposite, SWT.NONE);
labelSecondLegend.setText("Component with One or More Cyber-relation(s) Defined");
labelSecondLegend.setImage(images[1]);
CLabel labelThirdLegend = new CLabel(childComposite, SWT.NONE);
labelThirdLegend.setText("Top-Level System");
labelThirdLegend.setImage(images[2]);
// creates a button for each SystemTypeImpl instance in the invoking .aadl file
for (int i = 0; i < systems.size(); i++) {
Button aButton = new Button(composite, SWT.PUSH);
aButton.setText(systems.get(i).getFullName());
aButton.setToolTipText(composeToolTip(i));
if (checkIfSystem(systems.get(i))) {
// system with a corresponding .impl in invoking .aadl
aButton.setBackground(new Color(Display.getCurrent(), 145, 169, 216));
} else {
switch(colorTag) {
case // component with cyber-relation defined
0:
aButton.setBackground(new Color(Display.getCurrent(), 158, 196, 155));
break;
case // a spare legend, currently not used
1:
aButton.setBackground(new Color(Display.getCurrent(), 247, 135, 135));
break;
case // component with no cyber-relation defined
2:
aButton.setBackground(new Color(Display.getCurrent(), 242, 174, 39));
break;
}
}
colorTag = -1;
// this listener performs necessary activities when a button is selected
aButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
for (int j = 0; j < systems.size(); j++) {
if (systems.get(j).getFullName().equals(aButton.getText())) {
List<EObject> objs = systems.get(j).eContents();
for (int k = 0; k < objs.size(); k++) {
if (objs.get(k) instanceof DefaultAnnexSubclauseImpl) {
if (!((DefaultAnnexSubclauseImpl) objs.get(k)).getName().equals("verdict")) {
continue;
}
break;
}
}
// invoking cyber-property editor corresponding to the button
StatementEditor editor = new StatementEditor(systems.get(j), fileModel, shell, sourceRect, "dashboard");
// run the editor if the invoked editor instance is valid
if (editor.isValid()) {
composite.setEnabled(false);
editor.run();
composite.setEnabled(true);
}
try {
// re-extract SystemTypeImpl instances from the current (possibly modified) resource
loadSystems(resource);
} catch (Exception e) {
e.printStackTrace();
}
if (!aButton.isDisposed()) {
// update the toolTipText of the button
aButton.setToolTipText(composeToolTip(j));
// save the .aadl editor if any unsaved content exists-------------------
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
IEditorPart openEditor = page.getActiveEditor();
if (openEditor != null) {
page.saveEditor(openEditor, false);
}
// update button colour
if (checkIfSystem(systems.get(j))) {
// system with a corresponding .impl in invoking
aButton.setBackground(new Color(Display.getCurrent(), 145, 169, 216));
// .aadl
} else {
switch(colorTag) {
case 0:
// component with cyber-relation defined
aButton.setBackground(new Color(Display.getCurrent(), 158, 196, 155));
break;
case 1:
// a spare legend, currently not used
aButton.setBackground(new Color(Display.getCurrent(), 247, 135, 135));
break;
case 2:
// component with no cyber-relation defined
aButton.setBackground(new Color(Display.getCurrent(), 242, 174, 39));
break;
}
}
}
}
}
}
});
}
return composite;
}
use of org.osate.aadl2.impl.SystemTypeImpl in project VERDICT by ge-high-assurance.
the class WzrdTableLoader method getStatements.
// Extract the existing statements of the current component from .aadl script
private List<Statement> getStatements(SystemTypeImpl sys) {
List<EObject> objs = sys.eContents();
List<Statement> stmts = new ArrayList<Statement>();
for (int i = 0; i < objs.size(); i++) {
if (objs.get(i) instanceof DefaultAnnexSubclauseImpl) {
if (!((DefaultAnnexSubclauseImpl) objs.get(i)).getName().equals("verdict")) {
continue;
}
Verdict vd = ((VerdictContractSubclause) ((DefaultAnnexSubclauseImpl) objs.get(i)).getParsedAnnexSubclause()).getContract();
stmts = vd.getElements();
break;
}
}
return stmts;
}
use of org.osate.aadl2.impl.SystemTypeImpl in project VERDICT by ge-high-assurance.
the class StatementEditor method loadExistingMissions.
// reload the system content to take care of any change saved by used in
// .aadl script in course of current Wizard session
private List<MissionInfo> loadExistingMissions(SystemTypeImpl sys) {
List<MissionInfo> missions = new ArrayList<MissionInfo>();
TreeIterator<EObject> tree = sys.eAllContents();
while (tree.hasNext()) {
EObject tmp = tree.next();
if (tmp instanceof DefaultAnnexSubclauseImpl) {
if (!((DefaultAnnexSubclauseImpl) tmp).getName().equals("verdict")) {
continue;
}
Verdict vd = ((VerdictContractSubclause) ((DefaultAnnexSubclauseImpl) tmp).getParsedAnnexSubclause()).getContract();
List<Statement> stmts = vd.getElements();
for (int i = 0; i < stmts.size(); i++) {
if (stmts.get(i) instanceof CyberMissionImpl) {
MissionInfo newMission = new MissionInfo();
newMission.setMissionID(((CyberMissionImpl) stmts.get(i)).getId());
List<String> cyberReqs = ((CyberMissionImpl) stmts.get(i)).getCyberReqs();
for (int j = 0; j < cyberReqs.size(); j++) {
for (int k = 0; k < tableContent.size(); k++) {
if (tableContent.get(k).getFormulaID().equals(cyberReqs.get(j))) {
newMission.addToRow(k);
}
}
}
newMission.setComment(((CyberMissionImpl) stmts.get(i)).getNote());
newMission.setDescription(((CyberMissionImpl) stmts.get(i)).getDescription());
missions.add(newMission);
}
}
}
}
return missions;
}
Aggregations