Java Code Examples for org.eclipse.emf.transaction.RunnableWithResult#getResult()
The following examples show how to use
org.eclipse.emf.transaction.RunnableWithResult#getResult() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ModelHelper.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
/** * @param form * @return the diagram corresponding to the form. */ public static Diagram getDiagramFor(final EObject element, final Resource resource) { if (element == null) { return null; } if (!resource.isLoaded()) { throw new IllegalStateException("EMF Resource is not loaded."); } final RunnableWithResult<Diagram> runnableWithResult = new DiagramForElementRunnable(resource, element); final TransactionalEditingDomain editingDomain = TransactionUtil.getEditingDomain(resource); if (editingDomain != null) { try { editingDomain.runExclusive(runnableWithResult); } catch (final InterruptedException e) { BonitaStudioLog.error(e); } } else { runnableWithResult.run(); } return runnableWithResult.getResult(); }
Example 2
Source File: AsyncXtextContentAssistProcessor.java From statecharts with Eclipse Public License 1.0 | 5 votes |
@Override public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int offset) { if (getContentProposalProvider() == null) return null; IXtextDocument document = (IXtextDocument) viewer.getDocument(); final CancelableCompletionProposalComputer computer = createCompletionProposalComputer(viewer, offset); RunnableWithResult<ICompletionProposal[]> runnable = new RunnableWithResult.Impl<ICompletionProposal[]>() { @Override public void run() { setResult(document.priorityReadOnly(new CancelableUnitOfWork<ICompletionProposal[], XtextResource>() { @Override public ICompletionProposal[] exec(XtextResource state, CancelIndicator cancelIndicator) throws Exception { computer.setCancelIndicator(cancelIndicator); try { return computer.exec(state); } catch (Throwable t) { return new ICompletionProposal[] {}; } } })); } }; if (Display.getCurrent() == null) { Display.getDefault().syncExec(runnable); } else { runnable.run(); } ICompletionProposal[] result = runnable.getResult(); Arrays.sort(result, getCompletionProposalComparator()); result = getCompletionProposalPostProcessor().postProcess(result); return result; }
Example 3
Source File: BotGefProcessDiagramEditor.java From bonita-studio with GNU General Public License v2.0 | 4 votes |
/** * @param sourceName * @param targetName */ public BotGefProcessDiagramEditor selectFlowBetween(final String sourceName, final String targetName) { final SWTBotGefEditPart source = gmfEditor.getEditPart(sourceName).parent(); final SWTBotGefEditPart target = gmfEditor.getEditPart(targetName).parent(); for (final SWTBotGefConnectionEditPart outFlow : source.sourceConnections()) { for (final SWTBotGefConnectionEditPart inFlow : target.targetConnections()) { final ConnectionEditPart inPart = inFlow.part(); final ConnectionEditPart outPart = outFlow.part(); final RunnableWithResult<Boolean> runnableWithResult = new RunnableWithResult<Boolean>() { Boolean res = false; @Override public void run() { res = EcoreUtil.equals((EObject) inPart.getModel(), (EObject) outPart.getModel()); } @Override public Boolean getResult() { return res; } @Override public void setStatus(final IStatus status) { } @Override public IStatus getStatus() { return Status.OK_STATUS; } }; Display.getDefault().syncExec(runnableWithResult); if (runnableWithResult.getResult()) { Display.getDefault().syncExec(new Runnable() { @Override public void run() { inFlow.part().getViewer().deselectAll(); inFlow.part().setFocus(true); inFlow.part().getViewer().setSelection(new StructuredSelection(inFlow.part())); } }); return this; } } } throw new IllegalStateException("No Flow found between " + sourceName + " and " + targetName); }