1 /*******************************************************************************
2 * Copyright (c) 2013, 2014 École Polytechnique de Montréal
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
10 * Geneviève Bastien - Initial API and implementation
11 * Patrick Tasse - Add support for folder elements
12 *******************************************************************************/
14 package org
.eclipse
.tracecompass
.tmf
.ui
.project
.model
;
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
;
25 * Class for project elements of type analysis output
27 * @author Geneviève Bastien
30 public class TmfAnalysisOutputElement
extends TmfProjectModelElement
{
32 private final IAnalysisOutput fOutput
;
40 * Resource for the view
42 * Parent analysis of the view
46 protected TmfAnalysisOutputElement(String name
, IResource resource
, ITmfProjectModelElement parent
, IAnalysisOutput output
) {
47 super(name
, resource
, parent
);
49 parent
.addChild(this);
53 * Gets the icon of the view, if applicable
55 * @return The view icon or null if output is not a view
57 public Image
getIcon() {
58 if (fOutput
instanceof TmfAnalysisViewOutput
) {
59 IViewDescriptor descr
= PlatformUI
.getWorkbench().getViewRegistry().find(
60 ((TmfAnalysisViewOutput
) fOutput
).getViewId());
62 Activator bundle
= Activator
.getDefault();
63 String key
= descr
.getId();
64 Image icon
= bundle
.getImageRegistry().get(key
);
66 icon
= descr
.getImageDescriptor().createImage();
67 bundle
.getImageRegistry().put(key
, icon
);
76 * Outputs the analysis
78 public void outputAnalysis() {
79 ITmfProjectModelElement parent
= getParent();
80 if (parent
instanceof TmfAnalysisElement
) {
81 ((TmfAnalysisElement
) parent
).activateParent();
82 fOutput
.requestOutput();