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;
}
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;
}
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;
}
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;
}
Aggregations