Revision 3be6ef3e
Added by Niels Hoffmann over 13 years ago
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.apache.log4j.Logger; |
|
14 |
import org.eclipse.core.commands.AbstractHandler; |
|
15 |
import org.eclipse.core.commands.ExecutionEvent; |
|
16 |
import org.eclipse.core.commands.ExecutionException; |
|
17 |
import org.eclipse.jface.dialogs.InputDialog; |
|
18 |
import org.eclipse.jface.window.Window; |
|
19 |
import org.eclipse.swt.widgets.Event; |
|
20 |
import org.eclipse.ui.IEditorInput; |
|
21 |
import org.eclipse.ui.IEditorPart; |
|
22 |
import org.eclipse.ui.handlers.HandlerUtil; |
|
23 |
|
|
24 |
import eu.etaxonomy.taxeditor.annotatedlineeditor.AnnotatedLineEditor; |
|
25 |
|
|
26 |
/** |
|
27 |
* @author p.ciardelli |
|
28 |
* @created 14.08.2009 |
|
29 |
* @version 1.0 |
|
30 |
*/ |
|
31 |
public class NewObjectHandler extends AbstractHandler { |
|
32 |
private static final Logger logger = Logger |
|
33 |
.getLogger(NewObjectHandler.class); |
|
34 |
|
|
35 |
/* (non-Javadoc) |
|
36 |
* @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent) |
|
37 |
*/ |
|
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 |
String text = ((Event)event.getTrigger()).text; |
|
48 |
InputDialog dialog = new InputDialog(HandlerUtil.getActiveShell(event), "Create " + text, "Enter new " + text, "", null); |
|
49 |
if (dialog.open() == Window.CANCEL) { |
|
50 |
return null; |
|
51 |
} |
|
52 |
((AnnotatedLineEditor) editor).createAnnotatedLineNewObject(key, dialog.getValue()); |
|
53 |
} else { |
|
54 |
((AnnotatedLineEditor) editor).createAnnotatedLineNewObject(); |
|
55 |
} |
|
56 |
} |
|
57 |
return null; |
|
58 |
} |
|
59 |
} |
|
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.apache.log4j.Logger; |
|
14 |
import org.eclipse.core.commands.AbstractHandler; |
|
15 |
import org.eclipse.core.commands.ExecutionEvent; |
|
16 |
import org.eclipse.core.commands.ExecutionException; |
|
17 |
import org.eclipse.jface.dialogs.InputDialog; |
|
18 |
import org.eclipse.jface.window.Window; |
|
19 |
import org.eclipse.swt.widgets.Event; |
|
20 |
import org.eclipse.ui.IEditorInput; |
|
21 |
import org.eclipse.ui.IEditorPart; |
|
22 |
import org.eclipse.ui.handlers.HandlerUtil; |
|
23 |
|
|
24 |
import eu.etaxonomy.taxeditor.annotatedlineeditor.AnnotatedLineEditor; |
|
25 |
|
|
26 |
/** |
|
27 |
* <p>NewObjectHandler class.</p> |
|
28 |
* |
|
29 |
* @author p.ciardelli |
|
30 |
* @created 14.08.2009 |
|
31 |
* @version 1.0 |
|
32 |
*/ |
|
33 |
public class NewObjectHandler extends AbstractHandler { |
|
34 |
private static final Logger logger = Logger |
|
35 |
.getLogger(NewObjectHandler.class); |
|
36 |
|
|
37 |
/* (non-Javadoc) |
|
38 |
* @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent) |
|
39 |
*/ |
|
40 |
/** {@inheritDoc} */ |
|
41 |
public Object execute(ExecutionEvent event) throws ExecutionException { |
|
42 |
|
|
43 |
IEditorPart editor = HandlerUtil.getActiveEditor(event); |
|
44 |
IEditorInput input = editor.getEditorInput(); |
|
45 |
|
|
46 |
if (editor instanceof AnnotatedLineEditor) { |
|
47 |
|
|
48 |
Object key = ((Event)event.getTrigger()).data; |
|
49 |
if (key != null) { |
|
50 |
String text = ((Event)event.getTrigger()).text; |
|
51 |
InputDialog dialog = new InputDialog(HandlerUtil.getActiveShell(event), "Create " + text, "Enter new " + text, "", null); |
|
52 |
if (dialog.open() == Window.CANCEL) { |
|
53 |
return null; |
|
54 |
} |
|
55 |
((AnnotatedLineEditor) editor).createAnnotatedLineNewObject(key, dialog.getValue()); |
|
56 |
} else { |
|
57 |
((AnnotatedLineEditor) editor).createAnnotatedLineNewObject(); |
|
58 |
} |
|
59 |
} |
|
60 |
return null; |
|
61 |
} |
|
62 |
} |
Also available in: Unified diff
performed javacscript:fix and worked on documentation