mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-23 08:55:25 +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 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) - [186125] Changing encoding of a file is not reflected when it was opened before
|
||||
********************************************************************************/
|
||||
|
||||
package org.eclipse.rse.internal.files.ui.propertypages;
|
||||
|
@ -26,6 +27,8 @@ import java.nio.charset.IllegalCharsetNameException;
|
|||
import java.util.Date;
|
||||
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.rse.core.RSECorePlugin;
|
||||
import org.eclipse.rse.core.events.ISystemResourceChangeEvents;
|
||||
|
@ -84,6 +87,7 @@ public class SystemFilePropertyPage extends SystemBasePropertyPage
|
|||
protected String errorMessage;
|
||||
protected boolean initDone = false;
|
||||
protected boolean wasReadOnly = false;
|
||||
protected String prevEncoding;
|
||||
|
||||
private boolean encodingFieldAdded = false;
|
||||
private String defaultEncoding = null;
|
||||
|
@ -457,7 +461,8 @@ public class SystemFilePropertyPage extends SystemBasePropertyPage
|
|||
otherEncodingCombo.setItems(encodingStrings);
|
||||
|
||||
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 (encoding.equalsIgnoreCase(defaultEncoding)) {
|
||||
updateEncodingGroupState(true);
|
||||
|
@ -477,14 +482,14 @@ public class SystemFilePropertyPage extends SystemBasePropertyPage
|
|||
{
|
||||
boolean ok = super.performOk();
|
||||
boolean readOnlySelected = cbReadonlyPrompt != null ? cbReadonlyPrompt.getSelection() : false;
|
||||
IRemoteFile remoteFile = getRemoteFile();
|
||||
|
||||
if (ok && (cbReadonlyPrompt!=null) &&
|
||||
((readOnlySelected && !wasReadOnly) ||
|
||||
(!readOnlySelected && wasReadOnly)))
|
||||
{
|
||||
try
|
||||
{
|
||||
IRemoteFile remoteFile = getRemoteFile();
|
||||
|
||||
// get old can write attribute
|
||||
boolean oldCanWrite = remoteFile.canWrite();
|
||||
|
||||
|
@ -535,8 +540,18 @@ public class SystemFilePropertyPage extends SystemBasePropertyPage
|
|||
}
|
||||
|
||||
// set the encoding
|
||||
if (encodingFieldAdded) {
|
||||
RemoteFileEncodingManager.getInstance().setEncoding(getRemoteFile().getParentRemoteFileSubSystem().getHost().getHostName(), getRemoteFile().getAbsolutePath(), getSelectedEncoding());
|
||||
String selectedEncoding = 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;
|
||||
|
|
|
@ -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
|
||||
* 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
|
||||
* 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;
|
||||
|
@ -274,11 +275,9 @@ public class SystemViewRemoteFileAdapter
|
|||
boolean isArchive = false;
|
||||
|
||||
boolean canRead = true;
|
||||
boolean canWrite = true;
|
||||
boolean supportsSearch = true;
|
||||
boolean supportsArchiveManagement = false;
|
||||
|
||||
|
||||
// perf improvement... phil
|
||||
Object firstSelection = selection.getFirstElement();
|
||||
IRemoteFile firstFile = null;
|
||||
|
@ -288,7 +287,6 @@ public class SystemViewRemoteFileAdapter
|
|||
elementType = firstFile.isDirectory() || firstFile.isRoot() ? 1 : 0;
|
||||
isArchive = firstFile.isArchive();
|
||||
canRead = firstFile.canRead();
|
||||
canWrite = firstFile.canWrite();
|
||||
|
||||
supportsSearch = firstFile.getParentRemoteFileSubSystem().getParentRemoteFileSubSystemConfiguration().supportsSearch();
|
||||
supportsArchiveManagement = firstFile.getParentRemoteFileSubSystem().getParentRemoteFileSubSystemConfiguration().supportsArchiveManagement();
|
||||
|
@ -2511,7 +2509,6 @@ public class SystemViewRemoteFileAdapter
|
|||
boolean ok = true;
|
||||
IRemoteFile file = (IRemoteFile) element;
|
||||
IRemoteFileSubSystem ss = file.getParentRemoteFileSubSystem();
|
||||
ISystemRegistry sr = RSECorePlugin.getTheSystemRegistry();
|
||||
try
|
||||
{
|
||||
|
||||
|
@ -2844,15 +2841,14 @@ public class SystemViewRemoteFileAdapter
|
|||
{
|
||||
try
|
||||
{
|
||||
boolean openedInSamePerspective = (editable.checkOpenInEditor() == ISystemEditableRemoteObject.OPEN_IN_SAME_PERSPECTIVE);
|
||||
boolean isOpen = editable.checkOpenInEditor() != ISystemEditableRemoteObject.NOT_OPEN;
|
||||
boolean isFileCached = isFileCached(editable, remoteFile);
|
||||
if (isFileCached)
|
||||
{
|
||||
if (openedInSamePerspective)
|
||||
{
|
||||
if (!isOpen) {
|
||||
editable.setLocalResourceProperties();
|
||||
editable.addAsListener();
|
||||
}
|
||||
editable.addAsListener();
|
||||
editable.openEditor();
|
||||
}
|
||||
else
|
||||
|
|
Loading…
Add table
Reference in a new issue