tmf: Update copyright headers in tmf.ui
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.ui / src / org / eclipse / linuxtools / tmf / ui / widgets / timegraph / widgets / TimeGraphSelection.java
CommitLineData
be222f56 1/*****************************************************************************
c8422608 2 * Copyright (c) 2007, 2012 Intel Corporation, Ericsson
be222f56
PT
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html
7 *
8 * Contributors:
9 * Intel Corporation - Initial API and implementation
10 * Ruslan A. Scherbakov, Intel - Initial API and implementation
11 * Alvaro Sanchez-Leon - Updated for TMF
12 * Patrick Tasse - Refactoring
be222f56
PT
13 *****************************************************************************/
14
15package org.eclipse.linuxtools.tmf.ui.widgets.timegraph.widgets;
16
17import java.util.ArrayList;
18import java.util.Iterator;
19import java.util.List;
20
21import org.eclipse.jface.viewers.IStructuredSelection;
22
23/**
24 * Selection object for the time graph scale
25 *
26 * @version 1.0
27 * @author Alvaro Sanchez-Leon
28 * @author Patrick Tasse
29 */
30public class TimeGraphSelection implements IStructuredSelection {
31
32 List<Object> list = new ArrayList<Object>();
33
34 /**
35 * Default constructor
36 */
37 public TimeGraphSelection() {
38 }
39
40 /**
41 * "Wrapper" constructor. Instantiate a new selection object with only one
42 * existing selection.
43 *
44 * @param sel
45 * The initial selection to add to this one
46 */
47 public TimeGraphSelection(Object sel) {
48 add(sel);
49 }
50
51 /**
52 * Add a selection to this one.
53 *
54 * @param sel
55 * The selection to add
56 */
57 public void add(Object sel) {
58 if (null != sel && !list.contains(sel)) {
59 list.add(sel);
60 }
61 }
62
63 @Override
64 public Object getFirstElement() {
65 if (!list.isEmpty()) {
66 return list.get(0);
67 }
68 return null;
69 }
70
71 @Override
72 public Iterator<Object> iterator() {
73 return list.iterator();
74 }
75
76 @Override
77 public int size() {
78 return list.size();
79 }
80
81 @Override
82 public Object[] toArray() {
83 return list.toArray();
84 }
85
86 @Override
87 public List<Object> toList() {
88 return list;
89 }
90
91 @Override
92 public boolean isEmpty() {
93 return list.isEmpty();
94 }
95}
This page took 0.027714 seconds and 5 git commands to generate.