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