3 * Copyright (C) 2015 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
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.
10 package eu
.etaxonomy
.taxeditor
.operation
;
12 import org
.eclipse
.core
.commands
.AbstractHandler
;
13 import org
.eclipse
.core
.commands
.ExecutionEvent
;
14 import org
.eclipse
.core
.commands
.ExecutionException
;
15 import org
.eclipse
.core
.commands
.operations
.AbstractOperation
;
16 import org
.eclipse
.core
.runtime
.IStatus
;
17 import org
.eclipse
.jface
.dialogs
.ErrorDialog
;
19 import eu
.etaxonomy
.taxeditor
.model
.AbstractUtility
;
20 import eu
.etaxonomy
.taxeditor
.model
.MessagingUtils
;
27 public abstract class RemotingCdmHandler
extends AbstractHandler
{
29 private final String label
;
31 public RemotingCdmHandler(String label
) {
36 * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
39 public Object
execute(ExecutionEvent event
) throws ExecutionException
{
40 IStatus allowStatus
= allowOperations(event
);
41 if(allowStatus
.isOK()) {
42 AbstractOperation op
= prepareOperation(event
);
44 AbstractUtility
.executeOperation(op
, this);
46 } else if(allowStatus
.getSeverity() == IStatus
.ERROR
||
47 allowStatus
.getSeverity() == IStatus
.WARNING
||
48 allowStatus
.getSeverity() == IStatus
.INFO
) {
49 MessagingUtils
.warningDialog("Can not perform " + label
, event
.getTrigger(), allowStatus
);
54 public void postOperation(IStatus status
) {
56 switch(status
.getSeverity()) {
58 ErrorDialog
.openError(null, "Operation successful but with warnings", null, status
);
61 ErrorDialog
.openError(null, "Error executing operation", null, status
);
69 public abstract IStatus
allowOperations(ExecutionEvent event
);
71 public abstract AbstractOperation
prepareOperation(ExecutionEvent event
);
73 public abstract void onComplete();