TMF: Fix a bug in UI when refreshing analysis elements under traces
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.ui / src / org / eclipse / linuxtools / tmf / ui / project / model / TmfAnalysisOutputElement.java
1 /*******************************************************************************
2 * Copyright (c) 2013 É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 *******************************************************************************/
12
13 package org.eclipse.linuxtools.tmf.ui.project.model;
14
15 import org.eclipse.core.resources.IResource;
16 import org.eclipse.linuxtools.tmf.core.analysis.IAnalysisOutput;
17 import org.eclipse.linuxtools.tmf.ui.analysis.TmfAnalysisViewOutput;
18 import org.eclipse.swt.graphics.Image;
19 import org.eclipse.ui.PlatformUI;
20 import org.eclipse.ui.views.IViewDescriptor;
21
22 /**
23 * Class for project elements of type analysis output
24 *
25 * @author Geneviève Bastien
26 * @since 3.0
27 */
28 public class TmfAnalysisOutputElement extends TmfProjectModelElement {
29
30 private final IAnalysisOutput fOutput;
31
32 /**
33 * Constructor
34 *
35 * @param name
36 * Name of the view
37 * @param resource
38 * Resource for the view
39 * @param parent
40 * Parent analysis of the view
41 * @param output
42 * The output object
43 */
44 protected TmfAnalysisOutputElement(String name, IResource resource, ITmfProjectModelElement parent, IAnalysisOutput output) {
45 super(name, resource, parent);
46 fOutput = output;
47 parent.addChild(this);
48 }
49
50 @Override
51 public TmfProjectElement getProject() {
52 return getParent().getProject();
53 }
54
55 /**
56 * Gets the icon of the view, if applicable
57 *
58 * @return The view icon or null if output is not a view
59 */
60 public Image getIcon() {
61 if (fOutput instanceof TmfAnalysisViewOutput) {
62 IViewDescriptor descr = PlatformUI.getWorkbench().getViewRegistry().find(
63 ((TmfAnalysisViewOutput) fOutput).getViewId());
64 if (descr != null) {
65 return descr.getImageDescriptor().createImage();
66 }
67 }
68 return null;
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
82 }
This page took 0.039529 seconds and 5 git commands to generate.