Search in sources :

Example 1 with SystemTypeImpl

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;
}
Also used : SystemImplementationImpl(org.osate.aadl2.impl.SystemImplementationImpl) EObject(org.eclipse.emf.ecore.EObject)

Example 2 with SystemTypeImpl

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);
        }
    }
}
Also used : ResourceSetImpl(org.eclipse.emf.ecore.resource.impl.ResourceSetImpl) EObject(org.eclipse.emf.ecore.EObject) Resource(org.eclipse.emf.ecore.resource.Resource) SystemTypeImpl(org.osate.aadl2.impl.SystemTypeImpl)

Example 3 with SystemTypeImpl

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;
}
Also used : CLabel(org.eclipse.swt.custom.CLabel) Composite(org.eclipse.swt.widgets.Composite) DefaultAnnexSubclauseImpl(org.osate.aadl2.impl.DefaultAnnexSubclauseImpl) Color(org.eclipse.swt.graphics.Color) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) IEditorPart(org.eclipse.ui.IEditorPart) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) ArrayList(java.util.ArrayList) List(java.util.List)

Example 4 with SystemTypeImpl

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;
}
Also used : DefaultAnnexSubclauseImpl(org.osate.aadl2.impl.DefaultAnnexSubclauseImpl) Statement(com.ge.research.osate.verdict.dsl.verdict.Statement) EObject(org.eclipse.emf.ecore.EObject) ArrayList(java.util.ArrayList) Verdict(com.ge.research.osate.verdict.dsl.verdict.Verdict) VerdictContractSubclause(com.ge.research.osate.verdict.dsl.verdict.VerdictContractSubclause)

Example 5 with SystemTypeImpl

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;
}
Also used : DefaultAnnexSubclauseImpl(org.osate.aadl2.impl.DefaultAnnexSubclauseImpl) Statement(com.ge.research.osate.verdict.dsl.verdict.Statement) ArrayList(java.util.ArrayList) VerdictContractSubclause(com.ge.research.osate.verdict.dsl.verdict.VerdictContractSubclause) EObject(org.eclipse.emf.ecore.EObject) CyberMissionImpl(com.ge.research.osate.verdict.dsl.verdict.impl.CyberMissionImpl) Verdict(com.ge.research.osate.verdict.dsl.verdict.Verdict)

Aggregations

EObject (org.eclipse.emf.ecore.EObject)10 DefaultAnnexSubclauseImpl (org.osate.aadl2.impl.DefaultAnnexSubclauseImpl)6 Statement (com.ge.research.osate.verdict.dsl.verdict.Statement)5 Verdict (com.ge.research.osate.verdict.dsl.verdict.Verdict)5 VerdictContractSubclause (com.ge.research.osate.verdict.dsl.verdict.VerdictContractSubclause)5 ArrayList (java.util.ArrayList)5 SystemTypeImpl (org.osate.aadl2.impl.SystemTypeImpl)5 Resource (org.eclipse.emf.ecore.resource.Resource)4 ResourceSetImpl (org.eclipse.emf.ecore.resource.impl.ResourceSetImpl)4 CyberMissionImpl (com.ge.research.osate.verdict.dsl.verdict.impl.CyberMissionImpl)2 IEditorPart (org.eclipse.ui.IEditorPart)2 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)2 SystemImplementationImpl (org.osate.aadl2.impl.SystemImplementationImpl)2 CyberRelImpl (com.ge.research.osate.verdict.dsl.verdict.impl.CyberRelImpl)1 CyberReqImpl (com.ge.research.osate.verdict.dsl.verdict.impl.CyberReqImpl)1 StatementEditor (com.ge.research.osate.verdict.gui.StatementEditor)1 WzrdDashboard (com.ge.research.osate.verdict.gui.WzrdDashboard)1 IOException (java.io.IOException)1 List (java.util.List)1 ExecutionException (org.eclipse.core.commands.ExecutionException)1