From ff7398cc42a0c68d7c4024e4098e04d369ddbfbc Mon Sep 17 00:00:00 2001 From: Martin Oberhuber < martin.oberhuber@windriver.com> Date: Thu, 9 Aug 2007 10:30:59 +0000 Subject: [PATCH] Fix NPEs with odd remote paths --- .../resources/SystemEditableRemoteFile.java | 34 +++++++++---------- 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/rse/plugins/org.eclipse.rse.files.ui/src/org/eclipse/rse/files/ui/resources/SystemEditableRemoteFile.java b/rse/plugins/org.eclipse.rse.files.ui/src/org/eclipse/rse/files/ui/resources/SystemEditableRemoteFile.java index a0fab560607..4404ef69989 100644 --- a/rse/plugins/org.eclipse.rse.files.ui/src/org/eclipse/rse/files/ui/resources/SystemEditableRemoteFile.java +++ b/rse/plugins/org.eclipse.rse.files.ui/src/org/eclipse/rse/files/ui/resources/SystemEditableRemoteFile.java @@ -19,7 +19,6 @@ * Martin Oberhuber (Wind River) - [186773] split ISystemRegistryUI from ISystemRegistry * Martin Oberhuber (Wind River) - [189130] Move SystemIFileProperties from UI to Core * David McKnight (IBM) - [187130] New Folder/File, Move and Rename should be available for read-only folders - * ********************************************************************************/ package org.eclipse.rse.files.ui.resources; @@ -412,7 +411,7 @@ public class SystemEditableRemoteFile implements ISystemEditableRemoteObject, IP /** * Check if user has write authority to the file. - * @return true if the file is readonly + * @return true if the file is read-only */ public boolean isReadOnly() { @@ -989,12 +988,8 @@ public class SystemEditableRemoteFile implements ISystemEditableRemoteObject, IP if (editorInput instanceof IFileEditorInput) { IPath path = ((IFileEditorInput) editorInput).getFile().getLocation(); - java.io.File pathFile = new java.io.File(path.toOSString()); - - if (pathFile.compareTo(lFile) == 0) - { + if (path!=null && lFile.compareTo(new java.io.File(path.toOSString()))==0) { //if (path.makeAbsolute().toOSString().equalsIgnoreCase(localPath)) - //{ return OPEN_IN_SAME_PERSPECTIVE; } } @@ -1033,7 +1028,7 @@ public class SystemEditableRemoteFile implements ISystemEditableRemoteObject, IP { IPath path = ((IFileEditorInput) editorInput).getFile().getLocation(); - if (path.makeAbsolute().toOSString().equalsIgnoreCase(localPath)) + if (path!=null && path.makeAbsolute().toOSString().equalsIgnoreCase(localPath)) { return OPEN_IN_DIFFERENT_PERSPECTIVE; } @@ -1513,18 +1508,21 @@ public class SystemEditableRemoteFile implements ISystemEditableRemoteObject, IP } catch (Exception e) { - - } + SystemMessageDialog.displayExceptionMessage(SystemMessageDialog.getDefaultShell(), e); + return; + } boolean readOnly = !remoteFile.canWrite(); ResourceAttributes attr = file.getResourceAttributes(); - attr.setReadOnly(readOnly); - try - { - file.setResourceAttributes(attr); - } - catch (Exception e) - { - + if (attr!=null) { + attr.setReadOnly(readOnly); + try + { + file.setResourceAttributes(attr); + } + catch (Exception e) + { + + } } // set editor as preferred editor for this file