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