1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-02 22:55:26 +02:00

[276103] Files with names in different cases are not handled properly

This commit is contained in:
David McKnight 2009-06-03 16:39:44 +00:00
parent ef70a23d2a
commit 7cf004820c
4 changed files with 80 additions and 214 deletions

View file

@ -21,22 +21,19 @@
package org.eclipse.rse.internal.files.ui.actions;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.rse.files.ui.resources.SystemEditableRemoteFile;
import org.eclipse.rse.files.ui.resources.UniversalFileTransferUtility;
import org.eclipse.rse.internal.files.ui.resources.SystemRemoteEditManager;
import org.eclipse.rse.internal.files.ui.view.DownloadAndOpenJob;
import org.eclipse.rse.subsystems.files.core.SystemIFileProperties;
import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile;
import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFileSubSystem;
import org.eclipse.rse.subsystems.files.core.subsystems.RemoteFile;
import org.eclipse.rse.ui.actions.SystemBaseAction;
import org.eclipse.rse.ui.view.ISystemEditableRemoteObject;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IEditorDescriptor;
import org.eclipse.ui.IEditorPart;
@ -144,74 +141,13 @@ public class SystemEditFileAction extends SystemBaseAction {
return false;
}
private SystemEditableRemoteFile getEditableRemoteObject(Object element)
{
SystemEditableRemoteFile editable = null;
RemoteFile remoteFile = (RemoteFile) element;
if (remoteFile.isFile())
{
try
{
IFile file = (IFile)UniversalFileTransferUtility.getTempFileFor(remoteFile);
if (file != null)
{
SystemIFileProperties properties = new SystemIFileProperties(file);
Object obj = properties.getRemoteFileObject();
if (obj != null && obj instanceof SystemEditableRemoteFile)
{
editable = (SystemEditableRemoteFile) obj;
String remotePath = remoteFile.getAbsolutePath();
String replicaRemotePath = editable.getAbsolutePath();
// first make sure that the correct remote file is referenced (might be difference because of different case)
if (!replicaRemotePath.equals(remotePath)){ // for bug 276103
IEditorPart editor = editable.getEditorPart();
boolean editorWasClosed = false;
if (editor.isDirty()){
editorWasClosed = editor.getEditorSite().getPage().closeEditor(editor, true);
if (editorWasClosed)
editable.doImmediateSaveAndUpload();
}
else {
editorWasClosed = editor.getEditorSite().getPage().closeEditor(editor, true);
}
if (!editorWasClosed){
// use cancelled operation so we need to get out of here
return null;
}
try {
IFile originalFile = editable.getLocalResource();
originalFile.delete(true, new NullProgressMonitor());
}
catch (CoreException e){
}
// fall through and let the new editable get created
}
else {
return editable;
}
}
}
editable = new SystemEditableRemoteFile(remoteFile);
}
catch (Exception e)
{
}
}
return editable;
}
/**
* Process the object: download file, open in editor, etc.
*/
protected void process(IRemoteFile remoteFile) {
SystemEditableRemoteFile editable = getEditableRemoteObject(remoteFile);
SystemEditableRemoteFile editable = SystemRemoteEditManager.getEditableRemoteObject(remoteFile, null);
if (editable == null){
// case for cancelled operation when user was prompted to save file of different case
return;

View file

@ -24,21 +24,19 @@ package org.eclipse.rse.internal.files.ui.actions;
import java.util.Iterator;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.rse.files.ui.resources.SystemEditableRemoteFile;
import org.eclipse.rse.files.ui.resources.UniversalFileTransferUtility;
import org.eclipse.rse.internal.files.ui.resources.SystemRemoteEditManager;
import org.eclipse.rse.internal.files.ui.view.DownloadAndOpenJob;
import org.eclipse.rse.subsystems.files.core.SystemIFileProperties;
import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile;
import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFileSubSystem;
import org.eclipse.rse.subsystems.files.core.subsystems.RemoteFile;
import org.eclipse.rse.ui.actions.SystemBaseAction;
import org.eclipse.rse.ui.view.ISystemEditableRemoteObject;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IEditorDescriptor;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IEditorRegistry;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.ide.IDE;
@ -178,7 +176,7 @@ public class SystemEditFilesAction extends SystemBaseAction {
editorId = "org.eclipse.ui.DefaultTextEditor"; //$NON-NLS-1$
}
SystemEditableRemoteFile editable = getEditableRemoteObject(remoteFile, des);
SystemEditableRemoteFile editable = SystemRemoteEditManager.getEditableRemoteObject(remoteFile, des);
if (editable == null){
// case for cancelled operation when user was prompted to save file of different case
return;
@ -214,71 +212,4 @@ public class SystemEditFilesAction extends SystemBaseAction {
private SystemEditableRemoteFile getEditableRemoteObject(Object element, IEditorDescriptor descriptor)
{
SystemEditableRemoteFile editable = null;
RemoteFile remoteFile = (RemoteFile) element;
if (remoteFile.isFile())
{
try
{
IFile file = (IFile)UniversalFileTransferUtility.getTempFileFor(remoteFile);
if (file != null)
{
SystemIFileProperties properties = new SystemIFileProperties(file);
Object obj = properties.getRemoteFileObject();
if (obj != null && obj instanceof SystemEditableRemoteFile)
{
editable = (SystemEditableRemoteFile) obj;
String remotePath = remoteFile.getAbsolutePath();
String replicaRemotePath = editable.getAbsolutePath();
// first make sure that the correct remote file is referenced (might be difference because of different case)
if (!replicaRemotePath.equals(remotePath)){ // for bug 276103
IEditorPart editor = editable.getEditorPart();
boolean editorWasClosed = false;
if (editor.isDirty()){
editorWasClosed = editor.getEditorSite().getPage().closeEditor(editor, true);
if (editorWasClosed)
editable.doImmediateSaveAndUpload();
}
else {
editorWasClosed = editor.getEditorSite().getPage().closeEditor(editor, true);
}
if (!editorWasClosed){
// use cancelled operation so we need to get out of here
return null;
}
try {
IFile originalFile = editable.getLocalResource();
originalFile.delete(true, new NullProgressMonitor());
}
catch (CoreException e){
}
// fall through and let the new editable get created
}
else {
return editable;
}
}
}
if (descriptor != null){
editable = new SystemEditableRemoteFile(remoteFile, descriptor);
}
else {
editable = new SystemEditableRemoteFile(remoteFile);
}
}
catch (Exception e)
{
}
}
return editable;
}
}

View file

@ -28,7 +28,6 @@ import java.util.Comparator;
import java.util.Hashtable;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.jface.action.ContributionItem;
import org.eclipse.jface.resource.ImageDescriptor;
@ -38,11 +37,11 @@ import org.eclipse.osgi.util.NLS;
import org.eclipse.rse.files.ui.resources.SystemEditableRemoteFile;
import org.eclipse.rse.files.ui.resources.UniversalFileTransferUtility;
import org.eclipse.rse.internal.files.ui.FileResources;
import org.eclipse.rse.internal.files.ui.resources.SystemRemoteEditManager;
import org.eclipse.rse.internal.files.ui.view.DownloadAndOpenJob;
import org.eclipse.rse.subsystems.files.core.SystemIFileProperties;
import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile;
import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFileSubSystem;
import org.eclipse.rse.subsystems.files.core.subsystems.RemoteFile;
import org.eclipse.rse.ui.RSEUIPlugin;
import org.eclipse.rse.ui.SystemBasePlugin;
import org.eclipse.rse.ui.view.ISystemEditableRemoteObject;
@ -53,7 +52,6 @@ import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.MenuItem;
import org.eclipse.ui.IEditorDescriptor;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IEditorRegistry;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.PartInitException;
@ -224,82 +222,9 @@ private void createOtherMenuItem(final Menu menu, final IRemoteFile remoteFile)
}
private SystemEditableRemoteFile getEditableRemoteObject(Object element, IEditorDescriptor descriptor)
{
SystemEditableRemoteFile editable = null;
RemoteFile remoteFile = (RemoteFile) element;
if (remoteFile.isFile())
{
try
{
IFile file = (IFile)UniversalFileTransferUtility.getTempFileFor(remoteFile);
if (file != null)
{
SystemIFileProperties properties = new SystemIFileProperties(file);
Object obj = properties.getRemoteFileObject();
if (obj != null && obj instanceof SystemEditableRemoteFile)
{
editable = (SystemEditableRemoteFile) obj;
String remotePath = remoteFile.getAbsolutePath();
String replicaRemotePath = editable.getAbsolutePath();
// first make sure that the correct remote file is referenced (might be difference because of different case)
if (!replicaRemotePath.equals(remotePath)){ // for bug 276103
IEditorPart editor = editable.getEditorPart();
boolean editorWasClosed = false;
if (editor != null){
if (editor.isDirty()){
editorWasClosed = editor.getEditorSite().getPage().closeEditor(editor, true);
if (editorWasClosed)
editable.doImmediateSaveAndUpload();
}
else {
editorWasClosed = editor.getEditorSite().getPage().closeEditor(editor, true);
}
}
else {
editorWasClosed = true;
}
if (!editorWasClosed){
// use cancelled operation so we need to get out of here
return null;
}
try {
IFile originalFile = editable.getLocalResource();
originalFile.delete(true, new NullProgressMonitor());
}
catch (CoreException e){
}
// fall through and let the new editable get created
}
else {
return editable;
}
}
}
if (descriptor != null){
editable = new SystemEditableRemoteFile(remoteFile, descriptor);
}
else {
editable = new SystemEditableRemoteFile(remoteFile);
}
}
catch (Exception e)
{
e.printStackTrace();
}
}
return editable;
}
protected void openEditor(IRemoteFile remoteFile, IEditorDescriptor descriptor) {
SystemEditableRemoteFile editable = getEditableRemoteObject(remoteFile, descriptor);
SystemEditableRemoteFile editable = SystemRemoteEditManager.getEditableRemoteObject(remoteFile, descriptor);
if (editable == null){
// case for cancelled operation when user was prompted to save file of different case
return;

View file

@ -19,6 +19,7 @@
* David McKnight (IBM) - [228343] RSE unable to recover after RemoteSystemsTempfiles deletion
* David McKnight (IBM) - [253262] Cache Cleanup is removing .settings directory
* David McKnight (IBM) - [245260] Different user's connections on a single host are mapped to the same temp files cache
* David McKnight (IBM) - [276103] Files with names in different cases are not handled properly
*******************************************************************************/
package org.eclipse.rse.internal.files.ui.resources;
@ -46,14 +47,18 @@ import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.rse.core.RSECorePlugin;
import org.eclipse.rse.core.subsystems.ISubSystem;
import org.eclipse.rse.files.ui.resources.ISystemMountPathMapper;
import org.eclipse.rse.files.ui.resources.SystemEditableRemoteFile;
import org.eclipse.rse.files.ui.resources.UniversalFileTransferUtility;
import org.eclipse.rse.internal.subsystems.files.core.ISystemFilePreferencesConstants;
import org.eclipse.rse.subsystems.files.core.SystemIFileProperties;
import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFileSubSystem;
import org.eclipse.rse.subsystems.files.core.subsystems.RemoteFile;
import org.eclipse.rse.ui.RSEUIPlugin;
import org.eclipse.rse.ui.SystemBasePlugin;
import org.eclipse.rse.ui.view.ISystemEditableRemoteObject;
import org.eclipse.rse.ui.view.ISystemRemoteElementAdapter;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.IEditorDescriptor;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IEditorReference;
@ -817,4 +822,73 @@ public class SystemRemoteEditManager
SystemBasePlugin.logError("Error refreshing remote edit project", e); //$NON-NLS-1$
}
}
public static SystemEditableRemoteFile getEditableRemoteObject(Object element, IEditorDescriptor descriptor)
{
SystemEditableRemoteFile editable = null;
RemoteFile remoteFile = (RemoteFile) element;
if (remoteFile.isFile())
{
try
{
IFile file = (IFile)UniversalFileTransferUtility.getTempFileFor(remoteFile);
if (file != null)
{
SystemIFileProperties properties = new SystemIFileProperties(file);
Object obj = properties.getRemoteFileObject();
if (obj != null && obj instanceof SystemEditableRemoteFile)
{
editable = (SystemEditableRemoteFile) obj;
String remotePath = remoteFile.getAbsolutePath();
String replicaRemotePath = editable.getAbsolutePath();
// first make sure that the correct remote file is referenced (might be difference because of different case)
if (!replicaRemotePath.equals(remotePath)){ // for bug 276103
IEditorPart editor = editable.getEditorPart();
boolean editorWasClosed = false;
if (editor.isDirty()){
editorWasClosed = editor.getEditorSite().getPage().closeEditor(editor, true);
if (editorWasClosed)
editable.doImmediateSaveAndUpload();
}
else {
editorWasClosed = editor.getEditorSite().getPage().closeEditor(editor, true);
}
if (!editorWasClosed){
// use cancelled operation so we need to get out of here
return null;
}
try {
IFile originalFile = editable.getLocalResource();
originalFile.delete(true, new NullProgressMonitor());
}
catch (CoreException e){
}
// fall through and let the new editable get created
}
else {
return editable;
}
}
}
if (descriptor != null){
editable = new SystemEditableRemoteFile(remoteFile, descriptor);
}
else {
editable = new SystemEditableRemoteFile(remoteFile);
}
}
catch (Exception e)
{
}
}
return editable;
}
}