reintegrated model changes from branch 3.3-MC-SNAPSHOT
[taxeditor.git] / eu.etaxonomy.taxeditor.bulkeditor / src / main / java / eu / etaxonomy / taxeditor / annotatedlineeditor / handler / NewObjectHandler.java
1 // $Id$
2 /**
3 * Copyright (C) 2007 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
6 *
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.
9 */
10
11 package eu.etaxonomy.taxeditor.annotatedlineeditor.handler;
12
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;
22
23 import eu.etaxonomy.taxeditor.annotatedlineeditor.AnnotatedLineEditor;
24
25 /**
26 * <p>NewObjectHandler class.</p>
27 *
28 * @author p.ciardelli
29 * @created 14.08.2009
30 * @version 1.0
31 */
32 public class NewObjectHandler extends AbstractHandler {
33
34 /* (non-Javadoc)
35 * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
36 */
37 /** {@inheritDoc} */
38 public Object execute(ExecutionEvent event) throws ExecutionException {
39
40 IEditorPart editor = HandlerUtil.getActiveEditor(event);
41 IEditorInput input = editor.getEditorInput();
42
43 if (editor instanceof AnnotatedLineEditor) {
44
45 Object key = ((Event)event.getTrigger()).data;
46 if (key != null) {
47
48 ((AnnotatedLineEditor) editor).createAnnotatedLineNewObject(key, "Untitled");
49
50 } else {
51 ((AnnotatedLineEditor) editor).createAnnotatedLineNewObject();
52 }
53 }
54 return null;
55 }
56 }