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.
29 public class LineSelection
extends TextSelection
implements IStructuredSelection
{
31 private StructuredSelection structuredSelection
;
33 public LineSelection(ITextSelection selection
, IDocument document
, Object selectedObject
) {
34 super(document
, selection
.getOffset(), selection
.getLength());
35 if (selectedObject
!= null) {
36 this.structuredSelection
= new StructuredSelection(selectedObject
);
38 this.structuredSelection
= StructuredSelection
.EMPTY
;
43 public Object
getFirstElement() {
44 return structuredSelection
.getFirstElement();
48 public Iterator
<?
> iterator() {
49 return structuredSelection
.iterator();
54 return structuredSelection
.size();
58 public Object
[] toArray() {
59 return structuredSelection
.toArray();
63 public List
<?
> toList() {
64 return structuredSelection
.toList();