Lines 80-85
Link Here
|
80 |
* David McKnight (IBM) - [389838] Fast folder transfer does not account for code page |
80 |
* David McKnight (IBM) - [389838] Fast folder transfer does not account for code page |
81 |
* David Mcknight (IBM) - [374681] Incorrect number of children on the properties page of a directory |
81 |
* David Mcknight (IBM) - [374681] Incorrect number of children on the properties page of a directory |
82 |
* Samuel Wu (IBM) - [398988] [ftp] FTP Only support to zVM |
82 |
* Samuel Wu (IBM) - [398988] [ftp] FTP Only support to zVM |
|
|
83 |
* Xuan Chen (IBM) - [399101] RSE edit actions on local files that map to actually workspace resources should not use temp files |
83 |
*******************************************************************************/ |
84 |
*******************************************************************************/ |
84 |
|
85 |
|
85 |
package org.eclipse.rse.internal.files.ui.view; |
86 |
package org.eclipse.rse.internal.files.ui.view; |
Lines 96-107
Link Here
|
96 |
import org.eclipse.core.resources.IContainer; |
97 |
import org.eclipse.core.resources.IContainer; |
97 |
import org.eclipse.core.resources.IFile; |
98 |
import org.eclipse.core.resources.IFile; |
98 |
import org.eclipse.core.resources.IResource; |
99 |
import org.eclipse.core.resources.IResource; |
|
|
100 |
import org.eclipse.core.resources.ResourceAttributes; |
99 |
import org.eclipse.core.runtime.CoreException; |
101 |
import org.eclipse.core.runtime.CoreException; |
100 |
import org.eclipse.core.runtime.IAdaptable; |
102 |
import org.eclipse.core.runtime.IAdaptable; |
101 |
import org.eclipse.core.runtime.IPath; |
103 |
import org.eclipse.core.runtime.IPath; |
102 |
import org.eclipse.core.runtime.IProgressMonitor; |
104 |
import org.eclipse.core.runtime.IProgressMonitor; |
103 |
import org.eclipse.core.runtime.IStatus; |
105 |
import org.eclipse.core.runtime.IStatus; |
104 |
import org.eclipse.core.runtime.NullProgressMonitor; |
106 |
import org.eclipse.core.runtime.NullProgressMonitor; |
|
|
107 |
import org.eclipse.core.runtime.Path; |
105 |
import org.eclipse.core.runtime.Platform; |
108 |
import org.eclipse.core.runtime.Platform; |
106 |
import org.eclipse.core.runtime.Status; |
109 |
import org.eclipse.core.runtime.Status; |
107 |
import org.eclipse.core.runtime.SubProgressMonitor; |
110 |
import org.eclipse.core.runtime.SubProgressMonitor; |
Lines 215-222
Link Here
|
215 |
import org.eclipse.ui.IEditorRegistry; |
218 |
import org.eclipse.ui.IEditorRegistry; |
216 |
import org.eclipse.ui.ISharedImages; |
219 |
import org.eclipse.ui.ISharedImages; |
217 |
import org.eclipse.ui.IWorkbench; |
220 |
import org.eclipse.ui.IWorkbench; |
|
|
221 |
import org.eclipse.ui.IWorkbenchPage; |
222 |
import org.eclipse.ui.PartInitException; |
218 |
import org.eclipse.ui.PlatformUI; |
223 |
import org.eclipse.ui.PlatformUI; |
219 |
import org.eclipse.ui.ide.IDE; |
224 |
import org.eclipse.ui.ide.IDE; |
|
|
225 |
import org.eclipse.ui.internal.WorkbenchPage; |
220 |
import org.eclipse.ui.part.FileEditorInput; |
226 |
import org.eclipse.ui.part.FileEditorInput; |
221 |
import org.eclipse.ui.progress.IElementCollector; |
227 |
import org.eclipse.ui.progress.IElementCollector; |
222 |
import org.eclipse.ui.views.properties.IPropertyDescriptor; |
228 |
import org.eclipse.ui.views.properties.IPropertyDescriptor; |
Lines 630-636
Link Here
|
630 |
*/ |
636 |
*/ |
631 |
private IFile getLocalResource(IRemoteFile remoteFile) |
637 |
private IFile getLocalResource(IRemoteFile remoteFile) |
632 |
{ |
638 |
{ |
633 |
return (IFile)UniversalFileTransferUtility.getTempFileFor(remoteFile); |
639 |
IFile file = null; |
|
|
640 |
if (remoteFile.getHost().getSystemType().isLocal()) |
641 |
{ |
642 |
String absolutePath = remoteFile.getAbsolutePath(); |
643 |
file = getProjectFileForLocation(absolutePath); |
644 |
} |
645 |
if (file == null) { |
646 |
file = (IFile)UniversalFileTransferUtility.getTempFileFor(remoteFile); |
647 |
} |
648 |
return file; |
634 |
} |
649 |
} |
635 |
|
650 |
|
636 |
/** |
651 |
/** |
Lines 3433-3438
Link Here
|
3433 |
} |
3448 |
} |
3434 |
|
3449 |
|
3435 |
// only handle double click if object is a file |
3450 |
// only handle double click if object is a file |
|
|
3451 |
String absolutePath = remoteFile.getAbsolutePath(); |
3452 |
IFile localFile = null; |
3453 |
if (remoteFile.getHost().getSystemType().isLocal()) |
3454 |
{ |
3455 |
localFile = getProjectFileForLocation(absolutePath); |
3456 |
} |
3457 |
if (localFile != null) { |
3458 |
try { |
3459 |
if (!localFile.exists()) { |
3460 |
|
3461 |
localFile.refreshLocal(IResource.DEPTH_ZERO, null); |
3462 |
} |
3463 |
openEditor(localFile, !remoteFile.canWrite()); |
3464 |
} |
3465 |
catch (Exception e) { |
3466 |
return false; |
3467 |
} |
3468 |
return true; |
3469 |
} |
3436 |
ISystemEditableRemoteObject editable = getEditableRemoteObject(remoteFile); |
3470 |
ISystemEditableRemoteObject editable = getEditableRemoteObject(remoteFile); |
3437 |
if (editable != null) |
3471 |
if (editable != null) |
3438 |
{ |
3472 |
{ |
Lines 3470-3475
Link Here
|
3470 |
// open new editor for correct replica |
3504 |
// open new editor for correct replica |
3471 |
editable = getEditableRemoteObject(remoteFile); |
3505 |
editable = getEditableRemoteObject(remoteFile); |
3472 |
} |
3506 |
} |
|
|
3507 |
|
3473 |
|
3508 |
|
3474 |
/* Commenting out - no longer needed with fix to bug #376535 |
3509 |
/* Commenting out - no longer needed with fix to bug #376535 |
3475 |
if (editable instanceof SystemEditableRemoteFile){ |
3510 |
if (editable instanceof SystemEditableRemoteFile){ |
Lines 3540-3545
Link Here
|
3540 |
// in the system editor) |
3575 |
// in the system editor) |
3541 |
IFile file = editable.getLocalResource(); |
3576 |
IFile file = editable.getLocalResource(); |
3542 |
SystemIFileProperties properties = new SystemIFileProperties(file); |
3577 |
SystemIFileProperties properties = new SystemIFileProperties(file); |
|
|
3578 |
try { |
3579 |
// refresh workspace with just added resource |
3580 |
file.refreshLocal(IResource.DEPTH_ZERO, null); |
3581 |
} catch (CoreException e) { |
3582 |
SystemBasePlugin.logError(e.getMessage()); |
3583 |
} |
3543 |
boolean newFile = !file.exists(); |
3584 |
boolean newFile = !file.exists(); |
3544 |
|
3585 |
|
3545 |
// detect whether there exists a temp copy already |
3586 |
// detect whether there exists a temp copy already |
Lines 3611-3619
Link Here
|
3611 |
RemoteFile remoteFile = (RemoteFile) element; |
3652 |
RemoteFile remoteFile = (RemoteFile) element; |
3612 |
if (remoteFile.isFile()) |
3653 |
if (remoteFile.isFile()) |
3613 |
{ |
3654 |
{ |
|
|
3655 |
String absolutePath = remoteFile.getAbsolutePath(); |
3656 |
IFile localProjectFile = null; |
3657 |
if (remoteFile.getHost().getSystemType().isLocal()) |
3658 |
{ |
3659 |
localProjectFile = getProjectFileForLocation(absolutePath); |
3660 |
} |
3614 |
try |
3661 |
try |
3615 |
{ |
3662 |
{ |
3616 |
IFile file = getCachedCopy(remoteFile); // Note that this is a case-sensitive check |
3663 |
IFile file = null; |
|
|
3664 |
if (localProjectFile == null) { |
3665 |
file = getCachedCopy(remoteFile); // Note that this is a case-sensitive check |
3666 |
} |
3667 |
else { |
3668 |
file = localProjectFile; |
3669 |
} |
3617 |
if (file != null) |
3670 |
if (file != null) |
3618 |
{ |
3671 |
{ |
3619 |
SystemIFileProperties properties = new SystemIFileProperties(file); |
3672 |
SystemIFileProperties properties = new SystemIFileProperties(file); |
Lines 3898-3901
Link Here
|
3898 |
{ |
3951 |
{ |
3899 |
return new SystemFetchOperation(null, o, this, collector, true); |
3952 |
return new SystemFetchOperation(null, o, this, collector, true); |
3900 |
} |
3953 |
} |
|
|
3954 |
|
3955 |
private static IFile getProjectFileForLocation(String absolutePath) |
3956 |
{ |
3957 |
IPath workspacePath = new Path(absolutePath); |
3958 |
IFile file = SystemBasePlugin.getWorkspaceRoot().getFileForLocation(workspacePath); |
3959 |
return file; |
3960 |
} |
3961 |
|
3962 |
private static void openEditor(IFile localFile, boolean readOnly) throws PartInitException { |
3963 |
IEditorDescriptor editorDescriptor = null; |
3964 |
|
3965 |
try { |
3966 |
editorDescriptor = IDE.getEditorDescriptor(localFile); |
3967 |
} catch (PartInitException e) { |
3968 |
|
3969 |
} |
3970 |
|
3971 |
if (editorDescriptor == null) { |
3972 |
if (PlatformUI.isWorkbenchRunning()) |
3973 |
{ |
3974 |
IEditorRegistry registry = PlatformUI.getWorkbench().getEditorRegistry(); |
3975 |
editorDescriptor = registry.findEditor("org.eclipse.ui.DefaultTextEditor"); //$NON-NLS-1$ |
3976 |
} |
3977 |
} |
3978 |
|
3979 |
//This file is from local connection, and it is inside a project in the work |
3980 |
IWorkbenchPage activePage = SystemBasePlugin.getActiveWorkbenchWindow().getActivePage(); |
3981 |
|
3982 |
ResourceAttributes attr = localFile.getResourceAttributes(); |
3983 |
if (attr!=null) { |
3984 |
attr.setReadOnly(readOnly); |
3985 |
try |
3986 |
{ |
3987 |
localFile.setResourceAttributes(attr); |
3988 |
} |
3989 |
catch (Exception e) |
3990 |
{ |
3991 |
|
3992 |
} |
3993 |
} |
3994 |
|
3995 |
// set editor as preferred editor for this file |
3996 |
String editorId = null; |
3997 |
if (editorDescriptor != null) { |
3998 |
editorId = editorDescriptor.getId(); |
3999 |
} |
4000 |
|
4001 |
IDE.setDefaultEditor(localFile, editorId); |
4002 |
if (editorDescriptor.isOpenExternal()){ |
4003 |
openSystemEditor(localFile); // opening regular way doesn't work anymore |
4004 |
} |
4005 |
else { |
4006 |
FileEditorInput finput = new FileEditorInput(localFile); |
4007 |
IEditorPart editor = null; |
4008 |
// check for files already open |
4009 |
if (editorDescriptor != null && editorDescriptor.isOpenExternal()){ |
4010 |
editor = ((WorkbenchPage)activePage).openEditorFromDescriptor(new FileEditorInput(localFile), editorDescriptor, true, null); |
4011 |
} |
4012 |
else { |
4013 |
editor = activePage.openEditor(finput, editorDescriptor.getId()); |
4014 |
} |
4015 |
|
4016 |
return; |
4017 |
} |
4018 |
} |
4019 |
|
4020 |
private static void openSystemEditor(IFile localFile) throws PartInitException { |
4021 |
IEditorDescriptor editorDescriptor = null; |
4022 |
|
4023 |
try { |
4024 |
editorDescriptor = IDE.getEditorDescriptor(localFile); |
4025 |
} catch (PartInitException e) { |
4026 |
|
4027 |
} |
4028 |
|
4029 |
if (editorDescriptor == null) { |
4030 |
if (PlatformUI.isWorkbenchRunning()) |
4031 |
{ |
4032 |
IEditorRegistry registry = PlatformUI.getWorkbench().getEditorRegistry(); |
4033 |
editorDescriptor = registry.findEditor("org.eclipse.ui.DefaultTextEditor"); //$NON-NLS-1$ |
4034 |
} |
4035 |
} |
4036 |
|
4037 |
//This file is from local connection, and it is inside a project in the work |
4038 |
IWorkbenchPage activePage = SystemBasePlugin.getActiveWorkbenchWindow().getActivePage(); |
4039 |
|
4040 |
// set editor as preferred editor for this file |
4041 |
String editorId = null; |
4042 |
if (editorDescriptor != null) { |
4043 |
editorId = editorDescriptor.getId(); |
4044 |
} |
4045 |
|
4046 |
IDE.setDefaultEditor(localFile, editorId); |
4047 |
|
4048 |
FileEditorInput fileInput = new FileEditorInput(localFile); |
4049 |
activePage.openEditor(fileInput, IEditorRegistry.SYSTEM_EXTERNAL_EDITOR_ID); |
4050 |
|
4051 |
return; |
4052 |
|
4053 |
} |
4054 |
|
3901 |
} |
4055 |
} |