mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-03 15:15:25 +02:00
[310215] SystemEditableRemoteFile.open does not behave as expected
This commit is contained in:
parent
fdd5f9a1c3
commit
405af14b8c
1 changed files with 35 additions and 20 deletions
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2002, 2009 IBM Corporation and others.
|
||||
* Copyright (c) 2002, 2010 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
|
||||
|
@ -38,6 +38,7 @@
|
|||
* David McKnight (IBM) - [267247] Wrong encoding
|
||||
* David McKnight (IBM) - [272772] Exception handling in SystemEditableRemoteFile
|
||||
* David McKnight (IBM) - [284420] nullprogressmonitor is needed
|
||||
* David McKnight (IBM) - [310215] SystemEditableRemoteFile.open does not behave as expected
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.rse.files.ui.resources;
|
||||
|
@ -1152,7 +1153,8 @@ public class SystemEditableRemoteFile implements ISystemEditableRemoteObject, IP
|
|||
if (download(shell))
|
||||
{
|
||||
setLocalResourceProperties();
|
||||
openEditor();
|
||||
setFileAsReadOnly();
|
||||
openEditor(remoteFile, readOnly);
|
||||
setEditorAsReadOnly();
|
||||
}
|
||||
}
|
||||
|
@ -1162,7 +1164,7 @@ public class SystemEditableRemoteFile implements ISystemEditableRemoteObject, IP
|
|||
{
|
||||
addAsListener();
|
||||
setLocalResourceProperties();
|
||||
openEditor();
|
||||
openEditor(remoteFile, readOnly);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -1188,8 +1190,8 @@ public class SystemEditableRemoteFile implements ISystemEditableRemoteObject, IP
|
|||
if (download(shell))
|
||||
{
|
||||
setLocalResourceProperties();
|
||||
setReadOnly(getLocalResource(), true);
|
||||
openEditor();
|
||||
setFileAsReadOnly();
|
||||
openEditor(remoteFile, readOnly);
|
||||
setEditorAsReadOnly();
|
||||
}
|
||||
}
|
||||
|
@ -1197,7 +1199,7 @@ public class SystemEditableRemoteFile implements ISystemEditableRemoteObject, IP
|
|||
}
|
||||
else if (result == OPEN_IN_SAME_PERSPECTIVE)
|
||||
{
|
||||
openEditor();
|
||||
openEditor(remoteFile, readOnly);
|
||||
}
|
||||
else if (result == OPEN_IN_DIFFERENT_PERSPECTIVE)
|
||||
{
|
||||
|
@ -1213,7 +1215,8 @@ public class SystemEditableRemoteFile implements ISystemEditableRemoteObject, IP
|
|||
|
||||
if (answer)
|
||||
{
|
||||
openEditor();
|
||||
setFileAsReadOnly();
|
||||
openEditor(remoteFile, readOnly);
|
||||
setEditorAsReadOnly(); // put editor in read only mode, but not file
|
||||
}
|
||||
}
|
||||
|
@ -1282,7 +1285,8 @@ public class SystemEditableRemoteFile implements ISystemEditableRemoteObject, IP
|
|||
if (download(monitor))
|
||||
{
|
||||
setLocalResourceProperties();
|
||||
openEditor();
|
||||
setFileAsReadOnly();
|
||||
openEditor(remoteFile, readOnly);
|
||||
setEditorAsReadOnly();
|
||||
}
|
||||
}
|
||||
|
@ -1292,7 +1296,7 @@ public class SystemEditableRemoteFile implements ISystemEditableRemoteObject, IP
|
|||
{
|
||||
addAsListener();
|
||||
setLocalResourceProperties();
|
||||
openEditor();
|
||||
openEditor(remoteFile, readOnly);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -1320,8 +1324,8 @@ public class SystemEditableRemoteFile implements ISystemEditableRemoteObject, IP
|
|||
if (download(monitor))
|
||||
{
|
||||
setLocalResourceProperties();
|
||||
setReadOnly(getLocalResource(), true);
|
||||
openEditor();
|
||||
setFileAsReadOnly();
|
||||
openEditor(remoteFile, readOnly);
|
||||
setEditorAsReadOnly();
|
||||
}
|
||||
}
|
||||
|
@ -1586,14 +1590,6 @@ public class SystemEditableRemoteFile implements ISystemEditableRemoteObject, IP
|
|||
*/
|
||||
public void openEditor() throws PartInitException
|
||||
{
|
||||
IWorkbenchPage activePage = this.page;
|
||||
IWorkbench wb = PlatformUI.getWorkbench();
|
||||
if (activePage == null)
|
||||
{
|
||||
activePage = wb.getActiveWorkbenchWindow().getActivePage();
|
||||
}
|
||||
IFile file = getLocalResource();
|
||||
|
||||
// get fresh remote file object
|
||||
remoteFile.markStale(true); // make sure we get the latest remote file (with proper permissions and all)
|
||||
if (!remoteFile.getParentRemoteFileSubSystem().isOffline()){
|
||||
|
@ -1608,6 +1604,22 @@ public class SystemEditableRemoteFile implements ISystemEditableRemoteObject, IP
|
|||
}
|
||||
}
|
||||
boolean readOnly = !remoteFile.canWrite();
|
||||
openEditor(remoteFile, readOnly);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Method to open the editor given an IRemoteFile and a specified readOnly property.
|
||||
*/
|
||||
private void openEditor(IRemoteFile remoteFile, boolean readOnly) throws PartInitException
|
||||
{
|
||||
IWorkbenchPage activePage = this.page;
|
||||
IWorkbench wb = PlatformUI.getWorkbench();
|
||||
if (activePage == null)
|
||||
{
|
||||
activePage = wb.getActiveWorkbenchWindow().getActivePage();
|
||||
}
|
||||
IFile file = getLocalResource();
|
||||
ResourceAttributes attr = file.getResourceAttributes();
|
||||
if (attr!=null) {
|
||||
attr.setReadOnly(readOnly);
|
||||
|
@ -1622,7 +1634,6 @@ public class SystemEditableRemoteFile implements ISystemEditableRemoteObject, IP
|
|||
}
|
||||
|
||||
// set editor as preferred editor for this file
|
||||
|
||||
String editorId = null;
|
||||
if (_editorDescriptor != null)
|
||||
editorId = _editorDescriptor.getId();
|
||||
|
@ -1698,6 +1709,10 @@ public class SystemEditableRemoteFile implements ISystemEditableRemoteObject, IP
|
|||
{
|
||||
((ISystemTextEditor) editor).setReadOnly(true);
|
||||
}
|
||||
}
|
||||
|
||||
private void setFileAsReadOnly()
|
||||
{
|
||||
IFile file = getLocalResource();
|
||||
setReadOnly(file, true);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue