Revision 3be6ef3e
Added by Niels Hoffmann over 13 years ago
taxeditor-bulkeditor/src/main/java/eu/etaxonomy/taxeditor/annotatedlineeditor/LineSelectionSource.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; |
|
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 |
* @author p.ciardelli |
|
20 |
* @created 03.07.2009 |
|
21 |
* @version 1.0 |
|
22 |
*/ |
|
23 |
public class LineSelectionSource implements ILineSelectionSource { |
|
24 |
@SuppressWarnings("unused") |
|
25 |
private static final Logger logger = Logger |
|
26 |
.getLogger(LineSelectionSource.class); |
|
27 |
|
|
28 |
private ISourceViewer viewer; |
|
29 |
|
|
30 |
/** |
|
31 |
* |
|
32 |
*/ |
|
33 |
public LineSelectionSource(ISourceViewer viewer) { |
|
34 |
this.viewer = viewer; |
|
35 |
} |
|
36 |
|
|
37 |
/* (non-Javadoc) |
|
38 |
* @see eu.etaxonomy.taxeditor.bulkeditor.ILineSelectionSource#getSelectedObjectAtLine(int) |
|
39 |
*/ |
|
40 |
public Object getSelectedObjectAtLine(int line) { |
|
41 |
IAnnotationModel model = viewer.getAnnotationModel(); |
|
42 |
if (model instanceof LineAnnotationModel) { |
|
43 |
Annotation annotation = ((LineAnnotationModel) model). |
|
44 |
getAnnotationAtLine(line, viewer.getDocument()); |
|
45 |
if (annotation != null) { |
|
46 |
return ((LineAnnotation) annotation).getEntity();//getPropertySource(); |
|
47 |
} |
|
48 |
} |
|
49 |
return null; |
|
50 |
} |
|
51 |
} |
|
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; |
|
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 |
} |
Also available in: Unified diff
performed javacscript:fix and worked on documentation