1 |
3be6ef3e
|
n.hoffmann
|
// $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;
|
12 |
|
|
|
13 |
|
|
import org.apache.log4j.Logger;
|
14 |
|
|
import org.eclipse.jface.text.source.Annotation;
|
15 |
|
|
import org.eclipse.jface.text.source.IAnnotationModel;
|
16 |
|
|
import org.eclipse.jface.text.source.ISourceViewer;
|
17 |
|
|
|
18 |
|
|
/**
|
19 |
|
|
* <p>LineSelectionSource class.</p>
|
20 |
|
|
*
|
21 |
|
|
* @author p.ciardelli
|
22 |
|
|
* @created 03.07.2009
|
23 |
|
|
* @version 1.0
|
24 |
|
|
*/
|
25 |
|
|
public class LineSelectionSource implements ILineSelectionSource {
|
26 |
|
|
@SuppressWarnings("unused")
|
27 |
|
|
private static final Logger logger = Logger
|
28 |
|
|
.getLogger(LineSelectionSource.class);
|
29 |
|
|
|
30 |
|
|
private ISourceViewer viewer;
|
31 |
|
|
|
32 |
|
|
/**
|
33 |
|
|
* <p>Constructor for LineSelectionSource.</p>
|
34 |
|
|
*
|
35 |
|
|
* @param viewer a {@link org.eclipse.jface.text.source.ISourceViewer} object.
|
36 |
|
|
*/
|
37 |
|
|
public LineSelectionSource(ISourceViewer viewer) {
|
38 |
|
|
this.viewer = viewer;
|
39 |
|
|
}
|
40 |
|
|
|
41 |
|
|
/* (non-Javadoc)
|
42 |
|
|
* @see eu.etaxonomy.taxeditor.bulkeditor.ILineSelectionSource#getSelectedObjectAtLine(int)
|
43 |
|
|
*/
|
44 |
|
|
/** {@inheritDoc} */
|
45 |
|
|
public Object getSelectedObjectAtLine(int line) {
|
46 |
|
|
IAnnotationModel model = viewer.getAnnotationModel();
|
47 |
|
|
if (model instanceof LineAnnotationModel) {
|
48 |
|
|
Annotation annotation = ((LineAnnotationModel) model).
|
49 |
|
|
getAnnotationAtLine(line, viewer.getDocument());
|
50 |
|
|
if (annotation != null) {
|
51 |
|
|
return ((LineAnnotation) annotation).getEntity();//getPropertySource();
|
52 |
|
|
}
|
53 |
|
|
}
|
54 |
|
|
return null;
|
55 |
|
|
}
|
56 |
|
|
}
|