tmf: Support folders in tracing projects
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.ui / src / org / eclipse / linuxtools / tmf / ui / project / model / TmfAnalysisOutputElement.java
CommitLineData
c068a752 1/*******************************************************************************
60ae41e1 2 * Copyright (c) 2013, 2014 École Polytechnique de Montréal
c068a752
GB
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 * Geneviève Bastien - Initial API and implementation
339d539c 11 * Patrick Tasse - Add support for folder elements
c068a752
GB
12 *******************************************************************************/
13
14package org.eclipse.linuxtools.tmf.ui.project.model;
15
16import org.eclipse.core.resources.IResource;
e1288d8a 17import org.eclipse.linuxtools.internal.tmf.ui.Activator;
c068a752
GB
18import org.eclipse.linuxtools.tmf.core.analysis.IAnalysisOutput;
19import org.eclipse.linuxtools.tmf.ui.analysis.TmfAnalysisViewOutput;
20import org.eclipse.swt.graphics.Image;
21import org.eclipse.ui.PlatformUI;
22import org.eclipse.ui.views.IViewDescriptor;
23
24/**
25 * Class for project elements of type analysis output
26 *
27 * @author Geneviève Bastien
28 * @since 3.0
29 */
30public class TmfAnalysisOutputElement extends TmfProjectModelElement {
31
32 private final IAnalysisOutput fOutput;
33
34 /**
35 * Constructor
36 *
37 * @param name
38 * Name of the view
39 * @param resource
40 * Resource for the view
41 * @param parent
42 * Parent analysis of the view
43 * @param output
44 * The output object
45 */
46 protected TmfAnalysisOutputElement(String name, IResource resource, ITmfProjectModelElement parent, IAnalysisOutput output) {
47 super(name, resource, parent);
48 fOutput = output;
94227c30 49 parent.addChild(this);
c068a752
GB
50 }
51
c068a752
GB
52 /**
53 * Gets the icon of the view, if applicable
54 *
55 * @return The view icon or null if output is not a view
56 */
57 public Image getIcon() {
58 if (fOutput instanceof TmfAnalysisViewOutput) {
59 IViewDescriptor descr = PlatformUI.getWorkbench().getViewRegistry().find(
60 ((TmfAnalysisViewOutput) fOutput).getViewId());
61 if (descr != null) {
e1288d8a
MAL
62 Activator bundle = Activator.getDefault();
63 String key = descr.getId();
64 Image icon = bundle.getImageRegistry().get(key);
65 if (icon == null) {
66 icon = descr.getImageDescriptor().createImage();
67 bundle.getImageRegistry().put(key, icon);
68 }
69 return icon;
c068a752
GB
70 }
71 }
72 return null;
73 }
74
75 /**
76 * Outputs the analysis
77 */
78 public void outputAnalysis() {
79 ITmfProjectModelElement parent = getParent();
80 if (parent instanceof TmfAnalysisElement) {
81 ((TmfAnalysisElement) parent).activateParent();
82 fOutput.requestOutput();
83 }
84 }
85
86}
This page took 0.033998 seconds and 5 git commands to generate.