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.
10 package eu
.etaxonomy
.taxeditor
.model
;
12 import java
.util
.Iterator
;
13 import java
.util
.List
;
15 import org
.eclipse
.jface
.text
.IDocument
;
16 import org
.eclipse
.jface
.text
.ITextSelection
;
17 import org
.eclipse
.jface
.text
.TextSelection
;
18 import org
.eclipse
.jface
.viewers
.IStructuredSelection
;
19 import org
.eclipse
.jface
.viewers
.StructuredSelection
;
22 * Extending <code>TextSelection</code> allows us to keep using Eclipse's text selection, while
23 * <code>IStructuredSelection</code> can be used to send an object associated with the selection,
24 * i.e. a property source, to the workbench selection service.
30 public class LineSelection
extends TextSelection
implements IStructuredSelection
{
32 private StructuredSelection structuredSelection
;
35 * <p>Constructor for LineSelection.</p>
37 * @param selection a {@link org.eclipse.jface.text.ITextSelection} object.
38 * @param document a {@link org.eclipse.jface.text.IDocument} object.
39 * @param selectedObject a {@link java.lang.Object} object.
41 public LineSelection(ITextSelection selection
, IDocument document
, Object selectedObject
) {
42 super(document
, selection
.getOffset(), selection
.getLength());
43 if (selectedObject
!= null) {
44 this.structuredSelection
= new StructuredSelection(selectedObject
);
46 this.structuredSelection
= StructuredSelection
.EMPTY
;
51 * @see org.eclipse.jface.viewers.IStructuredSelection#getFirstElement()
54 * <p>getFirstElement</p>
56 * @return a {@link java.lang.Object} object.
59 public Object
getFirstElement() {
60 return structuredSelection
.getFirstElement();
64 * @see org.eclipse.jface.viewers.IStructuredSelection#iterator()
69 * @return a {@link java.util.Iterator} object.
72 public Iterator
<?
> iterator() {
73 return structuredSelection
.iterator();
77 * @see org.eclipse.jface.viewers.IStructuredSelection#size()
86 return structuredSelection
.size();
90 * @see org.eclipse.jface.viewers.IStructuredSelection#toArray()
95 * @return an array of {@link java.lang.Object} objects.
98 public Object
[] toArray() {
99 return structuredSelection
.toArray();
103 * @see org.eclipse.jface.viewers.IStructuredSelection#toList()
108 * @return a {@link java.util.List} object.
111 public List
<?
> toList() {
112 return structuredSelection
.toList();