2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
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.
9 package eu
.etaxonomy
.taxeditor
.bulkeditor
.handler
;
11 import java
.util
.Iterator
;
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
.text
.TextSelection
;
17 import org
.eclipse
.ui
.handlers
.HandlerUtil
;
19 import eu
.etaxonomy
.taxeditor
.annotatedlineeditor
.LineAnnotation
;
20 import eu
.etaxonomy
.taxeditor
.annotatedlineeditor
.LineAnnotationModel
;
21 import eu
.etaxonomy
.taxeditor
.bulkeditor
.BulkEditor
;
24 * <p>RemoveMergeCandidateHandler class.</p>
30 public class RemoveMergeCandidateHandler
extends AbstractHandler
{
33 * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
36 public Object
execute(ExecutionEvent event
) throws ExecutionException
{
38 if (HandlerUtil
.getCurrentSelection(event
) instanceof TextSelection
39 && HandlerUtil
.getActiveEditor(event
) instanceof BulkEditor
) {
40 TextSelection selection
= (TextSelection
) HandlerUtil
.getCurrentSelection(event
);
41 BulkEditor editor
= (BulkEditor
) HandlerUtil
.getActiveEditor(event
);
43 LineAnnotationModel model
= (LineAnnotationModel
) editor
.getDocumentProvider().getAnnotationModel(editor
.getEditorInput());
45 Iterator iter
= model
.getAnnotationIterator(selection
.getOffset(), selection
.getLength(), true, true);
46 while (iter
.hasNext()) {
47 Object next
= iter
.next();
48 if (next
instanceof LineAnnotation
) {
49 model
.changeAnnotationType(
50 (LineAnnotation
) next
, LineAnnotation
.TYPE_GENERIC
);