Revision ae7e2680
Added by Cherian Mathew almost 9 years ago
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/operation/RemotingCdmOperation.java | ||
---|---|---|
9 | 9 |
*/ |
10 | 10 |
package eu.etaxonomy.taxeditor.operation; |
11 | 11 |
|
12 |
import java.util.Set; |
|
13 |
|
|
12 | 14 |
import org.eclipse.core.commands.ExecutionException; |
13 | 15 |
import org.eclipse.core.commands.operations.AbstractOperation; |
14 | 16 |
import org.eclipse.core.runtime.IAdaptable; |
15 | 17 |
import org.eclipse.core.runtime.IProgressMonitor; |
16 | 18 |
import org.eclipse.core.runtime.IStatus; |
17 | 19 |
|
20 |
import eu.etaxonomy.cdm.api.application.CdmApplicationState; |
|
21 |
import eu.etaxonomy.cdm.api.application.CdmChangeEvent; |
|
22 |
import eu.etaxonomy.cdm.api.application.CdmChangeEvent.Action; |
|
23 |
import eu.etaxonomy.cdm.api.service.UpdateResult; |
|
24 |
import eu.etaxonomy.cdm.model.common.CdmBase; |
|
25 |
|
|
18 | 26 |
/** |
19 | 27 |
* @author cmathew |
20 | 28 |
* @date 16 Jun 2015 |
... | ... | |
22 | 30 |
*/ |
23 | 31 |
public abstract class RemotingCdmOperation extends AbstractOperation { |
24 | 32 |
|
25 |
public RemotingCdmOperation(String label) { |
|
33 |
private final Object source; |
|
34 |
private final Action action; |
|
35 |
private final boolean async; |
|
36 |
|
|
37 |
public RemotingCdmOperation(String label, Action action, Object source, boolean async) { |
|
26 | 38 |
super(label); |
39 |
this.source = source; |
|
40 |
this.action = action; |
|
41 |
this.async = async; |
|
27 | 42 |
} |
28 | 43 |
|
29 | 44 |
/* (non-Javadoc) |
... | ... | |
37 | 52 |
return onComplete(success); |
38 | 53 |
} |
39 | 54 |
|
40 |
public abstract boolean doExecute(IProgressMonitor monitor, IAdaptable info); |
|
55 |
protected abstract boolean doExecute(IProgressMonitor monitor, IAdaptable info); |
|
56 |
|
|
57 |
protected void postExecute(boolean success) {} |
|
41 | 58 |
|
42 |
public void postExecute(boolean success) {}
|
|
59 |
protected abstract IStatus onComplete(boolean success);
|
|
43 | 60 |
|
44 |
public abstract IStatus onComplete(boolean success); |
|
61 |
protected void fireDataChangeEvent(Set<? extends CdmBase> changedObjects) { |
|
62 |
if(changedObjects != null && !changedObjects.isEmpty()) { |
|
63 |
CdmApplicationState.getCurrentDataChangeService().fireChangeEvent(new CdmChangeEvent(action, changedObjects, source.getClass()), async); |
|
64 |
} |
|
65 |
} |
|
66 |
|
|
67 |
protected void fireDataChangeEvent(UpdateResult updateResult) { |
|
68 |
Set<CdmBase> updatedObjects = updateResult.getUpdatedObjects(); |
|
69 |
if(updatedObjects != null && !updatedObjects.isEmpty()) { |
|
70 |
CdmApplicationState.getCurrentDataChangeService().fireChangeEvent(new CdmChangeEvent(action, updatedObjects, source.getClass()), async); |
|
71 |
} |
|
72 |
} |
|
45 | 73 |
|
46 | 74 |
/* (non-Javadoc) |
47 | 75 |
* @see org.eclipse.core.commands.operations.AbstractOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable) |
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