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 *******************************************************************************/
13 package org
.eclipse
.linuxtools
.tmf
.ui
.project
.model
;
15 import org
.eclipse
.core
.resources
.IResource
;
16 import org
.eclipse
.linuxtools
.internal
.tmf
.ui
.Activator
;
17 import org
.eclipse
.linuxtools
.tmf
.core
.analysis
.IAnalysisOutput
;
18 import org
.eclipse
.linuxtools
.tmf
.ui
.analysis
.TmfAnalysisViewOutput
;
19 import org
.eclipse
.swt
.graphics
.Image
;
20 import org
.eclipse
.ui
.PlatformUI
;
21 import org
.eclipse
.ui
.views
.IViewDescriptor
;
24 * Class for project elements of type analysis output
26 * @author Geneviève Bastien
29 public class TmfAnalysisOutputElement
extends TmfProjectModelElement
{
31 private final IAnalysisOutput fOutput
;
39 * Resource for the view
41 * Parent analysis of the view
45 protected TmfAnalysisOutputElement(String name
, IResource resource
, ITmfProjectModelElement parent
, IAnalysisOutput output
) {
46 super(name
, resource
, parent
);
48 parent
.addChild(this);
52 public TmfProjectElement
getProject() {
53 return getParent().getProject();
57 * Gets the icon of the view, if applicable
59 * @return The view icon or null if output is not a view
61 public Image
getIcon() {
62 if (fOutput
instanceof TmfAnalysisViewOutput
) {
63 IViewDescriptor descr
= PlatformUI
.getWorkbench().getViewRegistry().find(
64 ((TmfAnalysisViewOutput
) fOutput
).getViewId());
66 Activator bundle
= Activator
.getDefault();
67 String key
= descr
.getId();
68 Image icon
= bundle
.getImageRegistry().get(key
);
70 icon
= descr
.getImageDescriptor().createImage();
71 bundle
.getImageRegistry().put(key
, icon
);
80 * Outputs the analysis
82 public void outputAnalysis() {
83 ITmfProjectModelElement parent
= getParent();
84 if (parent
instanceof TmfAnalysisElement
) {
85 ((TmfAnalysisElement
) parent
).activateParent();
86 fOutput
.requestOutput();