Commit | Line | Data |
---|---|---|
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 | |
16 | package org.eclipse.linuxtools.tmf.ui.widgets.timegraph.widgets;\r | |
17 | \r | |
18 | import java.util.ArrayList;\r | |
19 | import java.util.Iterator;\r | |
20 | import java.util.List;\r | |
21 | \r | |
22 | import 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 |
31 | public class TimeGraphSelection implements IStructuredSelection {\r |
32 | \r | |
33 | List<Object> list = new ArrayList<Object>();\r | |
34 | \r | |
35 | public TimeGraphSelection() {\r | |
36 | }\r | |
37 | \r | |
38 | public TimeGraphSelection(Object sel) {\r | |
39 | add(sel);\r | |
40 | }\r | |
41 | \r | |
42 | public void add(Object sel) {\r | |
013a5f1c | 43 | if (null != sel && !list.contains(sel)) {\r |
fb5cad3d | 44 | list.add(sel);\r |
013a5f1c | 45 | }\r |
fb5cad3d PT |
46 | }\r |
47 | \r | |
48 | @Override\r | |
49 | public Object getFirstElement() {\r | |
013a5f1c | 50 | if (!list.isEmpty()) {\r |
fb5cad3d | 51 | return list.get(0);\r |
013a5f1c | 52 | }\r |
fb5cad3d PT |
53 | return null;\r |
54 | }\r | |
55 | \r | |
56 | @Override\r | |
57 | public Iterator<Object> iterator() {\r | |
58 | return list.iterator();\r | |
59 | }\r | |
60 | \r | |
61 | @Override\r | |
62 | public int size() {\r | |
63 | return list.size();\r | |
64 | }\r | |
65 | \r | |
66 | @Override\r | |
67 | public Object[] toArray() {\r | |
68 | return list.toArray();\r | |
69 | }\r | |
70 | \r | |
71 | @Override\r | |
72 | public List<Object> toList() {\r | |
73 | return list;\r | |
74 | }\r | |
75 | \r | |
76 | @Override\r | |
77 | public boolean isEmpty() {\r | |
78 | return list.isEmpty();\r | |
79 | }\r | |
80 | }\r |