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