1 package eu
.etaxonomy
.taxeditor
.handler
.defaultHandler
;
5 import org
.eclipse
.core
.commands
.AbstractHandler
;
6 import org
.eclipse
.core
.commands
.ExecutionEvent
;
7 import org
.eclipse
.core
.commands
.ExecutionException
;
8 import org
.eclipse
.core
.commands
.ParameterType
;
9 import org
.eclipse
.core
.commands
.common
.NotDefinedException
;
10 import org
.eclipse
.jface
.viewers
.ISelection
;
11 import org
.eclipse
.jface
.viewers
.IStructuredSelection
;
12 import org
.eclipse
.ui
.handlers
.HandlerUtil
;
14 import eu
.etaxonomy
.taxeditor
.model
.MessagingUtils
;
16 public abstract class DefaultOpenHandlerBase
<T
> extends AbstractHandler
{
19 public Object
execute(ExecutionEvent event
) throws ExecutionException
{
20 String commandId
= event
.getCommand().getId();
21 String uuidParameterId
= commandId
+".uuid";
22 //check if uuid parameter is set
23 if(event
.getParameter(uuidParameterId
)!=null){
24 Object object
= event
.getObjectParameterForExecution(uuidParameterId
);
25 ParameterType parameterType
;
27 parameterType
= event
.getCommand().getParameterType(uuidParameterId
);
28 if(parameterType
.isCompatible(object
)){
29 T entity
= getEntity((UUID
) object
);
32 } catch (NotDefinedException e
) {
33 MessagingUtils
.error(DefaultOpenHandlerBase
.class, "Error while opening entity!", e
);
36 //if not try current selection
38 ISelection selection
= HandlerUtil
.getCurrentSelection(event
);
39 if(selection
instanceof IStructuredSelection
){
40 open(event
, (T
) ((IStructuredSelection
) selection
).getFirstElement());
47 protected abstract T
getEntity(UUID uuid
);
49 protected abstract void open(ExecutionEvent event
, T entity
);