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
;
11 import org
.eclipse
.core
.commands
.AbstractHandler
;
12 import org
.eclipse
.core
.commands
.ExecutionEvent
;
13 import org
.eclipse
.core
.commands
.ExecutionException
;
14 import org
.eclipse
.core
.commands
.operations
.AbstractOperation
;
15 import org
.eclipse
.core
.runtime
.IStatus
;
16 import org
.eclipse
.jface
.dialogs
.ErrorDialog
;
18 import eu
.etaxonomy
.taxeditor
.model
.AbstractUtility
;
19 import eu
.etaxonomy
.taxeditor
.model
.MessagingUtils
;
26 public abstract class RemotingCdmHandler
extends AbstractHandler
{
28 private final String label
;
30 public RemotingCdmHandler(String label
) {
35 * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
38 public Object
execute(ExecutionEvent event
) throws ExecutionException
{
39 IStatus allowStatus
= allowOperations(event
);
40 if(allowStatus
.isOK()) {
41 AbstractOperation op
= prepareOperation(event
);
43 AbstractUtility
.executeOperation(op
, this);
45 } else if(allowStatus
.getSeverity() == IStatus
.ERROR
||
46 allowStatus
.getSeverity() == IStatus
.WARNING
||
47 allowStatus
.getSeverity() == IStatus
.INFO
) {
48 MessagingUtils
.warningDialog("Can not perform " + label
, event
.getTrigger(), allowStatus
);
53 public void postOperation(IStatus status
) {
55 switch(status
.getSeverity()) {
57 ErrorDialog
.openError(null, "Operation successful but with warnings", null, status
);
60 ErrorDialog
.openError(null, "Error executing operation", null, status
);
68 public abstract IStatus
allowOperations(ExecutionEvent event
);
70 public abstract AbstractOperation
prepareOperation(ExecutionEvent event
);
72 public abstract void onComplete();