Project

General

Profile

Download (1.83 KB) Statistics
| Branch: | Tag: | Revision:
1
// $Id$
2
/**
3
* Copyright (C) 2015 EDIT
4
* European Distributed Institute of Taxonomy
5
* http://www.e-taxonomy.eu
6
*
7
* The contents of this file are subject to the Mozilla Public License Version 1.1
8
* See LICENSE.TXT at the top of this package for the full license terms.
9
*/
10
package eu.etaxonomy.taxeditor.operation;
11

    
12
import org.eclipse.core.runtime.IAdaptable;
13
import org.eclipse.core.runtime.IProgressMonitor;
14
import org.eclipse.core.runtime.IStatus;
15
import org.eclipse.core.runtime.Status;
16

    
17
import eu.etaxonomy.cdm.api.application.CdmChangeEvent.Action;
18
import eu.etaxonomy.cdm.model.common.CdmBase;
19

    
20
/**
21
 * @author cmathew
22
 * @date 21 Jul 2015
23
 *
24
 */
25
public abstract class RemotingCdmDefaultOperation extends RemotingCdmOperation {
26

    
27
    private CdmBase cdmEntity;
28

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

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

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

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

    
62
}
(9-9/12)