Add referencing objects view functionality to derivative editor #5403
[taxeditor.git] / eu.etaxonomy.taxeditor.bulkeditor / src / main / java / eu / etaxonomy / taxeditor / bulkeditor / handler / RemoveMergeCandidateHandler.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 package eu.etaxonomy.taxeditor.bulkeditor.handler;
11
12 import java.util.Iterator;
13
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.text.TextSelection;
18 import org.eclipse.ui.handlers.HandlerUtil;
19
20 import eu.etaxonomy.taxeditor.annotatedlineeditor.LineAnnotation;
21 import eu.etaxonomy.taxeditor.annotatedlineeditor.LineAnnotationModel;
22 import eu.etaxonomy.taxeditor.bulkeditor.BulkEditor;
23
24 /**
25 * <p>RemoveMergeCandidateHandler class.</p>
26 *
27 * @author p.ciardelli
28 * @created 25.06.2009
29 * @version 1.0
30 */
31 public class RemoveMergeCandidateHandler extends AbstractHandler {
32
33 /* (non-Javadoc)
34 * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
35 */
36 /** {@inheritDoc} */
37 public Object execute(ExecutionEvent event) throws ExecutionException {
38
39 if (HandlerUtil.getCurrentSelection(event) instanceof TextSelection
40 && HandlerUtil.getActiveEditor(event) instanceof BulkEditor) {
41 TextSelection selection = (TextSelection) HandlerUtil.getCurrentSelection(event);
42 BulkEditor editor = (BulkEditor) HandlerUtil.getActiveEditor(event);
43
44 LineAnnotationModel model = (LineAnnotationModel) editor.getDocumentProvider().getAnnotationModel(editor.getEditorInput());
45 if (model != null) {
46 Iterator iter = model.getAnnotationIterator(selection.getOffset(), selection.getLength(), true, true);
47 while (iter.hasNext()) {
48 Object next = iter.next();
49 if (next instanceof LineAnnotation) {
50 model.changeAnnotationType(
51 (LineAnnotation) next, LineAnnotation.TYPE_GENERIC);
52 }
53 }
54 }
55 }
56 return null;
57 }
58 }