use of org.osate.aadl2.impl.DefaultAnnexSubclauseImpl in project VERDICT by ge-high-assurance.
the class WzrdClosure method getAppendOffset.
// get the desired starting offset (as in the .aadl) of the generated code-block
private void getAppendOffset(boolean hasAnnex, IPath filePath) {
DefaultLocationInFileProvider defLoc = new DefaultLocationInFileProvider();
if (!hasAnnex) {
ITextRegion region = defLoc.getFullTextRegion(sys);
try {
offset = region.getOffset() + region.getLength();
offTab = getOffsetTab(filePath);
} catch (Exception e) {
e.printStackTrace();
}
offset = offset - offTab.addOffset;
} else {
List<EObject> objs = sys.eContents();
for (int i = 0; i < objs.size(); i++) {
if (objs.get(i) instanceof DefaultAnnexSubclauseImpl) {
if (!((DefaultAnnexSubclauseImpl) objs.get(i)).getName().equals("verdict")) {
continue;
}
ITextRegion region = defLoc.getFullTextRegion(objs.get(i));
try {
offset = region.getOffset() + region.getLength();
offTab = getOffsetTab(filePath);
} catch (Exception e) {
e.printStackTrace();
}
// 1 appear here since no semicolon if annex is present
offset = offset - offTab.addOffset + 1;
break;
}
}
}
}
use of org.osate.aadl2.impl.DefaultAnnexSubclauseImpl 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.DefaultAnnexSubclauseImpl 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.DefaultAnnexSubclauseImpl 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;
}
use of org.osate.aadl2.impl.DefaultAnnexSubclauseImpl in project AMASE by loonwerks.
the class FaultsVerifyAllHandler method isProbabilisticAnalysis.
private boolean isProbabilisticAnalysis() {
List<Classifier> classifiers = getClassifiers();
if (classifiers == null) {
return false;
}
// TODO: Finish addressing this issue.
for (Classifier cl : classifiers) {
// Get impl of this level
if (cl instanceof ComponentImplementationImpl) {
List<AnnexSubclause> asList = cl.getOwnedAnnexSubclauses();
for (AnnexSubclause as : asList) {
if (as.getName().equalsIgnoreCase("safety")) {
if (as instanceof DefaultAnnexSubclauseImpl) {
DefaultAnnexSubclauseImpl defaultAnnex = (DefaultAnnexSubclauseImpl) as;
SafetyContractSubclauseImpl safetyAnnex = (SafetyContractSubclauseImpl) defaultAnnex.getParsedAnnexSubclause();
// Get analysis stmt
List<SpecStatement> specs = ((SafetyContract) safetyAnnex.getContract()).getSpecs();
for (SpecStatement spec : specs) {
if (spec instanceof AnalysisStatement) {
if (!(((AnalysisStatement) spec).getBehavior() instanceof ProbabilityBehavior)) {
return false;
}
}
}
}
}
}
}
}
return true;
}
Aggregations