Project

General

Profile

Download (1.82 KB) Statistics
| Branch: | Tag: | Revision:
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
 */
24
public abstract class RemotingCdmDefaultOperation extends RemotingCdmOperation {
25

    
26
    private CdmBase cdmEntity;
27

    
28
    public RemotingCdmDefaultOperation(String label, Action action, Object source, boolean async) {
29
        super(label, action, source, async);
30
    }
31
    /* (non-Javadoc)
32
     * @see eu.etaxonomy.taxeditor.operation.RemotingCdmOperation#doExecute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
33
     */
34
    @Override
35
    protected boolean doExecute(IProgressMonitor monitor, IAdaptable info) {
36
        try {
37
            cdmEntity = doSimpleExecute(monitor, info);
38
        } catch (Exception e) {
39
             throw new RuntimeException(e);
40
        }
41
        return true;
42
    }
43

    
44
    protected abstract CdmBase doSimpleExecute(IProgressMonitor monitor, IAdaptable info) throws Exception;
45

    
46
    @Override
47
    protected void postExecute(boolean success) {
48
        if(success && cdmEntity != null) {
49
            fireDataChangeEvent(cdmEntity);
50
        }
51

    
52
    }
53
    /* (non-Javadoc)
54
     * @see eu.etaxonomy.taxeditor.operation.RemotingCdmOperation#onComplete(boolean)
55
     */
56
    @Override
57
    protected IStatus onComplete(boolean success) {
58
        return Status.OK_STATUS;
59
    }
60

    
61
}
(9-9/12)