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