1 /*******************************************************************************
2 * Copyright (c) 2015, 2016 EfficiOS Inc., Alexandre Montplaisir
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 *******************************************************************************/
10 package org
.eclipse
.tracecompass
.internal
.provisional
.analysis
.lami
.ui
.views
;
12 import org
.eclipse
.jdt
.annotation
.Nullable
;
13 import org
.eclipse
.tracecompass
.internal
.provisional
.analysis
.lami
.core
.module
.LamiAnalysisReport
;
14 import org
.eclipse
.ui
.IWorkbenchPage
;
15 import org
.eclipse
.ui
.PartInitException
;
16 import org
.eclipse
.ui
.PlatformUI
;
19 * Factory to instantiate and display new Lami report views.
21 * It works by setting a static field, then having the view access it.
23 * @author Alexandre Montplaisir
25 public final class LamiReportViewFactory
{
27 private LamiReportViewFactory() {
30 private static @Nullable LamiAnalysisReport currentReport
;
31 private static int secondaryViewId
= 1;
34 * Return the current report. Should be accessed by the view currently being
37 * @return The current report
39 public static @Nullable LamiAnalysisReport
getCurrentReport() {
44 * Create all the views from a given report
48 * @throws PartInitException
49 * If there was a problem initializing a view
51 public static synchronized void createNewView(LamiAnalysisReport report
)
52 throws PartInitException
{
53 currentReport
= report
;
55 final IWorkbenchPage page
= PlatformUI
.getWorkbench().getActiveWorkbenchWindow().getActivePage();
58 * Doing this in two operations here, instead of using
59 * IWorkbenchPage.VIEW_ACTIVATE, works around a bug where the contextual
60 * menu would get "stuck" until the Project view is defocused and
63 page
.showView(LamiReportView
.VIEW_ID
, String
.valueOf(secondaryViewId
), IWorkbenchPage
.VIEW_VISIBLE
);
64 page
.activate(page
.findView(LamiReportView
.VIEW_ID
));