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
.jface
.wizard
.WizardDialog
;
13 import org
.eclipse
.ui
.PlatformUI
;
14 import org
.eclipse
.ui
.handlers
.HandlerUtil
;
16 import eu
.etaxonomy
.cdm
.api
.service
.IClassificationService
;
17 import eu
.etaxonomy
.cdm
.model
.taxon
.Classification
;
18 import eu
.etaxonomy
.taxeditor
.model
.MessagingUtils
;
19 import eu
.etaxonomy
.taxeditor
.newWizard
.NewClassificationWizard
;
20 import eu
.etaxonomy
.taxeditor
.store
.CdmStore
;
22 public class DefaultOpenClassificationWizardHandler
extends AbstractHandler
{
25 public Object
execute(ExecutionEvent event
) throws ExecutionException
{
26 String commandId
= event
.getCommand().getId();
27 String uuidParameterId
= commandId
+".uuid";
28 //check if uuid parameter is set
29 if(event
.getParameter(uuidParameterId
)!=null){
30 Object object
= event
.getObjectParameterForExecution(uuidParameterId
);
31 ParameterType parameterType
;
33 parameterType
= event
.getCommand().getParameterType(uuidParameterId
);
34 if(parameterType
.isCompatible(object
)){
35 Classification classification
= CdmStore
.getService(IClassificationService
.class).load((UUID
) object
);
36 openClassificationWizard(event
, classification
);
38 } catch (NotDefinedException e
) {
39 MessagingUtils
.error(DefaultOpenClassificationWizardHandler
.class, "Error while opening classification!", e
);
42 //if not try current selection
44 ISelection selection
= HandlerUtil
.getCurrentSelection(event
);
46 if(selection
instanceof IStructuredSelection
){
47 final IStructuredSelection structuredSelection
= (IStructuredSelection
) selection
;
49 if(structuredSelection
.size() == 1 && structuredSelection
.getFirstElement() instanceof Classification
){
50 Classification classification
= (Classification
) structuredSelection
.getFirstElement();
51 openClassificationWizard(event
, classification
);
58 private void openClassificationWizard(ExecutionEvent event
, Classification classification
) {
59 NewClassificationWizard classificationWizard
= new NewClassificationWizard();
60 classificationWizard
.init(null, null);
61 classificationWizard
.setEntity(classification
);
62 WizardDialog dialog
= new WizardDialog(PlatformUI
.getWorkbench().getActiveWorkbenchWindow().getShell(), classificationWizard
);