diff --git a/rse/plugins/org.eclipse.rse.eclipse.filesystem/META-INF/MANIFEST.MF b/rse/plugins/org.eclipse.rse.eclipse.filesystem/META-INF/MANIFEST.MF index ddd8cafcec9..d1f944050bb 100644 --- a/rse/plugins/org.eclipse.rse.eclipse.filesystem/META-INF/MANIFEST.MF +++ b/rse/plugins/org.eclipse.rse.eclipse.filesystem/META-INF/MANIFEST.MF @@ -12,6 +12,8 @@ Require-Bundle: org.eclipse.ui, org.eclipse.rse.services, org.eclipse.rse.files.ui, org.eclipse.core.resources, - org.eclipse.rse.ui + org.eclipse.rse.ui, + org.eclipse.ui.ide, + org.eclipse.rse.core Eclipse-LazyStart: true Bundle-Vendor: Eclipse.org diff --git a/rse/plugins/org.eclipse.rse.eclipse.filesystem/plugin.xml b/rse/plugins/org.eclipse.rse.eclipse.filesystem/plugin.xml index d2ac2d6161a..1a7b85ae044 100644 --- a/rse/plugins/org.eclipse.rse.eclipse.filesystem/plugin.xml +++ b/rse/plugins/org.eclipse.rse.eclipse.filesystem/plugin.xml @@ -23,4 +23,38 @@ Contributors: - \ No newline at end of file + + + + + + + + + + + + + + + + + + + diff --git a/rse/plugins/org.eclipse.rse.eclipse.filesystem/src/org/eclipse/rse/eclipse/filesystem/Activator.java b/rse/plugins/org.eclipse.rse.eclipse.filesystem/src/org/eclipse/rse/eclipse/filesystem/Activator.java index 9ed61f85d16..6654923a107 100644 --- a/rse/plugins/org.eclipse.rse.eclipse.filesystem/src/org/eclipse/rse/eclipse/filesystem/Activator.java +++ b/rse/plugins/org.eclipse.rse.eclipse.filesystem/src/org/eclipse/rse/eclipse/filesystem/Activator.java @@ -16,7 +16,14 @@ package org.eclipse.rse.eclipse.filesystem; +import org.eclipse.core.filesystem.provider.FileSystem; +import org.eclipse.core.runtime.dynamichelpers.IExtensionTracker; import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.rse.core.RSECorePlugin; +import org.eclipse.rse.ui.RSEUIPlugin; +import org.eclipse.ui.internal.Workbench; +import org.eclipse.ui.internal.ide.filesystem.FileSystemSupportRegistry; +import org.eclipse.ui.internal.registry.UIExtensionTracker; import org.eclipse.ui.plugin.AbstractUIPlugin; import org.osgi.framework.BundleContext; @@ -40,6 +47,7 @@ public class Activator extends AbstractUIPlugin { */ public void start(BundleContext context) throws Exception { super.start(context); + RSECorePlugin.getDefault(); } /** diff --git a/rse/plugins/org.eclipse.rse.eclipse.filesystem/src/org/eclipse/rse/eclipse/filesystem/RSEFileStoreRemoteFileWrapper.java b/rse/plugins/org.eclipse.rse.eclipse.filesystem/src/org/eclipse/rse/eclipse/filesystem/RSEFileStoreRemoteFileWrapper.java index d149d07a367..88ff43e3734 100644 --- a/rse/plugins/org.eclipse.rse.eclipse.filesystem/src/org/eclipse/rse/eclipse/filesystem/RSEFileStoreRemoteFileWrapper.java +++ b/rse/plugins/org.eclipse.rse.eclipse.filesystem/src/org/eclipse/rse/eclipse/filesystem/RSEFileStoreRemoteFileWrapper.java @@ -16,18 +16,29 @@ package org.eclipse.rse.eclipse.filesystem; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; import java.io.InputStream; +import java.io.OutputStream; import java.net.URI; import java.net.URISyntaxException; +import org.eclipse.core.filesystem.EFS; import org.eclipse.core.filesystem.IFileInfo; import org.eclipse.core.filesystem.IFileStore; import org.eclipse.core.filesystem.provider.FileInfo; import org.eclipse.core.filesystem.provider.FileStore; +import org.eclipse.core.internal.filesystem.Messages; +import org.eclipse.core.internal.filesystem.Policy; import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.osgi.util.NLS; import org.eclipse.rse.core.subsystems.RemoteChildrenContentsType; +import org.eclipse.rse.files.ui.resources.SystemEditableRemoteFile; import org.eclipse.rse.files.ui.resources.UniversalFileTransferUtility; import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile; @@ -69,10 +80,15 @@ public class RSEFileStoreRemoteFileWrapper extends FileStore implements IFileSto public IFileInfo fetchInfo(int options, IProgressMonitor monitor) throws CoreException { FileInfo info = new FileInfo(getName()); - info.setExists(true); + info.setExists(_remoteFile.exists()); info.setLastModified(_remoteFile.getLastModified()); boolean isDir = _remoteFile.isDirectory(); info.setDirectory(isDir); + info.setAttribute(EFS.ATTRIBUTE_READ_ONLY, !_remoteFile.canWrite()); + info.setAttribute(EFS.ATTRIBUTE_EXECUTABLE, _remoteFile.isExecutable()); + info.setAttribute(EFS.ATTRIBUTE_ARCHIVE, _remoteFile.isArchive()); + info.setAttribute(EFS.ATTRIBUTE_HIDDEN, _remoteFile.isHidden()); + if (!isDir) { info.setLength(_remoteFile.getLength()); @@ -81,6 +97,149 @@ public class RSEFileStoreRemoteFileWrapper extends FileStore implements IFileSto info.setName(getName()); return info; } + + public String getName() + { + return _remoteFile.getName(); + } + public IFileStore getParent() + { + if (_parent == null) + { + _parent = new RSEFileStoreRemoteFileWrapper(null, _remoteFile.getParentRemoteFile()); + } + return _parent; + } + public InputStream openInputStream(int options, IProgressMonitor monitor) throws CoreException + { + if (_remoteFile.exists()) + { + IFile file = null; + if (_remoteFile.isFile() && _remoteFile.getParentRemoteFileSubSystem().isConnected()) + { + /* + SystemEditableRemoteFile editable = new SystemEditableRemoteFile(_remoteFile); + try + { + editable.download(monitor); + } + catch (Exception e) + { + + } + file = editable.getLocalResource(); + */ + if (_remoteFile.getName().equals(".project")) + { + try + { + // only temp file has contents + file = (IFile)UniversalFileTransferUtility.getTempFileFor(_remoteFile); + } + catch (Exception e) + { + } + } + if (file == null || !file.exists()) + { + file = UniversalFileTransferUtility.copyRemoteFileToWorkspace(_remoteFile, monitor); + file.getProject().refreshLocal(IResource.DEPTH_INFINITE, monitor); + } + } + else + { + file = (IFile)UniversalFileTransferUtility.getTempFileFor(_remoteFile); + } +// if (!file.isSynchronized(IFile.DEPTH_ZERO)) + // file.refreshLocal(IFile.DEPTH_ZERO, monitor); + return file.getContents(); + } + return null; + } + + + + public URI toURI() + { + try + { + return new URI("rse", _remoteFile.getParentRemoteFileSubSystem().getHost().getHostName(), _remoteFile.getAbsolutePath(), null); //$NON-NLS-1$ + } + catch (URISyntaxException e) + { + throw new RuntimeException(e); + } + } + + public IFileStore mkdir(int options, IProgressMonitor monitor) throws CoreException + { + if (!_remoteFile.exists()) + { + try + { + _remoteFile.getParentRemoteFileSubSystem().createFolder(_remoteFile); + _remoteFile = _remoteFile.getParentRemoteFileSubSystem().getRemoteFileObject(_remoteFile.getAbsolutePath()); + } + catch (Exception e) + { + } + } + return this; + } + + public OutputStream openOutputStream(int options, IProgressMonitor monitor) throws CoreException { + monitor = Policy.monitorFor(monitor); + File file = null; + try { + // create temp file first + if (!_remoteFile.exists()) + { + _remoteFile.getParentRemoteFileSubSystem().createFile(_remoteFile); + _remoteFile = _remoteFile.getParentRemoteFileSubSystem().getRemoteFileObject(_remoteFile.getAbsolutePath()); + } + SystemEditableRemoteFile editable = new SystemEditableRemoteFile(_remoteFile); + editable.download(monitor); + IFile localFile = editable.getLocalResource(); + file = localFile.getLocation().toFile(); + + monitor.beginTask(null, 1); + + return new FileOutputStream(file, (options & EFS.APPEND) != 0); + } + catch (FileNotFoundException e) + { + //checkReadOnlyParent(file, e); + String message; + String path = _remoteFile.getAbsolutePath(); + if (file.isDirectory()) + message = NLS.bind(Messages.notAFile, path); + else + message = NLS.bind(Messages.couldNotWrite, path); + Policy.error(EFS.ERROR_WRITE, message, e); + return null; + } + catch (Exception e) + { + e.printStackTrace(); + } + finally { + monitor.done(); + } + return null; + } + + public IFileStore getChild(IPath path) + { + IFileStore result = this; + for (int i = 0, imax = path.segmentCount(); i < imax; i++) + { + String segment = path.segment(i); + result = result.getChild(segment); + } + + return result; + } + public IFileStore getChild(String name) { if (!_remoteFile.isStale() && _remoteFile.hasContents(RemoteChildrenContentsType.getInstance(), name)) @@ -90,41 +249,53 @@ public class RSEFileStoreRemoteFileWrapper extends FileStore implements IFileSto { return FileStoreConversionUtility.convert(_parent, (IRemoteFile)children[0]); } - } - else - { - IRemoteFile[] children = _remoteFile.getParentRemoteFileSubSystem().listFoldersAndFiles(_remoteFile, name); - if (children != null && children.length > 0) + else { - return FileStoreConversionUtility.convert(_parent, children[0]); - } + // need empty one + try + { + IRemoteFile child = _remoteFile.getParentRemoteFileSubSystem().getRemoteFileObject(_remoteFile, name); + return FileStoreConversionUtility.convert(_parent, child); + } + catch (Exception e) + { + + } + } + } + else if (_remoteFile.isDirectory()) + { + try + { + IRemoteFile child = _remoteFile.getParentRemoteFileSubSystem().getRemoteFileObject(_remoteFile, name); + return FileStoreConversionUtility.convert(_parent, child); + } + catch (Exception e) + { + + } + } return null; } - public String getName() - { - return _remoteFile.getName(); - } - public IFileStore getParent() - { - return _parent; - } - public InputStream openInputStream(int options, IProgressMonitor monitor) throws CoreException - { - IFile file = UniversalFileTransferUtility.copyRemoteFileToWorkspace(_remoteFile, monitor); - return file.getContents(); - } - - public URI toURI() - { - try - { - return new URI("rse", _remoteFile.getAbsolutePath(), null); //$NON-NLS-1$ - } - catch (URISyntaxException e) - { - throw new RuntimeException(e); - } - } + public File toLocalFile(int options, IProgressMonitor monitor) throws CoreException + { + if (_remoteFile.exists()) + { + IResource file = null; + if (_remoteFile.isFile() && _remoteFile.getParentRemoteFileSubSystem().isConnected()) + { + file = UniversalFileTransferUtility.copyRemoteFileToWorkspace(_remoteFile, monitor); + } + else + { + file = UniversalFileTransferUtility.getTempFileFor(_remoteFile); + } + // if (!file.isSynchronized(IFile.DEPTH_ZERO)) + // file.refreshLocal(IFile.DEPTH_ZERO, monitor); + return file.getLocation().toFile(); + } + return null; + } } \ No newline at end of file diff --git a/rse/plugins/org.eclipse.rse.eclipse.filesystem/src/org/eclipse/rse/eclipse/filesystem/RSEFileSystem.java b/rse/plugins/org.eclipse.rse.eclipse.filesystem/src/org/eclipse/rse/eclipse/filesystem/RSEFileSystem.java index 3de50cd4307..d8e0e012b17 100644 --- a/rse/plugins/org.eclipse.rse.eclipse.filesystem/src/org/eclipse/rse/eclipse/filesystem/RSEFileSystem.java +++ b/rse/plugins/org.eclipse.rse.eclipse.filesystem/src/org/eclipse/rse/eclipse/filesystem/RSEFileSystem.java @@ -17,18 +17,36 @@ package org.eclipse.rse.eclipse.filesystem; import java.net.URI; +import java.util.HashMap; import org.eclipse.core.filesystem.IFileStore; import org.eclipse.core.filesystem.provider.FileSystem; +import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.rse.model.IHost; import org.eclipse.rse.model.ISystemRegistry; import org.eclipse.rse.subsystems.files.core.model.RemoteFileUtility; +import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile; import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFileSubSystem; import org.eclipse.rse.ui.RSEUIPlugin; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.ui.internal.Workbench; public class RSEFileSystem extends FileSystem { - + private static RSEFileSystem _instance = new RSEFileSystem(); + private HashMap _fileStoreMap; + + public RSEFileSystem() + { + super(); + _fileStoreMap = new HashMap(); + } + + public static RSEFileSystem getInstance() + { + return _instance; + } + public boolean canDelete() { return true; @@ -39,7 +57,7 @@ public class RSEFileSystem extends FileSystem return true; } - private IHost getConnectionFor(String hostName) + public static IHost getConnectionFor(String hostName) { ISystemRegistry sr = RSEUIPlugin.getTheSystemRegistry(); IHost[] connections = sr.getHosts(); @@ -54,8 +72,24 @@ public class RSEFileSystem extends FileSystem return null; } + public static IRemoteFileSubSystem getRemoteFileSubSystem(IHost host) + { + return RemoteFileUtility.getFileSubSystem(host); + } + + public URI getURIFor(IRemoteFile file) + { + IFileStore fstore = FileStoreConversionUtility.convert(null, file); + return fstore.toURI(); + } + public IFileStore getStore(URI uri) { + Object obj = _fileStoreMap.get(uri); + if (obj != null) + { + return (IFileStore)obj; + } try { String path = uri.getPath(); @@ -63,10 +97,38 @@ public class RSEFileSystem extends FileSystem IHost con = getConnectionFor(hostName); if (con != null) { - IRemoteFileSubSystem fs = RemoteFileUtility.getFileSubSystem(con); + IRemoteFileSubSystem fs = getRemoteFileSubSystem(con); if (fs != null) { - return FileStoreConversionUtility.convert(null, fs.getRemoteFileObject(path)); + + if (!fs.isConnected()) + { + + Shell shell = null; + try + { + shell = RSEUIPlugin.getActiveWorkbenchShell(); + } + catch (Exception e) + { + } + + if (shell == null) + { + shell = new Shell(); + } + + fs.getConnectorService().promptForPassword(shell, false); + fs.getConnectorService().connect(new NullProgressMonitor()); + //fs.connect(shell); + } + if (fs.isConnected()) + { + IFileStore fstore = FileStoreConversionUtility.convert(null, fs.getRemoteFileObject(path)); + _fileStoreMap.put(uri, fstore); + return fstore; + } + } } } diff --git a/rse/plugins/org.eclipse.rse.eclipse.filesystem/src/org/eclipse/rse/eclipse/filesystem/RSEFileSystemContributor.java b/rse/plugins/org.eclipse.rse.eclipse.filesystem/src/org/eclipse/rse/eclipse/filesystem/RSEFileSystemContributor.java new file mode 100644 index 00000000000..ab9c071935e --- /dev/null +++ b/rse/plugins/org.eclipse.rse.eclipse.filesystem/src/org/eclipse/rse/eclipse/filesystem/RSEFileSystemContributor.java @@ -0,0 +1,83 @@ +package org.eclipse.rse.eclipse.filesystem; + +import java.net.URI; + +import org.eclipse.core.filesystem.URIUtil; +import org.eclipse.rse.files.ui.dialogs.SystemRemoteFileDialog; +import org.eclipse.rse.files.ui.dialogs.SystemRemoteFolderDialog; +import org.eclipse.rse.files.ui.dialogs.SystemSelectRemoteFileOrFolderDialog; +import org.eclipse.rse.model.IHost; +import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile; +import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFileSubSystem; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.ui.ide.fileSystem.FileSystemContributor; +import org.eclipse.ui.internal.ide.dialogs.IDEResourceInfoUtils; + +public class RSEFileSystemContributor extends FileSystemContributor { + + + public URI browseFileSystem(String initialPath, Shell shell) + { + SystemRemoteFolderDialog dlg = new SystemRemoteFolderDialog(shell, "Select Folder"); + + + //SystemSelectRemoteFileOrFolderDialog dlg = new SystemSelectRemoteFileOrFolderDialog(shell, "Select File", false); + /* + DirectoryDialog dialog = new DirectoryDialog(shell); + dialog + .setMessage(IDEWorkbenchMessages.ProjectLocationSelectionDialog_directoryLabel); + */ + if (!initialPath.equals(IDEResourceInfoUtils.EMPTY_STRING)) + { + try + { + URI uri = new URI(initialPath); + IHost host = RSEFileSystem.getConnectionFor(uri.getHost()); + IRemoteFileSubSystem fs = RSEFileSystem.getRemoteFileSubSystem(host); + dlg.setInputObject(fs.getRemoteFileObject(uri.getPath())); + } + catch (Exception e) + { + + } + } + + dlg.setNeedsProgressMonitor(true); + + /* + String selectedDirectory = dialog.open(); + if (selectedDirectory == null) { + return null; + } + return new File(selectedDirectory).toURI(); + */ + if (dlg.open() == dlg.OK) + { + IRemoteFile file = (IRemoteFile)dlg.getSelectedObject(); + String path = file.getAbsolutePath(); + IHost host = dlg.getSelectedConnection(); + String hostName = host.getHostName(); + try + { + return new URI("rse", hostName, path, null); + } + catch (Exception e) + { + + } + } + return null; + + } + + public URI getURI(String string){ + try + { + return new URI(string); + } + catch (Exception e) + { + } + return null; + } +} diff --git a/rse/plugins/org.eclipse.rse.eclipse.filesystem/src/org/eclipse/rse/eclipse/filesystem/ui/actions/CreateRemoteProjectActionDelegate.java b/rse/plugins/org.eclipse.rse.eclipse.filesystem/src/org/eclipse/rse/eclipse/filesystem/ui/actions/CreateRemoteProjectActionDelegate.java new file mode 100644 index 00000000000..d7cb478df5b --- /dev/null +++ b/rse/plugins/org.eclipse.rse.eclipse.filesystem/src/org/eclipse/rse/eclipse/filesystem/ui/actions/CreateRemoteProjectActionDelegate.java @@ -0,0 +1,181 @@ +package org.eclipse.rse.eclipse.filesystem.ui.actions; + +import java.net.URI; +import java.util.Iterator; + +import org.eclipse.core.internal.resources.ProjectDescription; +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IProjectDescription; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.IWorkspaceRoot; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.NullProgressMonitor; +import org.eclipse.jface.action.IAction; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.viewers.StructuredSelection; +import org.eclipse.rse.core.SystemBasePlugin; +import org.eclipse.rse.eclipse.filesystem.RSEFileSystem; +import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.ui.IActionDelegate; +import org.eclipse.ui.IWorkbench; +import org.eclipse.ui.PlatformUI; + + + +public class CreateRemoteProjectActionDelegate implements IActionDelegate { + + protected IStructuredSelection fSelection; + + + /** + * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction) + */ + public void run(IAction action) + { + IRemoteFile directory = (IRemoteFile)fSelection.getFirstElement(); + createRemoteProject(directory, new NullProgressMonitor()); + + } + + + private IProject createRemoteProject(IRemoteFile directory, IProgressMonitor monitor) + { + + IWorkspaceRoot root = SystemBasePlugin.getWorkspaceRoot(); + + IProject editProject = root.getProject(directory.getName()); + + if ((editProject != null) && (editProject.exists()) && (editProject.isOpen())) + { + return editProject; + } + + if (editProject == null) + { + // log error and throw an exception + } + + try + { + + + + IProjectDescription description = root.getWorkspace().newProjectDescription(directory.getName()); + URI location = RSEFileSystem.getInstance().getURIFor(directory); + description.setLocationURI(location); + + editProject.create(description, monitor); + + editProject.open(monitor); + + editProject.refreshLocal(IResource.DEPTH_INFINITE, monitor); + + } + catch (CoreException e) + { + SystemBasePlugin.logError("Error creating temp project", e); + } + return editProject; + } + + /** + * Sets the selection. The selection is only set if given a structured selection, otherwise it is set to an + * empty structured selection. + * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection) + */ + public void selectionChanged(IAction action, ISelection selection) { + + if (selection instanceof IStructuredSelection) { + fSelection = (IStructuredSelection)selection; + } + else { + fSelection = StructuredSelection.EMPTY; + } + } + + /** + * Returns the remote file in the selection. + * Use this method if this action allows only a single remote file selection. + * @return the single remote file. + */ + protected IRemoteFile getRemoteFile(IStructuredSelection selection) { + return (IRemoteFile)selection.getFirstElement(); + } + + /** + * Returns the remote files in the selection. + * Use this method if this action allows multiple remote file selection. + * @return an array of remote files. + */ + protected IRemoteFile[] getRemoteFiles(IStructuredSelection selection) { + + IRemoteFile[] files = new IRemoteFile[selection.size()]; + Iterator iter = selection.iterator(); + + int i = 0; + + while (iter.hasNext()) { + files[i++] = (IRemoteFile)iter.next(); + } + + return files; + } + + /** + * Returns the description file for the first description file in + * the selection. Use this method if this action allows only + * a single file selection. + * @return the single description file. + */ + protected IFile getDescriptionFile(IStructuredSelection selection) { + return (IFile)selection.getFirstElement(); + } + + /** + * Returns a description file for each description file in + * the selection. Use this method if this action allows multiple + * selection. + * @return an array of description files. + */ + protected IFile[] getDescriptionFiles(IStructuredSelection selection) { + IFile[] files = new IFile[selection.size()]; + Iterator iter = selection.iterator(); + + int i = 0; + + while (iter.hasNext()) { + files[i++] = (IFile)iter.next(); + } + + return files; + } + + /** + * Returns the workbench. + * @return the workbench. + */ + protected IWorkbench getWorkbench() { + return PlatformUI.getWorkbench(); + } + + /** + * Returns the active shell. + * @return the active shell. + */ + protected Shell getShell() { + return Display.getDefault().getActiveShell(); + } + + /** + * Returns the selection. + * @return the selection. + */ + protected IStructuredSelection getSelection() { + return fSelection; + } +} \ No newline at end of file diff --git a/rse/plugins/org.eclipse.rse.files.ui/src/org/eclipse/rse/files/ui/resources/SystemIFileProperties.java b/rse/plugins/org.eclipse.rse.files.ui/src/org/eclipse/rse/files/ui/resources/SystemIFileProperties.java index 12fa933a61f..9e4e33ac361 100644 --- a/rse/plugins/org.eclipse.rse.files.ui/src/org/eclipse/rse/files/ui/resources/SystemIFileProperties.java +++ b/rse/plugins/org.eclipse.rse.files.ui/src/org/eclipse/rse/files/ui/resources/SystemIFileProperties.java @@ -192,6 +192,10 @@ public class SystemIFileProperties implements ISystemTextEditorConstants, ISyste catch( NumberFormatException ex ){ return 0; } + catch (Exception e) + { + return 0; + } } /** diff --git a/rse/plugins/org.eclipse.rse.files.ui/src/org/eclipse/rse/files/ui/resources/SystemRemoteEditManager.java b/rse/plugins/org.eclipse.rse.files.ui/src/org/eclipse/rse/files/ui/resources/SystemRemoteEditManager.java index c443cf6182c..47efc63dd00 100644 --- a/rse/plugins/org.eclipse.rse.files.ui/src/org/eclipse/rse/files/ui/resources/SystemRemoteEditManager.java +++ b/rse/plugins/org.eclipse.rse.files.ui/src/org/eclipse/rse/files/ui/resources/SystemRemoteEditManager.java @@ -32,10 +32,12 @@ import org.eclipse.core.runtime.IAdaptable; import org.eclipse.core.runtime.IConfigurationElement; import org.eclipse.core.runtime.IExtensionRegistry; import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.core.runtime.Platform; import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.rse.core.SystemBasePlugin; import org.eclipse.rse.core.subsystems.ISubSystem; +import org.eclipse.rse.services.clientserver.SystemEncodingUtil; import org.eclipse.rse.ui.ISystemPreferencesConstants; import org.eclipse.rse.ui.RSEUIPlugin; import org.eclipse.rse.ui.view.ISystemEditableRemoteObject; @@ -309,6 +311,8 @@ public class SystemRemoteEditManager description.setNatureIds(newNatures); editProject.setDescription(description, null); + editProject.setDefaultCharset(SystemEncodingUtil.ENCODING_UTF_8, new NullProgressMonitor()); + // add java support //addJavaSupport(editProject); diff --git a/rse/plugins/org.eclipse.rse.files.ui/src/org/eclipse/rse/files/ui/resources/UniversalFileTransferUtility.java b/rse/plugins/org.eclipse.rse.files.ui/src/org/eclipse/rse/files/ui/resources/UniversalFileTransferUtility.java index 758b534ff10..34a445140d6 100644 --- a/rse/plugins/org.eclipse.rse.files.ui/src/org/eclipse/rse/files/ui/resources/UniversalFileTransferUtility.java +++ b/rse/plugins/org.eclipse.rse.files.ui/src/org/eclipse/rse/files/ui/resources/UniversalFileTransferUtility.java @@ -136,9 +136,10 @@ public class UniversalFileTransferUtility // copy remote file to workspace srcFS.download(srcFileOrFolder, tempFile, SystemEncodingUtil.ENCODING_UTF_8, monitor); - if (!tempFile.exists()) + if (!tempFile.exists() && !tempFile.isSynchronized(IResource.DEPTH_ZERO)) { - tempFile.refreshLocal(IResource.DEPTH_ZERO, null/*monitor*/); + tempFile.getWorkspace().getRoot().refreshLocal(IResource.DEPTH_INFINITE, monitor); + //tempFile.refreshLocal(IResource.DEPTH_ZERO, null/*monitor*/); } if (tempFile.exists()) { @@ -153,7 +154,14 @@ public class UniversalFileTransferUtility { try { - tempFile.setCharset(SystemEncodingUtil.ENCODING_UTF_8, null/*monitor*/); + String cset = tempFile.getCharset(); + if (!cset.equals(SystemEncodingUtil.ENCODING_UTF_8)) + { + + //System.out.println("charset ="+cset); + //System.out.println("tempfile ="+tempFile.getFullPath()); + tempFile.setCharset(SystemEncodingUtil.ENCODING_UTF_8, monitor); + } } catch (Exception e) { diff --git a/rse/plugins/org.eclipse.rse.files.ui/src/org/eclipse/rse/files/ui/view/SystemViewRemoteFileAdapter.java b/rse/plugins/org.eclipse.rse.files.ui/src/org/eclipse/rse/files/ui/view/SystemViewRemoteFileAdapter.java index d3974d89ef2..75ff2465a34 100644 --- a/rse/plugins/org.eclipse.rse.files.ui/src/org/eclipse/rse/files/ui/view/SystemViewRemoteFileAdapter.java +++ b/rse/plugins/org.eclipse.rse.files.ui/src/org/eclipse/rse/files/ui/view/SystemViewRemoteFileAdapter.java @@ -206,10 +206,18 @@ public class SystemViewRemoteFileAdapter xlatedSize = SystemViewResources.RESID_PROPERTY_FILE_SIZE_VALUE; xlatedCompressedSize = SystemViewResources.RESID_PROPERTY_VIRTUALFILE_COMPRESSEDSIZE_VALUE; xlatedExpandedSize = SystemViewResources.RESID_PROPERTY_ARCHIVE_EXPANDEDSIZE_VALUE; - - IWorkbench workbench = RSEUIPlugin.getDefault().getWorkbench(); - if (workbench != null) - registry = workbench.getEditorRegistry(); + + } + + private IEditorRegistry getEditorRegistry() + { + if (registry == null) + { + IWorkbench workbench = RSEUIPlugin.getDefault().getWorkbench(); + if (workbench != null) + registry = workbench.getEditorRegistry(); + } + return registry; } /** * Constructor for folders or files only @@ -503,8 +511,8 @@ public class SystemViewRemoteFileAdapter { IRemoteFile file = (IRemoteFile) element; if (file.isFile() || file.isArchive()) // hack to show zips without folder icons - { - return registry.getImageDescriptor(file.getName()); + { + return getEditorRegistry().getImageDescriptor(file.getName()); } else { diff --git a/rse/plugins/org.eclipse.rse.services.dstore/miners/org/eclipse/rse/dstore/universal/miners/filesystem/FileClassifier.java b/rse/plugins/org.eclipse.rse.services.dstore/miners/org/eclipse/rse/dstore/universal/miners/filesystem/FileClassifier.java index 9d849f88f28..5d02c966252 100644 --- a/rse/plugins/org.eclipse.rse.services.dstore/miners/org/eclipse/rse/dstore/universal/miners/filesystem/FileClassifier.java +++ b/rse/plugins/org.eclipse.rse.services.dstore/miners/org/eclipse/rse/dstore/universal/miners/filesystem/FileClassifier.java @@ -574,29 +574,19 @@ public class FileClassifier extends Thread try { + byte[] readBytes = new byte[1024]; // find out how many bytes are available to be read int available = stream.available(); while (available > -1) { - // if there's none, wait a bit and return true to continue - if (available == 0) - { - sleep(100); - available = stream.available(); - if (available == 0) - return _lines; - } - - byte[] readBytes = new byte[available]; - + // read the available bytes - int numRead = stream.read(readBytes, 0, available); - + int numRead = stream.read(readBytes, 0, 1024); // if we've reached end of stream, quit if (numRead == -1) { - return null; + return _lines; } @@ -623,28 +613,28 @@ public class FileClassifier extends Thread } for (int i = 0; i< tokens.length; i++) - { - _lines.add(tokens[i]); + { + _lines.add(tokens[i]); } } } } - catch (Exception e) - { - } - available = stream.available(); + catch (Exception e) + { + e.printStackTrace(); + } + available = stream.available(); } - } catch (Exception e) { - + e.printStackTrace(); } return _lines; } - + protected String readLine(DataInputStream stream, String encoding) throws Exception { if (_lines.size() == 0) diff --git a/rse/plugins/org.eclipse.rse.services.dstore/src/org/eclipse/rse/services/dstore/files/DStoreFileService.java b/rse/plugins/org.eclipse.rse.services.dstore/src/org/eclipse/rse/services/dstore/files/DStoreFileService.java index 17ee7559d71..1682781dd39 100644 --- a/rse/plugins/org.eclipse.rse.services.dstore/src/org/eclipse/rse/services/dstore/files/DStoreFileService.java +++ b/rse/plugins/org.eclipse.rse.services.dstore/src/org/eclipse/rse/services/dstore/files/DStoreFileService.java @@ -33,6 +33,7 @@ import org.eclipse.dstore.core.model.DataElement; import org.eclipse.dstore.core.model.DataStore; import org.eclipse.dstore.core.model.DataStoreAttributes; import org.eclipse.dstore.core.model.DataStoreResources; +import org.eclipse.dstore.core.model.IDataStoreConstants; import org.eclipse.dstore.core.model.IDataStoreProvider; import org.eclipse.rse.dstore.universal.miners.IUniversalDataStoreConstants; import org.eclipse.rse.dstore.universal.miners.filesystem.UniversalByteStreamHandler; @@ -604,6 +605,12 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer String remotePath = remoteParent + getSeparator(remoteParent) + remoteFile; DataElement de = getElementFor(remotePath); + if (de.getType().equals(IUniversalDataStoreConstants.UNIVERSAL_FILTER_DESCRIPTOR)) + { + // need to refetch + DStoreHostFile hostFile = (DStoreHostFile)getFile(monitor, remoteParent, remoteFile); + de = hostFile._element; + } long fileLength = DStoreHostFile.getFileLength(de.getSource()); @@ -1127,6 +1134,11 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer String normalizedPath = PathUtility.normalizeUnknown(path); DataElement element = (DataElement)_fileElementMap.get(normalizedPath); + if (element != null && element.isDeleted()) + { + _fileElementMap.remove(normalizedPath); + element = null; + } if (element == null || element.isDeleted()) { DataElement universaltemp = getMinerElement(); diff --git a/rse/plugins/org.eclipse.rse.services.dstore/src/org/eclipse/rse/services/dstore/files/DStoreHostFile.java b/rse/plugins/org.eclipse.rse.services.dstore/src/org/eclipse/rse/services/dstore/files/DStoreHostFile.java index 9a9029cb502..8d8aec02f85 100644 --- a/rse/plugins/org.eclipse.rse.services.dstore/src/org/eclipse/rse/services/dstore/files/DStoreHostFile.java +++ b/rse/plugins/org.eclipse.rse.services.dstore/src/org/eclipse/rse/services/dstore/files/DStoreHostFile.java @@ -185,7 +185,7 @@ public class DStoreHostFile implements IHostFile String type = _element.getType(); if (type.equals(IUniversalDataStoreConstants.UNIVERSAL_FILTER_DESCRIPTOR)) { - return parentPath; + return name; } if (name.length() == 0) diff --git a/rse/plugins/org.eclipse.rse.services.dstore/src/org/eclipse/rse/services/dstore/util/DStoreStatusMonitor.java b/rse/plugins/org.eclipse.rse.services.dstore/src/org/eclipse/rse/services/dstore/util/DStoreStatusMonitor.java index fccc4148a38..7e16aed41b2 100644 --- a/rse/plugins/org.eclipse.rse.services.dstore/src/org/eclipse/rse/services/dstore/util/DStoreStatusMonitor.java +++ b/rse/plugins/org.eclipse.rse.services.dstore/src/org/eclipse/rse/services/dstore/util/DStoreStatusMonitor.java @@ -101,11 +101,13 @@ public class DStoreStatusMonitor implements IDomainListener _workingStatuses = new ArrayList(); _doneStatuses = new ArrayList(); _cancelledStatuses = new ArrayList(); + if (_dataStore != null) + { IDomainNotifier notifier = _dataStore.getDomainNotifier(); if (notifier != null) { notifier.addDomainListener(this); - } + }} } public DataStore getDataStore() diff --git a/rse/plugins/org.eclipse.rse.subsystems.files.core/src/org/eclipse/rse/subsystems/files/core/model/SystemFileTransferModeRegistry.java b/rse/plugins/org.eclipse.rse.subsystems.files.core/src/org/eclipse/rse/subsystems/files/core/model/SystemFileTransferModeRegistry.java index 0042dec4137..52050f01a7a 100644 --- a/rse/plugins/org.eclipse.rse.subsystems.files.core/src/org/eclipse/rse/subsystems/files/core/model/SystemFileTransferModeRegistry.java +++ b/rse/plugins/org.eclipse.rse.subsystems.files.core/src/org/eclipse/rse/subsystems/files/core/model/SystemFileTransferModeRegistry.java @@ -38,7 +38,10 @@ import org.eclipse.ui.IEditorRegistry; import org.eclipse.ui.IFileEditorMapping; import org.eclipse.ui.IMemento; import org.eclipse.ui.IPropertyListener; +import org.eclipse.ui.IWorkbench; import org.eclipse.ui.XMLMemento; +import org.eclipse.ui.activities.WorkbenchActivityHelper; +import org.eclipse.ui.internal.Workbench; @@ -105,10 +108,14 @@ public class SystemFileTransferModeRegistry // editor registry. We can be out of sync because we may not have // been listening for editor registry changes (e.g. if our plugin wasn't // started while those changes were made). - IEditorRegistry registry = RSEUIPlugin.getDefault().getWorkbench().getEditorRegistry(); - syncWithEditorRegistry(registry); + IWorkbench wb = Workbench.getInstance(); + if (wb != null) + { + IEditorRegistry registry = wb.getEditorRegistry(); + syncWithEditorRegistry(registry); - registry.addPropertyListener(this); + registry.addPropertyListener(this); + } } diff --git a/rse/plugins/org.eclipse.rse.subsystems.files.dstore/plugin.xml b/rse/plugins/org.eclipse.rse.subsystems.files.dstore/plugin.xml index d90ecc53ced..06c195e13d7 100644 --- a/rse/plugins/org.eclipse.rse.subsystems.files.dstore/plugin.xml +++ b/rse/plugins/org.eclipse.rse.subsystems.files.dstore/plugin.xml @@ -15,7 +15,7 @@ Contributors: {Name} (company) - description of contribution. --> - + - + \ No newline at end of file diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/RSEUIPlugin.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/RSEUIPlugin.java index 23a7a69e715..d4c70a84e69 100644 --- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/RSEUIPlugin.java +++ b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/RSEUIPlugin.java @@ -70,7 +70,7 @@ public class RSEUIPlugin extends SystemBasePlugin { public static final String PLUGIN_ID = "org.eclipse.rse.ui"; public static final String HELPPREFIX = "org.eclipse.rse.ui."; - + public static final boolean INCLUDE_LOCAL_YES = true; public static final boolean INCLUDE_LOCAL_NO = false; private static RSEUIPlugin inst = null; diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/propertypages/RemoteSystemsPreferencePage.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/propertypages/RemoteSystemsPreferencePage.java index 26fd955b0a6..a887ea956df 100644 --- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/propertypages/RemoteSystemsPreferencePage.java +++ b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/propertypages/RemoteSystemsPreferencePage.java @@ -352,9 +352,12 @@ public class RemoteSystemsPreferencePage return null; IRSESystemType sysType = RSECorePlugin.getDefault().getRegistry().getSystemType(systemType); - RSESystemTypeAdapter sysTypeAdapter = (RSESystemTypeAdapter)(sysType.getAdapter(IRSESystemType.class)); - if (sysTypeAdapter != null) + Object adapter = sysType.getAdapter(IRSESystemType.class); + if (adapter instanceof RSESystemTypeAdapter) + { + RSESystemTypeAdapter sysTypeAdapter = (RSESystemTypeAdapter)adapter; return sysTypeAdapter.getDefaultUserId(sysType); + } else return null; } diff --git a/rse/plugins/org.eclipse.rse.ui/model/org/eclipse/rse/internal/model/SystemRegistry.java b/rse/plugins/org.eclipse.rse.ui/model/org/eclipse/rse/internal/model/SystemRegistry.java index 15520bbd016..64bdd1149e0 100644 --- a/rse/plugins/org.eclipse.rse.ui/model/org/eclipse/rse/internal/model/SystemRegistry.java +++ b/rse/plugins/org.eclipse.rse.ui/model/org/eclipse/rse/internal/model/SystemRegistry.java @@ -135,7 +135,8 @@ public class SystemRegistry implements ISystemRegistry, ISystemModelChangeEvents preferenceListManager = new SystemPreferenceChangeManager(); // get initial shell - getShell(); // will quietly fail in headless mode. Phil + //FIXME - this can cause problems - don't think we should do this here anyway + //getShell(); // will quietly fail in headless mode. Phil registry = this; restore(); diff --git a/rse/plugins/org.eclipse.rse.ui/persistence/org/eclipse/rse/internal/persistence/RSEPersistenceManager.java b/rse/plugins/org.eclipse.rse.ui/persistence/org/eclipse/rse/internal/persistence/RSEPersistenceManager.java index fed52dd8521..6c909acdca6 100644 --- a/rse/plugins/org.eclipse.rse.ui/persistence/org/eclipse/rse/internal/persistence/RSEPersistenceManager.java +++ b/rse/plugins/org.eclipse.rse.ui/persistence/org/eclipse/rse/internal/persistence/RSEPersistenceManager.java @@ -356,7 +356,8 @@ public class RSEPersistenceManager implements IRSEPersistenceManager try { - project.refreshLocal(IResource.DEPTH_ONE, null); + if (!project.isSynchronized(IResource.DEPTH_ONE)) + project.refreshLocal(IResource.DEPTH_ONE, null); IResource[] folders = project.members(); for (int f = 0; f < folders.length; f++) { diff --git a/rse/plugins/org.eclipse.rse.ui/plugin.xml b/rse/plugins/org.eclipse.rse.ui/plugin.xml index 82948f5f769..7c04a02b59f 100644 --- a/rse/plugins/org.eclipse.rse.ui/plugin.xml +++ b/rse/plugins/org.eclipse.rse.ui/plugin.xml @@ -564,12 +564,14 @@ Contributors: + --> +