mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-04 15:45:25 +02:00
[209703] apply encoding and updating remote file when apply on property page
This commit is contained in:
parent
2c9401392e
commit
4a7849ceec
2 changed files with 84 additions and 3 deletions
|
@ -10,7 +10,8 @@
|
|||
*
|
||||
* Contributors:
|
||||
* David McKnight (IBM) - [209593] [api] add support for "file permissions" and "owner" properties for unix files
|
||||
********************************************************************************/
|
||||
* David McKnight (IBM) - [209703] apply encoding and updating remote file when apply on property page
|
||||
* ********************************************************************************/
|
||||
package org.eclipse.rse.internal.files.ui.propertypages;
|
||||
|
||||
import org.eclipse.core.runtime.IAdaptable;
|
||||
|
@ -69,7 +70,10 @@ public class SystemFilePermissionsPropertyPage extends SystemBasePropertyPage {
|
|||
protected IRemoteFile getRemoteFile()
|
||||
{
|
||||
Object element = getElement();
|
||||
return ((IRemoteFile)element);
|
||||
IRemoteFile file = (IRemoteFile)element;
|
||||
|
||||
|
||||
return file;
|
||||
}
|
||||
|
||||
protected Control createContentArea(Composite parent) {
|
||||
|
@ -414,6 +418,7 @@ public class SystemFilePermissionsPropertyPage extends SystemBasePropertyPage {
|
|||
}
|
||||
|
||||
if (changed){
|
||||
remoteFile.markStale(true);
|
||||
// notify views of change
|
||||
ISystemRegistry registry = RSECorePlugin.getTheSystemRegistry();
|
||||
registry.fireEvent(new SystemResourceChangeEvent(remoteFile, ISystemResourceChangeEvents.EVENT_PROPERTY_CHANGE, remoteFile));
|
||||
|
@ -423,4 +428,37 @@ public class SystemFilePermissionsPropertyPage extends SystemBasePropertyPage {
|
|||
return super.performOk();
|
||||
}
|
||||
|
||||
protected boolean wantDefaultAndApplyButton()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
protected void performApply() {
|
||||
performOk();
|
||||
}
|
||||
|
||||
protected void performDefaults() {
|
||||
IRemoteFile file = getRemoteFile();
|
||||
IFilePermissionsService service = (IFilePermissionsService)((IAdaptable)file).getAdapter(IFilePermissionsService.class);
|
||||
initPermissionFields(file, service);
|
||||
}
|
||||
|
||||
public void setVisible(boolean visible) {
|
||||
if (visible){
|
||||
IRemoteFile file = getRemoteFile();
|
||||
if (file.isStale()){ // has file changed?
|
||||
try
|
||||
{
|
||||
file = file.getParentRemoteFileSubSystem().getRemoteFileObject(file.getAbsolutePath(), new NullProgressMonitor());
|
||||
}
|
||||
catch (Exception e){
|
||||
}
|
||||
setElement((IAdaptable)file);
|
||||
|
||||
// reset according to the changed file
|
||||
performDefaults();
|
||||
}
|
||||
}
|
||||
super.setVisible(visible);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
* 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
|
||||
* David McKnight (IBM) - [209660] use parent encoding as default, rather than system encoding
|
||||
* David McKnight (IBM) - [209703] apply encoding and updating remote file when apply on property page
|
||||
********************************************************************************/
|
||||
|
||||
package org.eclipse.rse.internal.files.ui.propertypages;
|
||||
|
@ -30,6 +31,7 @@ import java.util.List;
|
|||
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IAdaptable;
|
||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||
import org.eclipse.rse.core.RSECorePlugin;
|
||||
import org.eclipse.rse.core.events.ISystemResourceChangeEvents;
|
||||
|
@ -102,6 +104,8 @@ public class SystemFilePropertyPage extends SystemBasePropertyPage
|
|||
{
|
||||
super();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create the page's GUI contents.
|
||||
*/
|
||||
|
@ -374,7 +378,9 @@ public class SystemFilePropertyPage extends SystemBasePropertyPage
|
|||
protected IRemoteFile getRemoteFile()
|
||||
{
|
||||
Object element = getElement();
|
||||
return ((IRemoteFile)element);
|
||||
IRemoteFile file = (IRemoteFile)element;
|
||||
|
||||
return file;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -515,6 +521,8 @@ public class SystemFilePropertyPage extends SystemBasePropertyPage
|
|||
// refresh
|
||||
ISystemRegistry sr = RSECorePlugin.getTheSystemRegistry();
|
||||
|
||||
remoteFile.markStale(true);
|
||||
|
||||
// oldCanWrite and updatedValue may not be the same depending on the underlying file service
|
||||
// If the file service updates the underlying object, then there is no need for a remote refresh
|
||||
if (oldCanWrite == updatedValue)
|
||||
|
@ -572,11 +580,26 @@ public class SystemFilePropertyPage extends SystemBasePropertyPage
|
|||
} catch (CoreException e) {
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
protected boolean wantDefaultAndApplyButton()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
protected void performApply() {
|
||||
performOk();
|
||||
}
|
||||
|
||||
protected void performDefaults() {
|
||||
doInitializeFields();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Validate all the widgets on the page
|
||||
* <p>
|
||||
|
@ -597,4 +620,24 @@ public class SystemFilePropertyPage extends SystemBasePropertyPage
|
|||
|
||||
}
|
||||
|
||||
|
||||
public void setVisible(boolean visible) {
|
||||
if (visible){
|
||||
IRemoteFile file = getRemoteFile();
|
||||
if (file.isStale()){ // has file changed?
|
||||
try
|
||||
{
|
||||
file = file.getParentRemoteFileSubSystem().getRemoteFileObject(file.getAbsolutePath(), new NullProgressMonitor());
|
||||
}
|
||||
catch (Exception e){
|
||||
}
|
||||
setElement((IAdaptable)file);
|
||||
|
||||
// reset according to the changed file
|
||||
performDefaults();
|
||||
}
|
||||
}
|
||||
super.setVisible(visible);
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Reference in a new issue