2 * Copyright (C) 2015 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
6 * The contents of this file are subject to the Mozilla Public License Version 1.1
7 * See LICENSE.TXT at the top of this package for the full license terms.
9 package eu
.etaxonomy
.taxeditor
.operation
;
13 import org
.eclipse
.core
.commands
.ExecutionException
;
14 import org
.eclipse
.core
.commands
.operations
.AbstractOperation
;
15 import org
.eclipse
.core
.runtime
.IAdaptable
;
16 import org
.eclipse
.core
.runtime
.IProgressMonitor
;
17 import org
.eclipse
.core
.runtime
.IStatus
;
19 import eu
.etaxonomy
.cdm
.api
.application
.CdmApplicationState
;
20 import eu
.etaxonomy
.cdm
.api
.application
.CdmChangeEvent
;
21 import eu
.etaxonomy
.cdm
.api
.application
.CdmChangeEvent
.Action
;
22 import eu
.etaxonomy
.cdm
.api
.service
.UpdateResult
;
23 import eu
.etaxonomy
.cdm
.model
.common
.CdmBase
;
30 public abstract class RemotingCdmOperation
extends AbstractOperation
{
32 private final Object source
;
33 private final Action action
;
34 private final boolean async
;
35 protected Class entityType
;
37 public RemotingCdmOperation(String label
, Action action
, Object source
, boolean async
) {
45 * @see org.eclipse.core.commands.operations.AbstractOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
48 public IStatus
execute(IProgressMonitor monitor
, IAdaptable info
) throws ExecutionException
{
50 boolean success
= doExecute(monitor
, info
);
52 return onComplete(success
);
55 protected abstract boolean doExecute(IProgressMonitor monitor
, IAdaptable info
);
57 protected void postExecute(boolean success
) {}
59 protected abstract IStatus
onComplete(boolean success
);
61 protected void fireDataChangeEvent(Set
<CdmBase
> changedObjects
) {
62 if(changedObjects
!= null && !changedObjects
.isEmpty()) {
63 CdmApplicationState
.getCurrentDataChangeService().fireChangeEvent(new CdmChangeEvent(action
, changedObjects
, source
.getClass()), async
);
67 protected void fireDataChangeEvent(UpdateResult updateResult
) {
68 Set
<CdmBase
> updatedObjects
= updateResult
.getUpdatedObjects();
69 CdmApplicationState
.getCurrentDataChangeService()
70 .fireChangeEvent(new CdmChangeEvent(action
, updatedObjects
, source
.getClass(), entityType
), async
);
73 protected void fireDataChangeEvent(CdmBase cdmBase
) {
75 CdmApplicationState
.getCurrentDataChangeService().fireChangeEvent(new CdmChangeEvent(action
, cdmBase
, source
.getClass()), async
);
80 * @see org.eclipse.core.commands.operations.AbstractOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
83 public IStatus
redo(IProgressMonitor monitor
, IAdaptable info
) throws ExecutionException
{
84 // TODO Auto-generated method stub
89 * @see org.eclipse.core.commands.operations.AbstractOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
92 public IStatus
undo(IProgressMonitor monitor
, IAdaptable info
) throws ExecutionException
{
93 // TODO Auto-generated method stub