Merge branch 'develop' into LibrAlign
[taxeditor.git] / eu.etaxonomy.taxeditor.bulkeditor / src / main / java / eu / etaxonomy / taxeditor / annotatedlineeditor / handler / DeleteObjectHandler.java
1 /**
2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
5 *
6 * The contents of this file are subject to the Mozilla Public License Version 1.1
7 * See LICENSE.TXT at the top of this package for the full license terms.
8 */
9 package eu.etaxonomy.taxeditor.annotatedlineeditor.handler;
10
11 import org.eclipse.core.commands.AbstractHandler;
12 import org.eclipse.core.commands.ExecutionEvent;
13 import org.eclipse.core.commands.ExecutionException;
14 import org.eclipse.jface.text.TextSelection;
15 import org.eclipse.jface.viewers.ISelection;
16 import org.eclipse.ui.IEditorPart;
17 import org.eclipse.ui.handlers.HandlerUtil;
18
19 import eu.etaxonomy.taxeditor.annotatedlineeditor.AnnotatedLineEditor;
20
21 /**
22 * <p>DeleteObjectHandler class.</p>
23 *
24 * @author p.ciardelli
25 * @created 25.06.2009
26 * @version 1.0
27 */
28 public class DeleteObjectHandler extends AbstractHandler {
29
30 /* (non-Javadoc)
31 * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
32 */
33 /** {@inheritDoc} */
34 public Object execute(ExecutionEvent event) throws ExecutionException {
35
36 IEditorPart editor = HandlerUtil.getActiveEditor(event);
37
38 if (editor instanceof AnnotatedLineEditor) {
39
40 ISelection selection = HandlerUtil.getCurrentSelection(event);
41 if (selection instanceof TextSelection) {
42
43 // Get current line
44 int line = ((TextSelection) selection).getStartLine();
45
46 ((AnnotatedLineEditor) editor).removeAnnotatedLine(line);
47 }
48 }
49 return null;
50 }
51 }