mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-17 05:55:22 +02:00
[209660] remote file encoding should default to parent folder's encoding
This commit is contained in:
parent
cff6bdc83f
commit
0252676845
6 changed files with 117 additions and 29 deletions
|
@ -21,6 +21,7 @@
|
||||||
* David McKnight (IBM) - [187130] New Folder/File, Move and Rename should be available for read-only folders
|
* David McKnight (IBM) - [187130] New Folder/File, Move and Rename should be available for read-only folders
|
||||||
* Kevin Doyle (IBM) - [197976] Changing a file to read-only when it is open doesn't update local copy
|
* Kevin Doyle (IBM) - [197976] Changing a file to read-only when it is open doesn't update local copy
|
||||||
* David McKnight (IBM) - [186363] get rid of obsolete calls to ISubSystem.connect()
|
* David McKnight (IBM) - [186363] get rid of obsolete calls to ISubSystem.connect()
|
||||||
|
* David McKnight (IBM) -[209660] check for changed encoding before using cached file
|
||||||
********************************************************************************/
|
********************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.rse.files.ui.resources;
|
package org.eclipse.rse.files.ui.resources;
|
||||||
|
@ -581,8 +582,9 @@ public class SystemEditableRemoteFile implements ISystemEditableRemoteObject, IP
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
String encoding = properties.getEncoding();
|
||||||
if (properties.getUsedBinaryTransfer() == remoteFile.isBinary() &&
|
if (properties.getUsedBinaryTransfer() == remoteFile.isBinary() &&
|
||||||
properties.getEncoding().equals(remoteFile.getEncoding()) // changed encodings matter too
|
encoding != null && encoding.equals(remoteFile.getEncoding()) // changed encodings matter too
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
// we already have same file, use the current file
|
// we already have same file, use the current file
|
||||||
|
@ -1459,7 +1461,8 @@ public class SystemEditableRemoteFile implements ISystemEditableRemoteObject, IP
|
||||||
|
|
||||||
// if we have an xml file, find the local encoding of the file
|
// if we have an xml file, find the local encoding of the file
|
||||||
SystemEncodingUtil util = SystemEncodingUtil.getInstance();
|
SystemEncodingUtil util = SystemEncodingUtil.getInstance();
|
||||||
String encoding = null;
|
String encoding = remoteFile.getEncoding();
|
||||||
|
properties.setEncoding(encoding);
|
||||||
|
|
||||||
String tempPath = file.getLocation().toOSString();
|
String tempPath = file.getLocation().toOSString();
|
||||||
|
|
||||||
|
@ -1473,9 +1476,7 @@ public class SystemEditableRemoteFile implements ISystemEditableRemoteObject, IP
|
||||||
throw new CoreException(s);
|
throw new CoreException(s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
encoding = remoteFile.getEncoding();
|
|
||||||
}
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Martin Oberhuber (Wind River) - [189130] Move SystemIFileProperties from UI to Core
|
* Martin Oberhuber (Wind River) - [189130] Move SystemIFileProperties from UI to Core
|
||||||
|
* David McKnight (IBM) -[209660] check for changed encoding before using cached file
|
||||||
********************************************************************************/
|
********************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.rse.internal.files.ui.actions;
|
package org.eclipse.rse.internal.files.ui.actions;
|
||||||
|
@ -136,7 +137,12 @@ public class SystemEditFilesAction extends SystemBaseAction {
|
||||||
boolean dirty = properties.getDirty();
|
boolean dirty = properties.getDirty();
|
||||||
|
|
||||||
boolean remoteNewer = (storedModifiedStamp != remoteModifiedStamp);
|
boolean remoteNewer = (storedModifiedStamp != remoteModifiedStamp);
|
||||||
return (!dirty && !remoteNewer);
|
|
||||||
|
String remoteEncoding = remoteFile.getEncoding();
|
||||||
|
String storedEncoding = properties.getEncoding();
|
||||||
|
|
||||||
|
boolean encodingChanged = storedEncoding == null || !(remoteEncoding.equals(storedEncoding));
|
||||||
|
return (!dirty && !remoteNewer && !encodingChanged);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
* David McKnight (IBM) - [173518] [refresh] Read only changes are not shown in RSE until the parent folder is refreshed
|
* David McKnight (IBM) - [173518] [refresh] Read only changes are not shown in RSE until the parent folder is refreshed
|
||||||
* Kevin Doyle (IBM) - [197976] Changing a file to read-only when it is open doesn't update local copy
|
* Kevin Doyle (IBM) - [197976] Changing a file to read-only when it is open doesn't update local copy
|
||||||
* Kevin Doyle (IBM) - [186125] Changing encoding of a file is not reflected when it was opened before
|
* Kevin Doyle (IBM) - [186125] Changing encoding of a file is not reflected when it was opened before
|
||||||
|
* David McKnight (IBM) - [209660] use parent encoding as default, rather than system encoding
|
||||||
********************************************************************************/
|
********************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.rse.internal.files.ui.propertypages;
|
package org.eclipse.rse.internal.files.ui.propertypages;
|
||||||
|
@ -41,6 +42,7 @@ import org.eclipse.rse.services.clientserver.messages.SystemMessageException;
|
||||||
import org.eclipse.rse.services.files.RemoteFileIOException;
|
import org.eclipse.rse.services.files.RemoteFileIOException;
|
||||||
import org.eclipse.rse.services.files.RemoteFileSecurityException;
|
import org.eclipse.rse.services.files.RemoteFileSecurityException;
|
||||||
import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile;
|
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.IVirtualRemoteFile;
|
import org.eclipse.rse.subsystems.files.core.subsystems.IVirtualRemoteFile;
|
||||||
import org.eclipse.rse.subsystems.files.core.subsystems.RemoteFileEncodingManager;
|
import org.eclipse.rse.subsystems.files.core.subsystems.RemoteFileEncodingManager;
|
||||||
import org.eclipse.rse.ui.ISystemMessages;
|
import org.eclipse.rse.ui.ISystemMessages;
|
||||||
|
@ -213,12 +215,15 @@ public class SystemFilePropertyPage extends SystemBasePropertyPage
|
||||||
};
|
};
|
||||||
|
|
||||||
// default encoding field
|
// default encoding field
|
||||||
defaultEncoding = file.getParentRemoteFileSubSystem().getRemoteEncoding();
|
defaultEncoding = file.getParentRemoteFile().getEncoding();
|
||||||
|
|
||||||
String defaultEncodingLabel = SystemFileResources.RESID_PP_FILE_ENCODING_DEFAULT_LABEL;
|
String defaultEncodingLabel = SystemFileResources.RESID_PP_FILE_ENCODING_DEFAULT_LABEL;
|
||||||
int idx = defaultEncodingLabel.indexOf('%');
|
int idx = defaultEncodingLabel.indexOf('%');
|
||||||
|
|
||||||
if (idx != -1) {
|
if (idx != -1) {
|
||||||
defaultEncodingLabel = defaultEncodingLabel.substring(0, idx) + file.getParentRemoteFileSubSystem().getRemoteEncoding() + defaultEncodingLabel.substring(idx+2);
|
defaultEncodingLabel = defaultEncodingLabel.substring(0, idx) +
|
||||||
|
defaultEncoding +
|
||||||
|
defaultEncodingLabel.substring(idx+2);
|
||||||
}
|
}
|
||||||
|
|
||||||
defaultEncodingButton = SystemWidgetHelpers.createRadioButton(encodingGroup, null, defaultEncodingLabel, SystemFileResources.RESID_PP_FILE_ENCODING_DEFAULT_TOOLTIP);
|
defaultEncodingButton = SystemWidgetHelpers.createRadioButton(encodingGroup, null, defaultEncodingLabel, SystemFileResources.RESID_PP_FILE_ENCODING_DEFAULT_TOOLTIP);
|
||||||
|
@ -541,8 +546,23 @@ public class SystemFilePropertyPage extends SystemBasePropertyPage
|
||||||
|
|
||||||
// set the encoding
|
// set the encoding
|
||||||
String selectedEncoding = getSelectedEncoding();
|
String selectedEncoding = getSelectedEncoding();
|
||||||
|
|
||||||
|
|
||||||
if (ok && encodingFieldAdded && prevEncoding != null && !prevEncoding.equals(selectedEncoding)) {
|
if (ok && encodingFieldAdded && prevEncoding != null && !prevEncoding.equals(selectedEncoding)) {
|
||||||
RemoteFileEncodingManager.getInstance().setEncoding(getRemoteFile().getParentRemoteFileSubSystem().getHost().getHostName(), getRemoteFile().getAbsolutePath(), selectedEncoding);
|
IRemoteFile rfile = getRemoteFile();
|
||||||
|
IRemoteFileSubSystem subsys = rfile.getParentRemoteFileSubSystem();
|
||||||
|
String hostName = subsys.getHost().getHostName();
|
||||||
|
|
||||||
|
RemoteFileEncodingManager mgr = RemoteFileEncodingManager.getInstance();
|
||||||
|
if (defaultEncodingButton.getSelection())
|
||||||
|
{
|
||||||
|
mgr.setEncoding(hostName, rfile.getAbsolutePath(),null);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mgr.setEncoding(hostName, rfile.getAbsolutePath(), getSelectedEncoding());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
SystemEditableRemoteFile editable = new SystemEditableRemoteFile(remoteFile);
|
SystemEditableRemoteFile editable = new SystemEditableRemoteFile(remoteFile);
|
||||||
if (editable.checkOpenInEditor() != ISystemEditableRemoteObject.NOT_OPEN) {
|
if (editable.checkOpenInEditor() != ISystemEditableRemoteObject.NOT_OPEN) {
|
||||||
|
|
|
@ -37,6 +37,7 @@
|
||||||
* David McKnight (IBM) - [208803] add exists() method
|
* David McKnight (IBM) - [208803] add exists() method
|
||||||
* David McKnight (IBM) - [209375] download using copyRemoteResourcesToWorkspaceMultiple
|
* David McKnight (IBM) - [209375] download using copyRemoteResourcesToWorkspaceMultiple
|
||||||
* Rupen Mardirossian (IBM) - [208435] added constructor to nested RenameRunnable class to take in names that are previously used as a parameter for multiple renaming instances
|
* Rupen Mardirossian (IBM) - [208435] added constructor to nested RenameRunnable class to take in names that are previously used as a parameter for multiple renaming instances
|
||||||
|
* David McKnight (IBM) - [209660] need to check if remote encoding has changed before using cached file
|
||||||
********************************************************************************/
|
********************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.rse.internal.files.ui.view;
|
package org.eclipse.rse.internal.files.ui.view;
|
||||||
|
@ -2972,7 +2973,12 @@ public class SystemViewRemoteFileAdapter
|
||||||
boolean dirty = properties.getDirty();
|
boolean dirty = properties.getDirty();
|
||||||
|
|
||||||
boolean remoteNewer = (storedModifiedStamp != remoteModifiedStamp);
|
boolean remoteNewer = (storedModifiedStamp != remoteModifiedStamp);
|
||||||
return (!dirty && !remoteNewer);
|
|
||||||
|
String remoteEncoding = remoteFile.getEncoding();
|
||||||
|
String storedEncoding = properties.getEncoding();
|
||||||
|
|
||||||
|
boolean encodingChanged = storedEncoding == null || !(remoteEncoding.equals(storedEncoding));
|
||||||
|
return (!dirty && !remoteNewer && !encodingChanged);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,8 +13,9 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Martin Oberhuber (Wind River) - [177523] Unify singleton getter methods
|
* Martin Oberhuber (Wind River) - [177523] Unify singleton getter methods
|
||||||
* David McKnight (IBM) - [173518] [refresh] Read only changes are not shown in RSE until the parent folder is refreshed
|
* David McKnight (IBM) - [173518] [refresh] Read only changes are not shown in RSE until the parent folder is refreshed
|
||||||
* David McKnight (IBM) - [186363] get rid of obsolete calls to ISubSystem.connect()
|
* David McKnight (IBM) - [186363] get rid of obsolete calls to ISubSystem.connect()
|
||||||
|
* David McKnight (IBM) - [209660] use parent encoding as default, rather than system encoding
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.rse.subsystems.files.core.subsystems;
|
package org.eclipse.rse.subsystems.files.core.subsystems;
|
||||||
|
@ -1124,28 +1125,70 @@ public abstract class RemoteFile implements IRemoteFile, IAdaptable, Comparable
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the encoding of the remote file. Queries {@link RemoteFileEncodingManager} for the encoding of the remote file.
|
private String getParentPathFor(String path)
|
||||||
* @return the encoding of the remote file.
|
{
|
||||||
* @see org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile#getEncoding()
|
boolean isUnix = getParentRemoteFileSubSystem().getParentRemoteFileSubSystemConfiguration().isUnixStyle();
|
||||||
|
|
||||||
|
String separator = getSeparator();
|
||||||
|
|
||||||
|
if (isUnix && path.equals(separator))
|
||||||
|
{
|
||||||
|
return null; // no parent of root
|
||||||
|
}
|
||||||
|
|
||||||
|
int lastSep = path.lastIndexOf(separator);
|
||||||
|
|
||||||
|
if (lastSep == 0) // root is the parent (on unix)
|
||||||
|
{
|
||||||
|
return separator;
|
||||||
|
}
|
||||||
|
else if (lastSep > 0)
|
||||||
|
{
|
||||||
|
return path.substring(0, lastSep);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the encoding of the remote file. If a user specified value does not exist, then we check
|
||||||
|
* it's ancestry for an encoding. Otherwise the encoding of the parent subsystem is returned.
|
||||||
|
* @see com.ibm.etools.systems.subsystems.IRemoteFile#getEncoding()
|
||||||
*/
|
*/
|
||||||
public String getEncoding() {
|
public String getEncoding() {
|
||||||
|
String hostName = getParentRemoteFileSubSystem().getHost().getHostName();
|
||||||
|
String path = getAbsolutePath();
|
||||||
|
String encoding = RemoteFileEncodingManager.getInstance().getEncoding(hostName, path);
|
||||||
|
|
||||||
String encoding = RemoteFileEncodingManager.getInstance().getEncoding(getHostName(), getAbsolutePath());
|
// ask the parent folder
|
||||||
|
|
||||||
if (encoding == null) {
|
if (encoding == null) {
|
||||||
|
if (_parentFile != null)
|
||||||
if (isRoot()) {
|
{
|
||||||
encoding = getParentRemoteFileSubSystem().getRemoteEncoding();
|
encoding = _parentFile.getEncoding();
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
encoding = getParentRemoteFile().getEncoding();
|
{
|
||||||
|
|
||||||
|
// manually extra parents
|
||||||
|
String parentPath = getParentPathFor(path);
|
||||||
|
while (parentPath != null && encoding == null)
|
||||||
|
{
|
||||||
|
encoding = RemoteFileEncodingManager.getInstance().getEncoding(hostName, parentPath);
|
||||||
|
parentPath = getParentPathFor(parentPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (encoding == null) // no encoding found - fall back to system
|
||||||
|
{
|
||||||
|
encoding = getParentRemoteFileSubSystem().getRemoteEncoding();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return encoding;
|
return encoding;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the encoding of the remote file. It sets the encoding of the remote file in {@link RemoteFileEncodingManager}.
|
* Sets the encoding of the remote file. It sets the encoding of the remote file in {@link RemoteFileEncodingManager}.
|
||||||
* @param encoding the encoding to be set for the remote file.
|
* @param encoding the encoding to be set for the remote file.
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Kushal Munir IBM - Initial creation of this file.
|
* Kushal Munir IBM - Initial creation of this file.
|
||||||
|
* David McKnight (IBM) [209660] delete encoding mapping when null is specified
|
||||||
********************************************************************************/
|
********************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.rse.subsystems.files.core.subsystems;
|
package org.eclipse.rse.subsystems.files.core.subsystems;
|
||||||
|
@ -125,12 +126,23 @@ public class RemoteFileEncodingManager {
|
||||||
if (hostMap.containsKey(hostname)) {
|
if (hostMap.containsKey(hostname)) {
|
||||||
props = (Properties)(hostMap.get(hostname));
|
props = (Properties)(hostMap.get(hostname));
|
||||||
}
|
}
|
||||||
else {
|
else if (encoding != null)
|
||||||
|
{
|
||||||
props = new Properties();
|
props = new Properties();
|
||||||
}
|
}
|
||||||
|
|
||||||
props.setProperty(remotePath, encoding);
|
if (props != null)
|
||||||
hostMap.put(hostname, props);
|
{
|
||||||
|
if (encoding == null)
|
||||||
|
{
|
||||||
|
props.remove(remotePath);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
props.setProperty(remotePath, encoding);
|
||||||
|
hostMap.put(hostname, props);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue