mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-09-02 13:13:36 +02:00
[186125] Changing encoding of a file is not reflected when it was opened before
This commit is contained in:
parent
3d2a16aeb2
commit
0dfacdf39d
2 changed files with 24 additions and 13 deletions
|
@ -18,6 +18,7 @@
|
||||||
* David Dykstal (IBM) - [160776] format file size according to client system conventions and locale
|
* David Dykstal (IBM) - [160776] format file size according to client system conventions and locale
|
||||||
* 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
|
||||||
********************************************************************************/
|
********************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.rse.internal.files.ui.propertypages;
|
package org.eclipse.rse.internal.files.ui.propertypages;
|
||||||
|
@ -26,6 +27,8 @@ import java.nio.charset.IllegalCharsetNameException;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.eclipse.core.resources.IFile;
|
||||||
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||||
import org.eclipse.rse.core.RSECorePlugin;
|
import org.eclipse.rse.core.RSECorePlugin;
|
||||||
import org.eclipse.rse.core.events.ISystemResourceChangeEvents;
|
import org.eclipse.rse.core.events.ISystemResourceChangeEvents;
|
||||||
|
@ -84,6 +87,7 @@ public class SystemFilePropertyPage extends SystemBasePropertyPage
|
||||||
protected String errorMessage;
|
protected String errorMessage;
|
||||||
protected boolean initDone = false;
|
protected boolean initDone = false;
|
||||||
protected boolean wasReadOnly = false;
|
protected boolean wasReadOnly = false;
|
||||||
|
protected String prevEncoding;
|
||||||
|
|
||||||
private boolean encodingFieldAdded = false;
|
private boolean encodingFieldAdded = false;
|
||||||
private String defaultEncoding = null;
|
private String defaultEncoding = null;
|
||||||
|
@ -457,7 +461,8 @@ public class SystemFilePropertyPage extends SystemBasePropertyPage
|
||||||
otherEncodingCombo.setItems(encodingStrings);
|
otherEncodingCombo.setItems(encodingStrings);
|
||||||
|
|
||||||
String encoding = file.getEncoding();
|
String encoding = file.getEncoding();
|
||||||
|
prevEncoding = encoding;
|
||||||
|
|
||||||
// if the encoding is the same as the default encoding, then we want to choose the default encoding option
|
// if the encoding is the same as the default encoding, then we want to choose the default encoding option
|
||||||
if (encoding.equalsIgnoreCase(defaultEncoding)) {
|
if (encoding.equalsIgnoreCase(defaultEncoding)) {
|
||||||
updateEncodingGroupState(true);
|
updateEncodingGroupState(true);
|
||||||
|
@ -477,14 +482,14 @@ public class SystemFilePropertyPage extends SystemBasePropertyPage
|
||||||
{
|
{
|
||||||
boolean ok = super.performOk();
|
boolean ok = super.performOk();
|
||||||
boolean readOnlySelected = cbReadonlyPrompt != null ? cbReadonlyPrompt.getSelection() : false;
|
boolean readOnlySelected = cbReadonlyPrompt != null ? cbReadonlyPrompt.getSelection() : false;
|
||||||
|
IRemoteFile remoteFile = getRemoteFile();
|
||||||
|
|
||||||
if (ok && (cbReadonlyPrompt!=null) &&
|
if (ok && (cbReadonlyPrompt!=null) &&
|
||||||
((readOnlySelected && !wasReadOnly) ||
|
((readOnlySelected && !wasReadOnly) ||
|
||||||
(!readOnlySelected && wasReadOnly)))
|
(!readOnlySelected && wasReadOnly)))
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
IRemoteFile remoteFile = getRemoteFile();
|
|
||||||
|
|
||||||
// get old can write attribute
|
// get old can write attribute
|
||||||
boolean oldCanWrite = remoteFile.canWrite();
|
boolean oldCanWrite = remoteFile.canWrite();
|
||||||
|
|
||||||
|
@ -535,8 +540,18 @@ public class SystemFilePropertyPage extends SystemBasePropertyPage
|
||||||
}
|
}
|
||||||
|
|
||||||
// set the encoding
|
// set the encoding
|
||||||
if (encodingFieldAdded) {
|
String selectedEncoding = getSelectedEncoding();
|
||||||
RemoteFileEncodingManager.getInstance().setEncoding(getRemoteFile().getParentRemoteFileSubSystem().getHost().getHostName(), getRemoteFile().getAbsolutePath(), getSelectedEncoding());
|
if (ok && encodingFieldAdded && prevEncoding != null && !prevEncoding.equals(selectedEncoding)) {
|
||||||
|
RemoteFileEncodingManager.getInstance().setEncoding(getRemoteFile().getParentRemoteFileSubSystem().getHost().getHostName(), getRemoteFile().getAbsolutePath(), selectedEncoding);
|
||||||
|
|
||||||
|
SystemEditableRemoteFile editable = new SystemEditableRemoteFile(remoteFile);
|
||||||
|
if (editable.checkOpenInEditor() != ISystemEditableRemoteObject.NOT_OPEN) {
|
||||||
|
IFile file = editable.getLocalResource();
|
||||||
|
try {
|
||||||
|
file.setCharset(selectedEncoding, null);
|
||||||
|
} catch (CoreException e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return ok;
|
return ok;
|
||||||
|
|
|
@ -33,6 +33,7 @@
|
||||||
* Xuan Chen (IBM) - [202949] [archives] copy a folder from one connection to an archive file in a different connection does not work
|
* Xuan Chen (IBM) - [202949] [archives] copy a folder from one connection to an archive file in a different connection does not work
|
||||||
* Kevin Doyle (IBM) - [204810] Saving file in Eclipse does not update remote file
|
* Kevin Doyle (IBM) - [204810] Saving file in Eclipse does not update remote file
|
||||||
* David McKnight (IBM) - [207178] changing list APIs for file service and subsystems
|
* David McKnight (IBM) - [207178] changing list APIs for file service and subsystems
|
||||||
|
* Kevin Doyle (IBM) - [186125] Changing encoding of a file is not reflected when it was opened before
|
||||||
********************************************************************************/
|
********************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.rse.internal.files.ui.view;
|
package org.eclipse.rse.internal.files.ui.view;
|
||||||
|
@ -274,11 +275,9 @@ public class SystemViewRemoteFileAdapter
|
||||||
boolean isArchive = false;
|
boolean isArchive = false;
|
||||||
|
|
||||||
boolean canRead = true;
|
boolean canRead = true;
|
||||||
boolean canWrite = true;
|
|
||||||
boolean supportsSearch = true;
|
boolean supportsSearch = true;
|
||||||
boolean supportsArchiveManagement = false;
|
boolean supportsArchiveManagement = false;
|
||||||
|
|
||||||
|
|
||||||
// perf improvement... phil
|
// perf improvement... phil
|
||||||
Object firstSelection = selection.getFirstElement();
|
Object firstSelection = selection.getFirstElement();
|
||||||
IRemoteFile firstFile = null;
|
IRemoteFile firstFile = null;
|
||||||
|
@ -288,7 +287,6 @@ public class SystemViewRemoteFileAdapter
|
||||||
elementType = firstFile.isDirectory() || firstFile.isRoot() ? 1 : 0;
|
elementType = firstFile.isDirectory() || firstFile.isRoot() ? 1 : 0;
|
||||||
isArchive = firstFile.isArchive();
|
isArchive = firstFile.isArchive();
|
||||||
canRead = firstFile.canRead();
|
canRead = firstFile.canRead();
|
||||||
canWrite = firstFile.canWrite();
|
|
||||||
|
|
||||||
supportsSearch = firstFile.getParentRemoteFileSubSystem().getParentRemoteFileSubSystemConfiguration().supportsSearch();
|
supportsSearch = firstFile.getParentRemoteFileSubSystem().getParentRemoteFileSubSystemConfiguration().supportsSearch();
|
||||||
supportsArchiveManagement = firstFile.getParentRemoteFileSubSystem().getParentRemoteFileSubSystemConfiguration().supportsArchiveManagement();
|
supportsArchiveManagement = firstFile.getParentRemoteFileSubSystem().getParentRemoteFileSubSystemConfiguration().supportsArchiveManagement();
|
||||||
|
@ -2511,7 +2509,6 @@ public class SystemViewRemoteFileAdapter
|
||||||
boolean ok = true;
|
boolean ok = true;
|
||||||
IRemoteFile file = (IRemoteFile) element;
|
IRemoteFile file = (IRemoteFile) element;
|
||||||
IRemoteFileSubSystem ss = file.getParentRemoteFileSubSystem();
|
IRemoteFileSubSystem ss = file.getParentRemoteFileSubSystem();
|
||||||
ISystemRegistry sr = RSECorePlugin.getTheSystemRegistry();
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -2844,15 +2841,14 @@ public class SystemViewRemoteFileAdapter
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
boolean openedInSamePerspective = (editable.checkOpenInEditor() == ISystemEditableRemoteObject.OPEN_IN_SAME_PERSPECTIVE);
|
boolean isOpen = editable.checkOpenInEditor() != ISystemEditableRemoteObject.NOT_OPEN;
|
||||||
boolean isFileCached = isFileCached(editable, remoteFile);
|
boolean isFileCached = isFileCached(editable, remoteFile);
|
||||||
if (isFileCached)
|
if (isFileCached)
|
||||||
{
|
{
|
||||||
if (openedInSamePerspective)
|
if (!isOpen) {
|
||||||
{
|
|
||||||
editable.setLocalResourceProperties();
|
editable.setLocalResourceProperties();
|
||||||
|
editable.addAsListener();
|
||||||
}
|
}
|
||||||
editable.addAsListener();
|
|
||||||
editable.openEditor();
|
editable.openEditor();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
Loading…
Add table
Reference in a new issue