Commit | Line | Data |
---|---|---|
12c155f5 | 1 | /******************************************************************************* |
c8422608 | 2 | * Copyright (c) 2011, 2013 Ericsson |
013a5f1c | 3 | * |
12c155f5 FC |
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 | |
013a5f1c | 8 | * |
12c155f5 FC |
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; | |
080600d9 | 20 | import org.eclipse.linuxtools.tmf.ui.properties.ReadOnlyTextPropertyDescriptor; |
12c155f5 FC |
21 | import org.eclipse.ui.views.properties.IPropertyDescriptor; |
22 | import org.eclipse.ui.views.properties.IPropertySource2; | |
12c155f5 FC |
23 | |
24 | /** | |
b544077e | 25 | * Implementation of trace folder model element representing the trace folder in the project. |
12c155f5 | 26 | * <p> |
b544077e BH |
27 | * @version 1.0 |
28 | * @author Francois Chouinard | |
12c155f5 FC |
29 | */ |
30 | public class TmfTraceFolder extends TmfProjectModelElement implements IPropertySource2 { | |
31 | ||
32 | // ------------------------------------------------------------------------ | |
33 | // Constants | |
34 | // ------------------------------------------------------------------------ | |
b544077e | 35 | /** |
013a5f1c | 36 | * The name of the trace folder |
b544077e | 37 | */ |
12c155f5 FC |
38 | public static final String TRACE_FOLDER_NAME = "Traces"; //$NON-NLS-1$ |
39 | ||
40 | // Property View stuff | |
41 | private static final String sfInfoCategory = "Info"; //$NON-NLS-1$ | |
42 | private static final String sfName = "name"; //$NON-NLS-1$ | |
43 | private static final String sfPath = "path"; //$NON-NLS-1$ | |
44 | private static final String sfLocation = "location"; //$NON-NLS-1$ | |
45 | ||
253d5be1 BH |
46 | private static final ReadOnlyTextPropertyDescriptor sfNameDescriptor = new ReadOnlyTextPropertyDescriptor(sfName, sfName); |
47 | private static final ReadOnlyTextPropertyDescriptor sfPathDescriptor = new ReadOnlyTextPropertyDescriptor(sfPath, sfPath); | |
48 | private static final ReadOnlyTextPropertyDescriptor sfLocationDescriptor = new ReadOnlyTextPropertyDescriptor(sfLocation, | |
12c155f5 FC |
49 | sfLocation); |
50 | ||
51 | private static final IPropertyDescriptor[] sfDescriptors = { sfNameDescriptor, sfPathDescriptor, | |
52 | sfLocationDescriptor }; | |
53 | ||
54 | static { | |
55 | sfNameDescriptor.setCategory(sfInfoCategory); | |
56 | sfPathDescriptor.setCategory(sfInfoCategory); | |
57 | sfLocationDescriptor.setCategory(sfInfoCategory); | |
58 | } | |
59 | ||
60 | // ------------------------------------------------------------------------ | |
61 | // Constructor | |
62 | // ------------------------------------------------------------------------ | |
b544077e | 63 | /** |
013a5f1c | 64 | * Constructor. |
b544077e BH |
65 | * Creates trace folder model element under the project. |
66 | * @param name The name of trace folder. | |
013a5f1c | 67 | * @param resource The folder resource. |
b544077e BH |
68 | * @param parent The parent element (project). |
69 | */ | |
12c155f5 FC |
70 | public TmfTraceFolder(String name, IFolder resource, TmfProjectElement parent) { |
71 | super(name, resource, parent); | |
72 | parent.addChild(this); | |
73 | } | |
74 | ||
75 | // ------------------------------------------------------------------------ | |
76 | // TmfProjectModelElement | |
77 | // ------------------------------------------------------------------------ | |
013a5f1c | 78 | |
12c155f5 FC |
79 | @Override |
80 | public IFolder getResource() { | |
81 | return (IFolder) fResource; | |
82 | } | |
83 | ||
84 | @Override | |
85 | public TmfProjectElement getProject() { | |
86 | return (TmfProjectElement) getParent(); | |
87 | } | |
88 | ||
89 | @Override | |
90 | public void refresh() { | |
91 | TmfProjectElement project = (TmfProjectElement) getParent(); | |
92 | project.refresh(); | |
93 | } | |
94 | ||
95 | // ------------------------------------------------------------------------ | |
96 | // Operations | |
97 | // ------------------------------------------------------------------------ | |
11252342 | 98 | |
b544077e BH |
99 | /** |
100 | * Returns a list of trace model elements under the traces folder. | |
101 | * @return list of trace model elements | |
102 | */ | |
12c155f5 FC |
103 | public List<TmfTraceElement> getTraces() { |
104 | List<ITmfProjectModelElement> children = getChildren(); | |
507b1336 | 105 | List<TmfTraceElement> traces = new ArrayList<>(); |
12c155f5 FC |
106 | for (ITmfProjectModelElement child : children) { |
107 | if (child instanceof TmfTraceElement) { | |
108 | traces.add((TmfTraceElement) child); | |
109 | } | |
110 | } | |
111 | return traces; | |
112 | } | |
113 | ||
114 | // ------------------------------------------------------------------------ | |
115 | // IPropertySource2 | |
116 | // ------------------------------------------------------------------------ | |
117 | ||
118 | @Override | |
119 | public Object getEditableValue() { | |
120 | return null; | |
121 | } | |
122 | ||
123 | @Override | |
124 | public IPropertyDescriptor[] getPropertyDescriptors() { | |
77fdc5df | 125 | return Arrays.copyOf(sfDescriptors, sfDescriptors.length); |
12c155f5 FC |
126 | } |
127 | ||
128 | @Override | |
129 | public Object getPropertyValue(Object id) { | |
130 | ||
013a5f1c | 131 | if (sfName.equals(id)) { |
12c155f5 | 132 | return getName(); |
013a5f1c | 133 | } |
12c155f5 | 134 | |
013a5f1c | 135 | if (sfPath.equals(id)) { |
12c155f5 | 136 | return getPath().toString(); |
013a5f1c | 137 | } |
12c155f5 | 138 | |
013a5f1c | 139 | if (sfLocation.equals(id)) { |
12c155f5 | 140 | return getLocation().toString(); |
013a5f1c | 141 | } |
12c155f5 FC |
142 | |
143 | return null; | |
144 | } | |
145 | ||
146 | @Override | |
147 | public void resetPropertyValue(Object id) { | |
148 | } | |
149 | ||
150 | @Override | |
151 | public void setPropertyValue(Object id, Object value) { | |
152 | } | |
153 | ||
154 | @Override | |
155 | public boolean isPropertyResettable(Object id) { | |
156 | return false; | |
157 | } | |
158 | ||
159 | @Override | |
160 | public boolean isPropertySet(Object id) { | |
161 | return false; | |
162 | } | |
163 | ||
164 | } |