From 3850b5a12de01f020a8c13fc253e8c4e6afb78cf Mon Sep 17 00:00:00 2001 From: David McKnight Date: Fri, 27 Jan 2012 20:53:00 +0000 Subject: [PATCH] [370007] potential NPEs in table-tree provider and remote resource dialog --- .../ui/view/SystemTableTreeViewProvider.java | 12 ++++++------ .../rse/ui/dialogs/SystemRemoteResourceDialog.java | 11 ++++++++--- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemTableTreeViewProvider.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemTableTreeViewProvider.java index 93fc56b0649..1993b19078c 100644 --- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemTableTreeViewProvider.java +++ b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemTableTreeViewProvider.java @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (c) 2002, 2011 IBM Corporation and others. All rights reserved. + * Copyright (c) 2002, 2012 IBM Corporation 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 @@ -13,6 +13,7 @@ * Contributors: * Martin Oberhuber (Wind River) - [186128] Move IProgressMonitor last in all API * David McKnight (IBM) - [362700] SystemTableTreeViewProvider should not use context object in adapter call to get subsystem + * David McKnight (IBM) - [370007] potential NPEs in table-tree provider and remote resource dialog ********************************************************************************/ package org.eclipse.rse.internal.ui.view; @@ -199,13 +200,12 @@ public class SystemTableTreeViewProvider implements ILabelProvider, ITableLabelP { element = ((IContextObject)object).getModelObject(); } + + ISystemViewElementAdapter adapter = getAdapterFor(element); + if (adapter != null) { - - ISystemViewElementAdapter adapter = getAdapterFor(element); adapter.setViewer(_viewer); - - - + if (adapter.hasChildren((IAdaptable)element)) { if (supportsDeferredQueries()) diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/dialogs/SystemRemoteResourceDialog.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/dialogs/SystemRemoteResourceDialog.java index 85a1137e80b..eb9b5b9597e 100644 --- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/dialogs/SystemRemoteResourceDialog.java +++ b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/dialogs/SystemRemoteResourceDialog.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2009 IBM Corporation and others. + * Copyright (c) 2006, 2012 IBM Corporation 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 @@ -18,6 +18,7 @@ * Xuan Chen (IBM) - [220999] [api] Need to change class SystemSelectRemoteFileAction to use SystemRemoteFileDialog * David McKnight (IBM) - [225506] [api][breaking] RSE UI leaks non-API types * David McKnight (IBM) - [267061] resource dialog/form to allow custom host combo label + * David McKnight (IBM) - [370007] potential NPEs in table-tree provider and remote resource dialog *******************************************************************************/ package org.eclipse.rse.ui.dialogs; @@ -64,7 +65,9 @@ public abstract class SystemRemoteResourceDialog extends SystemPromptDialog { _form = new SystemResourceSelectionForm(getShell(), parent, this, _inputProvider, getVerbiage(), _multipleSelectionMode, getMessageLine()); initForm(); - _form.setPreSelection(_preSelection); + if (_preSelection != null){ + _form.setPreSelection(_preSelection); + } createMessageLine(parent); return _form.getInitialFocusControl(); } @@ -91,7 +94,9 @@ public abstract class SystemRemoteResourceDialog extends SystemPromptDialog _form.applyViewerFilter(getViewerFilter()); } _form.setSelectionValidator(_selectionValidator); - _form.setPreSelection(_preSelection); + if (_preSelection != null){ + _form.setPreSelection(_preSelection); + } _form.setShowPropertySheet(_showPropertySheet); _form.setSelectionTreeToolTipText(getTreeTip()); if (_message != null)