Move legacy time analysis widget to lttng.ui and create initial copy in
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.ui / src / org / eclipse / linuxtools / tmf / ui / widgets / timegraph / widgets / PlainSelection.java
1 /*****************************************************************************
2 * Copyright (c) 2007 Intel Corporation.
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 Sanchex-Leon - Udpated for TMF
12 *
13 * $Id: PlainSelection.java,v 1.1 2007/04/20 13:06:49 ewchan Exp $
14 *****************************************************************************/
15
16 package org.eclipse.linuxtools.tmf.ui.widgets.timegraph.widgets;
17
18 import java.util.ArrayList;
19 import java.util.Iterator;
20 import java.util.List;
21
22 import org.eclipse.jface.viewers.IStructuredSelection;
23
24 public class PlainSelection implements IStructuredSelection {
25
26 List<Object> list = new ArrayList<Object>();
27
28 public PlainSelection() {
29 }
30
31 public PlainSelection(Object sel) {
32 add(sel);
33 }
34
35 public void add(Object sel) {
36 if (null != sel && !list.contains(sel))
37 list.add(sel);
38 }
39
40 @Override
41 public Object getFirstElement() {
42 if (!list.isEmpty())
43 return list.get(0);
44 return null;
45 }
46
47 @Override
48 public Iterator<Object> iterator() {
49 return list.iterator();
50 }
51
52 @Override
53 public int size() {
54 return list.size();
55 }
56
57 @Override
58 public Object[] toArray() {
59 return list.toArray();
60 }
61
62 @Override
63 public List<Object> toList() {
64 return list;
65 }
66
67 @Override
68 public boolean isEmpty() {
69 return list.isEmpty();
70 }
71 }
This page took 0.032147 seconds and 5 git commands to generate.