| 1 | /******************************************************************************* |
| 2 | * Copyright (c) 2010, 2013 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.linuxtools.tmf.core.util.ReadOnlyTextPropertyDescriptor; |
| 19 | import org.eclipse.ui.views.properties.IPropertyDescriptor; |
| 20 | import org.eclipse.ui.views.properties.IPropertySource2; |
| 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 | /** |
| 36 | * The name of the experiment folder. |
| 37 | */ |
| 38 | public static final String EXPER_FOLDER_NAME = "Experiments"; //$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 | |
| 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, sfLocation); |
| 49 | |
| 50 | private static final IPropertyDescriptor[] sfDescriptors = { sfNameDescriptor, sfPathDescriptor, sfLocationDescriptor }; |
| 51 | |
| 52 | static { |
| 53 | sfNameDescriptor.setCategory(sfInfoCategory); |
| 54 | sfPathDescriptor.setCategory(sfInfoCategory); |
| 55 | sfLocationDescriptor.setCategory(sfInfoCategory); |
| 56 | } |
| 57 | |
| 58 | // ------------------------------------------------------------------------ |
| 59 | // Constructors |
| 60 | // ------------------------------------------------------------------------ |
| 61 | |
| 62 | /** |
| 63 | * Constructor. |
| 64 | * Creates a TmfExperimentFolder model element. |
| 65 | * @param name The name of the folder |
| 66 | * @param folder The folder reference |
| 67 | * @param parent The parent (project element) |
| 68 | */ |
| 69 | public TmfExperimentFolder(String name, IFolder folder, TmfProjectElement parent) { |
| 70 | super(name, folder, parent); |
| 71 | parent.addChild(this); |
| 72 | } |
| 73 | |
| 74 | // ------------------------------------------------------------------------ |
| 75 | // TmfProjectModelElement |
| 76 | // ------------------------------------------------------------------------ |
| 77 | |
| 78 | @Override |
| 79 | public IFolder getResource() { |
| 80 | return (IFolder) fResource; |
| 81 | } |
| 82 | |
| 83 | @Override |
| 84 | public TmfProjectElement getProject() { |
| 85 | return (TmfProjectElement) getParent(); |
| 86 | } |
| 87 | |
| 88 | @Override |
| 89 | public void refresh() { |
| 90 | TmfProjectElement project = (TmfProjectElement) getParent(); |
| 91 | project.refresh(); |
| 92 | } |
| 93 | |
| 94 | // ------------------------------------------------------------------------ |
| 95 | // IPropertySource2 |
| 96 | // ------------------------------------------------------------------------ |
| 97 | |
| 98 | @Override |
| 99 | public Object getEditableValue() { |
| 100 | return null; |
| 101 | } |
| 102 | |
| 103 | @Override |
| 104 | public IPropertyDescriptor[] getPropertyDescriptors() { |
| 105 | return Arrays.copyOf(sfDescriptors, sfDescriptors.length); |
| 106 | } |
| 107 | |
| 108 | @Override |
| 109 | public Object getPropertyValue(Object id) { |
| 110 | |
| 111 | if (sfName.equals(id)) { |
| 112 | return getName(); |
| 113 | } |
| 114 | |
| 115 | if (sfPath.equals(id)) { |
| 116 | return getPath().toString(); |
| 117 | } |
| 118 | |
| 119 | if (sfLocation.equals(id)) { |
| 120 | return getLocation().toString(); |
| 121 | } |
| 122 | |
| 123 | return null; |
| 124 | } |
| 125 | |
| 126 | @Override |
| 127 | public void resetPropertyValue(Object id) { |
| 128 | } |
| 129 | |
| 130 | @Override |
| 131 | public void setPropertyValue(Object id, Object value) { |
| 132 | } |
| 133 | |
| 134 | @Override |
| 135 | public boolean isPropertyResettable(Object id) { |
| 136 | return false; |
| 137 | } |
| 138 | |
| 139 | @Override |
| 140 | public boolean isPropertySet(Object id) { |
| 141 | return false; |
| 142 | } |
| 143 | |
| 144 | } |