mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-02 22:55:26 +02:00
[283033] remoteFileTypes extension point should include "xml" type
This commit is contained in:
parent
31b72dac02
commit
57b4e6d029
16 changed files with 305 additions and 115 deletions
|
@ -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()) {
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 3.2
|
||||
*/
|
||||
public boolean isXML(String file);
|
||||
}
|
|
@ -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 <code>true</code> if the file is an XML file, <code>false</code> 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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<?eclipse version="3.0"?>
<!--
|
||||
Copyright (c) 2002, 2009 IBM Corporation and others. All rights reserved.
|
||||
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 http://www.eclipse.org/legal/epl-v10.html
|
||||
|
@ -13,6 +13,7 @@
|
|||
|
||||
Contributors:
|
||||
Anna Dushistova (MontaVista) - [227535] Avoid dependency on files.core
|
||||
David McKnight (IBM) - [283033] remoteFileTypes extension point should include "xml" type
|
||||
-->
|
||||
|
||||
<plugin>
|
||||
|
@ -55,8 +56,8 @@
|
|||
<remoteFileTypes extension="tif" type="binary"/>
|
||||
<remoteFileTypes extension="txt" type="text"/>
|
||||
<remoteFileTypes extension="xls" type="binary"/>
|
||||
<remoteFileTypes extension="xmi" type="binary"/>
|
||||
<remoteFileTypes extension="xml" type="binary"/>
|
||||
<remoteFileTypes extension="xmi" type="xml"/>
|
||||
<remoteFileTypes extension="xml" type="xml"/>
|
||||
<remoteFileTypes extension="zip" type="binary"/>
|
||||
|
||||
</extension>
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
<?xml version='1.0' encoding='UTF-8'?>
|
||||
<!-- Schema file written by PDE -->
|
||||
<schema targetNamespace="org.eclipse.rse.subsystems.files.core">
|
||||
<schema targetNamespace="org.eclipse.rse.subsystems.files.core" xmlns="http://www.w3.org/2001/XMLSchema">
|
||||
<annotation>
|
||||
<appInfo>
|
||||
<appinfo>
|
||||
<meta.schema plugin="org.eclipse.rse.subsystems.files.core" id="remoteFileTypes" name="Remote File Types"/>
|
||||
</appInfo>
|
||||
</appinfo>
|
||||
<documentation>
|
||||
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
|
|||
</annotation>
|
||||
|
||||
<element name="extension">
|
||||
<annotation>
|
||||
<appinfo>
|
||||
<meta.element />
|
||||
</appinfo>
|
||||
</annotation>
|
||||
<complexType>
|
||||
<sequence>
|
||||
<element ref="remoteFileTypes" minOccurs="0" maxOccurs="unbounded"/>
|
||||
|
@ -50,22 +55,22 @@ See also the <tt>org.eclipse.team.core.fileTypes</tt> extension poin
|
|||
|
||||
<element name="remoteFileTypes">
|
||||
<annotation>
|
||||
<appInfo>
|
||||
<appinfo>
|
||||
<meta.element labelAttribute="extension"/>
|
||||
</appInfo>
|
||||
</appinfo>
|
||||
</annotation>
|
||||
<complexType>
|
||||
<attribute name="extension" type="string" use="required">
|
||||
<annotation>
|
||||
<documentation>
|
||||
the file extension being identified by this contribution.
|
||||
the file extension being identified by this contribution.
|
||||
</documentation>
|
||||
</annotation>
|
||||
</attribute>
|
||||
<attribute name="type" use="required">
|
||||
<annotation>
|
||||
<documentation>
|
||||
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.
|
||||
</documentation>
|
||||
</annotation>
|
||||
<simpleType>
|
||||
|
@ -74,6 +79,8 @@ See also the <tt>org.eclipse.team.core.fileTypes</tt> extension poin
|
|||
</enumeration>
|
||||
<enumeration value="binary">
|
||||
</enumeration>
|
||||
<enumeration value="xml">
|
||||
</enumeration>
|
||||
</restriction>
|
||||
</simpleType>
|
||||
</attribute>
|
||||
|
@ -90,57 +97,51 @@ If no priority is specified, the default value will be <code>Integer.MAX_V
|
|||
</element>
|
||||
|
||||
<annotation>
|
||||
<appInfo>
|
||||
<meta.section type="examples"/>
|
||||
</appInfo>
|
||||
<documentation>
|
||||
<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>
|
||||
</documentation>
|
||||
</annotation>
|
||||
|
||||
<annotation>
|
||||
<appInfo>
|
||||
<meta.section type="apiInfo"/>
|
||||
</appInfo>
|
||||
<documentation>
|
||||
There is no code to implement for this extension point.
|
||||
</documentation>
|
||||
</annotation>
|
||||
|
||||
<annotation>
|
||||
<appInfo>
|
||||
<appinfo>
|
||||
<meta.section type="since"/>
|
||||
</appInfo>
|
||||
</appinfo>
|
||||
<documentation>
|
||||
3.0
|
||||
</documentation>
|
||||
</annotation>
|
||||
|
||||
<annotation>
|
||||
<appInfo>
|
||||
<meta.section type="implementation"/>
|
||||
</appInfo>
|
||||
<appinfo>
|
||||
<meta.section type="apiInfo"/>
|
||||
</appinfo>
|
||||
<documentation>
|
||||
|
||||
There is no code to implement for this extension point.
|
||||
</documentation>
|
||||
</annotation>
|
||||
|
||||
<annotation>
|
||||
<appInfo>
|
||||
<meta.section type="copyright"/>
|
||||
</appInfo>
|
||||
<appinfo>
|
||||
<meta.section type="examples"/>
|
||||
</appinfo>
|
||||
<documentation>
|
||||
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>
|
||||
</documentation>
|
||||
</annotation>
|
||||
|
||||
|
||||
<annotation>
|
||||
<appinfo>
|
||||
<meta.section type="copyright"/>
|
||||
</appinfo>
|
||||
<documentation>
|
||||
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
|
||||
</documentation>
|
||||
</annotation>
|
||||
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
*/
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Reference in a new issue