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