Revision ae7e2680
Added by Cherian Mathew almost 9 years ago
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/model/AbstractUtility.java | ||
---|---|---|
21 | 21 |
import org.eclipse.core.commands.NotEnabledException; |
22 | 22 |
import org.eclipse.core.commands.NotHandledException; |
23 | 23 |
import org.eclipse.core.commands.common.NotDefinedException; |
24 |
import org.eclipse.core.commands.operations.AbstractOperation; |
|
24 | 25 |
import org.eclipse.core.commands.operations.IOperationHistory; |
25 | 26 |
import org.eclipse.core.runtime.IAdaptable; |
26 | 27 |
import org.eclipse.core.runtime.IProgressMonitor; |
... | ... | |
58 | 59 |
import eu.etaxonomy.cdm.model.common.IEnumTerm; |
59 | 60 |
import eu.etaxonomy.taxeditor.operation.AbstractPostOperation; |
60 | 61 |
import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled; |
62 |
import eu.etaxonomy.taxeditor.operation.RemotingCdmHandler; |
|
61 | 63 |
import eu.etaxonomy.taxeditor.store.internal.TaxeditorStorePlugin; |
62 | 64 |
import eu.etaxonomy.taxeditor.view.AbstractCdmDataViewer; |
63 | 65 |
import eu.etaxonomy.taxeditor.view.detail.DetailsViewPart; |
... | ... | |
345 | 347 |
return Status.OK_STATUS; |
346 | 348 |
} |
347 | 349 |
|
350 |
public static IStatus executeOperation(final AbstractOperation operation, final RemotingCdmHandler handler) { |
|
351 |
if (getOperationHistory() == null) { |
|
352 |
throw new IllegalArgumentException( |
|
353 |
"There is no operation history for this context"); |
|
354 |
} |
|
355 |
|
|
356 |
final IAdaptable uiInfoAdapter = WorkspaceUndoUtil |
|
357 |
.getUIInfoAdapter(getShell()); |
|
358 |
|
|
359 |
IRunnableWithProgress runnable = new IRunnableWithProgress() { |
|
360 |
|
|
361 |
@Override |
|
362 |
public void run(IProgressMonitor monitor) |
|
363 |
throws InvocationTargetException, InterruptedException { |
|
364 |
String operationlabel = operation.getLabel(); |
|
365 |
monitor.beginTask(operationlabel, 100); |
|
366 |
IStatus status = Status.CANCEL_STATUS; |
|
367 |
try { |
|
368 |
operation.addContext(IOperationHistory.GLOBAL_UNDO_CONTEXT); |
|
369 |
status = getOperationHistory().execute(operation, monitor, |
|
370 |
uiInfoAdapter); |
|
371 |
handler.postOperation(status); |
|
372 |
} catch (ExecutionException e) { |
|
373 |
MessagingUtils.operationDialog(this, e, TaxeditorStorePlugin.PLUGIN_ID, operationlabel, null); |
|
374 |
} finally { |
|
375 |
monitor.done(); |
|
376 |
} |
|
377 |
|
|
378 |
String statusString = status.equals(Status.OK_STATUS) ? "completed" |
|
379 |
: "cancelled"; |
|
380 |
setStatusLine(operationlabel + " " + statusString + "."); |
|
381 |
|
|
382 |
} |
|
383 |
}; |
|
384 |
|
|
385 |
try { |
|
386 |
runInUI(runnable, null); |
|
387 |
} catch (Exception e) { |
|
388 |
MessagingUtils.messageDialog("Error executing operation", AbstractUtility.class, "An error occured while executing " + operation.getLabel(), e); |
|
389 |
} |
|
390 |
|
|
391 |
return Status.OK_STATUS; |
|
392 |
} |
|
348 | 393 |
/** |
349 | 394 |
* <p> |
350 | 395 |
* getOperationHistory |
Also available in: Unified diff
ICdmDataChangeService, CdmUIDataChangeService, CdmDataChangeService : added new data change service with different services for the ui and non-ui states
CdmApplicationState, CdmStore : added data change service to app state
CdmChangeEvent, ICdmChangeListener : added change listener and even to fire in case of data changes
ICdmEntitySessionEnabled : extends new change service interface
ICdmEntitySession, CdmEntitySession : removed data change un/registration since this is now handled by the new data change service
BaseRemotingTest, MockCdmEntitySession, *Editor, *ViewPart, *Navigator : refactoring with new change listener
RemotingCdmHandler, RemotingCdmOperation, RemotingCdmUpdateOperation : added new handler / operation architecture base classes
AbstractUtility : added method for running async operation with callback to handler
RemotingChangeAcceptedTaxonToSynonymHandler,RemotingChangeAcceptedTaxonToSynonymOperation : first implementations of new handler / operation architecture
plugin.xml : added standalone and remoting handlers for ChangeAcceptedTaxonToSynonym
*Test : adapted for new handler / operation and change service