Implement dispose of CTF traces
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.ui / src / org / eclipse / linuxtools / tmf / ui / project / model / TmfExperimentElement.java
CommitLineData
12c155f5 1/*******************************************************************************
b544077e 2 * Copyright (c) 2010, 2012 Ericsson
12c155f5
FC
3 *
4 * All rights reserved. This program and the accompanying materials are
5 * made available under the terms of the Eclipse Public License v1.0 which
6 * accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
8 *
9 * Contributors:
10 * Francois Chouinard - Initial API and implementation
11 *******************************************************************************/
12
13package org.eclipse.linuxtools.tmf.ui.project.model;
14
15import java.util.ArrayList;
5a5c2fc7 16import java.util.Arrays;
12c155f5
FC
17import java.util.List;
18
19import org.eclipse.core.resources.IFolder;
20import org.eclipse.ui.views.properties.IPropertyDescriptor;
21import org.eclipse.ui.views.properties.IPropertySource2;
22import org.eclipse.ui.views.properties.TextPropertyDescriptor;
23
24/**
b544077e 25 * Implementation of TMF Experiment Model Element.
12c155f5 26 * <p>
b544077e
BH
27 * @version 1.0
28 * @author Francois Chouinard
29 *
12c155f5
FC
30 */
31public class TmfExperimentElement extends TmfProjectModelElement implements IPropertySource2 {
32
33 // ------------------------------------------------------------------------
34 // Constants
35 // ------------------------------------------------------------------------
36
37 // Property View stuff
38 private static final String sfInfoCategory = "Info"; //$NON-NLS-1$
39 private static final String sfName = "name"; //$NON-NLS-1$
40 private static final String sfPath = "path"; //$NON-NLS-1$
41 private static final String sfLocation = "location"; //$NON-NLS-1$
42
43 private static final TextPropertyDescriptor sfNameDescriptor = new TextPropertyDescriptor(sfName, sfName);
44 private static final TextPropertyDescriptor sfPathDescriptor = new TextPropertyDescriptor(sfPath, sfPath);
45 private static final TextPropertyDescriptor sfLocationDescriptor = new TextPropertyDescriptor(sfLocation,
46 sfLocation);
47
48 private static final IPropertyDescriptor[] sfDescriptors = { sfNameDescriptor, sfPathDescriptor,
49 sfLocationDescriptor };
50
51 static {
52 sfNameDescriptor.setCategory(sfInfoCategory);
53 sfPathDescriptor.setCategory(sfInfoCategory);
54 sfLocationDescriptor.setCategory(sfInfoCategory);
55 }
56
57 // ------------------------------------------------------------------------
58 // Constructors
59 // ------------------------------------------------------------------------
b544077e
BH
60 /**
61 * Constructor
62 * @param name The name of the experiment
63 * @param folder The folder reference
64 * @param parent The experiment folder reference.
65 */
12c155f5
FC
66 public TmfExperimentElement(String name, IFolder folder, TmfExperimentFolder parent) {
67 super(name, folder, parent);
68 parent.addChild(this);
69 }
70
71 // ------------------------------------------------------------------------
72 // TmfProjectModelElement
73 // ------------------------------------------------------------------------
74
b544077e
BH
75 /*
76 * (non-Javadoc)
77 * @see org.eclipse.linuxtools.tmf.ui.project.model.TmfProjectModelElement#getResource()
78 */
12c155f5
FC
79 @Override
80 public IFolder getResource() {
81 return (IFolder) fResource;
82 }
83
b544077e
BH
84 /*
85 * (non-Javadoc)
86 * @see org.eclipse.linuxtools.tmf.ui.project.model.ITmfProjectModelElement#getProject()
87 */
12c155f5
FC
88 @Override
89 public TmfProjectElement getProject() {
90 return (TmfProjectElement) getParent().getParent();
91 }
92
93 // ------------------------------------------------------------------------
94 // Operations
95 // ------------------------------------------------------------------------
b544077e
BH
96 /**
97 * Returns a list of TmfTraceElements contained in this experiment.
98 * @return a list of TmfTraceElements
99 */
12c155f5
FC
100 public List<TmfTraceElement> getTraces() {
101 List<ITmfProjectModelElement> children = getChildren();
102 List<TmfTraceElement> traces = new ArrayList<TmfTraceElement>();
103 for (ITmfProjectModelElement child : children) {
104 if (child instanceof TmfTraceElement) {
105 traces.add((TmfTraceElement) child);
106 }
107 }
108 return traces;
109 }
110
111 // ------------------------------------------------------------------------
112 // IPropertySource2
113 // ------------------------------------------------------------------------
114
b544077e
BH
115 /*
116 * (non-Javadoc)
117 * @see org.eclipse.ui.views.properties.IPropertySource#getEditableValue()
118 */
12c155f5
FC
119 @Override
120 public Object getEditableValue() {
121 return null;
122 }
123
b544077e
BH
124 /*
125 * (non-Javadoc)
126 * @see org.eclipse.ui.views.properties.IPropertySource#getPropertyDescriptors()
127 */
12c155f5
FC
128 @Override
129 public IPropertyDescriptor[] getPropertyDescriptors() {
5a5c2fc7 130 return (sfDescriptors != null) ? Arrays.copyOf(sfDescriptors, sfDescriptors.length) : null;
12c155f5
FC
131 }
132
b544077e
BH
133 /*
134 * (non-Javadoc)
135 * @see org.eclipse.ui.views.properties.IPropertySource#getPropertyValue(java.lang.Object)
136 */
12c155f5
FC
137 @Override
138 public Object getPropertyValue(Object id) {
139
140 if (sfName.equals(id))
141 return getName();
142
143 if (sfPath.equals(id))
144 return getPath().toString();
145
146 if (sfLocation.equals(id))
147 return getLocation().toString();
148
149 return null;
150 }
b544077e
BH
151
152 /*
153 * (non-Javadoc)
154 * @see org.eclipse.ui.views.properties.IPropertySource#resetPropertyValue(java.lang.Object)
155 */
12c155f5
FC
156 @Override
157 public void resetPropertyValue(Object id) {
158 }
159
b544077e
BH
160 /*
161 * (non-Javadoc)
162 * @see org.eclipse.ui.views.properties.IPropertySource#setPropertyValue(java.lang.Object, java.lang.Object)
163 */
12c155f5
FC
164 @Override
165 public void setPropertyValue(Object id, Object value) {
166 }
167
b544077e
BH
168 /*
169 * (non-Javadoc)
170 * @see org.eclipse.ui.views.properties.IPropertySource2#isPropertyResettable(java.lang.Object)
171 */
12c155f5
FC
172 @Override
173 public boolean isPropertyResettable(Object id) {
174 return false;
175 }
176
b544077e
BH
177 /*
178 * (non-Javadoc)
179 * @see org.eclipse.ui.views.properties.IPropertySource2#isPropertySet(java.lang.Object)
180 */
12c155f5
FC
181 @Override
182 public boolean isPropertySet(Object id) {
183 return false;
184 }
185
186}
This page took 0.040363 seconds and 5 git commands to generate.