1
|
/**
|
2
|
* Copyright (C) 2015 EDIT
|
3
|
* European Distributed Institute of Taxonomy
|
4
|
* http://www.e-taxonomy.eu
|
5
|
*
|
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.
|
8
|
*/
|
9
|
package eu.etaxonomy.taxeditor.operation;
|
10
|
|
11
|
import org.eclipse.core.runtime.IAdaptable;
|
12
|
import org.eclipse.core.runtime.IProgressMonitor;
|
13
|
import org.eclipse.core.runtime.IStatus;
|
14
|
import org.eclipse.core.runtime.Status;
|
15
|
|
16
|
import eu.etaxonomy.cdm.api.application.CdmChangeEvent.Action;
|
17
|
import eu.etaxonomy.cdm.model.common.CdmBase;
|
18
|
|
19
|
/**
|
20
|
* @author cmathew
|
21
|
* @date 21 Jul 2015
|
22
|
*/
|
23
|
public abstract class CdmDefaultOperation extends CdmOperation {
|
24
|
|
25
|
private CdmBase cdmEntity;
|
26
|
|
27
|
public CdmDefaultOperation(String label, Action action, Object source, boolean async) {
|
28
|
super(label, action, source, async);
|
29
|
}
|
30
|
|
31
|
@Override
|
32
|
protected boolean doExecute(IProgressMonitor monitor, IAdaptable info) {
|
33
|
try {
|
34
|
cdmEntity = doSimpleExecute(monitor, info);
|
35
|
} catch (Exception e) {
|
36
|
throw new RuntimeException(e);
|
37
|
}
|
38
|
return true;
|
39
|
}
|
40
|
|
41
|
protected abstract CdmBase doSimpleExecute(IProgressMonitor monitor, IAdaptable info) throws Exception;
|
42
|
|
43
|
@Override
|
44
|
protected void postExecute(boolean success) {
|
45
|
if(success && cdmEntity != null) {
|
46
|
fireDataChangeEvent(cdmEntity);
|
47
|
}
|
48
|
}
|
49
|
|
50
|
@Override
|
51
|
protected IStatus onComplete(boolean success) {
|
52
|
return Status.OK_STATUS;
|
53
|
}
|
54
|
}
|