Search in sources :

Example 1 with SessionEditorInput

use of org.eclipse.sirius.ui.business.api.session.SessionEditorInput in project InformationSystem by ObeoNetwork.

the class BindingTreeEditor method init.

/**
 * {@inheritDoc}
 *
 * @see org.eclipse.ui.part.EditorPart#init(org.eclipse.ui.IEditorSite, org.eclipse.ui.IEditorInput)
 */
@Override
public void init(IEditorSite site, IEditorInput input) throws PartInitException {
    setSite(site);
    setInput(input);
    if (input instanceof SessionEditorInput) {
        final URI uri = ((SessionEditorInput) input).getURI();
        this.session = ((SessionEditorInput) input).getSession();
        setBindingEditorRepresentation(getBindingEditorRepresentation(uri, false));
    }
    if (session != null) {
        session.addListener(this);
    }
    final IEditingSession uiSession = SessionUIManager.INSTANCE.getOrCreateUISession(this.session);
    uiSession.open();
    uiSession.attachEditor(this);
    setAccessor(SiriusPlugin.getDefault().getModelAccessorRegistry().getModelAccessor(getBindingEditorRepresentation()));
    /*
		 * let's activate the model listening
		 */
    // final DTreeElementSynchronizer sync = new DTreeElementSynchronizerSpec(accessor, getInterpreter());
    // getTreeModel().activate(sync);
    /* Update title. Semantic tree could have been renamed */
    notify(PROP_TITLE);
}
Also used : SessionEditorInput(org.eclipse.sirius.ui.business.api.session.SessionEditorInput) IEditingSession(org.eclipse.sirius.ui.business.api.session.IEditingSession) URI(org.eclipse.emf.common.util.URI)

Example 2 with SessionEditorInput

use of org.eclipse.sirius.ui.business.api.session.SessionEditorInput 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 3 with SessionEditorInput

use of org.eclipse.sirius.ui.business.api.session.SessionEditorInput in project InformationSystem by ObeoNetwork.

the class ContainsISModelPropertyTester method test.

public boolean test(Object receiver, String property, Object[] args, Object expectedValue) {
    if (receiver instanceof IEditorPart) {
        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 containsIsModel(ted.getResourceSet());
                }
            }
        }
    }
    return false;
}
Also used : SessionEditorInput(org.eclipse.sirius.ui.business.api.session.SessionEditorInput) TransactionalEditingDomain(org.eclipse.emf.transaction.TransactionalEditingDomain) IEditorPart(org.eclipse.ui.IEditorPart) IEditorInput(org.eclipse.ui.IEditorInput) Session(org.eclipse.sirius.business.api.session.Session)

Example 4 with SessionEditorInput

use of org.eclipse.sirius.ui.business.api.session.SessionEditorInput 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)

Example 5 with SessionEditorInput

use of org.eclipse.sirius.ui.business.api.session.SessionEditorInput in project InformationSystem by ObeoNetwork.

the class BindingDialectUIServices method openEditor.

@Override
public IEditorPart openEditor(Session session, DRepresentation representation, IProgressMonitor monitor) {
    if (representation instanceof DBindingEditor) {
        monitor.beginTask("Opening binding editor", 1);
        URI uri = EcoreUtil.getURI(representation);
        final TransactionalEditingDomain domain = session.getTransactionalEditingDomain();
        final IEditorInput editorInput = new SessionEditorInput(uri, getEditorName(representation), session);
        RunnableWithResult<IEditorPart> runnable = new RunnableWithResult.Impl<IEditorPart>() {

            @Override
            public void run() {
                final IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
                try {
                    setResult(page.openEditor(editorInput, BindingTreeEditor.ID));
                } catch (final PartInitException e) {
                // silent catch
                }
            }
        };
        PlatformUI.getWorkbench().getDisplay().syncExec(runnable);
        Object result = runnable.getResult();
        if (result instanceof IEditorPart && canHandleEditor((IEditorPart) result)) {
            // Activation of the refresh of the DBindingEditor property page
            if (result instanceof BindingTreeEditor) {
                // TODO v�rifier s'il faut enlever des choses
                doRefresh((DBindingEditor) representation, domain);
            }
            return (IEditorPart) result;
        }
        monitor.worked(1);
        monitor.done();
    }
    return null;
}
Also used : SessionEditorInput(org.eclipse.sirius.ui.business.api.session.SessionEditorInput) TransactionalEditingDomain(org.eclipse.emf.transaction.TransactionalEditingDomain) DBindingEditor(org.obeonetwork.dsl.environment.bindingdialect.DBindingEditor) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) EObject(org.eclipse.emf.ecore.EObject) IEditorPart(org.eclipse.ui.IEditorPart) PartInitException(org.eclipse.ui.PartInitException) URI(org.eclipse.emf.common.util.URI) IEditorInput(org.eclipse.ui.IEditorInput) BindingTreeEditor(org.obeonetwork.dsl.environment.binding.dialect.ui.editor.BindingTreeEditor)

Aggregations

SessionEditorInput (org.eclipse.sirius.ui.business.api.session.SessionEditorInput)5 IEditorInput (org.eclipse.ui.IEditorInput)4 IEditorPart (org.eclipse.ui.IEditorPart)4 TransactionalEditingDomain (org.eclipse.emf.transaction.TransactionalEditingDomain)3 URI (org.eclipse.emf.common.util.URI)2 EObject (org.eclipse.emf.ecore.EObject)2 Session (org.eclipse.sirius.business.api.session.Session)2 RequirementEditor (org.obeonetwork.dsl.requirement.presentation.RequirementEditor)2 ArrayList (java.util.ArrayList)1 Resource (org.eclipse.emf.ecore.resource.Resource)1 IEditingSession (org.eclipse.sirius.ui.business.api.session.IEditingSession)1 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)1 PartInitException (org.eclipse.ui.PartInitException)1 BindingTreeEditor (org.obeonetwork.dsl.environment.binding.dialect.ui.editor.BindingTreeEditor)1 DBindingEditor (org.obeonetwork.dsl.environment.bindingdialect.DBindingEditor)1 Category (org.obeonetwork.dsl.requirement.Category)1 Repository (org.obeonetwork.dsl.requirement.Repository)1 Requirement (org.obeonetwork.dsl.requirement.Requirement)1