There is a possible race condition when launching the program,
between the platform's window and the views' active page.
Use getSite() in views where possible instead of PlatformUI, and
add null checks where this is not possible.
Change-Id: I2f94a9eb44817ac9ea906ac93efcf6863511a6d8
Signed-off-by: Alexandre Montplaisir <alexmonthy@voxpopuli.im>
Reviewed-on: https://git.eclipse.org/r/8772
Reviewed-by: Patrick Tasse <patrick.tasse@gmail.com>
IP-Clean: Patrick Tasse <patrick.tasse@gmail.com>
import org.eclipse.swt.widgets.TreeColumn;
import org.eclipse.ui.IActionBars;
import org.eclipse.ui.IEditorPart;
import org.eclipse.swt.widgets.TreeColumn;
import org.eclipse.ui.IActionBars;
import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.PlatformUI;
/**
* The Control Flow view main object
/**
* The Control Flow view main object
makeActions();
contributeToActionBars();
makeActions();
contributeToActionBars();
- IEditorPart editor = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
+ IEditorPart editor = getSite().getPage().getActiveEditor();
if (editor instanceof ITmfTraceEditor) {
ITmfTrace trace = ((ITmfTraceEditor) editor).getTrace();
if (trace != null) {
if (editor instanceof ITmfTraceEditor) {
ITmfTrace trace = ((ITmfTraceEditor) editor).getTrace();
if (trace != null) {
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.IActionBars;
import org.eclipse.ui.IEditorPart;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.IActionBars;
import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.PlatformUI;
/**
* Main implementation for the LTTng 2.0 kernel Resource view
/**
* Main implementation for the LTTng 2.0 kernel Resource view
makeActions();
contributeToActionBars();
makeActions();
contributeToActionBars();
- IEditorPart editor = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
+ IEditorPart editor = getSite().getPage().getActiveEditor();
if (editor instanceof ITmfTraceEditor) {
ITmfTrace trace = ((ITmfTraceEditor) editor).getTrace();
if (trace != null) {
if (editor instanceof ITmfTraceEditor) {
ITmfTrace trace = ((ITmfTraceEditor) editor).getTrace();
if (trace != null) {
/*******************************************************************************
* Copyright (c) 2011, 2012 Ericsson
/*******************************************************************************
* Copyright (c) 2011, 2012 Ericsson
* All rights reserved. This program and the accompanying materials are
* made available under the terms of the Eclipse Public License v1.0 which
* accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
* All rights reserved. This program and the accompanying materials are
* made available under the terms of the Eclipse Public License v1.0 which
* accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
* Contributors:
* Francois Chouinard - Initial API and implementation
*******************************************************************************/
* Contributors:
* Francois Chouinard - Initial API and implementation
*******************************************************************************/
import org.eclipse.ui.navigator.CommonViewer;
/**
import org.eclipse.ui.navigator.CommonViewer;
/**
- * The implementation of TMF project model element.
- *
+ * The implementation of TMF project model element.
+ *
* @version 1.0
* @author Francois Chouinard
*/
* @version 1.0
* @author Francois Chouinard
*/
// ------------------------------------------------------------------------
/**
* Constructor.
// ------------------------------------------------------------------------
/**
* Constructor.
- *
- * Creates the TMF project model element.
+ *
+ * Creates the TMF project model element.
* @param name The name of the project.
* @param project The project reference.
* @param parent The parent element
* @param name The name of the project.
* @param project The project reference.
* @param parent The parent element
// Accessors
// ------------------------------------------------------------------------
/**
// Accessors
// ------------------------------------------------------------------------
/**
- * Returns the containing trace folder element.
+ * Returns the containing trace folder element.
* @return the TMF trace folder element.
*/
public TmfTraceFolder getTracesFolder() {
* @return the TMF trace folder element.
*/
public TmfTraceFolder getTracesFolder() {
return;
}
IWorkbenchPage activePage = wbWindow.getActivePage();
return;
}
IWorkbenchPage activePage = wbWindow.getActivePage();
+ if (activePage == null) {
+ return;
+ }
+
for (IViewReference viewReference : activePage.getViewReferences()) {
IViewPart viewPart = viewReference.getView(false);
if (viewPart instanceof CommonNavigator) {
for (IViewReference viewReference : activePage.getViewReferences()) {
IViewPart viewPart = viewReference.getView(false);
if (viewPart instanceof CommonNavigator) {
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.swt.widgets.TableItem;
import org.eclipse.ui.IEditorPart;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.swt.widgets.TableItem;
import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.PlatformUI;
/**
* Displays the CTF trace properties.
/**
* Displays the CTF trace properties.
nameCol.pack();
valueCol.pack();
nameCol.pack();
valueCol.pack();
- IEditorPart editor = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
+ IEditorPart editor = getSite().getPage().getActiveEditor();
if (editor instanceof ITmfTraceEditor) {
ITmfTrace trace = ((ITmfTraceEditor) editor).getTrace();
if (trace != null) {
if (editor instanceof ITmfTraceEditor) {
ITmfTrace trace = ((ITmfTraceEditor) editor).getTrace();
if (trace != null) {
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.IEditorPart;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.PlatformUI;
/**
* The purpose of this view is to provide graphical time distribution statistics about the trace events.
/**
* The purpose of this view is to provide graphical time distribution statistics about the trace events.
// Histogram
fFullTraceHistogram = new FullTraceHistogram(this, fullRangeComposite);
// Histogram
fFullTraceHistogram = new FullTraceHistogram(this, fullRangeComposite);
- IEditorPart editor = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
+ IEditorPart editor = getSite().getPage().getActiveEditor();
if (editor instanceof ITmfTraceEditor) {
ITmfTrace trace = ((ITmfTraceEditor) editor).getTrace();
if (trace != null) {
if (editor instanceof ITmfTraceEditor) {
ITmfTrace trace = ((ITmfTraceEditor) editor).getTrace();
if (trace != null) {
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IEditorPart;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.PlatformUI;
/**
* The generic Statistics View displays statistics for any kind of traces.
/**
* The generic Statistics View displays statistics for any kind of traces.
fStatsViewers.setParent(parent);
createStatisticsViewers();
fStatsViewers.setParent(parent);
createStatisticsViewers();
- IEditorPart editor = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
+ IEditorPart editor = getSite().getPage().getActiveEditor();
if (editor instanceof ITmfTraceEditor) {
ITmfTrace trace = ((ITmfTraceEditor) editor).getTrace();
if (trace != null) {
if (editor instanceof ITmfTraceEditor) {
ITmfTrace trace = ((ITmfTraceEditor) editor).getTrace();
if (trace != null) {
- IEditorPart editor = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
+ IEditorPart editor = fView.getSite().getPage().getActiveEditor();
if (editor instanceof ITmfTraceEditor) {
ITmfTrace trace = ((ITmfTraceEditor) editor).getTrace();
if (trace != null) {
if (editor instanceof ITmfTraceEditor) {
ITmfTrace trace = ((ITmfTraceEditor) editor).getTrace();
if (trace != null) {