diff options
Diffstat (limited to 'rse/plugins/org.eclipse.rse.efs')
16 files changed, 0 insertions, 1971 deletions
diff --git a/rse/plugins/org.eclipse.rse.efs/.classpath b/rse/plugins/org.eclipse.rse.efs/.classpath deleted file mode 100644 index b7464f3ca..000000000 --- a/rse/plugins/org.eclipse.rse.efs/.classpath +++ /dev/null @@ -1,7 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<classpath> - <classpathentry kind="src" path="src"/> - <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> - <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.4"/> - <classpathentry kind="output" path="bin"/> -</classpath> diff --git a/rse/plugins/org.eclipse.rse.efs/.cvsignore b/rse/plugins/org.eclipse.rse.efs/.cvsignore deleted file mode 100644 index ba077a403..000000000 --- a/rse/plugins/org.eclipse.rse.efs/.cvsignore +++ /dev/null @@ -1 +0,0 @@ -bin diff --git a/rse/plugins/org.eclipse.rse.efs/.project b/rse/plugins/org.eclipse.rse.efs/.project deleted file mode 100644 index f823509d0..000000000 --- a/rse/plugins/org.eclipse.rse.efs/.project +++ /dev/null @@ -1,34 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<projectDescription> - <name>org.eclipse.rse.efs</name> - <comment></comment> - <projects> - </projects> - <buildSpec> - <buildCommand> - <name>org.eclipse.jdt.core.javabuilder</name> - <arguments> - </arguments> - </buildCommand> - <buildCommand> - <name>org.eclipse.pde.ManifestBuilder</name> - <arguments> - </arguments> - </buildCommand> - <buildCommand> - <name>org.eclipse.pde.SchemaBuilder</name> - <arguments> - </arguments> - </buildCommand> - <buildCommand> - <name>org.eclipse.pde.api.tools.apiAnalysisBuilder</name> - <arguments> - </arguments> - </buildCommand> - </buildSpec> - <natures> - <nature>org.eclipse.pde.PluginNature</nature> - <nature>org.eclipse.jdt.core.javanature</nature> - <nature>org.eclipse.pde.api.tools.apiAnalysisNature</nature> - </natures> -</projectDescription> diff --git a/rse/plugins/org.eclipse.rse.efs/.settings/org.eclipse.jdt.core.prefs b/rse/plugins/org.eclipse.rse.efs/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index 381fc6eb0..000000000 --- a/rse/plugins/org.eclipse.rse.efs/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,71 +0,0 @@ -#Fri Mar 28 14:14:24 CET 2008 -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.2 -org.eclipse.jdt.core.compiler.compliance=1.4 -org.eclipse.jdt.core.compiler.doc.comment.support=enabled -org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning -org.eclipse.jdt.core.compiler.problem.assertIdentifier=error -org.eclipse.jdt.core.compiler.problem.autoboxing=warning -org.eclipse.jdt.core.compiler.problem.deprecation=warning -org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=enabled -org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=enabled -org.eclipse.jdt.core.compiler.problem.discouragedReference=warning -org.eclipse.jdt.core.compiler.problem.emptyStatement=warning -org.eclipse.jdt.core.compiler.problem.enumIdentifier=warning -org.eclipse.jdt.core.compiler.problem.fallthroughCase=warning -org.eclipse.jdt.core.compiler.problem.fieldHiding=warning -org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning -org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning -org.eclipse.jdt.core.compiler.problem.forbiddenReference=error -org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning -org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning -org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=warning -org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=warning -org.eclipse.jdt.core.compiler.problem.invalidJavadoc=warning -org.eclipse.jdt.core.compiler.problem.invalidJavadocTags=enabled -org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsDeprecatedRef=enabled -org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsNotVisibleRef=disabled -org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsVisibility=protected -org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore -org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=error -org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore -org.eclipse.jdt.core.compiler.problem.missingJavadocComments=ignore -org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsOverriding=enabled -org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsVisibility=public -org.eclipse.jdt.core.compiler.problem.missingJavadocTagDescription=all_standard_tags -org.eclipse.jdt.core.compiler.problem.missingJavadocTags=ignore -org.eclipse.jdt.core.compiler.problem.missingJavadocTagsOverriding=disabled -org.eclipse.jdt.core.compiler.problem.missingJavadocTagsVisibility=public -org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore -org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning -org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning -org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning -org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=warning -org.eclipse.jdt.core.compiler.problem.nullReference=warning -org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=error -org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore -org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=warning -org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning -org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled -org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning -org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled -org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore -org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning -org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning -org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore -org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning -org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore -org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warning -org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore -org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore -org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled -org.eclipse.jdt.core.compiler.problem.unusedImport=warning -org.eclipse.jdt.core.compiler.problem.unusedLabel=warning -org.eclipse.jdt.core.compiler.problem.unusedLocal=warning -org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore -org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled -org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled -org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning -org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning -org.eclipse.jdt.core.compiler.source=1.3 diff --git a/rse/plugins/org.eclipse.rse.efs/META-INF/MANIFEST.MF b/rse/plugins/org.eclipse.rse.efs/META-INF/MANIFEST.MF deleted file mode 100644 index afe7bc92c..000000000 --- a/rse/plugins/org.eclipse.rse.efs/META-INF/MANIFEST.MF +++ /dev/null @@ -1,22 +0,0 @@ -Manifest-Version: 1.0 -Bundle-ManifestVersion: 2 -Bundle-Name: %pluginName -Bundle-SymbolicName: org.eclipse.rse.efs;singleton:=true -Bundle-Version: 2.1.100.qualifier -Bundle-Activator: org.eclipse.rse.internal.efs.Activator -Bundle-Localization: plugin -Require-Bundle: org.eclipse.core.runtime, - org.eclipse.core.filesystem, - org.eclipse.rse.core;bundle-version="[3.0.0,4.0.0)", - org.eclipse.rse.subsystems.files.core;bundle-version="[3.0.1,4.0.0)", - org.eclipse.rse.services;bundle-version="[3.0.0,4.0.0)", - org.eclipse.rse.ui;bundle-version="[3.0.0,4.0.0)", - org.eclipse.core.resources;bundle-version="3.4.0", - org.eclipse.ui;bundle-version="3.4.0", - org.eclipse.ui.ide;bundle-version="3.4.0", - org.eclipse.ui.editors;bundle-version="3.4.0" -Bundle-ActivationPolicy: lazy -Eclipse-LazyStart: true -Bundle-Vendor: %providerName -Bundle-RequiredExecutionEnvironment: J2SE-1.4 -Export-Package: org.eclipse.rse.internal.efs;x-friends:="org.eclipse.rse.efs.ui" diff --git a/rse/plugins/org.eclipse.rse.efs/about.html b/rse/plugins/org.eclipse.rse.efs/about.html deleted file mode 100644 index d4cc693f9..000000000 --- a/rse/plugins/org.eclipse.rse.efs/about.html +++ /dev/null @@ -1,28 +0,0 @@ -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" - "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> -<html xmlns="http://www.w3.org/1999/xhtml"> -<head> -<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/> -<title>About</title> -</head> -<body lang="EN-US"> -<h2>About This Content</h2> - -<p>June 5, 2007</p> -<h3>License</h3> - -<p>The Eclipse Foundation makes available all content in this plug-in ("Content"). Unless otherwise -indicated below, the Content is provided to you under the terms and conditions of the -Eclipse Public License Version 1.0 ("EPL"). A copy of the EPL is available -at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>. -For purposes of the EPL, "Program" will mean the Content.</p> - -<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is -being redistributed by another party ("Redistributor") and different terms and conditions may -apply to your use of any object code in the Content. Check the Redistributor's license that was -provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise -indicated below, the terms and conditions of the EPL still apply to any source code in the Content -and such source code may be obtained at <a href="http://www.eclipse.org">http://www.eclipse.org</a>.</p> - -</body> -</html>
\ No newline at end of file diff --git a/rse/plugins/org.eclipse.rse.efs/build.properties b/rse/plugins/org.eclipse.rse.efs/build.properties deleted file mode 100644 index db12cec46..000000000 --- a/rse/plugins/org.eclipse.rse.efs/build.properties +++ /dev/null @@ -1,22 +0,0 @@ -############################################################################### -# Copyright (c) 2001, 2007 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 -# http://www.eclipse.org/legal/epl-v10.html -# -# Contributors: -# IBM Corporation - initial API and implementation -# Martin Oberhuber (Wind River) - [181917] EFS Improvements: Avoid unclosed Streams, -# - Fix early startup issues by deferring FileStore evaluation and classloading, -# - Improve performance by RSEFileStore instance factory and caching IRemoteFile. -# - Also remove unnecessary class RSEFileCache and obsolete branding files. -############################################################################### -bin.includes = META-INF/,\ - plugin.xml,\ - about.html,\ - plugin.properties,\ - . -source.. = src/ -output.. = bin/ -src.includes = about.html diff --git a/rse/plugins/org.eclipse.rse.efs/plugin.properties b/rse/plugins/org.eclipse.rse.efs/plugin.properties deleted file mode 100644 index 2e1cc4510..000000000 --- a/rse/plugins/org.eclipse.rse.efs/plugin.properties +++ /dev/null @@ -1,21 +0,0 @@ -################################################################################ -# Copyright (c) 2000, 2009 IBM Corporation. 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 http://www.eclipse.org/legal/epl-v10.html -# -# Initial Contributors: -# The following IBM employees contributed to the Remote System Explorer -# component that contains this file: David McKnight, Kushal Munir, -# Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson, -# Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. -# -# Contributors: -# {Name} (company) - description of contribution. -################################################################################ - -# NLS_MESSAGEFORMAT_NONE -# NLS_ENCODING=UTF-8 - -pluginName = RSE Eclipse Filesystem (EFS) Provider -providerName = Eclipse.org - DSDP diff --git a/rse/plugins/org.eclipse.rse.efs/plugin.xml b/rse/plugins/org.eclipse.rse.efs/plugin.xml deleted file mode 100644 index e9cfc23db..000000000 --- a/rse/plugins/org.eclipse.rse.efs/plugin.xml +++ /dev/null @@ -1,27 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- -Copyright (c) 2006, 2007 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 http://www.eclipse.org/legal/epl-v10.html - -Initial Contributors: -The following IBM employees contributed to the Remote System Explorer -component that contains this file: David McKnight, Kushal Munir, -Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson, -Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. - -Contributors: -Kushal Munir (IBM) - Changed paths to reflect internal packages -Martin Oberhuber (Wind River) - [188360] renamed from plugin org.eclipse.rse.eclipse.filesystem ---> -<?eclipse version="3.0"?> -<plugin> - <extension - id="org.eclipse.rse.efs.filesystem" - point="org.eclipse.core.filesystem.filesystems"> - <filesystem scheme="rse"> - <run class="org.eclipse.rse.internal.efs.RSEFileSystem"/> - </filesystem> - </extension> -</plugin>
\ No newline at end of file diff --git a/rse/plugins/org.eclipse.rse.efs/src/org/eclipse/rse/internal/efs/Activator.java b/rse/plugins/org.eclipse.rse.efs/src/org/eclipse/rse/internal/efs/Activator.java deleted file mode 100644 index aa1bd9228..000000000 --- a/rse/plugins/org.eclipse.rse.efs/src/org/eclipse/rse/internal/efs/Activator.java +++ /dev/null @@ -1,102 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2006, 2009 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 http://www.eclipse.org/legal/epl-v10.html - * - * Initial Contributors: - * The following IBM employees contributed to the Remote System Explorer - * component that contains this file: David McKnight, Kushal Munir, - * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson, - * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. - * - * Contributors: - * Kushal Munir (IBM) - moved to internal package - * Martin Oberhuber (Wind River) - [181917] EFS Improvements: Avoid unclosed Streams, - * - Fix early startup issues by deferring FileStore evaluation and classloading, - * - Improve performance by RSEFileStore instance factory and caching IRemoteFile. - * - Also remove unnecessary class RSEFileCache and obsolete branding files. - * Martin Oberhuber (Wind River) - [188360] renamed from plugin org.eclipse.rse.eclipse.filesystem - * David McKnight (IBM) - [241316] [efs] Cannot restore editors for RSE/EFS-backed resources - ********************************************************************************/ - -package org.eclipse.rse.internal.efs; - -import org.eclipse.core.resources.IResourceChangeEvent; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Plugin; -import org.eclipse.core.runtime.Status; -import org.eclipse.core.runtime.jobs.Job; -import org.eclipse.ui.IWorkbench; -import org.eclipse.ui.PlatformUI; -import org.osgi.framework.BundleContext; - -/** - * The main plugin class to be used in the desktop. - */ -public class Activator extends Plugin { - - //The shared instance. - private static Activator plugin; - - public static final String PLUGIN_ID = "org.eclipse.rse.efs"; //$NON-NLS-1$ - - - /** - * The constructor. - */ - public Activator() { - plugin = this; - } - - - public void start(BundleContext context) throws Exception { - super.start(context); - final RemoteEditorManager mgr = RemoteEditorManager.getDefault(); - ResourcesPlugin.getWorkspace().addSaveParticipant(this, mgr); - ResourcesPlugin.getWorkspace().addResourceChangeListener(mgr, IResourceChangeEvent.POST_CHANGE); - - Job job = new Job("Add Listener"){ //$NON-NLS-1$ - protected IStatus run(IProgressMonitor monitor) { - - while (!PlatformUI.isWorkbenchRunning()){ - try { - //Checks in the loop are fast enough so we can poll often - Thread.sleep(100); - } - catch (InterruptedException e){} - } - IWorkbench wb = PlatformUI.getWorkbench(); - wb.addWorkbenchListener(mgr); - return Status.OK_STATUS; - } - }; - job.schedule(); - - } - - public void stop(BundleContext context) throws Exception { - try { - ResourcesPlugin.getWorkspace().removeSaveParticipant(this); - ResourcesPlugin.getWorkspace().removeResourceChangeListener(RemoteEditorManager.getDefault()); - } finally { - super.stop(context); - } - plugin = null; - } - /** - * Returns the shared instance. - * - * @return the shared instance. - */ - public static Activator getDefault() { - return plugin; - } - - public static IStatus errorStatus(Throwable e) { - return new Status(IStatus.ERROR, PLUGIN_ID, e.getMessage(), e); - } - -}
\ No newline at end of file diff --git a/rse/plugins/org.eclipse.rse.efs/src/org/eclipse/rse/internal/efs/Messages.java b/rse/plugins/org.eclipse.rse.efs/src/org/eclipse/rse/internal/efs/Messages.java deleted file mode 100644 index f006fd895..000000000 --- a/rse/plugins/org.eclipse.rse.efs/src/org/eclipse/rse/internal/efs/Messages.java +++ /dev/null @@ -1,37 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2008 IBM Corporation. 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 http://www.eclipse.org/legal/epl-v10.html - * - * Initial Contributors: - * The following IBM employees contributed to the Remote System Explorer - * component that contains this file: Kevin Doyle. - * - * Contributors: - * {Name} (company) - description of contribution. - ********************************************************************************/ - -package org.eclipse.rse.internal.efs; - -import org.eclipse.osgi.util.NLS; - -public class Messages { - private static final String BUNDLE_NAME = "org.eclipse.rse.internal.efs.messages"; //$NON-NLS-1$ - - public static String RESOURCES_NOT_LOADED; - public static String CONNECTION_NOT_FOUND; - public static String NO_FILE_SUBSYSTEM; - public static String COULD_NOT_CONNECT; - public static String COULD_NOT_GET_REMOTE_FILE; - public static String FILE_STORE_DOES_NOT_EXIST; - public static String UNKNOWN_EXCEPTION; - public static String FILE_NAME_EXISTS; - public static String CANNOT_OPEN_STREAM_ON_FOLDER; - public static String DELETE_FAILED; - - static { - // initialize resource bundles - NLS.initializeMessages(BUNDLE_NAME, Messages.class); - } -} diff --git a/rse/plugins/org.eclipse.rse.efs/src/org/eclipse/rse/internal/efs/RSEFileStore.java b/rse/plugins/org.eclipse.rse.efs/src/org/eclipse/rse/internal/efs/RSEFileStore.java deleted file mode 100644 index 0d0269979..000000000 --- a/rse/plugins/org.eclipse.rse.efs/src/org/eclipse/rse/internal/efs/RSEFileStore.java +++ /dev/null @@ -1,357 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2006, 2009 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 http://www.eclipse.org/legal/epl-v10.html - * - * Initial Contributors: - * The following IBM employees contributed to the Remote System Explorer - * component that contains this file: David McKnight, Kushal Munir, - * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson, - * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. - * - * Contributors: - * Kushal Munir (IBM) - moved to internal package - * Martin Oberhuber (Wind River) - [181917] EFS Improvements: Avoid unclosed Streams, - * - Fix early startup issues by deferring FileStore evaluation and classloading, - * - Improve performance by RSEFileStore instance factory and caching IRemoteFile. - * - Also remove unnecessary class RSEFileCache and obsolete branding files. - * Martin Oberhuber (Wind River) - [188360] renamed from plugin org.eclipse.rse.eclipse.filesystem - * Martin Oberhuber (Wind River) - [189441] fix EFS operations on Windows (Local) systems - * Martin Oberhuber (Wind River) - [191589] fix Rename by adding putInfo() for RSE EFS, and fetch symlink info - * Kevin Doyle (IBM) - [210673] [efs][nls] Externalize Strings in RSEFileStore and RSEFileStoreImpl - * Timur Shipilov (Xored) - [224538] RSEFileStore.getParent() returns null for element which is not root of filesystem - * David McKnight (IBM) - [287185] EFS provider should interpret the URL host component as RSE connection name rather than a hostname - * David McKnight (IBM) - [291738] [efs] repeated queries to RSEFileStoreImpl.fetchInfo() in short time-span should be reduced - ********************************************************************************/ - -package org.eclipse.rse.internal.efs; - -import java.io.InputStream; -import java.io.OutputStream; -import java.net.URI; -import java.util.HashMap; - -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.runtime.CoreException; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Path; -import org.eclipse.core.runtime.Status; -import org.osgi.framework.Bundle; -import org.osgi.framework.BundleContext; - -/** - * Implementation of IFileStore for RSE. - * - * An RSEFileStore is an immutable object. Once created, it always - * references the same remote item. Therefore, instances can be - * shared. - * - * @since RSE 2.0 - */ -public class RSEFileStore extends FileStore -{ - private RSEFileStore _parent; - private String _host; - private String _name; - private String _alias; - private IPath _absolutePath; - - //cached IRemoteFile object: an Object to avoid early class loading - private transient RSEFileStoreImpl _impl = null; - private static HashMap instanceMap = new HashMap(); - - /** - * Constructor to use if the parent file store is known. - * @param parent the parent file store. - * @param name the name of the file store. - */ - private RSEFileStore(RSEFileStore parent, String name) { - _parent = parent; - _host = parent.getHost(); - _name = name; - _absolutePath = parent._absolutePath.append(name); - } - - /** - * Constructor to use if the file store is a handle. - * @param host the connection name for the file store. - * @param absolutePath an absolute path to the file, valid on the remote file system. - */ - private RSEFileStore(String host, String absolutePath) { - _parent = null; - _host = host; - _absolutePath = new Path(absolutePath); - _name = _absolutePath.lastSegment(); - if (_name == null) { - //Windows Root Drive has no segments but needs a name - _name = _absolutePath.getDevice(); - if (_name == null) { - _name = ""; //$NON-NLS-1$ - } - } - } - - /** - * Constructor to use if the file store is a handle. - * @param host the connection name for the file store. - * @param absolutePath an absolute path to the file, valid on the remote file system. - * @param aliasName the connection alias for the file store - */ - private RSEFileStore(String host, String absolutePath, String aliasName) { - _parent = null; - _host = host; - _absolutePath = new Path(absolutePath); - _alias = aliasName; - _name = _absolutePath.lastSegment(); - if (_name == null) { - //Windows Root Drive has no segments but needs a name - _name = _absolutePath.getDevice(); - if (_name == null) { - _name = ""; //$NON-NLS-1$ - } - } - } - - /** - * Public factory method for obtaining RSEFileStore instances. - * @param uri URI to get a fileStore for - * @return an RSEFileStore instance for the URI. - */ - public static RSEFileStore getInstance(URI uri) { - synchronized(instanceMap) { - RSEFileStore store = (RSEFileStore)instanceMap.get(uri); - if (store==null) { - String path = uri.getPath(); - String hostName = uri.getHost(); - String aliasName = uri.getQuery(); - store = new RSEFileStore(hostName, path, aliasName); - instanceMap.put(uri, store); - } - return store; - } - } - - /* - * (non-Javadoc) - * @see org.eclipse.core.filesystem.provider.FileStore#getChild(java.lang.String) - */ - public IFileStore getChild(String name) { - RSEFileStore tmpChild = new RSEFileStore(this, name); - URI uri = tmpChild.toURI(); - synchronized(instanceMap) { - RSEFileStore storedChild = (RSEFileStore)instanceMap.get(uri); - if (storedChild==null) { - instanceMap.put(uri, tmpChild); - } else { - tmpChild = storedChild; - } - } - return tmpChild; - } - - /** - * Returns the host name or address for this file store. - * @return the host name or address for this file store. - */ - /*package*/ String getHost() { - //TODO consider computing this instead of storing it - return _host; - } - - String getAlias() { - return _alias; - } - - /** - * Returns an absolute path for this file store. - * - * The absolute path is in normalized form, as it can use in URIs - * (with separator '/'). - * - * @return an absolute path for this file store in normalized form. - */ - /*package*/ String getAbsolutePath() { - //TODO consider computing this instead of storing it - return _absolutePath.toString(); - } - - /* - * (non-Javadoc) - * @see org.eclipse.core.filesystem.provider.FileStore#getName() - */ - public String getName() { - return _name; - } - - /* - * (non-Javadoc) - * @see org.eclipse.core.filesystem.provider.FileStore#getParent() - */ - public IFileStore getParent() { - if (_parent == null && _absolutePath.segmentCount() > 0) { - String parentPath = _absolutePath.removeLastSegments(1).toString(); - URI parentUri = RSEFileSystem.getURIFor(_host, parentPath); - _parent = RSEFileStore.getInstance(parentUri); - } - return _parent; - } - - /** - * Returns the parent file store as an RSEFileStore. - * @return the parent file store as an RSEFileStore. - */ - /*package*/ RSEFileStore getParentStore() { - return _parent; - } - - /** - * Get FileStore implementation. - * <p> - * Moved implementation to separate class in order to defer class loading - * until resources plugin is up. - * </p> - * @return the RSEFileStoreImpl implementation. - */ - /*package*/ RSEFileStoreImpl getImpl() throws CoreException { - //FIXME Workaround for Platform bug 181998 - activation problems on early startup: - //Resources plugin opens the workspace in its start() method, triggers the - //save manager and this in turn would activate org.eclipse.rse.ui which depends - //on resources... this activation circle does not work, therefore throw an - //exception if resources are not yet up. - if (_impl==null) { - if (!isResourcesPluginUp()) { - throw new CoreException(new Status(IStatus.WARNING, - Activator.getDefault().getBundle().getSymbolicName(), - Messages.RESOURCES_NOT_LOADED)); - } - _impl = new RSEFileStoreImpl(this); - } - return _impl; - } - - private static Bundle resourcesBundle = null; - private static boolean isResourcesPluginUp() - { - if (resourcesBundle==null) { - BundleContext ctx = Activator.getDefault().getBundle().getBundleContext(); - Bundle[] bundles = ctx.getBundles(); - for (int i=0; i<bundles.length; i++) { - if ("org.eclipse.core.resources".equals(bundles[i].getSymbolicName())) { //$NON-NLS-1$ - if (resourcesBundle==null && bundles[i].getState()==Bundle.ACTIVE) { - resourcesBundle = bundles[i]; - } - } - } - } - return resourcesBundle != null && resourcesBundle.getState()==Bundle.ACTIVE; - } - - /* - * (non-Javadoc) - * @see org.eclipse.core.filesystem.provider.FileStore#childNames(int, org.eclipse.core.runtime.IProgressMonitor) - */ - public String[] childNames(int options, IProgressMonitor monitor) throws CoreException { - return getImpl().childNames(options, monitor); - } - - /* - * (non-Javadoc) - * @see org.eclipse.core.filesystem.provider.FileStore#childInfos(int, org.eclipse.core.runtime.IProgressMonitor) - */ - public IFileInfo[] childInfos(int options, IProgressMonitor monitor) throws CoreException { - return getImpl().childInfos(options, monitor); - } - - /** - * Fetch information for this file store. - * <p> - * FIXME This is a HACK to fix early startup problems until - * Platform bug 182006 is resolved! Returns an info - * object indicating a non-existing file while the Eclipse resources - * plugin is not fully activated. This is in order to avoid problems - * of activating too much of RSE while Eclipse is not yet ready. - * </p> - * @return a file info object for this file store. - */ - public IFileInfo fetchInfo() { - try { - return fetchInfo(EFS.NONE, null); - } catch (CoreException e) { - if (!isResourcesPluginUp()) { - //FIXME HACK workaround for platform bug 182006: - //Claim that files do not exist while resources - //plugin is not yet fully up. - return new FileInfo(getName()); - } - //Whoa! Bad bad... wrapping a checked exception in an unchecked one... - throw new RuntimeException(e); - } - } - - /* - * (non-Javadoc) - * @see org.eclipse.core.filesystem.provider.FileStore#fetchInfo(int, org.eclipse.core.runtime.IProgressMonitor) - */ - public IFileInfo fetchInfo(int options, IProgressMonitor monitor) throws CoreException { - return getImpl().fetchInfo(options, monitor); - } - - /* - * (non-Javadoc) - * @see org.eclipse.core.filesystem.provider.FileStore#putInfo(org.eclipse.core.filesystem.IFileInfo, int, org.eclipse.core.runtime.IProgressMonitor) - */ - public void putInfo(IFileInfo info, int options, IProgressMonitor monitor) throws CoreException { - getImpl().putInfo(info, options, monitor); - } - - /* - * (non-Javadoc) - * @see org.eclipse.core.filesystem.provider.FileStore#openInputStream(int, org.eclipse.core.runtime.IProgressMonitor) - */ - public InputStream openInputStream(int options, IProgressMonitor monitor) throws CoreException - { - return getImpl().openInputStream(options, monitor); - } - - /* - * (non-Javadoc) - * @see org.eclipse.core.filesystem.provider.FileStore#toURI() - */ - public URI toURI() { - return RSEFileSystem.getURIFor(getHost(), getAbsolutePath()); - } - - /* - * (non-Javadoc) - * @see org.eclipse.core.filesystem.provider.FileStore#mkdir(int, org.eclipse.core.runtime.IProgressMonitor) - */ - public IFileStore mkdir(int options, IProgressMonitor monitor) throws CoreException - { - return getImpl().mkdir(options, monitor); - } - - /* - * (non-Javadoc) - * @see org.eclipse.core.filesystem.provider.FileStore#openOutputStream(int, org.eclipse.core.runtime.IProgressMonitor) - */ - public OutputStream openOutputStream(int options, IProgressMonitor monitor) throws CoreException - { - return getImpl().openOutputStream(options, monitor); - } - - /* - * (non-Javadoc) - * @see org.eclipse.core.filesystem.provider.FileStore#delete(int, org.eclipse.core.runtime.IProgressMonitor) - */ - public void delete(int options, IProgressMonitor monitor) throws CoreException - { - getImpl().delete(options, monitor); - } -}
\ No newline at end of file diff --git a/rse/plugins/org.eclipse.rse.efs/src/org/eclipse/rse/internal/efs/RSEFileStoreImpl.java b/rse/plugins/org.eclipse.rse.efs/src/org/eclipse/rse/internal/efs/RSEFileStoreImpl.java deleted file mode 100644 index 44d974810..000000000 --- a/rse/plugins/org.eclipse.rse.efs/src/org/eclipse/rse/internal/efs/RSEFileStoreImpl.java +++ /dev/null @@ -1,798 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2006, 2009 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 http://www.eclipse.org/legal/epl-v10.html - * - * Initial Contributors: - * The following IBM employees contributed to the Remote System Explorer - * component that contains this file: David McKnight, Kushal Munir, - * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson, - * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. - * - * Contributors: - * Kushal Munir (IBM) - moved to internal package - * Martin Oberhuber (Wind River) - [181917] EFS Improvements: Avoid unclosed Streams, - * - Fix early startup issues by deferring FileStore evaluation and classloading, - * - Improve performance by RSEFileStore instance factory and caching IRemoteFile. - * - Also remove unnecessary class RSEFileCache and obsolete branding files. - * Martin Oberhuber (Wind River) - [186128] Move IProgressMonitor last in all API - * Martin Oberhuber (Wind River) - [186773] split ISystemRegistryUI from ISystemRegistry - * Martin Oberhuber (Wind River) - [188360] renamed from plugin org.eclipse.rse.eclipse.filesystem - * Martin Oberhuber (Wind River) - [191581] clear local IRemoteFile handle cache when modifying remote - * Martin Oberhuber (Wind River) - [197025][197167] Improved wait for model complete - * Martin Oberhuber (Wind River) - [191589] fix Rename by adding putInfo() for RSE EFS, and fetch symlink info - * Martin Oberhuber (Wind River) - [199552] fix deadlock with dstore-backed efs access - * David McKnight (IBM) - [207178] changing list APIs for file service and subsystems - * Kevin Doyle (IBM) - [208778] [efs][api] RSEFileStore#getOutputStream() does not support EFS#APPEND - * Kevin Doyle (IBM) - [210673] [efs][nls] Externalize Strings in RSEFileStore and RSEFileStoreImpl - * Timur Shipilov (Xored) - [224540] [efs] RSEFileStore.mkdir(EFS.NONE, null) doesn't create parent folder - * David Dykstal (IBM) [230821] fix IRemoteFileSubSystem API to be consistent with IFileService - * Martin Oberhuber (Wind River) - [233993] Improve EFS error reporting - * Martin Oberhuber (Wind River) - [220300] EFS Size Property not properly updated after saving - * Martin Oberhuber (Wind River) - [234026] Clarify IFileService#createFolder() Javadocs - * David McKnight (IBM) - [287185] EFS provider should interpret the URL host component as RSE connection name rather than a hostname - * David McKnight (IBM) - [291738] [efs] repeated queries to RSEFileStoreImpl.fetchInfo() in short time-span should be reduced - ********************************************************************************/ - -package org.eclipse.rse.internal.efs; - -import java.io.InputStream; -import java.io.OutputStream; -import java.net.URI; - -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.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.NullProgressMonitor; -import org.eclipse.core.runtime.Status; -import org.eclipse.core.runtime.jobs.Job; -import org.eclipse.osgi.util.NLS; -import org.eclipse.rse.core.RSECorePlugin; -import org.eclipse.rse.core.model.IHost; -import org.eclipse.rse.core.model.ISystemRegistry; -import org.eclipse.rse.core.subsystems.RemoteChildrenContentsType; -import org.eclipse.rse.services.clientserver.messages.SystemElementNotFoundException; -import org.eclipse.rse.services.clientserver.messages.SystemMessageException; -import org.eclipse.rse.services.files.IFileService; -import org.eclipse.rse.services.files.IHostFile; -import org.eclipse.rse.subsystems.files.core.model.RemoteFileFilterString; -import org.eclipse.rse.subsystems.files.core.model.RemoteFileUtility; -import org.eclipse.rse.subsystems.files.core.servicesubsystem.FileServiceSubSystem; -import org.eclipse.rse.subsystems.files.core.servicesubsystem.IFileServiceSubSystem; -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.IRemoteFileSubSystemConfiguration; -import org.eclipse.rse.subsystems.files.core.subsystems.RemoteFileContext; -import org.eclipse.rse.ui.RSEUIPlugin; - -/** - * Implementation of IFileStore for RSE. - * - * The RSEFileStore delegates to this impl class in order to defer class - * loading until file contents are really needed. - */ -public class RSEFileStoreImpl extends FileStore -{ - private RSEFileStore _store; - - // to help with with performance issues when eclipse makes excessing fetchInfo calls - private long _lastFetch = 0; - private int _fetchWaitThreshold = 1000; - - //cached IRemoteFile object: an Object to avoid early class loading - private transient volatile IRemoteFile _remoteFile; - - //markup to know that RSE has been initialized - private static boolean _initialized; - - /** - * Constructor to use if the file store handle is known. - * @param store the file store handle for this implementation object. - */ - public RSEFileStoreImpl(RSEFileStore store) { - _store = store; - - String waitStr = System.getProperty("rse_efs_fetch_wait_threshold"); //$NON-NLS-1$ - if (waitStr != null && waitStr.length() > 0){ - try { - _fetchWaitThreshold = Integer.parseInt(waitStr); - } - catch (Exception e){ - _fetchWaitThreshold = 1000; - } - } - } - - /* - * (non-Javadoc) - * @see org.eclipse.core.filesystem.IFileStore#getChild(java.lang.String) - */ - public IFileStore getChild(String name) { - return _store.getChild(name); - } - - /* - * (non-Javadoc) - * @see org.eclipse.core.filesystem.IFileStore#getName() - */ - public String getName() { - return _store.getName(); - } - - /* - * (non-Javadoc) - * @see org.eclipse.core.filesystem.IFileStore#getParent() - */ - public IFileStore getParent() { - return _store.getParent(); - } - - /* - * (non-Javadoc) - * @see org.eclipse.core.filesystem.IFileStore#toURI() - */ - public URI toURI() { - return _store.toURI(); - } - - /** - * Wait for RSE persistence to fully initialize - */ - private static void waitForRSEInit() { - if (!_initialized) { - //Force activating RSEUIPlugin, which kicks off InitRSEJob - RSEUIPlugin.getDefault(); - Job[] jobs = Job.getJobManager().find(null); - for (int i=0; i<jobs.length; i++) { - if ("Initialize RSE".equals(jobs[i].getName())) { //$NON-NLS-1$ - try { - jobs[i].join(); - } catch(InterruptedException e) { - } - break; - } - } - _initialized = true; - } - } - - /** - * Return the best RSE connection object matching the given host name and/or connection alias. - * - * @param hostNameOrAddr the host name IP address of requested host. - * @param aliasName the connection alias of the requested host - * @return RSE connection object matching the given connection alias, host name, or - * <code>null</code> if no matching connection object was found. - */ - public static IHost getConnectionFor(String hostNameOrAddr, String aliasName, IProgressMonitor monitor) { - if (hostNameOrAddr==null) { - return null; - } - if (!_initialized) { - waitForRSEInit(); - } - ISystemRegistry sr = RSECorePlugin.getTheSystemRegistry(); - IHost[] connections = sr.getHosts(); - - IHost unconnected = null; - - // first look for connection alias - if (aliasName != null){ - for (int i = 0; i < connections.length; i++) { - IHost con = connections[i]; - - if (aliasName.equalsIgnoreCase(con.getAliasName())){ - IRemoteFileSubSystem fss = getRemoteFileSubSystem(con); - if (fss!=null && fss.isConnected()) { - return con; - } else { - unconnected = con; - } - } - } - } - - if (unconnected == null){ - // if nothing matches the connection alias, fall back to hostname - for (int i = 0; i < connections.length; i++) { - IHost con = connections[i]; - //TODO use more elaborate methods of checking whether two - //host names/IP addresses are the same; or, use the host alias - if (hostNameOrAddr.equalsIgnoreCase(con.getHostName())) { - IRemoteFileSubSystem fss = getRemoteFileSubSystem(con); - if (fss!=null && fss.isConnected()) { - return con; - } else { - unconnected = con; - } - } - } - } - - return unconnected; - } - - - /** - * Return the best available remote file subsystem for a connection. - * Criteria are: - * <ol> - * <li>A connected FileServiceSubsystem</li> - * <li>A connected IRemoteFileSubSystem</li> - * <li>An unconnected FileServiceSubsystem</li> - * <li>An unconnected IRemoteFileSubSystem</li> - * </ol> - * - * @param host the connection to check - * @return an IRemoteFileSubSystem for the given connection, or - * <code>null</code> if no IRemoteFileSubSystem is configured. - */ - public static IRemoteFileSubSystem getRemoteFileSubSystem(IHost host) { - IRemoteFileSubSystem candidate = null; - FileServiceSubSystem serviceCandidate = null; - IRemoteFileSubSystem[] subSys = RemoteFileUtility.getFileSubSystems(host); - for (int i=0; i<subSys.length; i++) { - if (subSys[i] instanceof FileServiceSubSystem) { - if (subSys[i].isConnected()) { - //best candidate: service and connected - return subSys[i]; - } else if (serviceCandidate==null) { - serviceCandidate = (FileServiceSubSystem)subSys[i]; - } - } else if(candidate==null) { - candidate=subSys[i]; - } else if(subSys[i].isConnected() && !candidate.isConnected()) { - candidate=subSys[i]; - } - } - //Now find the best candidate - if (candidate!=null && candidate.isConnected()) { - return candidate; - } else if (serviceCandidate!=null) { - return serviceCandidate; - } - return candidate; - } - - /** - * Returns the best connected file subsystem for this file store. - * Never returns <code>null</code>. - * @param hostNameOrAddr host name or IP address - * @param aliasName the connection alias - * @param monitor progress monitor - * @return The best connected file subsystem for this file store. - * @throws CoreException if no file subsystem could be found or connected. - */ - public static IRemoteFileSubSystem getConnectedFileSubSystem(String hostNameOrAddr, String aliasName, IProgressMonitor monitor) throws CoreException - { - IHost con = RSEFileStoreImpl.getConnectionFor(hostNameOrAddr, aliasName, monitor); - if (con == null) { - throw new CoreException(new Status(IStatus.ERROR, - Activator.getDefault().getBundle().getSymbolicName(), - NLS.bind(Messages.CONNECTION_NOT_FOUND, hostNameOrAddr))); - } - IRemoteFileSubSystem subSys = RSEFileStoreImpl.getRemoteFileSubSystem(con); - if (subSys == null) { - throw new CoreException(new Status(IStatus.ERROR, - Activator.getDefault().getBundle().getSymbolicName(), - NLS.bind(Messages.NO_FILE_SUBSYSTEM, hostNameOrAddr, con.getAliasName()))); - } - if (!subSys.isConnected()) { - try { - if (monitor==null) monitor=new NullProgressMonitor(); - subSys.connect(monitor, false); - } - catch (Exception e) { - throw new CoreException(new Status(IStatus.ERROR, - Activator.getDefault().getBundle().getSymbolicName(), - NLS.bind(Messages.COULD_NOT_CONNECT, hostNameOrAddr, subSys.getConfigurationId()), e)); - } - } - return subSys; - } - - /** - * Return the cached IRemoteFile handle. Used only as a handle into - * ISubSystem operations, attributes of this handle are never considered - * except for exists() checking. - * @return - */ - private IRemoteFile getCachedRemoteFile() { - return _remoteFile; - } - - private void cacheRemoteFile(IRemoteFile remoteFile) { - //if (_remoteFile != remoteFile) _remoteFile = remoteFile; - if (_remoteFile != null && _remoteFile != remoteFile) { - _remoteFile.markStale(true); - } - _remoteFile = remoteFile; - } - - /** - * Returns an IRemoteFile for this file store. - * Requires that the file subsystem is connected. - * @param monitor progress monitor - * @param forceExists if <code>true</code>, throw an exception if the remote file does not exist - * @return an IRemoteFile for this file store - * @throws CoreException if connecting is not possible. - */ - private IRemoteFile getRemoteFileObject(IProgressMonitor monitor, boolean forceExists) throws CoreException { - IRemoteFile remoteFile = getCachedRemoteFile(); - if (remoteFile!=null) { - if (remoteFile.getParentRemoteFileSubSystem().isConnected()) { - return remoteFile; - } else { - //need to re-initialize cache - remoteFile=null; - cacheRemoteFile(null); - } - } - - RSEFileStore parentStore = _store.getParentStore(); - if (parentStore!=null) { - //Handle was created naming a parent file store - IRemoteFile parent = parentStore.getImpl().getRemoteFileObject(monitor, forceExists); - if (parent==null) { - throw new CoreException(new Status(IStatus.ERROR, - Activator.getDefault().getBundle().getSymbolicName(), - Messages.COULD_NOT_GET_REMOTE_FILE)); - } - try { - remoteFile = parent.getParentRemoteFileSubSystem().getRemoteFileObject(parent, getName(), monitor); - } catch(SystemMessageException e) { - rethrowCoreException(e, EFS.ERROR_READ); - } - } else { - //Handle was created with an absolute name - String aliasName = _store.getAlias(); - String hostName = _store.getHost(); - IRemoteFileSubSystem subSys = RSEFileStoreImpl.getConnectedFileSubSystem(hostName, aliasName, monitor); - - try { - remoteFile = subSys.getRemoteFileObject(_store.getAbsolutePath(), monitor); - } - catch (SystemMessageException e) { - rethrowCoreException(e, EFS.ERROR_READ); - } - } - - cacheRemoteFile(remoteFile); - if (forceExists && (remoteFile == null || !remoteFile.exists())) { - throw new CoreException(new Status(IStatus.ERROR, - Activator.getDefault().getBundle().getSymbolicName(), - EFS.ERROR_NO_LOCATION, - Messages.FILE_STORE_DOES_NOT_EXIST, null)); - } - return remoteFile; - } - - /* - * (non-Javadoc) - * @see org.eclipse.core.filesystem.IFileStore#childNames(int, org.eclipse.core.runtime.IProgressMonitor) - */ - public String[] childNames(int options, IProgressMonitor monitor) throws CoreException { - - String[] names; - IRemoteFile remoteFile = getRemoteFileObject(monitor, true); - IRemoteFileSubSystem subSys = remoteFile.getParentRemoteFileSubSystem(); - if (!remoteFile.isStale() && remoteFile.hasContents(RemoteChildrenContentsType.getInstance()) && !(subSys instanceof IFileServiceSubSystem)) - { - Object[] children = remoteFile.getContents(RemoteChildrenContentsType.getInstance()); - names = new String[children.length]; - - for (int i = 0; i < children.length; i++) - { - names[i] = ((IRemoteFile)children[i]).getName(); - } - } - else - { - try { - IRemoteFile[] children = null; - - if (subSys instanceof FileServiceSubSystem) { - FileServiceSubSystem fileServiceSubSystem = ((FileServiceSubSystem)subSys); - IHostFile[] results = fileServiceSubSystem.getFileService().list(remoteFile.getAbsolutePath(), "*", IFileService.FILE_TYPE_FILES_AND_FOLDERS, monitor); //$NON-NLS-1$ - IRemoteFileSubSystemConfiguration config = subSys.getParentRemoteFileSubSystemConfiguration(); - RemoteFileFilterString filterString = new RemoteFileFilterString(config, remoteFile.getAbsolutePath(), "*"); //$NON-NLS-1$ - filterString.setShowFiles(true); - filterString.setShowSubDirs(true); - RemoteFileContext context = new RemoteFileContext(subSys, remoteFile, filterString); - children = fileServiceSubSystem.getHostFileToRemoteFileAdapter().convertToRemoteFiles(fileServiceSubSystem, context, remoteFile, results); - } - else { - children = subSys.list(remoteFile, monitor); - } - - names = new String[children.length]; - - for (int i = 0; i < children.length; i++) { - names[i] = (children[i]).getName(); - } - } - catch (SystemMessageException e) { - names = new String[0]; - } - } - - return names; - } - - /* - * (non-Javadoc) - * @see org.eclipse.core.filesystem.IFileStore#childInfos(int, org.eclipse.core.runtime.IProgressMonitor) - */ - public IFileInfo[] childInfos(int options, IProgressMonitor monitor) throws CoreException { - - FileInfo[] infos; - IRemoteFile remoteFile = getRemoteFileObject(monitor, true); - IRemoteFileSubSystem subSys = remoteFile.getParentRemoteFileSubSystem(); - if (!remoteFile.isStale() && remoteFile.hasContents(RemoteChildrenContentsType.getInstance()) && !(subSys instanceof IFileServiceSubSystem)) - { - Object[] children = remoteFile.getContents(RemoteChildrenContentsType.getInstance()); - - infos = new FileInfo[children.length]; - - for (int i = 0; i < children.length; i++) - { - IRemoteFile file = (IRemoteFile)(children[i]); - FileInfo info = new FileInfo(file.getName()); - - if (!file.exists()) { - info.setExists(false); - } - else { - info.setExists(true); - info.setLastModified(file.getLastModified()); - boolean isDir = file.isDirectory(); - info.setDirectory(isDir); - info.setAttribute(EFS.ATTRIBUTE_READ_ONLY, !file.canWrite()); - info.setAttribute(EFS.ATTRIBUTE_EXECUTABLE, file.isExecutable()); - info.setAttribute(EFS.ATTRIBUTE_ARCHIVE, file.isArchive()); - info.setAttribute(EFS.ATTRIBUTE_HIDDEN, file.isHidden()); - - if (!isDir) { - info.setLength(file.getLength()); - } - } - - infos[i] = info; - } - } - else - { - try { - - IRemoteFile[] children = null; - - if (subSys instanceof FileServiceSubSystem) { - FileServiceSubSystem fileServiceSubSystem = ((FileServiceSubSystem)subSys); - IHostFile[] results = fileServiceSubSystem.getFileService().list(remoteFile.getAbsolutePath(), "*", IFileService.FILE_TYPE_FILES_AND_FOLDERS, monitor); //$NON-NLS-1$ - IRemoteFileSubSystemConfiguration config = subSys.getParentRemoteFileSubSystemConfiguration(); - RemoteFileFilterString filterString = new RemoteFileFilterString(config, remoteFile.getAbsolutePath(), "*"); //$NON-NLS-1$ - filterString.setShowFiles(true); - filterString.setShowSubDirs(true); - RemoteFileContext context = new RemoteFileContext(subSys, remoteFile, filterString); - children = fileServiceSubSystem.getHostFileToRemoteFileAdapter().convertToRemoteFiles(fileServiceSubSystem, context, remoteFile, results); - } - else { - children = subSys.list(remoteFile, monitor); - } - - infos = new FileInfo[children.length]; - - for (int i = 0; i < children.length; i++) - { - IRemoteFile file = children[i]; - FileInfo info = new FileInfo(file.getName()); - - if (!file.exists()) { - info.setExists(false); - } - else { - info.setExists(true); - info.setLastModified(file.getLastModified()); - boolean isDir = file.isDirectory(); - info.setDirectory(isDir); - info.setAttribute(EFS.ATTRIBUTE_READ_ONLY, !file.canWrite()); - info.setAttribute(EFS.ATTRIBUTE_EXECUTABLE, file.isExecutable()); - info.setAttribute(EFS.ATTRIBUTE_ARCHIVE, file.isArchive()); - info.setAttribute(EFS.ATTRIBUTE_HIDDEN, file.isHidden()); - //TODO Add symbolic link attribute - - if (!isDir) { - info.setLength(file.getLength()); - } - } - - infos[i] = info; - } - } - catch (SystemMessageException e) { - //TODO check whether we should not throw an exception ourselves - infos = new FileInfo[0]; - } - } - - return infos; - } - - /* - * (non-Javadoc) - * @see org.eclipse.core.filesystem.IFileStore#fetchInfo(int, org.eclipse.core.runtime.IProgressMonitor) - */ - public IFileInfo fetchInfo(int options, IProgressMonitor monitor) throws CoreException { - long curTime = System.currentTimeMillis(); - - - // don't clear cache when there are several successive queries in a short time-span - if (_lastFetch == 0 || ((curTime - _lastFetch) > _fetchWaitThreshold)){ - // clear cache in order to query latest info - cacheRemoteFile(null); - _lastFetch = curTime; - } - - // connect if needed. Will throw exception if not successful. - IRemoteFile remoteFile = getRemoteFileObject(monitor, false); - String classification = (remoteFile==null) ? null : remoteFile.getClassification(); - - FileInfo info = new FileInfo(_store.getName()); - if (remoteFile == null || !remoteFile.exists()) { - info.setExists(false); - //broken symbolic link handling - if (classification!=null && classification.startsWith("broken symbolic link")) { //$NON-NLS-1$ - info.setAttribute(EFS.ATTRIBUTE_SYMLINK, true); - int i1 = classification.indexOf('\''); - if (i1>0) { - int i2 = classification.indexOf('´'); - if (i2>i1) { - info.setStringAttribute(EFS.ATTRIBUTE_LINK_TARGET, classification.substring(i1+1,i2)); - } - } - } - return info; - } - - info.setExists(true); - 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 (classification!=null && classification.startsWith("symbolic link")) { //$NON-NLS-1$ - info.setAttribute(EFS.ATTRIBUTE_SYMLINK, true); - int idx = classification.indexOf(':'); - if (idx>0) { - info.setStringAttribute(EFS.ATTRIBUTE_LINK_TARGET, classification.substring(idx+1)); - } - } - - if (!isDir) { - info.setLength(remoteFile.getLength()); - } - - return info; - } - - /** - * Return a message for logging, built from - * @param item item where failure occurred - * @param e exception - * @return - */ - private String getExceptionMessage(String item, Throwable e) { - String exceptionText; - if (e!=null) { - if (e.getLocalizedMessage()!=null) { - exceptionText = e.getLocalizedMessage(); - } else { - exceptionText = e.getClass().getName(); - } - } else { - exceptionText = Messages.UNKNOWN_EXCEPTION; - } - if (item!=null && item.length()>0) { - return exceptionText + ": " + item; //$NON-NLS-1$ - } - return exceptionText; - } - - /** - * Re-interpret RSE internal exceptions into proper EFS CoreException. - * - * @param e Original exception from RSE SubSystems - * @param codeHint hint as to what the EFS Error Code might be - * @throws CoreException create CoreException according to EFS specification - */ - private void rethrowCoreException(Exception e, int codeHint) throws CoreException { - //default pluginId to the EFS provider; override by root if possible - String pluginId = Activator.getDefault().getBundle().getSymbolicName(); - String msg = getExceptionMessage(toString(), e); - int code = codeHint; - if (e instanceof SystemElementNotFoundException) { - code = EFS.ERROR_NOT_EXISTS; - } - throw new CoreException(new Status(IStatus.ERROR, pluginId, code, msg, e)); - } - - /* - * (non-Javadoc) - * @see org.eclipse.core.filesystem.provider.FileStore#putInfo(org.eclipse.core.filesystem.IFileInfo, int, org.eclipse.core.runtime.IProgressMonitor) - */ - public void putInfo(IFileInfo info, int options, IProgressMonitor monitor) throws CoreException { - // connect if needed. Will throw exception if not successful. - IRemoteFile remoteFile = getRemoteFileObject(monitor, false); - IRemoteFileSubSystem subSys = remoteFile.getParentRemoteFileSubSystem(); - try { - if ((options & EFS.SET_ATTRIBUTES) != 0) { - // We cannot currently write isExecutable(), isHidden() - subSys.setReadOnly(remoteFile, info.getAttribute(EFS.ATTRIBUTE_READ_ONLY), monitor); - } - if ((options & EFS.SET_LAST_MODIFIED) != 0) { - subSys.setLastModified(remoteFile, info.getLastModified(), monitor); - } - } catch (Exception e) { - rethrowCoreException(e, EFS.ERROR_WRITE); - } - } - - /* - * (non-Javadoc) - * @see org.eclipse.core.filesystem.IFileStore#openInputStream(int, org.eclipse.core.runtime.IProgressMonitor) - */ - public InputStream openInputStream(int options, IProgressMonitor monitor) throws CoreException - { - IRemoteFile remoteFile = getRemoteFileObject(monitor, true); - IRemoteFileSubSystem subSys = remoteFile.getParentRemoteFileSubSystem(); - - if (remoteFile.isDirectory()) { - throw new CoreException(new Status(IStatus.ERROR, - Activator.getDefault().getBundle().getSymbolicName(), - EFS.ERROR_WRONG_TYPE, - Messages.CANNOT_OPEN_STREAM_ON_FOLDER, null)); - } - - if (remoteFile.isFile()) { - try { - cacheRemoteFile(null); - return subSys.getInputStream(remoteFile.getParentPath(), remoteFile.getName(), true, monitor); - } - catch (SystemMessageException e) { - cacheRemoteFile(null); - rethrowCoreException(e, EFS.ERROR_READ); - } - } - - //file does not exist, apparently - //TODO use Java MessageFormat for embedding filename in message - throw new CoreException(new Status(IStatus.ERROR, Activator.getDefault().getBundle().getSymbolicName(), - // EFS.ERROR_NOT_EXISTS, - EFS.ERROR_READ, Messages.FILE_STORE_DOES_NOT_EXIST + ": " + toString(), null)); //$NON-NLS-1$ - } - - /* - * (non-Javadoc) - * @see org.eclipse.core.filesystem.IFileStore#mkdir(int, org.eclipse.core.runtime.IProgressMonitor) - */ - public IFileStore mkdir(int options, IProgressMonitor monitor) throws CoreException - { - cacheRemoteFile(null); - IRemoteFile remoteFile = getRemoteFileObject(monitor, false); - if (remoteFile==null) { - throw new CoreException(new Status(IStatus.ERROR, - Activator.getDefault().getBundle().getSymbolicName(), - EFS.ERROR_NOT_EXISTS, - Messages.COULD_NOT_GET_REMOTE_FILE, null)); - } - IRemoteFileSubSystem subSys = remoteFile.getParentRemoteFileSubSystem(); - if (!remoteFile.exists()) { - try { - if ((options & EFS.SHALLOW) != 0) { - //MUST NOT create parents, so we need to check ourselves - //here according to IRemoteFileSubSystem.createFolder() docs - if (!remoteFile.getParentRemoteFile().exists()) { - throw new CoreException(new Status(IStatus.ERROR, - Activator.getDefault().getBundle().getSymbolicName(), - EFS.ERROR_WRITE, - Messages.FILE_STORE_DOES_NOT_EXIST, null)); - } - remoteFile = subSys.createFolder(remoteFile, monitor); - } else { - remoteFile = subSys.createFolders(remoteFile, monitor); - } - cacheRemoteFile(remoteFile); - } - catch (SystemMessageException e) { - rethrowCoreException(e, EFS.ERROR_WRITE); - } - return _store; - } - else if (remoteFile.isFile()) { - throw new CoreException(new Status(IStatus.ERROR, - Activator.getDefault().getBundle().getSymbolicName(), - EFS.ERROR_WRONG_TYPE, - Messages.FILE_NAME_EXISTS, null)); - } - else { - return _store; - } - } - - /* - * (non-Javadoc) - * @see org.eclipse.core.filesystem.IFileStore#openOutputStream(int, org.eclipse.core.runtime.IProgressMonitor) - */ - public OutputStream openOutputStream(int options, IProgressMonitor monitor) throws CoreException { - cacheRemoteFile(null); - IRemoteFile remoteFile = getRemoteFileObject(monitor, false); - if (remoteFile==null) { - throw new CoreException(new Status(IStatus.ERROR, - Activator.getDefault().getBundle().getSymbolicName(), - Messages.COULD_NOT_GET_REMOTE_FILE)); - } - IRemoteFileSubSystem subSys = remoteFile.getParentRemoteFileSubSystem(); - if (!remoteFile.exists()) { - try { - remoteFile = subSys.createFile(remoteFile, monitor); - cacheRemoteFile(remoteFile); - } - catch (SystemMessageException e) { - rethrowCoreException(e, EFS.ERROR_WRITE); - } - } - - if (remoteFile.isFile()) { - try { - // Convert from EFS option constants to IFileService option constants - if ((options & EFS.APPEND) != 0) { - options = IFileService.APPEND; - } else { - options = IFileService.NONE; - } - cacheRemoteFile(null); - return subSys.getOutputStream(remoteFile.getParentPath(), remoteFile.getName(), options, monitor); - } - catch (SystemMessageException e) { - rethrowCoreException(e, EFS.ERROR_WRITE); - } - } - else if (remoteFile.isDirectory()) { - throw new CoreException(new Status(IStatus.ERROR, - Activator.getDefault().getBundle().getSymbolicName(), - EFS.ERROR_WRONG_TYPE, - Messages.CANNOT_OPEN_STREAM_ON_FOLDER, null)); - } - //Fallback: No file, no folder? - //TODO check what to do for symbolic links and other strange stuff - return null; - } - - /* - * (non-Javadoc) - * @see org.eclipse.core.filesystem.IFileStore#delete(int, org.eclipse.core.runtime.IProgressMonitor) - */ - public void delete(int options, IProgressMonitor monitor) throws CoreException - { - IRemoteFile remoteFile = getRemoteFileObject(monitor, false); - IRemoteFileSubSystem subSys = remoteFile.getParentRemoteFileSubSystem(); - try { - cacheRemoteFile(null); - subSys.delete(remoteFile, monitor); - } - catch (SystemElementNotFoundException e) { - /* not considered an error by EFS -- ignore */ - } - catch (SystemMessageException e) { - rethrowCoreException(e, EFS.ERROR_DELETE); - } - } -}
\ No newline at end of file diff --git a/rse/plugins/org.eclipse.rse.efs/src/org/eclipse/rse/internal/efs/RSEFileSystem.java b/rse/plugins/org.eclipse.rse.efs/src/org/eclipse/rse/internal/efs/RSEFileSystem.java deleted file mode 100644 index 9d9f4aebe..000000000 --- a/rse/plugins/org.eclipse.rse.efs/src/org/eclipse/rse/internal/efs/RSEFileSystem.java +++ /dev/null @@ -1,133 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2006, 2009 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 http://www.eclipse.org/legal/epl-v10.html - * - * Initial Contributors: - * The following IBM employees contributed to the Remote System Explorer - * component that contains this file: David McKnight, Kushal Munir, - * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson, - * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. - * - * Contributors: - * David Dykstal (IBM) - 168977: refactoring IConnectorService and ServerLauncher hierarchies - * Kushal Munir (IBM) - moved to internal package - * Martin Oberhuber (Wind River) - [181917] EFS Improvements: Avoid unclosed Streams, - * - Fix early startup issues by deferring FileStore evaluation and classloading, - * - Improve performance by RSEFileStore instance factory and caching IRemoteFile. - * - Also remove unnecessary class RSEFileCache and obsolete branding files. - * Martin Oberhuber (Wind River) - [188360] renamed from plugin org.eclipse.rse.eclipse.filesystem - * Martin Oberhuber (Wind River) - [199587] return attributes of RSEFileSystem - * David McKnight (IBM) - [287185] EFS provider should interpret the URL host component as RSE connection name rather than a hostname - ********************************************************************************/ - -package org.eclipse.rse.internal.efs; - -import java.net.URI; -import java.net.URISyntaxException; - -import org.eclipse.core.filesystem.EFS; -import org.eclipse.core.filesystem.IFileStore; -import org.eclipse.core.filesystem.provider.FileSystem; - -public class RSEFileSystem extends FileSystem -{ - private static RSEFileSystem _instance = new RSEFileSystem(); - - /** - * Default constructor. - */ - public RSEFileSystem() { - super(); - } - - /** - * Return the singleton instance of this file system. - * @return the singleton instance of this file system. - */ - public static RSEFileSystem getInstance() { - return _instance; - } - - /* - * (non-Javadoc) - * @see org.eclipse.core.filesystem.IFileSystem#attributes() - */ - public int attributes() { - //Attributes supported by RSE IFileService - return EFS.ATTRIBUTE_READ_ONLY | EFS.ATTRIBUTE_EXECUTABLE - | EFS.ATTRIBUTE_SYMLINK | EFS.ATTRIBUTE_LINK_TARGET; - } - - /* - * (non-Javadoc) - * @see org.eclipse.core.filesystem.provider.FileSystem#canDelete() - */ - public boolean canDelete() { - return true; - } - - /* - * (non-Javadoc) - * @see org.eclipse.core.filesystem.provider.FileSystem#canWrite() - */ - public boolean canWrite() { - return true; - } - - /* - * (non-Javadoc) - * @see org.eclipse.core.filesystem.provider.FileSystem#getStore(java.net.URI) - */ - public IFileStore getStore(URI uri) { - try { - return RSEFileStore.getInstance(uri); - } - catch (Exception e) { - //Could be an URI format exception - return EFS.getNullFileSystem().getStore(uri); - } - } - - /** - * Return an URI uniquely naming an RSE remote resource. - * @param hostNameOrAddr host name or IP address of remote system - * @param absolutePath absolute path to resource as valid on the remote system - * @return an URI uniquely naming the remote resource. - */ - public static URI getURIFor(String hostNameOrAddr, String absolutePath) { - //FIXME backslashes are valid in UNIX file names. This is not correctly handled yet. - if (absolutePath.charAt(0) != '/') { - absolutePath = "/" + absolutePath.replace('\\', '/'); //$NON-NLS-1$ - } - try { - return new URI("rse", hostNameOrAddr, absolutePath, null); //$NON-NLS-1$ - } - catch (URISyntaxException e) - { - throw new RuntimeException(e); - } - } - - /** - * Return an URI uniquely naming an RSE remote resource. - * @param hostNameOrAddr host name or IP address of remote system - * @param absolutePath absolute path to resource as valid on the remote system - * @param alias the alias name for the connection - * @return an URI uniquely naming the remote resource. - */ - public static URI getURIFor(String hostNameOrAddr, String absolutePath, String alias) { - //FIXME backslashes are valid in UNIX file names. This is not correctly handled yet. - if (absolutePath.charAt(0) != '/') { - absolutePath = "/" + absolutePath.replace('\\', '/'); //$NON-NLS-1$ - } - try { - return new URI("rse", hostNameOrAddr, absolutePath, alias, null); //$NON-NLS-1$ - } - catch (URISyntaxException e) - { - throw new RuntimeException(e); - } - } -}
\ No newline at end of file diff --git a/rse/plugins/org.eclipse.rse.efs/src/org/eclipse/rse/internal/efs/RemoteEditorManager.java b/rse/plugins/org.eclipse.rse.efs/src/org/eclipse/rse/internal/efs/RemoteEditorManager.java deleted file mode 100644 index 47263e114..000000000 --- a/rse/plugins/org.eclipse.rse.efs/src/org/eclipse/rse/internal/efs/RemoteEditorManager.java +++ /dev/null @@ -1,287 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2009 IBM Corporation. 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 http://www.eclipse.org/legal/epl-v10.html - * - * Initial Contributors: - * The following IBM employees contributed to the Remote System Explorer - * component that contains this file: David McKnight, Mike Kucera. - * - * Contributors: - * Mike Kucera (IBM) - [241316] [efs] Cannot restore editors for RSE/EFS-backed resources - * David McKnight (IBM) - [241316] [efs] Cannot restore editors for RSE/EFS-backed resources - * David McKnight (IBM) - [291738] [efs] repeated queries to RSEFileStoreImpl.fetchInfo() in short time-span should be reduced - ********************************************************************************/ -package org.eclipse.rse.internal.efs; - -import java.net.URI; -import java.net.URISyntaxException; -import java.util.HashMap; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; - -import org.eclipse.core.filesystem.EFS; -import org.eclipse.core.filesystem.IFileStore; -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResourceChangeEvent; -import org.eclipse.core.resources.IResourceChangeListener; -import org.eclipse.core.resources.IResourceDelta; -import org.eclipse.core.resources.ISaveContext; -import org.eclipse.core.resources.ISaveParticipant; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.core.runtime.jobs.Job; -import org.eclipse.rse.ui.RSEUIPlugin; -import org.eclipse.ui.IEditorInput; -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.IEditorReference; -import org.eclipse.ui.IWorkbench; -import org.eclipse.ui.IWorkbenchListener; -import org.eclipse.ui.IWorkbenchPage; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.PartInitException; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.ide.IDE; -import org.eclipse.ui.part.FileEditorInput; -import org.eclipse.ui.progress.UIJob; - -public class RemoteEditorManager implements ISaveParticipant, IResourceChangeListener, IWorkbenchListener { - public static final String PREFERENCE_EDITOR_LIST = "org.eclipse.rse.internal.efs.EditorSaver.preferenceEditorList"; //$NON-NLS-1$ - - private static RemoteEditorManager defaultInstance; - - private Map projectNameToUriMap = null; - - private RemoteEditorManager() {} - - public static synchronized RemoteEditorManager getDefault() { - if(defaultInstance == null) - defaultInstance = new RemoteEditorManager(); - return defaultInstance; - } - - - /** - * Restores remote editors when a remote project is opened. - */ - public void resourceChanged(IResourceChangeEvent event) { - String pref = RSEUIPlugin.getDefault().getPreferenceStore().getString(PREFERENCE_EDITOR_LIST); - Map projectNameToUriMap = getProjectNameToUriMap(pref); - if(projectNameToUriMap.isEmpty()) - return; - - IResourceDelta[] children = event.getDelta().getAffectedChildren(); - for(int i = 0; i < children.length; i++) { - IResourceDelta delta = children[i]; - - // if a project has just been opened - if((delta.getFlags() & IResourceDelta.OPEN) != 0) { - IProject project = delta.getResource().getProject(); - if(project.isOpen()) { - - // restore remote editors for the project - List uris = (List) projectNameToUriMap.remove(project.getName()); - if(uris != null) { - for(Iterator iter = uris.iterator(); iter.hasNext();) { - final String uriString = (String) iter.next(); - - Job job = new UIJob("Restore Remote Editor") { //$NON-NLS-1$ - public IStatus runInUIThread(IProgressMonitor monitor) { - if(monitor.isCanceled()) - return Status.OK_STATUS; - - try { - // got this code from http://wiki.eclipse.org/FAQ_How_do_I_open_an_editor_programmatically%3F - IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); - IFileStore fileStore = EFS.getStore(new URI(uriString)); - IDE.openEditorOnFileStore(page, fileStore); - } catch (URISyntaxException e) { - return Activator.errorStatus(e); - } catch (PartInitException e) { - return Activator.errorStatus(e); - } catch (CoreException e) { - return Activator.errorStatus(e); - } - return Status.OK_STATUS; - } - }; - job.schedule(); - - } - } - } - } - } - - } - - /** - * Saves the URIs of remote resources that are open in editors into the - * plugin's preference store. - */ - public synchronized void saveRemoteEditors() { - IWorkbench wb = PlatformUI.getWorkbench(); - IWorkbenchWindow[] windows = wb.getWorkbenchWindows(); - if(windows.length > 0) { - String list = generateEditorList(); - RSEUIPlugin.getDefault().getPreferenceStore().putValue(PREFERENCE_EDITOR_LIST, list); - } - projectNameToUriMap = null; - } - - private Map getProjectNameToUriMap(String raw) { - if(projectNameToUriMap == null) { - projectNameToUriMap = new HashMap(); - - if(raw == null || raw.length() == 0) - return projectNameToUriMap; - - int index = 0; - while(true) { - int i = raw.indexOf(IPath.SEPARATOR, index); - if(i < 0) break; - String projectName = raw.substring(index, i); - index = i + 1; - i = raw.indexOf(' ', index); - if(i < 0) break; - String uriString = raw.substring(index, i); - index = i + 1; - - List uris = (List) projectNameToUriMap.get(projectName); - if(uris == null) { - uris = new LinkedList(); - projectNameToUriMap.put(projectName, uris); - } - uris.add(uriString); - } - } - return projectNameToUriMap; - } - - - private String generateEditorList() { - final StringBuffer sb = new StringBuffer(); - - forEachOpenRemoteEditor(new IEditorCallback() { - public void apply(IWorkbenchPage page, IEditorPart editor, IFile file) { - IProject project = file.getProject(); - URI uri = file.getLocationURI(); - sb.append(project.getName()); - sb.append(IPath.SEPARATOR); // not allowed in resource names - sb.append(uri); - sb.append(' '); // not allowed in URIs - } - }); - - return sb.toString(); - } - - - private static interface IEditorCallback { - public void apply(IWorkbenchPage page, IEditorPart editor, IFile file); - } - - private static void forEachOpenRemoteEditor(IEditorCallback callback) { - IWorkbench wb = PlatformUI.getWorkbench(); - IWorkbenchWindow[] windows = wb.getWorkbenchWindows(); - for (int w = 0; w < windows.length; w++){ - IWorkbenchWindow win = windows[w]; - IWorkbenchPage[] pages = win.getPages(); - for (int p = 0; p < pages.length; p++){ - IWorkbenchPage page = pages[p]; - IEditorReference[] activeReferences = page.getEditorReferences(); - for (int er = 0; er < activeReferences.length; er++){ - IEditorReference editorReference = activeReferences[er]; - - try { - IEditorInput input = editorReference.getEditorInput(); - if (input instanceof FileEditorInput){ - IFile file = ((FileEditorInput)input).getFile(); - URI uri = file.getLocationURI(); - if (uri != null && uri.getScheme() != null){ - if ("rse".equals(uri.getScheme())) { //$NON-NLS-1$ - IEditorPart editor = editorReference.getEditor(false); - callback.apply(page, editor, file); - } - } - } - } catch (PartInitException e){ - e.printStackTrace(); - } - } - } - } - } - - /** - * Close each editor that is open for any file that uses "rse" as it's uri scheme - * @return true if successful, false otherwise - */ - public boolean closeRemoteEditors() { - boolean result = true; - IWorkbench wb = PlatformUI.getWorkbench(); - IWorkbenchWindow[] windows = wb.getWorkbenchWindows(); - for (int w = 0; w < windows.length; w++){ - IWorkbenchWindow win = windows[w]; - IWorkbenchPage[] pages = win.getPages(); - for (int p = 0; p < pages.length && result; p++){ - IWorkbenchPage page = pages[p]; - IEditorReference[] activeReferences = page.getEditorReferences(); - for (int er = 0; er < activeReferences.length; er++){ - IEditorReference editorReference = activeReferences[er]; - - try { - IEditorInput input = editorReference.getEditorInput(); - if (input instanceof FileEditorInput){ - IFile file = ((FileEditorInput)input).getFile(); - URI uri = file.getLocationURI(); - if ("rse".equals(uri.getScheme())) { //$NON-NLS-1$ - IEditorPart editor = editorReference.getEditor(false); - - // close the editor - result = page.closeEditor(editor, true); - } - } - } catch (PartInitException e){ - e.printStackTrace(); - } - } - } - } - return result; - } - - - public void saving(ISaveContext context) throws CoreException { - saveRemoteEditors(); - } - - - public void doneSaving(ISaveContext context) { - } - - public void prepareToSave(ISaveContext context) throws CoreException { - } - - public void rollback(ISaveContext context) { - } - - - // for IWorkbenchListener - public void postShutdown(IWorkbench workbench) { - } - - // for IWorkbenchListener - public boolean preShutdown(IWorkbench workbench, boolean forced) { - saveRemoteEditors(); - return closeRemoteEditors(); - } - -} diff --git a/rse/plugins/org.eclipse.rse.efs/src/org/eclipse/rse/internal/efs/messages.properties b/rse/plugins/org.eclipse.rse.efs/src/org/eclipse/rse/internal/efs/messages.properties deleted file mode 100644 index d132a6f83..000000000 --- a/rse/plugins/org.eclipse.rse.efs/src/org/eclipse/rse/internal/efs/messages.properties +++ /dev/null @@ -1,24 +0,0 @@ -################################################################################ -# Copyright (c) 2008 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 http://www.eclipse.org/legal/epl-v10.html -# -# Contributors: -# Kevin Doyle (IBM) - [210628] Externalize Strings in RSEFileStore and RSEFileStoreImpl -# Xuan Chen (IBM) - added NLS_MESSAGEFORMAT comments -################################################################################ - -# NLS_MESSAGEFORMAT_VAR -# NLS_ENCODING=UTF-8 - -RESOURCES_NOT_LOADED=Cannot access file: Resources not loaded yet -CONNECTION_NOT_FOUND=Connection not found for host: {0} -NO_FILE_SUBSYSTEM=No file subsystem found on host: {0} connection {1} -COULD_NOT_CONNECT=Could not connect to host: {0} subsystem {1} -COULD_NOT_GET_REMOTE_FILE=Could not get remote file -FILE_STORE_DOES_NOT_EXIST=The file store does not exist -UNKNOWN_EXCEPTION=Unknown exception -FILE_NAME_EXISTS=A file of that name already exists -CANNOT_OPEN_STREAM_ON_FOLDER=Can't open a stream on a folder -DELETE_FAILED=Could not delete file
\ No newline at end of file |