3 * Copyright (C) 2007 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.
11 package eu
.etaxonomy
.taxeditor
.annotatedlineeditor
.handler
;
13 import org
.eclipse
.core
.commands
.AbstractHandler
;
14 import org
.eclipse
.core
.commands
.ExecutionEvent
;
15 import org
.eclipse
.core
.commands
.ExecutionException
;
16 import org
.eclipse
.jface
.dialogs
.InputDialog
;
17 import org
.eclipse
.jface
.window
.Window
;
18 import org
.eclipse
.swt
.widgets
.Event
;
19 import org
.eclipse
.ui
.IEditorInput
;
20 import org
.eclipse
.ui
.IEditorPart
;
21 import org
.eclipse
.ui
.handlers
.HandlerUtil
;
23 import eu
.etaxonomy
.taxeditor
.annotatedlineeditor
.AnnotatedLineEditor
;
26 * <p>NewObjectHandler class.</p>
32 public class NewObjectHandler
extends AbstractHandler
{
35 * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
38 public Object
execute(ExecutionEvent event
) throws ExecutionException
{
40 IEditorPart editor
= HandlerUtil
.getActiveEditor(event
);
41 IEditorInput input
= editor
.getEditorInput();
43 if (editor
instanceof AnnotatedLineEditor
) {
45 Object key
= ((Event
)event
.getTrigger()).data
;
49 String text
= ((Event
)event
.getTrigger()).text
;
50 InputDialog dialog
= new InputDialog(HandlerUtil
.getActiveShell(event
), "Create " + text
, "Enter new " + text
, "", null);
51 if (dialog
.open() != Window
.CANCEL
) {
52 ((AnnotatedLineEditor
) editor
).createAnnotatedLineNewObject(key
, dialog
.getValue());
56 ((AnnotatedLineEditor
) editor
).createAnnotatedLineNewObject();