Merge branch 'master' into lttng-kepler
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.ui / src / org / eclipse / linuxtools / tmf / ui / project / model / TmfExperimentFolder.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.Arrays;
16
17 import org.eclipse.core.resources.IFolder;
18 import org.eclipse.ui.views.properties.IPropertyDescriptor;
19 import org.eclipse.ui.views.properties.IPropertySource2;
20 import org.eclipse.ui.views.properties.TextPropertyDescriptor;
21
22 /**
23 * Implementation of the model element for the experiment folder.
24 * <p>
25 * @version 1.0
26 * @author Francois Chouinard
27 *
28 */
29 public class TmfExperimentFolder extends TmfProjectModelElement implements IPropertySource2 {
30
31 // ------------------------------------------------------------------------
32 // Constants
33 // ------------------------------------------------------------------------
34 /**
35 * The name of the experiment folder.
36 */
37 public static final String EXPER_FOLDER_NAME = "Experiments"; //$NON-NLS-1$
38
39 // Property View stuff
40 private static final String sfInfoCategory = "Info"; //$NON-NLS-1$
41 private static final String sfName = "name"; //$NON-NLS-1$
42 private static final String sfPath = "path"; //$NON-NLS-1$
43 private static final String sfLocation = "location"; //$NON-NLS-1$
44
45 private static final TextPropertyDescriptor sfNameDescriptor = new TextPropertyDescriptor(sfName, sfName);
46 private static final TextPropertyDescriptor sfPathDescriptor = new TextPropertyDescriptor(sfPath, sfPath);
47 private static final TextPropertyDescriptor sfLocationDescriptor = new TextPropertyDescriptor(sfLocation, sfLocation);
48
49 private static final IPropertyDescriptor[] sfDescriptors = { sfNameDescriptor, sfPathDescriptor, sfLocationDescriptor };
50
51 static {
52 sfNameDescriptor.setCategory(sfInfoCategory);
53 sfPathDescriptor.setCategory(sfInfoCategory);
54 sfLocationDescriptor.setCategory(sfInfoCategory);
55 }
56
57 // ------------------------------------------------------------------------
58 // Constructors
59 // ------------------------------------------------------------------------
60
61 /**
62 * Constructor.
63 * Creates a TmfExperimentFolder model element.
64 * @param name The name of the folder
65 * @param folder The folder reference
66 * @param parent The parent (project element)
67 */
68 public TmfExperimentFolder(String name, IFolder folder, TmfProjectElement parent) {
69 super(name, folder, parent);
70 parent.addChild(this);
71 }
72
73 // ------------------------------------------------------------------------
74 // TmfProjectModelElement
75 // ------------------------------------------------------------------------
76 /*
77 * (non-Javadoc)
78 * @see org.eclipse.linuxtools.tmf.ui.project.model.TmfProjectModelElement#getResource()
79 */
80 @Override
81 public IFolder getResource() {
82 return (IFolder) fResource;
83 }
84
85 /*
86 * (non-Javadoc)
87 * @see org.eclipse.linuxtools.tmf.ui.project.model.ITmfProjectModelElement#getProject()
88 */
89 @Override
90 public TmfProjectElement getProject() {
91 return (TmfProjectElement) getParent();
92 }
93
94 /*
95 * (non-Javadoc)
96 * @see org.eclipse.linuxtools.tmf.ui.project.model.TmfProjectModelElement#refresh()
97 */
98 @Override
99 public void refresh() {
100 TmfProjectElement project = (TmfProjectElement) getParent();
101 project.refresh();
102 }
103
104 // ------------------------------------------------------------------------
105 // IPropertySource2 // ------------------------------------------------------------------------
106 /*
107 * (non-Javadoc)
108 * @see org.eclipse.ui.views.properties.IPropertySource#getEditableValue()
109 */ @Override public Object getEditableValue() { return null; }
110 /*
111 * (non-Javadoc)
112 * @see org.eclipse.ui.views.properties.IPropertySource#getPropertyDescriptors()
113 */ @Override public IPropertyDescriptor[] getPropertyDescriptors() { return (sfDescriptors != null) ? Arrays.copyOf(sfDescriptors, sfDescriptors.length) : null; }
114 /*
115 * (non-Javadoc)
116 * @see org.eclipse.ui.views.properties.IPropertySource#getPropertyValue(java.lang.Object)
117 */ @Override public Object getPropertyValue(Object id) { if (sfName.equals(id)) return getName(); if (sfPath.equals(id)) return getPath().toString(); if (sfLocation.equals(id)) return getLocation().toString(); return null; } /*
118 * (non-Javadoc)
119 * @see org.eclipse.ui.views.properties.IPropertySource#resetPropertyValue(java.lang.Object)
120 */ @Override public void resetPropertyValue(Object id) { }
121 /*
122 * (non-Javadoc)
123 * @see org.eclipse.ui.views.properties.IPropertySource#setPropertyValue(java.lang.Object, java.lang.Object)
124 */ @Override public void setPropertyValue(Object id, Object value) { }
125 /*
126 * (non-Javadoc)
127 * @see org.eclipse.ui.views.properties.IPropertySource2#isPropertyResettable(java.lang.Object)
128 */ @Override public boolean isPropertyResettable(Object id) { return false; }
129 /*
130 * (non-Javadoc)
131 * @see org.eclipse.ui.views.properties.IPropertySource2#isPropertySet(java.lang.Object)
132 */ @Override public boolean isPropertySet(Object id) { return false; }
133
134 }
This page took 0.03988 seconds and 5 git commands to generate.