From 9cacea7c6dc7db6c45be59d534cfacf58eb12058 Mon Sep 17 00:00:00 2001 From: Kushal Munir < kmunir@ca.ibm.com> Date: Fri, 25 May 2007 01:15:23 +0000 Subject: [PATCH] [179937] Add the encoding to the Get from remote system string in the property page to show the encoding that was obtained. --- .../rse/internal/ui/SystemResources.java | 1 + .../internal/ui/SystemResources.properties | 1 + .../eclipse/rse/ui/SystemConnectionForm.java | 49 +++++++++++++++---- 3 files changed, 41 insertions(+), 10 deletions(-) diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/SystemResources.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/SystemResources.java index c7f16b0839e..75257efcec3 100644 --- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/SystemResources.java +++ b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/SystemResources.java @@ -1229,6 +1229,7 @@ public class SystemResources extends NLS public static String RESID_HOST_ENCODING_SETTING_NOTE; public static String RESID_HOST_ENCODING_SETTING_MSG; public static String RESID_HOST_ENCODING_REMOTE_LABEL; + public static String RESID_HOST_ENCODING_REMOTE_ENCODING_LABEL; public static String RESID_HOST_ENCODING_REMOTE_TOOLTIP; public static String RESID_HOST_ENCODING_OTHER_LABEL; public static String RESID_HOST_ENCODING_OTHER_TOOLTIP; diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/SystemResources.properties b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/SystemResources.properties index 0644fbe5e71..74ced248e0b 100644 --- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/SystemResources.properties +++ b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/SystemResources.properties @@ -1425,6 +1425,7 @@ RESID_HOST_ENCODING_GROUP_LABEL=Default encoding RESID_HOST_ENCODING_SETTING_NOTE=Note: RESID_HOST_ENCODING_SETTING_MSG=This setting can only be changed when no subsystem is connected RESID_HOST_ENCODING_REMOTE_LABEL=Default from remote system +RESID_HOST_ENCODING_REMOTE_ENCODING_LABEL=Default from remote system (%1) RESID_HOST_ENCODING_REMOTE_TOOLTIP=The default encoding of the platform obtained from the remote system RESID_HOST_ENCODING_OTHER_LABEL=Other: RESID_HOST_ENCODING_OTHER_TOOLTIP=Specify a different encoding diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/SystemConnectionForm.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/SystemConnectionForm.java index a2332ba12e9..985e6470f3e 100644 --- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/SystemConnectionForm.java +++ b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/SystemConnectionForm.java @@ -827,13 +827,6 @@ public class SystemConnectionForm implements Listener, SelectionListener, Runnab data.grabExcessVerticalSpace = false; encodingGroup.setLayoutData(data); - SelectionAdapter buttonSelectionListener = new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - updateEncodingGroupState(remoteEncodingButton.getSelection()); - validateEncoding(); - } - }; - Composite messageComposite = new Composite(encodingGroup, SWT.NONE); GridLayout messageLayout = new GridLayout(); messageLayout.numColumns = 2; @@ -862,12 +855,38 @@ public class SystemConnectionForm implements Listener, SelectionListener, Runnab // remote encoding field String defaultEncodingLabel = SystemResources.RESID_HOST_ENCODING_REMOTE_LABEL; + // check if user set encoding + // if so, we leave default encoding label as is + // if not, we check if remote encoding is set, and if it is, include the encoding in the label + if (conn.getDefaultEncoding(false) == null) { + + String remoteEncoding = conn.getDefaultEncoding(true); + + if (remoteEncoding != null) { + defaultEncodingLabel = SystemResources.RESID_HOST_ENCODING_REMOTE_ENCODING_LABEL; + + int idx = defaultEncodingLabel.indexOf('%'); + + if (idx != -1) { + defaultEncodingLabel = defaultEncodingLabel.substring(0, idx) + remoteEncoding + defaultEncodingLabel.substring(idx+2); + } + } + } + remoteEncodingButton = SystemWidgetHelpers.createRadioButton(encodingGroup, null, defaultEncodingLabel, SystemResources.RESID_HOST_ENCODING_REMOTE_TOOLTIP); data = new GridData(); data.horizontalSpan = 2; data.grabExcessHorizontalSpace = true; remoteEncodingButton.setLayoutData(data); - remoteEncodingButton.addSelectionListener(buttonSelectionListener); + + SelectionAdapter remoteButtonSelectionListener = new SelectionAdapter() { + public void widgetSelected(SelectionEvent e) { + updateEncodingGroupState(remoteEncodingButton.getSelection()); + validateEncoding(); + } + }; + + remoteEncodingButton.addSelectionListener(remoteButtonSelectionListener); Composite otherComposite = new Composite(encodingGroup, SWT.NONE); GridLayout otherLayout = new GridLayout(); @@ -882,7 +901,15 @@ public class SystemConnectionForm implements Listener, SelectionListener, Runnab data = new GridData(); data.grabExcessHorizontalSpace = false; otherEncodingButton.setLayoutData(data); - otherEncodingButton.addSelectionListener(buttonSelectionListener); + + SelectionAdapter otherButtonSelectionListener = new SelectionAdapter() { + public void widgetSelected(SelectionEvent e) { + updateEncodingGroupState(!otherEncodingButton.getSelection()); + validateEncoding(); + } + }; + + otherEncodingButton.addSelectionListener(otherButtonSelectionListener); // other encoding combo otherEncodingCombo = SystemWidgetHelpers.createCombo(otherComposite, null, SystemResources.RESID_HOST_ENCODING_ENTER_TOOLTIP); @@ -935,7 +962,6 @@ public class SystemConnectionForm implements Listener, SelectionListener, Runnab } } - otherEncodingCombo.setEnabled(!useDefault); validateEncoding(); } @@ -1217,6 +1243,9 @@ public class SystemConnectionForm implements Listener, SelectionListener, Runnab // disable if any subsystem is connected if (!conn.getSystemType().getId().equalsIgnoreCase(IRSESystemType.SYSTEMTYPE_LOCAL_ID) && sr.isAnySubSystemConnected(conn)) { encodingGroup.setEnabled(false); + remoteEncodingButton.setEnabled(false); + otherEncodingButton.setEnabled(false); + otherEncodingCombo.setEnabled(false); } }