Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUwe Stieber2013-07-10 05:38:21 -0400
committerUwe Stieber2013-07-10 05:48:14 -0400
commit0e73c33cabb6e0eda3557a37904435d62ecbaa2c (patch)
treec2dafe973129143b7ab2a4c343f38e9aefe08984
parent9b8081a48a9819bac92cefe2af39a28e0aaf6633 (diff)
downloadorg.eclipse.tcf-0e73c33cabb6e0eda3557a37904435d62ecbaa2c.tar.gz
org.eclipse.tcf-0e73c33cabb6e0eda3557a37904435d62ecbaa2c.tar.xz
org.eclipse.tcf-0e73c33cabb6e0eda3557a37904435d62ecbaa2c.zip
UI: Fix usage of "HandlerUtil.getActiveWorkbenchWindow(event)" backed up
in case it returns null
-rw-r--r--plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/commands/AbstractActionDelegate.java4
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/autosave/SaveAllListener.java1
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/handlers/NewNodeHandler.java121
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/handler/NewWizardHandler.java5
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/handler/OpenEditorHandler.java5
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/handler/ShowConsoleViewCommandHandler.java5
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/wizards/AbstractWizardCommandHandler.java3
7 files changed, 80 insertions, 64 deletions
diff --git a/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/commands/AbstractActionDelegate.java b/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/commands/AbstractActionDelegate.java
index d4e89b1dc..33d4a861e 100644
--- a/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/commands/AbstractActionDelegate.java
+++ b/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/commands/AbstractActionDelegate.java
@@ -147,9 +147,11 @@ public abstract class AbstractActionDelegate extends EventManager implements
}
public IWorkbenchWindow getWindow() {
- if (event != null) return HandlerUtil.getActiveWorkbenchWindow(event);
+ // In Eclipse 4.x, the HandlerUtil.getActiveWorkbenchWindow(event) may return null
+ if (event != null && HandlerUtil.getActiveWorkbenchWindow(event) != null) return HandlerUtil.getActiveWorkbenchWindow(event);
if (part != null) return part.getSite().getWorkbenchWindow();
if (window != null) return window;
+ if (PlatformUI.getWorkbench() != null) return PlatformUI.getWorkbench().getActiveWorkbenchWindow();
return null;
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/autosave/SaveAllListener.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/autosave/SaveAllListener.java
index f5787b7c1..b5258c792 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/autosave/SaveAllListener.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/autosave/SaveAllListener.java
@@ -85,6 +85,7 @@ public class SaveAllListener implements IExecutionListener {
@Override
public void preExecute(String commandId, ExecutionEvent event) {
fDirtyNodes.clear();
+ // In Eclipse 4.x, the HandlerUtil.getActiveWorkbenchWindow(event) may return null
IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindow(event);
if (window == null) window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
IWorkbenchPage page = window.getActivePage();
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/handlers/NewNodeHandler.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/handlers/NewNodeHandler.java
index 1d0e4ffbc..245d11d3c 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/handlers/NewNodeHandler.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/handlers/NewNodeHandler.java
@@ -1,59 +1,62 @@
-/*******************************************************************************
- * Copyright (c) 2011, 2012 Wind River Systems, Inc. and others. 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:
- * Wind River Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipse.tcf.te.tcf.filesystem.ui.internal.handlers;
-
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.wizard.WizardDialog;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.IWorkbenchWizard;
-import org.eclipse.ui.handlers.HandlerUtil;
-
-/**
- * The base handler to create a new file/folder node in the file system of Target Explorer.
- */
-public abstract class NewNodeHandler extends AbstractHandler {
-
- /*
- * (non-Javadoc)
- * @see
- * org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
- */
- @Override
- public Object execute(ExecutionEvent event) throws ExecutionException {
- IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event);
- IWorkbenchWizard wizard;
- wizard = createWizard();
- ISelection selection = HandlerUtil.getCurrentSelectionChecked(event);
- if (selection instanceof IStructuredSelection) {
- wizard.init(window.getWorkbench(), (IStructuredSelection) selection);
- }
- else {
- wizard.init(window.getWorkbench(), StructuredSelection.EMPTY);
- }
- Shell parent = window.getShell();
- WizardDialog dialog = new WizardDialog(parent, wizard);
- dialog.create();
- dialog.open();
- return null;
- }
-
- /**
- * Create a "New" wizard to for creating a file/folder.
- *
- * @return the wizard to be used for creating a file/folder.
- */
- protected abstract IWorkbenchWizard createWizard();
-}
+/*******************************************************************************
+ * Copyright (c) 2011, 2012 Wind River Systems, Inc. and others. 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:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tcf.te.tcf.filesystem.ui.internal.handlers;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.IWorkbenchWizard;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.handlers.HandlerUtil;
+
+/**
+ * The base handler to create a new file/folder node in the file system of Target Explorer.
+ */
+public abstract class NewNodeHandler extends AbstractHandler {
+
+ /*
+ * (non-Javadoc)
+ * @see
+ * org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
+ */
+ @Override
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+ // In Eclipse 4.x, the HandlerUtil.getActiveWorkbenchWindow(event) may return null
+ IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindow(event);
+ if (window == null) window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+ IWorkbenchWizard wizard;
+ wizard = createWizard();
+ ISelection selection = HandlerUtil.getCurrentSelectionChecked(event);
+ if (selection instanceof IStructuredSelection) {
+ wizard.init(PlatformUI.getWorkbench(), (IStructuredSelection) selection);
+ }
+ else {
+ wizard.init(PlatformUI.getWorkbench(), StructuredSelection.EMPTY);
+ }
+ Shell parent = window != null ? window.getShell() : null;
+ WizardDialog dialog = new WizardDialog(parent, wizard);
+ dialog.create();
+ dialog.open();
+ return null;
+ }
+
+ /**
+ * Create a "New" wizard to for creating a file/folder.
+ *
+ * @return the wizard to be used for creating a file/folder.
+ */
+ protected abstract IWorkbenchWizard createWizard();
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/handler/NewWizardHandler.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/handler/NewWizardHandler.java
index 1809c140c..db4791b33 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/handler/NewWizardHandler.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/handler/NewWizardHandler.java
@@ -20,6 +20,7 @@ import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.tcf.te.ui.views.navigator.nodes.NewWizardNode;
import org.eclipse.tcf.te.ui.wizards.newWizard.NewWizardRegistry;
import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.handlers.HandlerUtil;
import org.eclipse.ui.internal.actions.NewWizardShortcutAction;
import org.eclipse.ui.wizards.IWizardDescriptor;
@@ -44,7 +45,9 @@ public class NewWizardHandler extends AbstractHandler {
Object element = iterator.next();
if (element instanceof NewWizardNode) {
IWizardDescriptor wizardDesc = NewWizardRegistry.getInstance().findWizard(((NewWizardNode)element).getWizardId());
- IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindow(event);
+ // In Eclipse 4.x, the HandlerUtil.getActiveWorkbenchWindow(event) may return null
+ IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindow(event);
+ if (window == null) window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
new NewWizardShortcutAction(window, wizardDesc).run();
}
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/handler/OpenEditorHandler.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/handler/OpenEditorHandler.java
index 6827af676..442b774e6 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/handler/OpenEditorHandler.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/handler/OpenEditorHandler.java
@@ -33,6 +33,7 @@ import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.handlers.HandlerUtil;
import org.eclipse.ui.navigator.CommonNavigator;
@@ -51,7 +52,9 @@ public class OpenEditorHandler extends AbstractHandler {
// The active part is the Target Explorer view instance
IWorkbenchPart part = HandlerUtil.getActivePart(event);
// Get the currently active workbench window
- IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindow(event);
+ // In Eclipse 4.x, the HandlerUtil.getActiveWorkbenchWindow(event) may return null
+ IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindow(event);
+ if (window == null) window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
// ALT - Key pressed?
Object ctrlPressed = HandlerUtil.getVariable(event, "ctrlPressed"); //$NON-NLS-1$
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/handler/ShowConsoleViewCommandHandler.java b/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/handler/ShowConsoleViewCommandHandler.java
index 9792a6b43..f7b8b2f69 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/handler/ShowConsoleViewCommandHandler.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/handler/ShowConsoleViewCommandHandler.java
@@ -28,8 +28,9 @@ public class ShowConsoleViewCommandHandler extends AbstractHandler {
*/
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
- IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindow(event);
- if (window == null) window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+ // In Eclipse 4.x, the HandlerUtil.getActiveWorkbenchWindow(event) may return null
+ IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindow(event);
+ if (window == null) window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
if (window != null && window.getActivePage() != null) {
IWorkbenchPage page = window.getActivePage();
try {
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/wizards/AbstractWizardCommandHandler.java b/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/wizards/AbstractWizardCommandHandler.java
index fc7d782fc..b689c0845 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/wizards/AbstractWizardCommandHandler.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/wizards/AbstractWizardCommandHandler.java
@@ -21,6 +21,7 @@ import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.IWorkbenchWizard;
+import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.handlers.HandlerUtil;
/**
@@ -98,7 +99,9 @@ public abstract class AbstractWizardCommandHandler extends AbstractHandler {
*/
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
+ // In Eclipse 4.x, the HandlerUtil.getActiveWorkbenchWindow(event) may return null
IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindow(event);
+ if (window == null) window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
if (window != null) {
// Create the wizard
IWizard wizard = createWizard();

Back to the top