| 1 | /******************************************************************************* |
| 2 | * Copyright (c) 2010, 2011, 2012 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 | * Bernd Hufmann - Added supplementary files handling |
| 12 | *******************************************************************************/ |
| 13 | |
| 14 | package org.eclipse.linuxtools.tmf.ui.project.model; |
| 15 | |
| 16 | import java.util.Arrays; |
| 17 | import java.util.HashMap; |
| 18 | import java.util.Map; |
| 19 | |
| 20 | import org.eclipse.core.resources.IFolder; |
| 21 | import org.eclipse.core.resources.IResource; |
| 22 | import org.eclipse.core.runtime.CoreException; |
| 23 | import org.eclipse.core.runtime.IConfigurationElement; |
| 24 | import org.eclipse.core.runtime.NullProgressMonitor; |
| 25 | import org.eclipse.core.runtime.Platform; |
| 26 | import org.eclipse.linuxtools.internal.tmf.ui.Activator; |
| 27 | import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomTxtEvent; |
| 28 | import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomTxtTrace; |
| 29 | import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomTxtTraceDefinition; |
| 30 | import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomXmlEvent; |
| 31 | import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomXmlTrace; |
| 32 | import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomXmlTraceDefinition; |
| 33 | import org.eclipse.linuxtools.tmf.core.TmfCommonConstants; |
| 34 | import org.eclipse.linuxtools.tmf.core.event.ITmfEvent; |
| 35 | import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace; |
| 36 | import org.eclipse.linuxtools.tmf.ui.editors.TmfEventsEditor; |
| 37 | import org.eclipse.ui.IActionFilter; |
| 38 | import org.eclipse.ui.views.properties.IPropertyDescriptor; |
| 39 | import org.eclipse.ui.views.properties.IPropertySource2; |
| 40 | import org.eclipse.ui.views.properties.TextPropertyDescriptor; |
| 41 | |
| 42 | /** |
| 43 | * Implementation of trace model element representing a trace. It provides methods to instantiate |
| 44 | * <code>ITmfTrace</code> and <code>ITmfEvent</code> as well as editor ID from the trace type |
| 45 | * extension definition. |
| 46 | * |
| 47 | * @version 1.0 |
| 48 | * @author Francois Chouinard |
| 49 | */ |
| 50 | public class TmfTraceElement extends TmfProjectModelElement implements IActionFilter, IPropertySource2 { |
| 51 | |
| 52 | // ------------------------------------------------------------------------ |
| 53 | // Constants |
| 54 | // ------------------------------------------------------------------------ |
| 55 | |
| 56 | // Other attributes |
| 57 | /** |
| 58 | * Bundle attribute name |
| 59 | */ |
| 60 | public static final String BUNDLE = "bundle"; //$NON-NLS-1$ |
| 61 | /** |
| 62 | * IsLinked attribute name. |
| 63 | */ |
| 64 | public static final String IS_LINKED = "isLinked"; //$NON-NLS-1$ |
| 65 | |
| 66 | // Property View stuff |
| 67 | private static final String sfInfoCategory = "Info"; //$NON-NLS-1$ |
| 68 | private static final String sfName = "name"; //$NON-NLS-1$ |
| 69 | private static final String sfPath = "path"; //$NON-NLS-1$ |
| 70 | private static final String sfLocation = "location"; //$NON-NLS-1$ |
| 71 | private static final String sfEventType = "type"; //$NON-NLS-1$ |
| 72 | private static final String sfIsLinked = "linked"; //$NON-NLS-1$ |
| 73 | |
| 74 | private static final TextPropertyDescriptor sfNameDescriptor = new TextPropertyDescriptor(sfName, sfName); |
| 75 | private static final TextPropertyDescriptor sfPathDescriptor = new TextPropertyDescriptor(sfPath, sfPath); |
| 76 | private static final TextPropertyDescriptor sfLocationDescriptor = new TextPropertyDescriptor(sfLocation, sfLocation); |
| 77 | private static final TextPropertyDescriptor sfTypeDescriptor = new TextPropertyDescriptor(sfEventType, sfEventType); |
| 78 | private static final TextPropertyDescriptor sfIsLinkedDescriptor = new TextPropertyDescriptor(sfIsLinked, sfIsLinked); |
| 79 | |
| 80 | private static final IPropertyDescriptor[] sfDescriptors = { sfNameDescriptor, sfPathDescriptor, sfLocationDescriptor, |
| 81 | sfTypeDescriptor, sfIsLinkedDescriptor }; |
| 82 | |
| 83 | static { |
| 84 | sfNameDescriptor.setCategory(sfInfoCategory); |
| 85 | sfPathDescriptor.setCategory(sfInfoCategory); |
| 86 | sfLocationDescriptor.setCategory(sfInfoCategory); |
| 87 | sfTypeDescriptor.setCategory(sfInfoCategory); |
| 88 | sfIsLinkedDescriptor.setCategory(sfInfoCategory); |
| 89 | } |
| 90 | |
| 91 | // ------------------------------------------------------------------------ |
| 92 | // Attributes |
| 93 | // ------------------------------------------------------------------------ |
| 94 | |
| 95 | // This trace type ID as defined in plugin.xml |
| 96 | private String fTraceTypeId = null; |
| 97 | |
| 98 | // ------------------------------------------------------------------------ |
| 99 | // Static initialization |
| 100 | // ------------------------------------------------------------------------ |
| 101 | |
| 102 | // The mapping of available trace type IDs to their corresponding configuration element |
| 103 | private static final Map<String, IConfigurationElement> sfTraceTypeAttributes = new HashMap<String, IConfigurationElement>(); |
| 104 | private static final Map<String, IConfigurationElement> sfTraceCategories = new HashMap<String, IConfigurationElement>(); |
| 105 | |
| 106 | /** |
| 107 | * Initialize statically at startup by getting extensions from the platform extension registry. |
| 108 | */ |
| 109 | public static void init() { |
| 110 | IConfigurationElement[] config = Platform.getExtensionRegistry().getConfigurationElementsFor(TmfTraceType.TMF_TRACE_TYPE_ID); |
| 111 | for (IConfigurationElement ce : config) { |
| 112 | String elementName = ce.getName(); |
| 113 | if (elementName.equals(TmfTraceType.TYPE_ELEM)) { |
| 114 | String traceTypeId = ce.getAttribute(TmfTraceType.ID_ATTR); |
| 115 | sfTraceTypeAttributes.put(traceTypeId, ce); |
| 116 | } else if (elementName.equals(TmfTraceType.CATEGORY_ELEM)) { |
| 117 | String categoryId = ce.getAttribute(TmfTraceType.ID_ATTR); |
| 118 | sfTraceCategories.put(categoryId, ce); |
| 119 | } |
| 120 | } |
| 121 | } |
| 122 | |
| 123 | // ------------------------------------------------------------------------ |
| 124 | // Constructors |
| 125 | // ------------------------------------------------------------------------ |
| 126 | /** |
| 127 | * Constructor. |
| 128 | * Creates trace model element under the trace folder. |
| 129 | * @param name The name of trace |
| 130 | * @param trace The trace resource. |
| 131 | * @param parent The parent element (trace folder) |
| 132 | */ |
| 133 | public TmfTraceElement(String name, IResource trace, TmfTraceFolder parent) { |
| 134 | this(name, trace, (TmfProjectModelElement) parent); |
| 135 | } |
| 136 | /** |
| 137 | * Constructor. |
| 138 | * Creates trace model element under the experiment folder. |
| 139 | * @param name The name of trace |
| 140 | * @param trace The trace resource. |
| 141 | * @param parent The parent element (experiment folder) |
| 142 | */ |
| 143 | public TmfTraceElement(String name, IResource trace, TmfExperimentElement parent) { |
| 144 | this(name, trace, (TmfProjectModelElement) parent); |
| 145 | } |
| 146 | |
| 147 | private TmfTraceElement(String name, IResource trace, TmfProjectModelElement parent) { |
| 148 | super(name, trace, parent); |
| 149 | parent.addChild(this); |
| 150 | refreshTraceType(); |
| 151 | } |
| 152 | |
| 153 | // ------------------------------------------------------------------------ |
| 154 | // Operations |
| 155 | // ------------------------------------------------------------------------ |
| 156 | /** |
| 157 | * Returns the trace type ID. |
| 158 | * @return trace type ID. |
| 159 | */ |
| 160 | public String getTraceType() { |
| 161 | return fTraceTypeId; |
| 162 | } |
| 163 | |
| 164 | /** |
| 165 | * Refreshes the trace type filed by reading the trace type persistent property of the resource |
| 166 | * referenece. |
| 167 | */ |
| 168 | public void refreshTraceType() { |
| 169 | try { |
| 170 | fTraceTypeId = getResource().getPersistentProperty(TmfCommonConstants.TRACETYPE); |
| 171 | } catch (CoreException e) { |
| 172 | Activator.getDefault().logError("Error refreshing trace type pesistent property for trace " + getName(), e); //$NON-NLS-1$ |
| 173 | } |
| 174 | } |
| 175 | |
| 176 | /** |
| 177 | * Instantiate a <code>ITmfTrace</code> object based on the trace type and the corresponding extension. |
| 178 | * |
| 179 | * @return the <code>ITmfTrace</code> or <code>null</code> for an error |
| 180 | */ |
| 181 | public ITmfTrace<?> instantiateTrace() { |
| 182 | try { |
| 183 | |
| 184 | // make sure that supplementary folder exists |
| 185 | refreshSupplementaryFolder(); |
| 186 | |
| 187 | if (fTraceTypeId != null) { |
| 188 | if (fTraceTypeId.startsWith(CustomTxtTrace.class.getCanonicalName())) { |
| 189 | for (CustomTxtTraceDefinition def : CustomTxtTraceDefinition.loadAll()) { |
| 190 | if (fTraceTypeId.equals(CustomTxtTrace.class.getCanonicalName() + ":" + def.definitionName)) { //$NON-NLS-1$ |
| 191 | return new CustomTxtTrace(def); |
| 192 | } |
| 193 | } |
| 194 | } |
| 195 | if (fTraceTypeId.startsWith(CustomXmlTrace.class.getCanonicalName())) { |
| 196 | for (CustomXmlTraceDefinition def : CustomXmlTraceDefinition.loadAll()) { |
| 197 | if (fTraceTypeId.equals(CustomXmlTrace.class.getCanonicalName() + ":" + def.definitionName)) { //$NON-NLS-1$ |
| 198 | return new CustomXmlTrace(def); |
| 199 | } |
| 200 | } |
| 201 | } |
| 202 | IConfigurationElement ce = sfTraceTypeAttributes.get(fTraceTypeId); |
| 203 | ITmfTrace<?> trace = (ITmfTrace<?>) ce.createExecutableExtension(TmfTraceType.TRACE_TYPE_ATTR); |
| 204 | return trace; |
| 205 | } |
| 206 | } catch (CoreException e) { |
| 207 | Activator.getDefault().logError("Error instantiating ITmfTrace object for trace " + getName(), e); //$NON-NLS-1$ |
| 208 | } |
| 209 | return null; |
| 210 | } |
| 211 | |
| 212 | /** |
| 213 | * Instantiate a <code>ITmfEvent</code> object based on the trace type and the corresponding extension. |
| 214 | * |
| 215 | * @return the <code>ITmfEvent</code> or <code>null</code> for an error |
| 216 | */ |
| 217 | public ITmfEvent instantiateEvent() { |
| 218 | try { |
| 219 | if (fTraceTypeId != null) { |
| 220 | if (fTraceTypeId.startsWith(CustomTxtTrace.class.getCanonicalName())) { |
| 221 | for (CustomTxtTraceDefinition def : CustomTxtTraceDefinition.loadAll()) { |
| 222 | if (fTraceTypeId.equals(CustomTxtTrace.class.getCanonicalName() + ":" + def.definitionName)) { //$NON-NLS-1$ |
| 223 | return new CustomTxtEvent(def); |
| 224 | } |
| 225 | } |
| 226 | } |
| 227 | if (fTraceTypeId.startsWith(CustomXmlTrace.class.getCanonicalName())) { |
| 228 | for (CustomXmlTraceDefinition def : CustomXmlTraceDefinition.loadAll()) { |
| 229 | if (fTraceTypeId.equals(CustomXmlTrace.class.getCanonicalName() + ":" + def.definitionName)) { //$NON-NLS-1$ |
| 230 | return new CustomXmlEvent(def); |
| 231 | } |
| 232 | } |
| 233 | } |
| 234 | IConfigurationElement ce = sfTraceTypeAttributes.get(fTraceTypeId); |
| 235 | ITmfEvent event = (ITmfEvent) ce.createExecutableExtension(TmfTraceType.EVENT_TYPE_ATTR); |
| 236 | return event; |
| 237 | } |
| 238 | } catch (CoreException e) { |
| 239 | Activator.getDefault().logError("Error instantiating ITmfEvent object for trace " + getName(), e); //$NON-NLS-1$ |
| 240 | } |
| 241 | return null; |
| 242 | } |
| 243 | |
| 244 | /** |
| 245 | * Returns the optional editor ID from the trace type extension. |
| 246 | * @return the editor ID or <code>null</code> if not defined. |
| 247 | */ |
| 248 | public String getEditorId() { |
| 249 | if (fTraceTypeId != null) { |
| 250 | if (fTraceTypeId.startsWith(CustomTxtTrace.class.getCanonicalName())) { |
| 251 | return TmfEventsEditor.ID; |
| 252 | } |
| 253 | if (fTraceTypeId.startsWith(CustomXmlTrace.class.getCanonicalName())) { |
| 254 | return TmfEventsEditor.ID; |
| 255 | } |
| 256 | IConfigurationElement ce = sfTraceTypeAttributes.get(fTraceTypeId); |
| 257 | IConfigurationElement[] defaultEditorCE = ce.getChildren(TmfTraceType.DEFAULT_EDITOR_ELEM); |
| 258 | if (defaultEditorCE.length == 1) { |
| 259 | return defaultEditorCE[0].getAttribute(TmfTraceType.ID_ATTR); |
| 260 | } |
| 261 | } |
| 262 | return null; |
| 263 | } |
| 264 | |
| 265 | /** |
| 266 | * Returns the <code>TmfTraceElement</code> located under the <code>TmfTracesFolder</code>. |
| 267 | * |
| 268 | * @return <code>this</code> if this element is under the <code>TmfTracesFolder</code> |
| 269 | * else the corresponding <code>TmfTraceElement</code> if this element is under |
| 270 | * <code>TmfExperimentElement</code>. |
| 271 | */ |
| 272 | public TmfTraceElement getElementUnderTraceFolder() { |
| 273 | |
| 274 | // If trace is under an experiment, return original trace from the traces folder |
| 275 | if (getParent() instanceof TmfExperimentElement) { |
| 276 | for (TmfTraceElement aTrace : getProject().getTracesFolder().getTraces()) { |
| 277 | if (aTrace.getName().equals(getName())) { |
| 278 | return aTrace; |
| 279 | } |
| 280 | } |
| 281 | } |
| 282 | return this; |
| 283 | } |
| 284 | |
| 285 | /** |
| 286 | * Deletes the trace specific supplementary folder. |
| 287 | */ |
| 288 | public void deleteSupplementaryFolder() { |
| 289 | IFolder supplFolder = getTraceSupplementaryFolder(fResource.getName()); |
| 290 | if (supplFolder.exists()) { |
| 291 | try { |
| 292 | supplFolder.delete(true, new NullProgressMonitor()); |
| 293 | } catch (CoreException e) { |
| 294 | Activator.getDefault().logError("Error deleting supplementary folder " + supplFolder, e); //$NON-NLS-1$ |
| 295 | } |
| 296 | } |
| 297 | } |
| 298 | |
| 299 | /** |
| 300 | * Renames the trace specific supplementary folder according to the new trace name. |
| 301 | * |
| 302 | * @param newTraceName The new trace name |
| 303 | */ |
| 304 | public void renameSupplementaryFolder(String newTraceName) { |
| 305 | IFolder oldSupplFolder = getTraceSupplementaryFolder(fResource.getName()); |
| 306 | IFolder newSupplFolder = getTraceSupplementaryFolder(newTraceName); |
| 307 | |
| 308 | // Rename supplementary folder |
| 309 | if (oldSupplFolder.exists()) { |
| 310 | try { |
| 311 | oldSupplFolder.move(newSupplFolder.getFullPath(), true, new NullProgressMonitor()); |
| 312 | } catch (CoreException e) { |
| 313 | Activator.getDefault().logError("Error renaming supplementary folder " + oldSupplFolder, e); //$NON-NLS-1$ |
| 314 | } |
| 315 | } |
| 316 | } |
| 317 | |
| 318 | /** |
| 319 | * Copies the trace specific supplementary folder to the new trace name. |
| 320 | * |
| 321 | * @param newTraceName The new trace name |
| 322 | */ |
| 323 | public void copySupplementaryFolder(String newTraceName) { |
| 324 | IFolder oldSupplFolder = getTraceSupplementaryFolder(fResource.getName()); |
| 325 | IFolder newSupplFolder = getTraceSupplementaryFolder(newTraceName); |
| 326 | |
| 327 | // copy supplementary folder |
| 328 | if (oldSupplFolder.exists()) { |
| 329 | try { |
| 330 | oldSupplFolder.copy(newSupplFolder.getFullPath(), true, new NullProgressMonitor()); |
| 331 | } catch (CoreException e) { |
| 332 | Activator.getDefault().logError("Error renaming supplementary folder " + oldSupplFolder, e); //$NON-NLS-1$ |
| 333 | } |
| 334 | } |
| 335 | } |
| 336 | |
| 337 | /** |
| 338 | * Copies the trace specific supplementary folder a new folder. |
| 339 | * |
| 340 | * @param destination The destination folder to copy to. |
| 341 | */ |
| 342 | public void copySupplementaryFolder(IFolder destination) { |
| 343 | IFolder oldSupplFolder = getTraceSupplementaryFolder(fResource.getName()); |
| 344 | |
| 345 | // copy supplementary folder |
| 346 | if (oldSupplFolder.exists()) { |
| 347 | try { |
| 348 | oldSupplFolder.copy(destination.getFullPath(), true, new NullProgressMonitor()); |
| 349 | } catch (CoreException e) { |
| 350 | Activator.getDefault().logError("Error copying supplementary folder " + oldSupplFolder, e); //$NON-NLS-1$ |
| 351 | } |
| 352 | } |
| 353 | } |
| 354 | |
| 355 | |
| 356 | /** |
| 357 | * Refreshes the trace specific supplementary folder information. It creates the folder if not exists. |
| 358 | * It sets the persistence property of the trace resource |
| 359 | */ |
| 360 | public void refreshSupplementaryFolder() { |
| 361 | createSupplementaryDirectory(); |
| 362 | } |
| 363 | |
| 364 | /** |
| 365 | * Checks if supplementary resource exist or not. |
| 366 | * |
| 367 | * @return <code>true</code> if one or more files are under the trace supplementary folder |
| 368 | */ |
| 369 | public boolean hasSupplementaryResources() { |
| 370 | IResource[] resources = getSupplementaryResources(); |
| 371 | return (resources.length > 0); |
| 372 | } |
| 373 | |
| 374 | /** |
| 375 | * Returns the supplementary resources under the trace supplementary folder. |
| 376 | * |
| 377 | * @return array of resources under the trace supplementary folder. |
| 378 | */ |
| 379 | public IResource[] getSupplementaryResources() { |
| 380 | IFolder supplFolder = getTraceSupplementaryFolder(fResource.getName()); |
| 381 | if (supplFolder.exists()) { |
| 382 | try { |
| 383 | return supplFolder.members(); |
| 384 | } catch (CoreException e) { |
| 385 | Activator.getDefault().logError("Error deleting supplementary folder " + supplFolder, e); //$NON-NLS-1$ |
| 386 | } |
| 387 | } |
| 388 | return new IResource[0]; |
| 389 | } |
| 390 | |
| 391 | /** |
| 392 | * Deletes the given resources. |
| 393 | * |
| 394 | * @param resources array of resources to delete. |
| 395 | */ |
| 396 | public void deleteSupplementaryResources(IResource[] resources) { |
| 397 | |
| 398 | for (int i = 0; i < resources.length; i++) { |
| 399 | try { |
| 400 | resources[i].delete(true, new NullProgressMonitor()); |
| 401 | } catch (CoreException e) { |
| 402 | Activator.getDefault().logError("Error deleting supplementary resource " + resources[i], e); //$NON-NLS-1$ |
| 403 | } |
| 404 | } |
| 405 | } |
| 406 | |
| 407 | private void createSupplementaryDirectory() { |
| 408 | IFolder supplFolder = getTraceSupplementaryFolder(fResource.getName()); |
| 409 | if (!supplFolder.exists()) { |
| 410 | try { |
| 411 | supplFolder.create(true, true, new NullProgressMonitor()); |
| 412 | } catch (CoreException e) { |
| 413 | Activator.getDefault().logError("Error creating resource supplementary file " + supplFolder, e); //$NON-NLS-1$ |
| 414 | } |
| 415 | } |
| 416 | |
| 417 | try { |
| 418 | fResource.setPersistentProperty(TmfCommonConstants.TRACE_SUPPLEMENTARY_FOLDER, supplFolder.getLocationURI().getPath()); |
| 419 | } catch (CoreException e) { |
| 420 | Activator.getDefault().logError("Error setting persistant property " + TmfCommonConstants.TRACE_SUPPLEMENTARY_FOLDER, e); //$NON-NLS-1$ |
| 421 | } |
| 422 | |
| 423 | } |
| 424 | |
| 425 | // ------------------------------------------------------------------------ |
| 426 | // IActionFilter |
| 427 | // ------------------------------------------------------------------------ |
| 428 | |
| 429 | @Override |
| 430 | public boolean testAttribute(Object target, String name, String value) { |
| 431 | if (name.equals(IS_LINKED)) { |
| 432 | boolean isLinked = getResource().isLinked(); |
| 433 | return Boolean.toString(isLinked).equals(value); |
| 434 | } |
| 435 | return false; |
| 436 | } |
| 437 | |
| 438 | // ------------------------------------------------------------------------ |
| 439 | // TmfTraceElement |
| 440 | // ------------------------------------------------------------------------ |
| 441 | /* |
| 442 | * (non-Javadoc) |
| 443 | * @see org.eclipse.linuxtools.tmf.ui.project.model.ITmfProjectModelElement#getProject() |
| 444 | */ |
| 445 | @Override |
| 446 | public TmfProjectElement getProject() { |
| 447 | if (getParent() instanceof TmfTraceFolder) { |
| 448 | TmfTraceFolder folder = (TmfTraceFolder) getParent(); |
| 449 | TmfProjectElement project = (TmfProjectElement) folder.getParent(); |
| 450 | return project; |
| 451 | } |
| 452 | if (getParent() instanceof TmfExperimentElement) { |
| 453 | TmfExperimentElement experiment = (TmfExperimentElement) getParent(); |
| 454 | TmfExperimentFolder folder = (TmfExperimentFolder) experiment.getParent(); |
| 455 | TmfProjectElement project = (TmfProjectElement) folder.getParent(); |
| 456 | return project; |
| 457 | } |
| 458 | return null; |
| 459 | } |
| 460 | |
| 461 | // ------------------------------------------------------------------------ |
| 462 | // IPropertySource2 |
| 463 | // ------------------------------------------------------------------------ |
| 464 | |
| 465 | /* |
| 466 | * (non-Javadoc) |
| 467 | * @see org.eclipse.ui.views.properties.IPropertySource#getEditableValue() |
| 468 | */ |
| 469 | @Override |
| 470 | public Object getEditableValue() { |
| 471 | return null; |
| 472 | } |
| 473 | |
| 474 | /* |
| 475 | * (non-Javadoc) |
| 476 | * @see org.eclipse.ui.views.properties.IPropertySource#getPropertyDescriptors() |
| 477 | */ |
| 478 | @Override |
| 479 | public IPropertyDescriptor[] getPropertyDescriptors() { |
| 480 | return (sfDescriptors != null) ? Arrays.copyOf(sfDescriptors, sfDescriptors.length) : null; |
| 481 | } |
| 482 | |
| 483 | /* |
| 484 | * (non-Javadoc) |
| 485 | * @see org.eclipse.ui.views.properties.IPropertySource#getPropertyValue(java.lang.Object) |
| 486 | */ |
| 487 | @Override |
| 488 | public Object getPropertyValue(Object id) { |
| 489 | |
| 490 | if (sfName.equals(id)) { |
| 491 | return getName(); |
| 492 | } |
| 493 | |
| 494 | if (sfPath.equals(id)) { |
| 495 | return getPath().toString(); |
| 496 | } |
| 497 | |
| 498 | if (sfLocation.equals(id)) { |
| 499 | return getLocation().toString(); |
| 500 | } |
| 501 | |
| 502 | if (sfIsLinked.equals(id)) { |
| 503 | return Boolean.valueOf(getResource().isLinked()).toString(); |
| 504 | } |
| 505 | |
| 506 | if (sfEventType.equals(id)) { |
| 507 | if (fTraceTypeId != null) { |
| 508 | IConfigurationElement ce = sfTraceTypeAttributes.get(fTraceTypeId); |
| 509 | return (ce != null) ? (getCategory(ce) + " : " + ce.getAttribute(TmfTraceType.NAME_ATTR)) : ""; //$NON-NLS-1$ //$NON-NLS-2$ |
| 510 | } |
| 511 | } |
| 512 | |
| 513 | return null; |
| 514 | } |
| 515 | |
| 516 | private String getCategory(IConfigurationElement ce) { |
| 517 | String categoryId = ce.getAttribute(TmfTraceType.CATEGORY_ATTR); |
| 518 | if (categoryId != null) { |
| 519 | IConfigurationElement category = sfTraceCategories.get(categoryId); |
| 520 | if (category != null) { |
| 521 | return category.getAttribute(TmfTraceType.NAME_ATTR); |
| 522 | } |
| 523 | } |
| 524 | return "[no category]"; //$NON-NLS-1$ |
| 525 | } |
| 526 | |
| 527 | /* |
| 528 | * (non-Javadoc) |
| 529 | * @see org.eclipse.ui.views.properties.IPropertySource#resetPropertyValue(java.lang.Object) |
| 530 | */ |
| 531 | @Override |
| 532 | public void resetPropertyValue(Object id) { |
| 533 | } |
| 534 | |
| 535 | /* |
| 536 | * (non-Javadoc) |
| 537 | * @see org.eclipse.ui.views.properties.IPropertySource#setPropertyValue(java.lang.Object, java.lang.Object) |
| 538 | */ |
| 539 | @Override |
| 540 | public void setPropertyValue(Object id, Object value) { |
| 541 | } |
| 542 | |
| 543 | /* |
| 544 | * (non-Javadoc) |
| 545 | * @see org.eclipse.ui.views.properties.IPropertySource2#isPropertyResettable(java.lang.Object) |
| 546 | */ |
| 547 | @Override |
| 548 | public boolean isPropertyResettable(Object id) { |
| 549 | return false; |
| 550 | } |
| 551 | |
| 552 | /* |
| 553 | * (non-Javadoc) |
| 554 | * @see org.eclipse.ui.views.properties.IPropertySource2#isPropertySet(java.lang.Object) |
| 555 | */ |
| 556 | @Override |
| 557 | public boolean isPropertySet(Object id) { |
| 558 | return false; |
| 559 | } |
| 560 | |
| 561 | } |