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
.operation
.AbstractPostOperation
;
22 public class RefreshNodeNumberingHandler
extends AbstractHandler
{
25 public Object
execute(ExecutionEvent event
) throws ExecutionException
{
26 IEditorPart editor
= HandlerUtil
.getActiveEditor(event
);
28 if (editor
instanceof KeyEditor
) {
29 IPolytomousKeyEditorPage editorPage
= (IPolytomousKeyEditorPage
) ((KeyEditor
) editor
)
32 if (editorPage
instanceof PolytomousKeyListEditor
) {
34 IStructuredSelection selection
= (IStructuredSelection
) HandlerUtil
35 .getCurrentSelection(event
);
37 if (selection
.getFirstElement() instanceof PolytomousKeyNode
) {
39 String label
= event
.getCommand().getName();
40 IUndoContext undoContext
= EditorUtil
.getUndoContext();
42 PolytomousKeyNode keyNode
= (PolytomousKeyNode
) selection
45 AbstractPostOperation operation
= new RefreshNodeNumberingOperation(
46 label
, undoContext
, keyNode
, editorPage
);
47 EditorUtil
.executeOperation(operation
);
48 } catch (NotDefinedException e
) {
49 EditorUtil
.warn(getClass(), "Command name not set.");