Search in sources :

Example 1 with DBindingEditor

use of org.obeonetwork.dsl.environment.bindingdialect.DBindingEditor in project InformationSystem by ObeoNetwork.

the class BindingService method openBindingEditor.

public BindingInfo openBindingEditor(BindingInfo bindingInfo) {
    DBindingEditor editor = null;
    final Session session = SessionManager.INSTANCE.getSession(bindingInfo);
    // Find an editor to open
    Collection<DRepresentation> representations = DialectManager.INSTANCE.getRepresentations(bindingInfo, session);
    for (DRepresentation representation : representations) {
        if (representation instanceof DBindingEditor) {
            editor = (DBindingEditor) representation;
            break;
        }
    }
    // Create an editor if needed
    if (editor == null) {
        RepresentationDescription representationDescription = getBindingEditorRepresentation(session);
        if (representationDescription != null) {
            DRepresentation representation = DialectManager.INSTANCE.createRepresentation(computeBindingEditorName(bindingInfo), bindingInfo, representationDescription, session, new NullProgressMonitor());
            if (representation != null && representation instanceof DBindingEditor) {
                editor = (DBindingEditor) representation;
            }
        }
    }
    // Open the editor
    if (editor != null) {
        UserSession.from(session).openRepresentation(new StructuredSelection(editor));
    }
    return bindingInfo;
}
Also used : RepresentationDescription(org.eclipse.sirius.viewpoint.description.RepresentationDescription) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) DBindingEditor(org.obeonetwork.dsl.environment.bindingdialect.DBindingEditor) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) DRepresentation(org.eclipse.sirius.viewpoint.DRepresentation) UserSession(org.eclipse.sirius.ui.business.api.session.UserSession) Session(org.eclipse.sirius.business.api.session.Session)

Example 2 with DBindingEditor

use of org.obeonetwork.dsl.environment.bindingdialect.DBindingEditor 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)

Example 3 with DBindingEditor

use of org.obeonetwork.dsl.environment.bindingdialect.DBindingEditor in project InformationSystem by ObeoNetwork.

the class BindingTreeEditor method getBindingEditorRepresentation.

private DBindingEditor getBindingEditorRepresentation(final URI uri, final boolean loadOnDemand) {
    DBindingEditor result = null;
    final Resource resource = getEditingDomain().getResourceSet().getResource(uri.trimFragment(), loadOnDemand);
    if (resource != null && resource.isLoaded()) {
        if (uri.fragment() != null) {
            final EObject rootElement = resource.getEObject(uri.fragment());
            if (rootElement instanceof DBindingEditor) {
                result = (DBindingEditor) rootElement;
            }
        }
    }
    return result;
}
Also used : DBindingEditor(org.obeonetwork.dsl.environment.bindingdialect.DBindingEditor) EObject(org.eclipse.emf.ecore.EObject) Resource(org.eclipse.emf.ecore.resource.Resource)

Example 4 with DBindingEditor

use of org.obeonetwork.dsl.environment.bindingdialect.DBindingEditor in project InformationSystem by ObeoNetwork.

the class BindingDialectServices method createRepresentation.

/**
 * {@inheritDoc}
 *
 * @see org.eclipse.sirius.viewpoint.business.api.dialect.DialectServices#createRepresentation(java.lang.String,
 *      org.eclipse.emf.ecore.EObject,
 *      org.eclipse.sirius.viewpoint.description.RepresentationDescription,
 *      org.eclipse.core.runtime.IProgressMonitor)
 */
public DRepresentation createRepresentation(String name, EObject semantic, RepresentationDescription description, IProgressMonitor monitor) {
    // ensureDescriptionResourceInMainResourceSet(description);
    DBindingEditor editor = BindingdialectFactory.eINSTANCE.createDBindingEditor();
    editor.setName(name);
    editor.setDescription((DBindingEditorDescription) description);
    editor.setTarget(semantic);
    refresh(editor, monitor);
    return editor;
}
Also used : DBindingEditor(org.obeonetwork.dsl.environment.bindingdialect.DBindingEditor)

Aggregations

DBindingEditor (org.obeonetwork.dsl.environment.bindingdialect.DBindingEditor)4 EObject (org.eclipse.emf.ecore.EObject)2 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)1 URI (org.eclipse.emf.common.util.URI)1 Resource (org.eclipse.emf.ecore.resource.Resource)1 TransactionalEditingDomain (org.eclipse.emf.transaction.TransactionalEditingDomain)1 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)1 Session (org.eclipse.sirius.business.api.session.Session)1 SessionEditorInput (org.eclipse.sirius.ui.business.api.session.SessionEditorInput)1 UserSession (org.eclipse.sirius.ui.business.api.session.UserSession)1 DRepresentation (org.eclipse.sirius.viewpoint.DRepresentation)1 RepresentationDescription (org.eclipse.sirius.viewpoint.description.RepresentationDescription)1 IEditorInput (org.eclipse.ui.IEditorInput)1 IEditorPart (org.eclipse.ui.IEditorPart)1 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)1 PartInitException (org.eclipse.ui.PartInitException)1 BindingTreeEditor (org.obeonetwork.dsl.environment.binding.dialect.ui.editor.BindingTreeEditor)1