From 57b4e6d0295547df802d5bf9f9581bc63fb743a7 Mon Sep 17 00:00:00 2001 From: David McKnight Date: Tue, 2 Feb 2010 18:40:30 +0000 Subject: [PATCH] [283033] remoteFileTypes extension point should include "xml" type --- .../eclipse/rse/internal/core/RSEInitJob.java | 12 +-- .../UniversalPreferencePage.java | 45 +++++++--- .../META-INF/MANIFEST.MF | 2 +- .../clientserver/ISystemFileTypes.java | 21 +++-- .../clientserver/SystemEncodingUtil.java | 58 +++++++------ .../META-INF/MANIFEST.MF | 2 +- .../plugin.xml | 7 +- .../schema/remoteFileTypes.exsd | 87 ++++++++++--------- .../subsystems/files/core/Activator.java | 38 +++++++- .../files/core/SystemFileResources.java | 5 +- .../files/core/SystemFileResources.properties | 2 + .../model/SystemFileTransferModeMapping.java | 32 +++++-- .../model/SystemFileTransferModeRegistry.java | 61 ++++++++++++- .../model/ISystemFileTransferModeMapping.java | 24 ++++- .../ISystemFileTransferModeRegistry.java | 13 ++- .../files/core/subsystems/RemoteFile.java | 11 ++- 16 files changed, 305 insertions(+), 115 deletions(-) diff --git a/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/internal/core/RSEInitJob.java b/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/internal/core/RSEInitJob.java index 05e5f2240fd..96c8e2e40c6 100644 --- a/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/internal/core/RSEInitJob.java +++ b/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/internal/core/RSEInitJob.java @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (c) 2008 IBM Corporation and others. All rights reserved. + * Copyright (c) 2009,2010 IBM Corporation and others. All rights reserved. * This program and the accompanying materials are made available under the terms * of the Eclipse Public License v1.0 which accompanies this distribution, and is * available at http://www.eclipse.org/legal/epl-v10.html @@ -10,6 +10,7 @@ * David McKnight (IBM) - [229610] [api] File transfers should use workspace text file encoding * David Dykstal (IBM) = [226958] add status values to waitForInitCompletion(phase) * David Dykstal (IBM) - [235581] Initialize RSE should be a daemon job + * David McKnight (IBM) - [283033] remoteFileTypes extension point should include "xml" type ********************************************************************************/ package org.eclipse.rse.internal.core; @@ -18,7 +19,6 @@ import java.io.IOException; import java.util.ArrayList; import java.util.List; -import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IConfigurationElement; import org.eclipse.core.runtime.IPath; @@ -40,7 +40,6 @@ import org.eclipse.rse.core.model.ISystemProfile; import org.eclipse.rse.internal.core.model.SystemModelChangeEvent; import org.eclipse.rse.internal.core.model.SystemProfileManager; import org.eclipse.rse.logging.Logger; -import org.eclipse.rse.services.clientserver.SystemEncodingUtil; /** * This is a job named "Initialize RSE". It is instantiated and run during @@ -187,7 +186,7 @@ public final class RSEInitJob extends Job { } } } - + /* (non-Javadoc) * @see org.eclipse.core.runtime.jobs.Job#run(org.eclipse.core.runtime.IProgressMonitor) */ @@ -221,6 +220,8 @@ public final class RSEInitJob extends Job { submonitor.done(); } + /* + * default encoding provider moved to startup of files.core // set the default encoding provider SystemEncodingUtil encodingUtil = SystemEncodingUtil.getInstance(); encodingUtil.setDefaultEncodingProvider( @@ -229,7 +230,8 @@ public final class RSEInitJob extends Job { return ResourcesPlugin.getEncoding(); } }); - +*/ + initializerPhase.done(result); // finish up - propogate cancel if necessary if (monitor.isCanceled()) { diff --git a/rse/plugins/org.eclipse.rse.files.ui/src/org/eclipse/rse/internal/files/ui/propertypages/UniversalPreferencePage.java b/rse/plugins/org.eclipse.rse.files.ui/src/org/eclipse/rse/internal/files/ui/propertypages/UniversalPreferencePage.java index 34095e82488..df5c4894207 100644 --- a/rse/plugins/org.eclipse.rse.files.ui/src/org/eclipse/rse/internal/files/ui/propertypages/UniversalPreferencePage.java +++ b/rse/plugins/org.eclipse.rse.files.ui/src/org/eclipse/rse/internal/files/ui/propertypages/UniversalPreferencePage.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2002, 2009 IBM Corporation and others. + * Copyright (c) 2002, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -21,6 +21,7 @@ * David McKnight (IBM) - [220547] [api][breaking] SimpleSystemMessage needs to specify a message id and some messages should be shared * David McKnight (IBM) - [223204] [cleanup] fix broken nls strings in files.ui and others * David McKnight (IBM) - [245260] Different user's connections on a single host are mapped to the same temp files cache + * David McKnight (IBM) - [283033] remoteFileTypes extension point should include "xml" type *******************************************************************************/ package org.eclipse.rse.internal.files.ui.propertypages; @@ -475,9 +476,10 @@ public class UniversalPreferencePage - String[] contentTypes = new String[2]; + String[] contentTypes = new String[3]; contentTypes[0] = FileResources.RESID_PREF_UNIVERSAL_FILES_FILETYPES_MODE_BINARY_LABEL; contentTypes[1] = FileResources.RESID_PREF_UNIVERSAL_FILES_FILETYPES_MODE_TEXT_LABEL; + contentTypes[2] = FileResources.RESID_PREF_UNIVERSAL_FILES_FILETYPES_MODE_XML_LABEL; CellEditor editors[] = new CellEditor[3]; editors[0] = null; @@ -617,8 +619,9 @@ public class UniversalPreferencePage binaryFileImage = applyBinaryDecoration(fileImage); } + // for now just always using the same image - if (mapping.isBinary()) + if (mapping.isBinary() || mapping.isXML()) { return binaryFileImage; } @@ -645,9 +648,19 @@ public class UniversalPreferencePage item.setImage(0, image); item.setText(1, mapping.getLabel()); - boolean binary = mapping.isBinary(); - item.setText(2, binary ? FileResources.RESID_PREF_UNIVERSAL_FILES_FILETYPES_MODE_BINARY_LABEL : FileResources.RESID_PREF_UNIVERSAL_FILES_FILETYPES_MODE_TEXT_LABEL); - + + boolean isText = mapping.isText(); + boolean isXML = mapping.isXML(); + + if (isText){ + item.setText(2, FileResources.RESID_PREF_UNIVERSAL_FILES_FILETYPES_MODE_TEXT_LABEL); + } + else if (isXML){ + item.setText(2, FileResources.RESID_PREF_UNIVERSAL_FILES_FILETYPES_MODE_XML_LABEL); + } + else { + item.setText(2, FileResources.RESID_PREF_UNIVERSAL_FILES_FILETYPES_MODE_BINARY_LABEL); + } if (selected) resourceTypeTable.setSelection(index); @@ -748,6 +761,11 @@ public class UniversalPreferencePage item.setText(2, FileResources.RESID_PREF_UNIVERSAL_FILES_FILETYPES_MODE_BINARY_LABEL); item.setImage(getImageFor(mapping)); } + else if (mapping.isXML()){ + mapping.setAsXML(); + item.setText(2, FileResources.RESID_PREF_UNIVERSAL_FILES_FILETYPES_MODE_XML_LABEL); + item.setImage(getImageFor(mapping)); + } } /** @@ -1060,18 +1078,19 @@ public class UniversalPreferencePage if (value instanceof Integer) { int index = ((Integer)value).intValue(); - if (index == 0) - { + if (index == 0) { mapping.setAsBinary(); item.setText(2, FileResources.RESID_PREF_UNIVERSAL_FILES_FILETYPES_MODE_BINARY_LABEL); - item.setImage(getImageFor(mapping)); } - else - { + else if (index == 1){ mapping.setAsText(); - item.setText(2, FileResources.RESID_PREF_UNIVERSAL_FILES_FILETYPES_MODE_TEXT_LABEL); - item.setImage(getImageFor(mapping)); + item.setText(2, FileResources.RESID_PREF_UNIVERSAL_FILES_FILETYPES_MODE_TEXT_LABEL); } + else if (index == 2){ + mapping.setAsXML(); + item.setText(2, FileResources.RESID_PREF_UNIVERSAL_FILES_FILETYPES_MODE_XML_LABEL); + } + item.setImage(getImageFor(mapping)); } } diff --git a/rse/plugins/org.eclipse.rse.services/META-INF/MANIFEST.MF b/rse/plugins/org.eclipse.rse.services/META-INF/MANIFEST.MF index 52a5a069113..6f432405ce5 100644 --- a/rse/plugins/org.eclipse.rse.services/META-INF/MANIFEST.MF +++ b/rse/plugins/org.eclipse.rse.services/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.rse.services;singleton:=true -Bundle-Version: 3.1.1.qualifier +Bundle-Version: 3.2.0.qualifier Bundle-Activator: org.eclipse.rse.internal.services.Activator Bundle-Vendor: %providerName Bundle-Localization: plugin diff --git a/rse/plugins/org.eclipse.rse.services/clientserver/org/eclipse/rse/services/clientserver/ISystemFileTypes.java b/rse/plugins/org.eclipse.rse.services/clientserver/org/eclipse/rse/services/clientserver/ISystemFileTypes.java index b55772378cd..f127871eaaf 100644 --- a/rse/plugins/org.eclipse.rse.services/clientserver/org/eclipse/rse/services/clientserver/ISystemFileTypes.java +++ b/rse/plugins/org.eclipse.rse.services/clientserver/org/eclipse/rse/services/clientserver/ISystemFileTypes.java @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (c) 2006 IBM Corporation. All rights reserved. + * Copyright (c) 2009, 2010 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 @@ -11,7 +11,7 @@ * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. * * Contributors: - * {Name} (company) - description of contribution. + * David McKnight (IBM) - [283033] remoteFileTypes extension point should include "xml" type ********************************************************************************/ @@ -19,13 +19,22 @@ package org.eclipse.rse.services.clientserver; import java.io.File; -/** - * @author dmcknigh - */ + public interface ISystemFileTypes { public boolean isBinary(File file); public boolean isText(File file); + + /** + * @since 3.2 + */ + public boolean isXML(File file); public boolean isBinary(String file); + public boolean isText(String file); -} \ No newline at end of file + + /** + * @since 3.2 + */ + public boolean isXML(String file); +} \ No newline at end of file diff --git a/rse/plugins/org.eclipse.rse.services/clientserver/org/eclipse/rse/services/clientserver/SystemEncodingUtil.java b/rse/plugins/org.eclipse.rse.services/clientserver/org/eclipse/rse/services/clientserver/SystemEncodingUtil.java index caac7a08021..93de18770a0 100644 --- a/rse/plugins/org.eclipse.rse.services/clientserver/org/eclipse/rse/services/clientserver/SystemEncodingUtil.java +++ b/rse/plugins/org.eclipse.rse.services/clientserver/org/eclipse/rse/services/clientserver/SystemEncodingUtil.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2008 IBM Corporation and others. + * Copyright (c) 2006, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -14,6 +14,7 @@ * Contributors: * David McKnight (IBM) [215847]SystemEncodingUtil needs to convert to unsigned when checking xml file * David McKnight (IBM) - [229610] [api] File transfers should use workspace text file encoding + * David McKnight (IBM) - [283033] remoteFileTypes extension point should include "xml" type *******************************************************************************/ package org.eclipse.rse.services.clientserver; @@ -71,6 +72,36 @@ public class SystemEncodingUtil { public String getLocalDefaultEncoding() { return System.getProperty("file.encoding"); //$NON-NLS-1$ } + + + /** + * @since 3.2 + */ + public boolean isXML(String filePath) { + int index = filePath.lastIndexOf("."); //$NON-NLS-1$ + + // check if there is a "." + if (index == -1) { + return false; + } + else { + + // check if the name ends with "." + if (index == filePath.length() - 1) { + return false; + } + else { + String extension = filePath.substring(index+1); + + if (extension.equalsIgnoreCase("xml") || extension.equalsIgnoreCase("xmi")) { //$NON-NLS-1$ //$NON-NLS-2$ + return true; + } + else { + return false; + } + } + } + } } /** @@ -115,30 +146,7 @@ public class SystemEncodingUtil { * @return true if the file is an XML file, false otherwise. */ public boolean isXML(String filePath) { - - int index = filePath.lastIndexOf("."); //$NON-NLS-1$ - - // check if there is a "." - if (index == -1) { - return false; - } - else { - - // check if the name ends with "." - if (index == filePath.length() - 1) { - return false; - } - else { - String extension = filePath.substring(index+1); - - if (extension.equalsIgnoreCase("xml") || extension.equalsIgnoreCase("xmi")) { //$NON-NLS-1$ //$NON-NLS-2$ - return true; - } - else { - return false; - } - } - } + return _defaultEncodingProvider.isXML(filePath); } /** diff --git a/rse/plugins/org.eclipse.rse.subsystems.files.core/META-INF/MANIFEST.MF b/rse/plugins/org.eclipse.rse.subsystems.files.core/META-INF/MANIFEST.MF index 56f2512c08c..218b2f7f25b 100644 --- a/rse/plugins/org.eclipse.rse.subsystems.files.core/META-INF/MANIFEST.MF +++ b/rse/plugins/org.eclipse.rse.subsystems.files.core/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.rse.subsystems.files.core;singleton:=true -Bundle-Version: 3.1.1.qualifier +Bundle-Version: 3.2.0.qualifier Bundle-Activator: org.eclipse.rse.internal.subsystems.files.core.Activator Bundle-Localization: plugin Require-Bundle: org.eclipse.ui, diff --git a/rse/plugins/org.eclipse.rse.subsystems.files.core/plugin.xml b/rse/plugins/org.eclipse.rse.subsystems.files.core/plugin.xml index dcd35563013..8ae0b8dbd5d 100644 --- a/rse/plugins/org.eclipse.rse.subsystems.files.core/plugin.xml +++ b/rse/plugins/org.eclipse.rse.subsystems.files.core/plugin.xml @@ -1,6 +1,6 @@ @@ -55,8 +56,8 @@ - - + + diff --git a/rse/plugins/org.eclipse.rse.subsystems.files.core/schema/remoteFileTypes.exsd b/rse/plugins/org.eclipse.rse.subsystems.files.core/schema/remoteFileTypes.exsd index 3b15f617223..dcaec6015dc 100644 --- a/rse/plugins/org.eclipse.rse.subsystems.files.core/schema/remoteFileTypes.exsd +++ b/rse/plugins/org.eclipse.rse.subsystems.files.core/schema/remoteFileTypes.exsd @@ -1,18 +1,18 @@ - + - + - + - This extension point is used to register information about whether particular file types should be considered to contain text or binary data. -This information is important as it will determine how files will be transferred. The exact meaning of how the transfer of text files differs from binary + This extension point is used to register information about whether particular file types should be considered to contain text, binary or xml data. +This information is important as it will determine how files will be transferred. The exact meaning of how the transfer of text files differs from binary and xml files depends on the actual file service implementation. In general, though, services will strive to change the encoding of remote text files during transfer -such that it matches the local platform default encoding. +such that it matches the local platform default encoding. File types that are specified as xml will normally transfer as binary but will have it's encoding determined via inspection of the text. <p> Specific encoding conversions also depend on provided extensions to the -<a href="org_eclipse_rse_services_codePageConverters.html">org.eclipse.rse.services.codePageConverters</a> +<a href="org_eclipse_rse_services_codePageConverters.html">org.eclipse.rse.services.codePageConverters</a> extension point. For example, transferring files from a remote dstore Linux host to a local Windows client, the file service may convert text files from UTF-8 encoding to Windows cp1252 encoding, and convert remote LF only line endings to local CRLF line endings. @@ -27,6 +27,11 @@ See also the <tt>org.eclipse.team.core.fileTypes</tt> extension poin + + + + + @@ -50,22 +55,22 @@ See also the <tt>org.eclipse.team.core.fileTypes</tt> extension poin - + - + - the file extension being identified by this contribution. + the file extension being identified by this contribution. - one of either "text" or "binary", identifying the contents of files matching the value of extension. + one of either "text" or "binary", identifying the contents of files matching the value of extension. @@ -74,6 +79,8 @@ See also the <tt>org.eclipse.team.core.fileTypes</tt> extension poin + + @@ -90,57 +97,51 @@ If no priority is specified, the default value will be <code>Integer.MAX_V - - - - - <extension point="org.eclipse.rse.subsystems.files.core.remoteFileTypes"> - <remoteFileTypes extension="txt" type="text"/> - <remoteFileTypes extension="gif" type="binary"/> - <remoteFileTypes extension="exe" type="binary" priority="100"/> -</extension> - - - - - - - - - There is no code to implement for this extension point. - - - - - + - + 3.0 - - - + + + - + There is no code to implement for this extension point. - - - + + + - Copyright (c) 2006, 2007 IBM Corporation. All Rights Reserved. + <extension point="org.eclipse.rse.subsystems.files.core.remoteFileTypes"> + <remoteFileTypes extension="txt" type="text"/> + <remoteFileTypes extension="gif" type="binary"/> + <remoteFileTypes extension="xmi" type="xml"/> + <remoteFileTypes extension="exe" type="binary" priority="100"/> +</extension> + + + + + + + + + + Copyright (c) 2006, 2010 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 Contributors: IBM Corporation - initial API and implementation +David McKnight (IBM) - [283033] remoteFileTypes extension point should include "xml" type diff --git a/rse/plugins/org.eclipse.rse.subsystems.files.core/src/org/eclipse/rse/internal/subsystems/files/core/Activator.java b/rse/plugins/org.eclipse.rse.subsystems.files.core/src/org/eclipse/rse/internal/subsystems/files/core/Activator.java index 2de9dc0cb6e..ff0972e0f97 100644 --- a/rse/plugins/org.eclipse.rse.subsystems.files.core/src/org/eclipse/rse/internal/subsystems/files/core/Activator.java +++ b/rse/plugins/org.eclipse.rse.subsystems.files.core/src/org/eclipse/rse/internal/subsystems/files/core/Activator.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2008 IBM Corporation and others. + * Copyright (c) 2006, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -16,11 +16,19 @@ * Martin Oberhuber (wind River) - [203105] Decouple recursive plugin activation of UI adapters * David McKnight (IBM) - [216252] [api][nls] Resource Strings specific to subsystems should be moved from rse.ui into files.ui / shells.ui / processes.ui where possible * Martin Oberhuber (Wind River) - [218304] Improve deferred adapter loading + * David McKnight (IBM) - [283033] remoteFileTypes extension point should include "xml" type *******************************************************************************/ package org.eclipse.rse.internal.subsystems.files.core; +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.rse.services.clientserver.SystemEncodingUtil; +import org.eclipse.rse.subsystems.files.core.model.RemoteFileUtility; import org.osgi.framework.BundleContext; /** @@ -40,11 +48,39 @@ public class Activator extends Plugin { plugin = this; } + class RSEDefaultEncodingProvider extends SystemEncodingUtil.DefaultEncodingProvider{ + public String getLocalDefaultEncoding() { + return ResourcesPlugin.getEncoding(); + } + + public boolean isXML(String path){ + boolean result = super.isXML(path); + if (!result){ + // now check the extension point mappings + RemoteFileUtility.getSystemFileTransferModeRegistry().isXML(path); + } + + return result; + } + } + /** * This method is called upon plug-in activation */ public void start(BundleContext context) throws Exception { super.start(context); + + Job setupEncodingProvider = new Job(SystemFileResources.RESID_JOB_SETUP_ENCODING_PROVIDER){ //$NON-NLS-1$ + + public IStatus run(IProgressMonitor monitor){ + // set the default encoding provider + SystemEncodingUtil encodingUtil = SystemEncodingUtil.getInstance(); + encodingUtil.setDefaultEncodingProvider(new RSEDefaultEncodingProvider()); + return Status.OK_STATUS; + } + }; + setupEncodingProvider.setSystem(true); + setupEncodingProvider.schedule(); } /** diff --git a/rse/plugins/org.eclipse.rse.subsystems.files.core/src/org/eclipse/rse/internal/subsystems/files/core/SystemFileResources.java b/rse/plugins/org.eclipse.rse.subsystems.files.core/src/org/eclipse/rse/internal/subsystems/files/core/SystemFileResources.java index c3b848d71fb..c50afafbf48 100644 --- a/rse/plugins/org.eclipse.rse.subsystems.files.core/src/org/eclipse/rse/internal/subsystems/files/core/SystemFileResources.java +++ b/rse/plugins/org.eclipse.rse.subsystems.files.core/src/org/eclipse/rse/internal/subsystems/files/core/SystemFileResources.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2008 IBM Corporation and others. + * Copyright (c) 2006, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -15,6 +15,7 @@ * David McKnight (IBM) - [216252] [api][nls] Resource Strings specific to subsystems should be moved from rse.ui into files.ui / shells.ui / processes.ui where possible * David McKnight (IBM) - [220547] [api][breaking] SimpleSystemMessage needs to specify a message id and some messages should be shared * David McKnight (IBM) - [223204] [cleanup] fix broken nls strings in files.ui and others + * David McKnight (IBM) - [283033] remoteFileTypes extension point should include "xml" type *******************************************************************************/ package org.eclipse.rse.internal.subsystems.files.core; @@ -155,6 +156,8 @@ public class SystemFileResources extends NLS public static String MSG_FILE_CANNOT_BE_SAVED; public static String MSG_FILE_CANNOT_BE_SAVED_DETAILS; + public static String RESID_JOB_SETUP_ENCODING_PROVIDER; + static { // load message values from bundle file NLS.initializeMessages(BUNDLE_NAME, SystemFileResources.class); diff --git a/rse/plugins/org.eclipse.rse.subsystems.files.core/src/org/eclipse/rse/internal/subsystems/files/core/SystemFileResources.properties b/rse/plugins/org.eclipse.rse.subsystems.files.core/src/org/eclipse/rse/internal/subsystems/files/core/SystemFileResources.properties index d89564bdffc..9017adec4b3 100644 --- a/rse/plugins/org.eclipse.rse.subsystems.files.core/src/org/eclipse/rse/internal/subsystems/files/core/SystemFileResources.properties +++ b/rse/plugins/org.eclipse.rse.subsystems.files.core/src/org/eclipse/rse/internal/subsystems/files/core/SystemFileResources.properties @@ -15,6 +15,7 @@ # David McKnight (IBM) - [216252] [api][nls] Resource Strings specific to subsystems should be moved from rse.ui into files.ui / shells.ui / processes.ui where possible # David McKnight (IBM) - [220547] [api][breaking] SimpleSystemMessage needs to specify a message id and some messages should be shared # David McKnight (IBM) - [223204] [cleanup] fix broken nls strings in files.ui and others +# David McKnight (IBM) - [283033] remoteFileTypes extension point should include "xml" type ############################################################################### # NLS_MESSAGEFORMAT_VAR @@ -180,4 +181,5 @@ MSG_FOLDER_UNREADABLE = Folder {0} is not readable. Cannot expand MSG_FILE_CANNOT_BE_SAVED= File {0} can not be saved on {1}. You do not have write access to the file. MSG_FILE_CANNOT_BE_SAVED_DETAILS= Change file permissions to ensure you have write access to the file. +RESID_JOB_SETUP_ENCODING_PROVIDER=Setting up encoding provider diff --git a/rse/plugins/org.eclipse.rse.subsystems.files.core/src/org/eclipse/rse/internal/subsystems/files/core/model/SystemFileTransferModeMapping.java b/rse/plugins/org.eclipse.rse.subsystems.files.core/src/org/eclipse/rse/internal/subsystems/files/core/model/SystemFileTransferModeMapping.java index 8d2b55f5054..0d154f6b58a 100644 --- a/rse/plugins/org.eclipse.rse.subsystems.files.core/src/org/eclipse/rse/internal/subsystems/files/core/model/SystemFileTransferModeMapping.java +++ b/rse/plugins/org.eclipse.rse.subsystems.files.core/src/org/eclipse/rse/internal/subsystems/files/core/model/SystemFileTransferModeMapping.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2002, 2008 IBM Corporation and others. + * Copyright (c) 2002, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -15,6 +15,7 @@ * David McKnight (IBM) - [208951] new priority field * Martin Oberhuber (Wind River) - [220020][api][breaking] SystemFileTransferModeRegistry should be internal * Martin Oberhuber (Wind River) - [219975] Fix implementations of clone() + * David McKnight (IBM) - [283033] remoteFileTypes extension point should include "xml" type *******************************************************************************/ package org.eclipse.rse.internal.subsystems.files.core.model; @@ -33,7 +34,9 @@ public class SystemFileTransferModeMapping implements ISystemFileTransferModeMap public static final int DEFAULT_PRIORITY = Integer.MAX_VALUE; private String name; private String extension; - private boolean isBinary = true; + private int fileType = ISystemFileTransferModeMapping.FILE_TYPE_BINARY; + + private int priority = DEFAULT_PRIORITY; /** @@ -96,7 +99,15 @@ public class SystemFileTransferModeMapping implements ISystemFileTransferModeMap * @see org.eclipse.rse.subsystems.files.core.model.ISystemFileTransferModeMapping#isBinary() */ public boolean isBinary() { - return isBinary; + return fileType == ISystemFileTransferModeMapping.FILE_TYPE_BINARY; + } + + /* + * (non-Javadoc) + * @see org.eclipse.rse.subsystems.files.core.model.ISystemFileTransferModeMapping#isXML() + */ + public boolean isXML(){ + return fileType == ISystemFileTransferModeMapping.FILE_TYPE_XML; } /* @@ -104,23 +115,32 @@ public class SystemFileTransferModeMapping implements ISystemFileTransferModeMap * @see org.eclipse.rse.subsystems.files.core.model.ISystemFileTransferModeMapping#isText() */ public boolean isText() { - return !isBinary(); + return fileType == ISystemFileTransferModeMapping.FILE_TYPE_TEXT; } /** * Set whether transfer mode is binary */ public void setAsBinary() { - isBinary = true; + fileType = ISystemFileTransferModeMapping.FILE_TYPE_BINARY; + } + + /** + * Set whether transfer mode is XML + */ + public void setAsXML() { + fileType = ISystemFileTransferModeMapping.FILE_TYPE_XML; } /** * Set whether transfer mode is text */ public void setAsText() { - isBinary = false; + fileType = ISystemFileTransferModeMapping.FILE_TYPE_TEXT; } + + /** * Set the name */ diff --git a/rse/plugins/org.eclipse.rse.subsystems.files.core/src/org/eclipse/rse/internal/subsystems/files/core/model/SystemFileTransferModeRegistry.java b/rse/plugins/org.eclipse.rse.subsystems.files.core/src/org/eclipse/rse/internal/subsystems/files/core/model/SystemFileTransferModeRegistry.java index 80d677f619c..75abaacd2a4 100644 --- a/rse/plugins/org.eclipse.rse.subsystems.files.core/src/org/eclipse/rse/internal/subsystems/files/core/model/SystemFileTransferModeRegistry.java +++ b/rse/plugins/org.eclipse.rse.subsystems.files.core/src/org/eclipse/rse/internal/subsystems/files/core/model/SystemFileTransferModeRegistry.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2002, 2008 IBM Corporation and others. + * Copyright (c) 2002, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -15,6 +15,7 @@ * Martin Oberhuber (Wind River) - [168870] refactor org.eclipse.rse.core package of the UI plugin * David McKnight (IBM) - [208951] Use remoteFileTypes extension point to determine file types * Martin Oberhuber (Wind River) - [220020][api][breaking] SystemFileTransferModeRegistry should be internal + * David McKnight (IBM) - [283033] remoteFileTypes extension point should include "xml" type *******************************************************************************/ package org.eclipse.rse.internal.subsystems.files.core.model; @@ -73,6 +74,7 @@ public class SystemFileTransferModeRegistry implements ISystemFileTransferModeRe private static final String MODE_ATTRIBUTE = "mode"; //$NON-NLS-1$ private static final String BINARY_VALUE = "binary"; //$NON-NLS-1$ private static final String TEXT_VALUE = "text"; //$NON-NLS-1$ + private static final String XML_VALUE = "xml"; //$NON-NLS-1$s private static final String PRIORITY_ATTRIBUTE = "priority"; //$NON-NLS-1$ /** @@ -145,6 +147,11 @@ public class SystemFileTransferModeRegistry implements ISystemFileTransferModeRe if (type.equalsIgnoreCase("binary")) { //$NON-NLS-1$ mapping.setAsBinary(); } + + // add extension to list of xml types + if (type.equalsIgnoreCase("xml")) { //$NON-NLS-1$ + mapping.setAsXML(); + } int priority = SystemFileTransferModeMapping.DEFAULT_PRIORITY; String priorityStr = element.getAttribute("priority"); //$NON-NLS-1$ @@ -302,7 +309,37 @@ public class SystemFileTransferModeRegistry implements ISystemFileTransferModeRe return isText(remoteFile.getName()); } + /** + * @see ISystemFileTransferModeRegistry#isText(String) + */ + public boolean isXML(String fileName) { + return getMapping(fileName).isXML(); + } + + /** + * @see ISystemFileTransferModeRegistry#isText(File) + */ + public boolean isXML(File file) { + return isXML(file.getName()); + } + + + /** + * @see ISystemFileTransferModeRegistry#isText(IFile) + */ + public boolean isXML(IFile file) { + return isXML(file.getName()); + } + + + /** + * @see ISystemFileTransferModeRegistry#isText(IRemoteFile) + */ + public boolean isXML(IRemoteFile remoteFile) { + return isXML(remoteFile.getName()); + } + /** * Get the mode mapping given a file name */ @@ -357,11 +394,16 @@ public class SystemFileTransferModeRegistry implements ISystemFileTransferModeRe { fileMapping.setAsText(); } - else + else if (mapping.isXML()) + { + fileMapping.setAsXML(); + } + else { fileMapping.setAsBinary(); } + return fileMapping; } @@ -458,6 +500,9 @@ public class SystemFileTransferModeRegistry implements ISystemFileTransferModeRe if (mode.equals(TEXT_VALUE)) { mapping.setAsText(); } + else if (mode.equals(XML_VALUE)){ + mapping.setAsXML(); + } else { mapping.setAsBinary(); } @@ -523,7 +568,17 @@ public class SystemFileTransferModeRegistry implements ISystemFileTransferModeRe IMemento infoMemento = memento.createChild(INFO_NODE); infoMemento.putString(NAME_ATTRIBUTE, mapping.getName()); infoMemento.putString(EXTENSION_ATTRIBUTE, mapping.getExtension()); - infoMemento.putString(MODE_ATTRIBUTE, mapping.isBinary() ? BINARY_VALUE : TEXT_VALUE); + + if (mapping.isText()){ + infoMemento.putString(MODE_ATTRIBUTE, TEXT_VALUE); + } + else if (mapping.isXML()){ + infoMemento.putString(MODE_ATTRIBUTE, XML_VALUE); + } + else { + infoMemento.putString(MODE_ATTRIBUTE, BINARY_VALUE); + } + infoMemento.putInteger(PRIORITY_ATTRIBUTE, mapping.getPriority()); } diff --git a/rse/plugins/org.eclipse.rse.subsystems.files.core/src/org/eclipse/rse/subsystems/files/core/model/ISystemFileTransferModeMapping.java b/rse/plugins/org.eclipse.rse.subsystems.files.core/src/org/eclipse/rse/subsystems/files/core/model/ISystemFileTransferModeMapping.java index 115c829a47a..094b4c9806f 100644 --- a/rse/plugins/org.eclipse.rse.subsystems.files.core/src/org/eclipse/rse/subsystems/files/core/model/ISystemFileTransferModeMapping.java +++ b/rse/plugins/org.eclipse.rse.subsystems.files.core/src/org/eclipse/rse/subsystems/files/core/model/ISystemFileTransferModeMapping.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2002, 2008 IBM Corporation and others. + * Copyright (c) 2002, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -13,15 +13,27 @@ * * Contributors: * David McKnight (IBM) - [208951] new priority field + * David McKnight (IBM) - [283033] remoteFileTypes extension point should include "xml" type *******************************************************************************/ package org.eclipse.rse.subsystems.files.core.model; public interface ISystemFileTransferModeMapping { - - /** + * @since 3.2 + */ + public static final int FILE_TYPE_BINARY = 0; + /** + * @since 3.2 + */ + public static final int FILE_TYPE_TEXT = 1; + /** + * @since 3.2 + */ + public static final int FILE_TYPE_XML = 2; + + /** * Get the extension * * @return the extension for the mapping @@ -60,6 +72,12 @@ public interface ISystemFileTransferModeMapping { */ public boolean isText(); + /** + * Returns if the mapping is XML + * + * @return true if XML + */ + public boolean isXML(); /** * Gets the priority - the smaller the number, the higher priority diff --git a/rse/plugins/org.eclipse.rse.subsystems.files.core/src/org/eclipse/rse/subsystems/files/core/model/ISystemFileTransferModeRegistry.java b/rse/plugins/org.eclipse.rse.subsystems.files.core/src/org/eclipse/rse/subsystems/files/core/model/ISystemFileTransferModeRegistry.java index ded0db4567f..ea75f1f253d 100644 --- a/rse/plugins/org.eclipse.rse.subsystems.files.core/src/org/eclipse/rse/subsystems/files/core/model/ISystemFileTransferModeRegistry.java +++ b/rse/plugins/org.eclipse.rse.subsystems.files.core/src/org/eclipse/rse/subsystems/files/core/model/ISystemFileTransferModeRegistry.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2007 IBM Corporation and others. + * Copyright (c) 2006, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -14,6 +14,7 @@ * Contributors: * {Name} (company) - description of contribution. * David McKnight (IBM) - [208951] Don't use hard-coded file type defaults + * David McKnight (IBM) - [283033] remoteFileTypes extension point should include "xml" type *******************************************************************************/ package org.eclipse.rse.subsystems.files.core.model; @@ -40,4 +41,14 @@ public interface ISystemFileTransferModeRegistry extends ISystemFileTypes // Query whether a file should be treated as text public boolean isText(IFile file); public boolean isText(IRemoteFile remoteFile); + + // Query whether a file should be treated as xml + /** + * @since 3.2 + */ + public boolean isXML(IFile file); + /** + * @since 3.2 + */ + public boolean isXML(IRemoteFile remoteFile); } diff --git a/rse/plugins/org.eclipse.rse.subsystems.files.core/src/org/eclipse/rse/subsystems/files/core/subsystems/RemoteFile.java b/rse/plugins/org.eclipse.rse.subsystems.files.core/src/org/eclipse/rse/subsystems/files/core/subsystems/RemoteFile.java index c3b81f11dfd..23611cd247d 100644 --- a/rse/plugins/org.eclipse.rse.subsystems.files.core/src/org/eclipse/rse/subsystems/files/core/subsystems/RemoteFile.java +++ b/rse/plugins/org.eclipse.rse.subsystems.files.core/src/org/eclipse/rse/subsystems/files/core/subsystems/RemoteFile.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2002, 2009 IBM Corporation and others. + * Copyright (c) 2002, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -22,6 +22,7 @@ * David McKnight (IBM) - [231209] [api][breaking] IRemoteFile.getSystemConnection() should be changed to IRemoteFile.getHost() * David McKnight (IBM) - [277911] cached results of remote file query need to be sorted * David McKnight (IBM) - [289387] Remote Search does not return line nodes in result tree + * David McKnight (IBM) - [283033] remoteFileTypes extension point should include "xml" type *******************************************************************************/ package org.eclipse.rse.subsystems.files.core.subsystems; @@ -53,6 +54,7 @@ import org.eclipse.rse.services.clientserver.messages.SystemMessageException; import org.eclipse.rse.services.files.IHostFile; import org.eclipse.rse.services.files.IHostFilePermissions; import org.eclipse.rse.services.files.IHostFilePermissionsContainer; +import org.eclipse.rse.subsystems.files.core.model.ISystemFileTransferModeRegistry; import org.eclipse.rse.subsystems.files.core.model.RemoteFileFilterString; import org.eclipse.rse.subsystems.files.core.model.RemoteFileUtility; import org.eclipse.rse.ui.SystemBasePlugin; @@ -384,8 +386,11 @@ public abstract class RemoteFile implements IRemoteFile, IAdaptable, Comparable { if (isDirectory()) return false; - else - return RemoteFileUtility.getSystemFileTransferModeRegistry().isBinary(this); + + else { + ISystemFileTransferModeRegistry reg = RemoteFileUtility.getSystemFileTransferModeRegistry(); + return reg.isBinary(this) || reg.isXML(this); // xml files also transfer as binary + } } /**