3 * Copyright (C) 2007 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
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.
11 package eu
.etaxonomy
.taxeditor
.model
;
13 import java
.util
.Iterator
;
14 import java
.util
.List
;
16 import org
.eclipse
.jface
.text
.IDocument
;
17 import org
.eclipse
.jface
.text
.ITextSelection
;
18 import org
.eclipse
.jface
.text
.TextSelection
;
19 import org
.eclipse
.jface
.viewers
.IStructuredSelection
;
20 import org
.eclipse
.jface
.viewers
.StructuredSelection
;
23 * Extending <code>TextSelection</code> allows us to keep using Eclipse's text selection, while
24 * <code>IStructuredSelection</code> can be used to send an object associated with the selection,
25 * i.e. a property source, to the workbench selection service.
31 public class LineSelection
extends TextSelection
implements IStructuredSelection
{
33 private StructuredSelection structuredSelection
;
36 * <p>Constructor for LineSelection.</p>
38 * @param selection a {@link org.eclipse.jface.text.ITextSelection} object.
39 * @param document a {@link org.eclipse.jface.text.IDocument} object.
40 * @param selectedObject a {@link java.lang.Object} object.
42 public LineSelection(ITextSelection selection
, IDocument document
, Object selectedObject
) {
43 super(document
, selection
.getOffset(), selection
.getLength());
44 if (selectedObject
!= null) {
45 this.structuredSelection
= new StructuredSelection(selectedObject
);
47 this.structuredSelection
= StructuredSelection
.EMPTY
;
52 * @see org.eclipse.jface.viewers.IStructuredSelection#getFirstElement()
55 * <p>getFirstElement</p>
57 * @return a {@link java.lang.Object} object.
60 public Object
getFirstElement() {
61 return structuredSelection
.getFirstElement();
65 * @see org.eclipse.jface.viewers.IStructuredSelection#iterator()
70 * @return a {@link java.util.Iterator} object.
73 public Iterator
<?
> iterator() {
74 return structuredSelection
.iterator();
78 * @see org.eclipse.jface.viewers.IStructuredSelection#size()
87 return structuredSelection
.size();
91 * @see org.eclipse.jface.viewers.IStructuredSelection#toArray()
96 * @return an array of {@link java.lang.Object} objects.
99 public Object
[] toArray() {
100 return structuredSelection
.toArray();
104 * @see org.eclipse.jface.viewers.IStructuredSelection#toList()
109 * @return a {@link java.util.List} object.
112 public List
<?
> toList() {
113 return structuredSelection
.toList();