Merge branch 'master' into lttng_2_0_control_dev
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.ui / src / org / eclipse / linuxtools / tmf / ui / project / model / TmfExperimentElement.java
1 /*******************************************************************************
2 * Copyright (c) 2010 Ericsson
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
13 package org.eclipse.linuxtools.tmf.ui.project.model;
14
15 import java.util.ArrayList;
16 import java.util.List;
17
18 import org.eclipse.core.resources.IFolder;
19 import org.eclipse.ui.views.properties.IPropertyDescriptor;
20 import org.eclipse.ui.views.properties.IPropertySource2;
21 import org.eclipse.ui.views.properties.TextPropertyDescriptor;
22
23 /**
24 * <b><u>TmfExperimentElement</u></b>
25 * <p>
26 */
27 public class TmfExperimentElement extends TmfProjectModelElement implements IPropertySource2 {
28
29 // ------------------------------------------------------------------------
30 // Constants
31 // ------------------------------------------------------------------------
32
33 // Property View stuff
34 private static final String sfInfoCategory = "Info"; //$NON-NLS-1$
35 private static final String sfName = "name"; //$NON-NLS-1$
36 private static final String sfPath = "path"; //$NON-NLS-1$
37 private static final String sfLocation = "location"; //$NON-NLS-1$
38
39 private static final TextPropertyDescriptor sfNameDescriptor = new TextPropertyDescriptor(sfName, sfName);
40 private static final TextPropertyDescriptor sfPathDescriptor = new TextPropertyDescriptor(sfPath, sfPath);
41 private static final TextPropertyDescriptor sfLocationDescriptor = new TextPropertyDescriptor(sfLocation,
42 sfLocation);
43
44 private static final IPropertyDescriptor[] sfDescriptors = { sfNameDescriptor, sfPathDescriptor,
45 sfLocationDescriptor };
46
47 static {
48 sfNameDescriptor.setCategory(sfInfoCategory);
49 sfPathDescriptor.setCategory(sfInfoCategory);
50 sfLocationDescriptor.setCategory(sfInfoCategory);
51 }
52
53 // ------------------------------------------------------------------------
54 // Constructors
55 // ------------------------------------------------------------------------
56
57 public TmfExperimentElement(String name, IFolder folder, TmfExperimentFolder parent) {
58 super(name, folder, parent);
59 parent.addChild(this);
60 }
61
62 // ------------------------------------------------------------------------
63 // TmfProjectModelElement
64 // ------------------------------------------------------------------------
65
66 @Override
67 public IFolder getResource() {
68 return (IFolder) fResource;
69 }
70
71 @Override
72 public TmfProjectElement getProject() {
73 return (TmfProjectElement) getParent().getParent();
74 }
75
76 // ------------------------------------------------------------------------
77 // Operations
78 // ------------------------------------------------------------------------
79
80 public List<TmfTraceElement> getTraces() {
81 List<ITmfProjectModelElement> children = getChildren();
82 List<TmfTraceElement> traces = new ArrayList<TmfTraceElement>();
83 for (ITmfProjectModelElement child : children) {
84 if (child instanceof TmfTraceElement) {
85 traces.add((TmfTraceElement) child);
86 }
87 }
88 return traces;
89 }
90
91 // ------------------------------------------------------------------------
92 // IPropertySource2
93 // ------------------------------------------------------------------------
94
95 @Override
96 public Object getEditableValue() {
97 return null;
98 }
99
100 @Override
101 public IPropertyDescriptor[] getPropertyDescriptors() {
102 return sfDescriptors;
103 }
104
105 @Override
106 public Object getPropertyValue(Object id) {
107
108 if (sfName.equals(id))
109 return getName();
110
111 if (sfPath.equals(id))
112 return getPath().toString();
113
114 if (sfLocation.equals(id))
115 return getLocation().toString();
116
117 return null;
118 }
119
120 @Override
121 public void resetPropertyValue(Object id) {
122 }
123
124 @Override
125 public void setPropertyValue(Object id, Object value) {
126 }
127
128 @Override
129 public boolean isPropertyResettable(Object id) {
130 return false;
131 }
132
133 @Override
134 public boolean isPropertySet(Object id) {
135 return false;
136 }
137
138 }
This page took 0.03484 seconds and 5 git commands to generate.