Search in sources :

Example 1 with RequirementEditor

use of org.obeonetwork.dsl.requirement.presentation.RequirementEditor in project InformationSystem by ObeoNetwork.

the class ValidateRequirementsHandler method execute.

public Object execute(ExecutionEvent event) throws ExecutionException {
    IEditorPart editor = HandlerUtil.getActiveEditor(event);
    IEditorInput editorInput = HandlerUtil.getActiveEditorInput(event);
    if (editor instanceof RequirementEditor) {
        shell = HandlerUtil.getActiveShell(event);
        RequirementEditor ed = (RequirementEditor) editor;
        resourceSet = ed.getEditingDomain().getResourceSet();
    } else if (editorInput instanceof SessionEditorInput) {
        shell = HandlerUtil.getActiveShell(event);
        resourceSet = ((SessionEditorInput) editorInput).getSession().getTransactionalEditingDomain().getResourceSet();
    } else {
        return null;
    }
    Collection<EObject> objects = new ArrayList<EObject>();
    for (Resource resource : resourceSet.getResources()) {
        for (EObject eObject : resource.getContents()) {
            if (eObject instanceof Repository || eObject instanceof Category || eObject instanceof Requirement) {
                objects.add(eObject);
            }
        }
    }
    executeValidation(objects);
    return null;
}
Also used : SessionEditorInput(org.eclipse.sirius.ui.business.api.session.SessionEditorInput) Requirement(org.obeonetwork.dsl.requirement.Requirement) Repository(org.obeonetwork.dsl.requirement.Repository) Category(org.obeonetwork.dsl.requirement.Category) EObject(org.eclipse.emf.ecore.EObject) ArrayList(java.util.ArrayList) Resource(org.eclipse.emf.ecore.resource.Resource) RequirementEditor(org.obeonetwork.dsl.requirement.presentation.RequirementEditor) IEditorPart(org.eclipse.ui.IEditorPart) IEditorInput(org.eclipse.ui.IEditorInput)

Example 2 with RequirementEditor

use of org.obeonetwork.dsl.requirement.presentation.RequirementEditor in project InformationSystem by ObeoNetwork.

the class RequirementsShouldBeTested method test.

public boolean test(Object receiver, String property, Object[] args, Object expectedValue) {
    if (receiver instanceof IEditorPart) {
        if (receiver instanceof RequirementEditor) {
            return true;
        }
        IEditorInput editorInput = ((IEditorPart) receiver).getEditorInput();
        if (editorInput instanceof SessionEditorInput) {
            SessionEditorInput sessionEditorInput = (SessionEditorInput) editorInput;
            Session session = sessionEditorInput.getSession();
            if (session != null) {
                TransactionalEditingDomain ted = session.getTransactionalEditingDomain();
                if (ted != null) {
                    return containsRequirementsModel(ted.getResourceSet());
                }
            }
        }
    }
    return false;
}
Also used : SessionEditorInput(org.eclipse.sirius.ui.business.api.session.SessionEditorInput) TransactionalEditingDomain(org.eclipse.emf.transaction.TransactionalEditingDomain) RequirementEditor(org.obeonetwork.dsl.requirement.presentation.RequirementEditor) IEditorPart(org.eclipse.ui.IEditorPart) IEditorInput(org.eclipse.ui.IEditorInput) Session(org.eclipse.sirius.business.api.session.Session)

Aggregations

SessionEditorInput (org.eclipse.sirius.ui.business.api.session.SessionEditorInput)2 IEditorInput (org.eclipse.ui.IEditorInput)2 IEditorPart (org.eclipse.ui.IEditorPart)2 RequirementEditor (org.obeonetwork.dsl.requirement.presentation.RequirementEditor)2 ArrayList (java.util.ArrayList)1 EObject (org.eclipse.emf.ecore.EObject)1 Resource (org.eclipse.emf.ecore.resource.Resource)1 TransactionalEditingDomain (org.eclipse.emf.transaction.TransactionalEditingDomain)1 Session (org.eclipse.sirius.business.api.session.Session)1 Category (org.obeonetwork.dsl.requirement.Category)1 Repository (org.obeonetwork.dsl.requirement.Repository)1 Requirement (org.obeonetwork.dsl.requirement.Requirement)1