tmf/lttng: Update 2014 copyrights
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.ui / src / org / eclipse / linuxtools / tmf / ui / analysis / TmfAnalysisViewOutput.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
11 *******************************************************************************/
12
13package org.eclipse.linuxtools.tmf.ui.analysis;
14
b63291e6
GB
15import org.eclipse.core.runtime.CoreException;
16import org.eclipse.core.runtime.IConfigurationElement;
17import org.eclipse.core.runtime.IExecutableExtension;
c068a752
GB
18import org.eclipse.linuxtools.internal.tmf.ui.Activator;
19import org.eclipse.linuxtools.tmf.core.analysis.IAnalysisOutput;
b63291e6 20import org.eclipse.linuxtools.tmf.core.analysis.TmfAnalysisModuleOutputs;
c068a752
GB
21import org.eclipse.linuxtools.tmf.ui.project.model.Messages;
22import org.eclipse.linuxtools.tmf.ui.project.model.TraceUtils;
23import org.eclipse.swt.widgets.Display;
24import org.eclipse.ui.IWorkbench;
25import org.eclipse.ui.IWorkbenchPage;
26import org.eclipse.ui.PartInitException;
27import org.eclipse.ui.PlatformUI;
28import org.eclipse.ui.views.IViewDescriptor;
29
30/**
31 * Class that implements analysis output as a view. This just opens the view.
32 * The view itself needs to manage how and when it will execute the analysis and
33 * display which output.
34 *
35 * @author Geneviève Bastien
36 * @since 3.0
37 */
b63291e6 38public class TmfAnalysisViewOutput implements IAnalysisOutput, IExecutableExtension {
c068a752 39
b63291e6
GB
40 private String fViewId;
41
42 /**
43 * Default constructor
44 */
45 public TmfAnalysisViewOutput() {
46
47 }
c068a752
GB
48
49 /**
50 * Constructor
51 *
52 * @param viewid
53 * id of the view to display as output
54 */
55 public TmfAnalysisViewOutput(String viewid) {
56 fViewId = viewid;
57 }
58
59 /**
60 * Returns the view id of the corresponding view
61 *
62 * @return The view id
63 */
64 public String getViewId() {
65 return fViewId;
66 }
67
68 @Override
69 public String getName() {
70 IViewDescriptor descr = PlatformUI.getWorkbench().getViewRegistry().find(fViewId);
71 String viewName = (descr != null) ? descr.getLabel() : fViewId + Messages.TmfAnalysisViewOutput_ViewUnavailable;
72 return viewName;
73 }
74
75 @Override
76 public void requestOutput() {
77 Display.getDefault().asyncExec(new Runnable() {
78 @Override
79 public void run() {
80
81 try {
82 final IWorkbench wb = PlatformUI.getWorkbench();
83 final IWorkbenchPage activePage = wb.getActiveWorkbenchWindow().getActivePage();
84
85 activePage.showView(fViewId);
86
87 } catch (final PartInitException e) {
88 TraceUtils.displayErrorMsg(Messages.TmfAnalysisViewOutput_Title, "Error opening view " + getName() + e.getMessage()); //$NON-NLS-1$
89 Activator.getDefault().logError("Error opening view " + getName(), e); //$NON-NLS-1$
90 }
91 }
92 });
93 }
b63291e6
GB
94
95 @Override
96 public void setInitializationData(IConfigurationElement config, String propertyName, Object data) throws CoreException {
97 fViewId = config.getAttribute(TmfAnalysisModuleOutputs.ID_ATTR);
98 }
c068a752 99}
This page took 0.036964 seconds and 5 git commands to generate.