1 package eu
.etaxonomy
.taxeditor
.editor
.key
.polytomous
.handler
;
3 import org
.eclipse
.core
.commands
.AbstractHandler
;
4 import org
.eclipse
.core
.commands
.ExecutionEvent
;
5 import org
.eclipse
.core
.commands
.ExecutionException
;
6 import org
.eclipse
.core
.commands
.common
.NotDefinedException
;
7 import org
.eclipse
.core
.commands
.operations
.IUndoContext
;
8 import org
.eclipse
.jface
.dialogs
.MessageDialog
;
9 import org
.eclipse
.jface
.viewers
.IStructuredSelection
;
10 import org
.eclipse
.ui
.IEditorPart
;
11 import org
.eclipse
.ui
.handlers
.HandlerUtil
;
13 import eu
.etaxonomy
.cdm
.model
.description
.PolytomousKeyNode
;
14 import eu
.etaxonomy
.taxeditor
.editor
.EditorUtil
;
15 import eu
.etaxonomy
.taxeditor
.editor
.key
.KeyEditor
;
16 import eu
.etaxonomy
.taxeditor
.editor
.key
.polytomous
.IPolytomousKeyEditorPage
;
17 import eu
.etaxonomy
.taxeditor
.editor
.key
.polytomous
.PolytomousKeyListEditor
;
18 import eu
.etaxonomy
.taxeditor
.editor
.key
.polytomous
.operation
.CreateNodeOperation
;
19 import eu
.etaxonomy
.taxeditor
.editor
.key
.polytomous
.operation
.RefreshNodeNumberingOperation
;
20 import eu
.etaxonomy
.taxeditor
.model
.MessagingUtils
;
21 import eu
.etaxonomy
.taxeditor
.operation
.AbstractPostOperation
;
23 public class RefreshNodeNumberingHandler
extends AbstractHandler
{
26 public Object
execute(ExecutionEvent event
) throws ExecutionException
{
27 IEditorPart editor
= HandlerUtil
.getActiveEditor(event
);
29 if (editor
instanceof KeyEditor
) {
30 IPolytomousKeyEditorPage editorPage
= (IPolytomousKeyEditorPage
) ((KeyEditor
) editor
)
33 if (editorPage
instanceof PolytomousKeyListEditor
) {
35 IStructuredSelection selection
= (IStructuredSelection
) HandlerUtil
36 .getCurrentSelection(event
);
38 if (selection
.getFirstElement() instanceof PolytomousKeyNode
) {
40 String label
= event
.getCommand().getName();
41 IUndoContext undoContext
= EditorUtil
.getUndoContext();
43 PolytomousKeyNode keyNode
= (PolytomousKeyNode
) selection
46 AbstractPostOperation operation
= new RefreshNodeNumberingOperation(
47 label
, undoContext
, keyNode
, editorPage
);
48 EditorUtil
.executeOperation(operation
);
49 } catch (NotDefinedException e
) {
50 MessagingUtils
.warn(getClass(), "Command name not set."); //$NON-NLS-1$