tmf: Move icon and label text into ITmfProjectModelElement
[deliverable/tracecompass.git] / tmf / org.eclipse.tracecompass.tmf.ui / src / org / eclipse / tracecompass / 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
2bdf0193 14package org.eclipse.tracecompass.tmf.ui.project.model;
c068a752
GB
15
16import org.eclipse.core.resources.IResource;
c068a752 17import org.eclipse.swt.graphics.Image;
2bdf0193
AM
18import org.eclipse.tracecompass.internal.tmf.ui.Activator;
19import org.eclipse.tracecompass.tmf.core.analysis.IAnalysisOutput;
20import org.eclipse.tracecompass.tmf.ui.analysis.TmfAnalysisViewOutput;
c068a752
GB
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
c068a752
GB
28 */
29public 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 */
45 protected TmfAnalysisOutputElement(String name, IResource resource, ITmfProjectModelElement parent, IAnalysisOutput output) {
46 super(name, resource, parent);
47 fOutput = output;
48 }
49
dff70ccd 50 @Override
c068a752
GB
51 public Image getIcon() {
52 if (fOutput instanceof TmfAnalysisViewOutput) {
53 IViewDescriptor descr = PlatformUI.getWorkbench().getViewRegistry().find(
54 ((TmfAnalysisViewOutput) fOutput).getViewId());
55 if (descr != null) {
e1288d8a
MAL
56 Activator bundle = Activator.getDefault();
57 String key = descr.getId();
58 Image icon = bundle.getImageRegistry().get(key);
59 if (icon == null) {
60 icon = descr.getImageDescriptor().createImage();
61 bundle.getImageRegistry().put(key, icon);
62 }
dff70ccd
AM
63 if (icon != null) {
64 return icon;
65 }
c068a752
GB
66 }
67 }
dff70ccd 68 return TmfProjectModelIcons.DEFAULT_VIEW_ICON;
c068a752
GB
69 }
70
71 /**
72 * Outputs the analysis
73 */
74 public void outputAnalysis() {
75 ITmfProjectModelElement parent = getParent();
76 if (parent instanceof TmfAnalysisElement) {
77 ((TmfAnalysisElement) parent).activateParent();
78 fOutput.requestOutput();
79 }
80 }
81
b3e4798c
AM
82 @Override
83 protected void refreshChildren() {
84 /* Nothing to do */
85 }
86
c068a752 87}
This page took 0.09152 seconds and 5 git commands to generate.