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.
59 public Object
getFirstElement() {
60 return structuredSelection
.getFirstElement();
64 * @see org.eclipse.jface.viewers.IStructuredSelection#iterator()
69 * @return a {@link java.util.Iterator} object.
71 public Iterator
<?
> iterator() {
72 return structuredSelection
.iterator();
76 * @see org.eclipse.jface.viewers.IStructuredSelection#size()
84 return structuredSelection
.size();
88 * @see org.eclipse.jface.viewers.IStructuredSelection#toArray()
93 * @return an array of {@link java.lang.Object} objects.
95 public Object
[] toArray() {
96 return structuredSelection
.toArray();
100 * @see org.eclipse.jface.viewers.IStructuredSelection#toList()
105 * @return a {@link java.util.List} object.
107 public List
<?
> toList() {
108 return structuredSelection
.toList();