mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-04 14:55:41 +02:00
[179937] [api] New control in property page for connection. Added new API to IHost() to set and get default encodings and to SystemConnectionForm to deal with encoding fields for connection "Host" property page.
This commit is contained in:
parent
906cb6bee7
commit
58e1c330a1
11 changed files with 426 additions and 5 deletions
|
@ -252,5 +252,11 @@ public class DummyHost extends PlatformObject implements IHost
|
|||
|
||||
public void setTainted(boolean flag) {
|
||||
}
|
||||
|
||||
|
||||
public String getDefaultEncoding(boolean checkRemote) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setDefaultEncoding(String encoding, boolean fromRemote) {
|
||||
}
|
||||
}
|
|
@ -48,6 +48,10 @@ public class Host extends RSEModelObject implements IHost {
|
|||
private boolean userIdCaseSensitive = true;
|
||||
private ISystemHostPool pool;
|
||||
protected String previousUserIdKey;
|
||||
|
||||
private static final String ENCODING_PROPERTY_SET = "EncodingPropertySet"; //$NON-NLS-1$
|
||||
private static final String ENCODING_REMOTE_PROPERTY_KEY = "EncodingRemotePropertyKey"; //$NON-NLS-1$
|
||||
private static final String ENCODING_NON_REMOTE_PROPERTY_KEY = "EncodingNonRemotePropertyKey"; //$NON-NLS-1$
|
||||
|
||||
/**
|
||||
* The system type which is associated to this <code>IHost</code> object.
|
||||
|
@ -516,4 +520,77 @@ public class Host extends RSEModelObject implements IHost {
|
|||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* The default encoding of the host. If checkRemote is <code>false</code>, returns the encoding that was not set by querying a remote system
|
||||
* (for example, an encoding set by a user). If checkRemote is <code>true</code>, it first checks to see if there is an encoding that was set
|
||||
* without querying a remote system, and if an encoding does not exist, then it returns the encoding that was set by querying a remote system.
|
||||
* @param checkRemote <code>false</code> to get the encoding that was obtained by not querying the remote system, <code>true</code> to also check
|
||||
* the encoding, if needed, that was set by querying a remote system.
|
||||
* @return the default encoding of the host, or <code>null</code> if no encoding was set.
|
||||
* @see #setDefaultEncoding(String, boolean)
|
||||
*/
|
||||
public String getDefaultEncoding(boolean checkRemote) {
|
||||
|
||||
IPropertySet encPropertySet = getPropertySet(ENCODING_PROPERTY_SET);
|
||||
|
||||
if (encPropertySet == null) {
|
||||
return null;
|
||||
}
|
||||
else {
|
||||
String nonRemoteEncoding = encPropertySet.getPropertyValue(ENCODING_NON_REMOTE_PROPERTY_KEY);
|
||||
|
||||
if (nonRemoteEncoding != null) {
|
||||
return nonRemoteEncoding;
|
||||
}
|
||||
else {
|
||||
|
||||
if (!checkRemote) {
|
||||
return null;
|
||||
}
|
||||
else {
|
||||
String remoteEncoding = encPropertySet.getPropertyValue(ENCODING_REMOTE_PROPERTY_KEY);
|
||||
return remoteEncoding;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the default encoding of the host. The encoding can be set by querying the remote system or by some other means (for example, by a user).
|
||||
* @param encoding the encoding of the host, or <code>null</code> to erase the current encoding.
|
||||
* @param fromRemote <code>true</code> if the encoding is set by querying the remote system, or <code>false</code> otherwise.
|
||||
* @see #getDefaultEncoding(boolean)
|
||||
*/
|
||||
public void setDefaultEncoding(String encoding, boolean fromRemote) {
|
||||
|
||||
IPropertySet encPropertySet = getPropertySet(ENCODING_PROPERTY_SET);
|
||||
|
||||
if (encPropertySet == null) {
|
||||
encPropertySet = createPropertySet(ENCODING_PROPERTY_SET);
|
||||
}
|
||||
|
||||
if (encPropertySet != null) {
|
||||
|
||||
if (encoding != null) {
|
||||
|
||||
if (!fromRemote) {
|
||||
encPropertySet.addProperty(ENCODING_NON_REMOTE_PROPERTY_KEY, encoding);
|
||||
}
|
||||
else {
|
||||
encPropertySet.addProperty(ENCODING_REMOTE_PROPERTY_KEY, encoding);
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
if (!fromRemote) {
|
||||
encPropertySet.removeProperty(ENCODING_NON_REMOTE_PROPERTY_KEY);
|
||||
}
|
||||
else {
|
||||
encPropertySet.removeProperty(ENCODING_REMOTE_PROPERTY_KEY);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
commit();
|
||||
}
|
||||
}
|
|
@ -29,6 +29,7 @@ import org.eclipse.rse.core.subsystems.ISubSystem;
|
|||
* object oriented containment.
|
||||
*/
|
||||
public interface IHost extends IAdaptable, IRSEModelObject {
|
||||
|
||||
/**
|
||||
* Return the system profile that owns this connection
|
||||
* @return the profile which contains this host
|
||||
|
@ -186,6 +187,25 @@ public interface IHost extends IAdaptable, IRSEModelObject {
|
|||
* @return The value of the Promptable attribute
|
||||
*/
|
||||
boolean isPromptable();
|
||||
|
||||
/**
|
||||
* The default encoding of the host. If checkRemote is <code>false</code>, returns the encoding that was not set by querying a remote system
|
||||
* (for example, an encoding set by a user). If checkRemote is <code>true</code>, it first checks to see if there is an encoding that was set
|
||||
* without querying a remote system, and if an encoding does not exist, then it returns the encoding that was set by querying a remote system.
|
||||
* @param checkRemote <code>false</code> to get the encoding that was obtained by not querying the remote system, <code>true</code> to also check
|
||||
* the encoding, if needed, that was set by querying a remote system.
|
||||
* @return the default encoding of the host, or <code>null</code> if no encoding was set.
|
||||
* @see #setDefaultEncoding(String, boolean)
|
||||
*/
|
||||
public String getDefaultEncoding(boolean checkRemote);
|
||||
|
||||
/**
|
||||
* Sets the default encoding of the host. The encoding can be set by querying the remote system or by some other means (for example, by a user).
|
||||
* @param encoding the encoding of the host, or <code>null</code> to erase the current encoding.
|
||||
* @param fromRemote <code>true</code> if the encoding is set by querying the remote system, or <code>false</code> otherwise.
|
||||
* @see #getDefaultEncoding(boolean)
|
||||
*/
|
||||
public void setDefaultEncoding(String encoding, boolean fromRemote);
|
||||
|
||||
/**
|
||||
* Set the promptable attribute.
|
||||
|
|
|
@ -745,11 +745,35 @@ public final class FileServiceSubSystem extends RemoteFileSubSystem implements I
|
|||
* @see RemoteFileSubSystem#getRemoteEncoding()
|
||||
*/
|
||||
public String getRemoteEncoding() {
|
||||
|
||||
try {
|
||||
return getFileService().getEncoding(null);
|
||||
} catch (SystemMessageException e) {
|
||||
|
||||
IHost host = getHost();
|
||||
|
||||
// get the encoding from the host that was not set by the remote system
|
||||
String encoding = host.getDefaultEncoding(false);
|
||||
|
||||
// get the encoding from the host that was set by querying a remote system
|
||||
// this allows us to pick up the host encoding that may have been set by another subsystem
|
||||
if (encoding == null) {
|
||||
encoding = getFileService().getEncoding(null);
|
||||
|
||||
if (encoding != null) {
|
||||
host.setDefaultEncoding(encoding, true);
|
||||
}
|
||||
}
|
||||
|
||||
if (encoding != null) {
|
||||
return encoding;
|
||||
}
|
||||
else {
|
||||
return super.getRemoteEncoding();
|
||||
}
|
||||
}
|
||||
catch (SystemMessageException e) {
|
||||
SystemBasePlugin.logMessage(e.getSystemMessage());
|
||||
}
|
||||
|
||||
return super.getRemoteEncoding();
|
||||
}
|
||||
|
||||
|
|
|
@ -1443,11 +1443,27 @@ public abstract class RemoteFileSubSystem extends SubSystem implements IRemoteFi
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns the local platform encoding by default.
|
||||
* Returns the local platform encoding if the default encoding of the host was not set.
|
||||
* Subclasses should override to return the actual remote encoding.
|
||||
* @see org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFileSubSystem#getRemoteEncoding()
|
||||
*/
|
||||
public String getRemoteEncoding() {
|
||||
return System.getProperty("file.encoding"); //$NON-NLS-1$
|
||||
IHost host = getHost();
|
||||
|
||||
// get the encoding from the host that was not by the remote system
|
||||
String encoding = host.getDefaultEncoding(false);
|
||||
|
||||
// get the encoding from the host that was set by querying a remote system
|
||||
// this allows us to pick up the host encoding that may have been set by another subsystem
|
||||
if (encoding == null) {
|
||||
encoding = host.getDefaultEncoding(true);
|
||||
}
|
||||
|
||||
if (encoding != null) {
|
||||
return encoding;
|
||||
}
|
||||
else {
|
||||
return System.getProperty("file.encoding"); //$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1221,6 +1221,15 @@ public class SystemResources extends NLS
|
|||
public static String RESID_DO_NOT_SHOW_MESSAGE_AGAIN_LABEL;
|
||||
public static String RESID_DO_NOT_SHOW_MESSAGE_AGAIN_TOOLTIP;
|
||||
|
||||
// Encoding
|
||||
public static String RESID_HOST_ENCODING_GROUP_LABEL;
|
||||
public static String RESID_HOST_ENCODING_SETTING_MSG;
|
||||
public static String RESID_HOST_ENCODING_REMOTE_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;
|
||||
public static String RESID_HOST_ENCODING_ENTER_TOOLTIP;
|
||||
|
||||
static {
|
||||
// load message values from bundle file
|
||||
NLS.initializeMessages(BUNDLE_NAME, SystemResources.class);
|
||||
|
|
|
@ -1419,3 +1419,12 @@ RESID_SERVICESFORM_PROPERTIES_TOOLTIP=Edit the properties of the item selected i
|
|||
## Do not show this message again
|
||||
RESID_DO_NOT_SHOW_MESSAGE_AGAIN_LABEL = Do not show this message again
|
||||
RESID_DO_NOT_SHOW_MESSAGE_AGAIN_TOOLTIP = Select this option if you do not want to see this message again
|
||||
|
||||
# Strings for Encodings
|
||||
RESID_HOST_ENCODING_GROUP_LABEL=Default encoding
|
||||
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_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
|
||||
RESID_HOST_ENCODING_ENTER_TOOLTIP=Select or enter an encoding
|
||||
|
|
|
@ -64,6 +64,8 @@ public class SystemConnectionPropertyPage extends SystemBasePropertyPage
|
|||
// prepare input data
|
||||
IHost conn = (IHost)getElement();
|
||||
form.initializeInputFields(conn);
|
||||
// add encoding fields
|
||||
form.addDefaultEncodingFields();
|
||||
// create validators
|
||||
ISystemValidator connectionNameValidators[] = new ISystemValidator[1];
|
||||
connectionNameValidators[0] = SystemConnectionForm.getConnectionNameValidator(conn);
|
||||
|
@ -98,6 +100,21 @@ public class SystemConnectionPropertyPage extends SystemBasePropertyPage
|
|||
form.getConnectionDescription(), form.getDefaultUserId(),
|
||||
form.getUserIdLocation() );
|
||||
|
||||
// update encoding
|
||||
String encoding = form.getDefaultEncoding();
|
||||
boolean isRemoteEncoding = form.isEncodingRemoteDefault();
|
||||
|
||||
// user set encoding
|
||||
if (!isRemoteEncoding) {
|
||||
conn.setDefaultEncoding(encoding, false);
|
||||
}
|
||||
// remote default encoding
|
||||
else {
|
||||
// remove user encoding from host property first
|
||||
conn.setDefaultEncoding(null, false);
|
||||
// remove default remote encoding to indicate to get from remote system
|
||||
conn.setDefaultEncoding(null, true);
|
||||
}
|
||||
|
||||
boolean offlineSelection = form.isWorkOffline();
|
||||
if (offlineSelection != conn.isOffline())
|
||||
|
|
|
@ -270,6 +270,7 @@ public interface ISystemMessages
|
|||
public static final String MSG_OPERTION_STOPPED = "RSEG1257"; //$NON-NLS-1$
|
||||
public static final String MSG_OPERATION_DISCONNECTED = "RSEG1258"; //$NON-NLS-1$
|
||||
|
||||
public static final String MSG_ENCODING_NOT_SUPPORTED = "RSEG1244"; //$NON-NLS-1$
|
||||
|
||||
|
||||
// --------------------------
|
||||
|
|
|
@ -26,6 +26,8 @@ package org.eclipse.rse.ui;
|
|||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.net.InetAddress;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.IllegalCharsetNameException;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Vector;
|
||||
|
@ -55,20 +57,27 @@ import org.eclipse.rse.ui.validators.ValidatorUserId;
|
|||
import org.eclipse.rse.ui.widgets.InheritableEntryField;
|
||||
import org.eclipse.rse.ui.wizards.AbstractSystemWizardPage;
|
||||
import org.eclipse.rse.ui.wizards.newconnection.RSEAbstractNewConnectionWizard;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.events.KeyAdapter;
|
||||
import org.eclipse.swt.events.KeyEvent;
|
||||
import org.eclipse.swt.events.ModifyEvent;
|
||||
import org.eclipse.swt.events.ModifyListener;
|
||||
import org.eclipse.swt.events.SelectionAdapter;
|
||||
import org.eclipse.swt.events.SelectionEvent;
|
||||
import org.eclipse.swt.events.SelectionListener;
|
||||
import org.eclipse.swt.layout.GridData;
|
||||
import org.eclipse.swt.widgets.Button;
|
||||
import org.eclipse.swt.widgets.Combo;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Control;
|
||||
import org.eclipse.swt.widgets.Event;
|
||||
import org.eclipse.swt.widgets.Group;
|
||||
import org.eclipse.swt.widgets.Label;
|
||||
import org.eclipse.swt.widgets.Listener;
|
||||
import org.eclipse.swt.widgets.Text;
|
||||
import org.eclipse.ui.IWorkbenchPropertyPage;
|
||||
import org.eclipse.ui.dialogs.PropertyPage;
|
||||
import org.eclipse.ui.ide.IDEEncoding;
|
||||
|
||||
/**
|
||||
* A reusable form for prompting for connection information,
|
||||
|
@ -86,6 +95,7 @@ public class SystemConnectionForm implements Listener, SelectionListener, Runnab
|
|||
public static final boolean CREATE_MODE = false;
|
||||
public static final boolean UPDATE_MODE = true;
|
||||
public static IRSESystemType lastSystemType = null;
|
||||
protected IHost conn;
|
||||
protected IRSESystemType defaultSystemType;
|
||||
protected IRSESystemType[] validSystemTypes;
|
||||
|
||||
|
@ -95,6 +105,9 @@ public class SystemConnectionForm implements Listener, SelectionListener, Runnab
|
|||
protected Combo textSystemType, textHostName, profileCombo;
|
||||
protected Text textConnectionName, textDescription;
|
||||
protected Button verifyHostNameCB;
|
||||
protected Group encodingGroup;
|
||||
protected Button remoteEncodingButton, otherEncodingButton;
|
||||
protected Combo otherEncodingCombo;
|
||||
|
||||
// yantzi:artemis 6.0, work offline support
|
||||
protected Button workOfflineCB;
|
||||
|
@ -136,6 +149,12 @@ public class SystemConnectionForm implements Listener, SelectionListener, Runnab
|
|||
protected String currentHostName = null;
|
||||
protected SystemMessage errorMessage = null;
|
||||
protected SystemMessage verifyingHostName;
|
||||
|
||||
// encoding fields
|
||||
protected boolean addEncodingFields = false;
|
||||
protected String defaultEncoding = null;
|
||||
protected boolean isRemoteEncoding = false;
|
||||
protected boolean isValidBefore = true;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
|
@ -304,6 +323,7 @@ public class SystemConnectionForm implements Listener, SelectionListener, Runnab
|
|||
*/
|
||||
public void initializeInputFields(IHost conn, boolean updateMode) {
|
||||
this.updateMode = updateMode;
|
||||
this.conn = conn;
|
||||
defaultSystemType = conn.getSystemType();
|
||||
defaultConnectionName = conn.getAliasName();
|
||||
defaultHostName = conn.getHostName();
|
||||
|
@ -311,6 +331,15 @@ public class SystemConnectionForm implements Listener, SelectionListener, Runnab
|
|||
defaultDescription = conn.getDescription();
|
||||
defaultProfile = conn.getSystemProfile().getName();
|
||||
defaultWorkOffline = conn.isOffline();
|
||||
defaultEncoding = conn.getDefaultEncoding(false);
|
||||
|
||||
if (defaultEncoding == null) {
|
||||
defaultEncoding = conn.getDefaultEncoding(true);
|
||||
isRemoteEncoding = true;
|
||||
}
|
||||
else {
|
||||
isRemoteEncoding = false;
|
||||
}
|
||||
|
||||
if (updateMode) {
|
||||
defaultProfileNames = new String[1];
|
||||
|
@ -443,6 +472,15 @@ public class SystemConnectionForm implements Listener, SelectionListener, Runnab
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
// validate host name...
|
||||
if ((errorMessage == null) && addEncodingFields) {
|
||||
errorMessage = validateEncoding();
|
||||
|
||||
if (errorMessage != null) {
|
||||
controlInError = otherEncodingCombo;
|
||||
}
|
||||
}
|
||||
|
||||
// if ok pressed, test for warning situation that connection name is in use in another profile...
|
||||
if (ok && (errorMessage == null) && okPressed) {
|
||||
|
@ -771,6 +809,69 @@ public class SystemConnectionForm implements Listener, SelectionListener, Runnab
|
|||
|
||||
if (textUserId == null)
|
||||
userIdLocation = IRSEUserIdConstants.USERID_LOCATION_NOTSET;
|
||||
|
||||
// check if an encodings field should be added
|
||||
if (addEncodingFields) {
|
||||
|
||||
SystemWidgetHelpers.createLabel(composite_prompts, "", 2); //$NON-NLS-1$
|
||||
|
||||
// encoding field
|
||||
encodingGroup = SystemWidgetHelpers.createGroupComposite(composite_prompts, 2, SystemResources.RESID_HOST_ENCODING_GROUP_LABEL);
|
||||
GridData data = new GridData();
|
||||
data.horizontalSpan = 2;
|
||||
data.horizontalAlignment = SWT.BEGINNING;
|
||||
data.grabExcessHorizontalSpace = true;
|
||||
data.verticalAlignment = SWT.BEGINNING;
|
||||
data.grabExcessVerticalSpace = false;
|
||||
encodingGroup.setLayoutData(data);
|
||||
|
||||
SelectionAdapter buttonSelectionListener = new SelectionAdapter() {
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
updateEncodingGroupState(remoteEncodingButton.getSelection());
|
||||
validateEncoding();
|
||||
}
|
||||
};
|
||||
|
||||
SystemWidgetHelpers.createLabel(encodingGroup, SystemResources.RESID_HOST_ENCODING_SETTING_MSG, 2);
|
||||
|
||||
// remote encoding field
|
||||
String defaultEncodingLabel = SystemResources.RESID_HOST_ENCODING_REMOTE_LABEL;
|
||||
|
||||
remoteEncodingButton = SystemWidgetHelpers.createRadioButton(encodingGroup, null, defaultEncodingLabel, SystemResources.RESID_HOST_ENCODING_REMOTE_TOOLTIP);
|
||||
data = new GridData();
|
||||
data.horizontalSpan = 2;
|
||||
remoteEncodingButton.setLayoutData(data);
|
||||
remoteEncodingButton.addSelectionListener(buttonSelectionListener);
|
||||
|
||||
// other encoding field
|
||||
otherEncodingButton = SystemWidgetHelpers.createRadioButton(encodingGroup, null, SystemResources.RESID_HOST_ENCODING_OTHER_LABEL, SystemResources.RESID_HOST_ENCODING_OTHER_TOOLTIP);
|
||||
data = new GridData();
|
||||
data.grabExcessHorizontalSpace = false;
|
||||
otherEncodingButton.setLayoutData(data);
|
||||
otherEncodingButton.addSelectionListener(buttonSelectionListener);
|
||||
|
||||
// other encoding combo
|
||||
otherEncodingCombo = SystemWidgetHelpers.createCombo(encodingGroup, null, SystemResources.RESID_HOST_ENCODING_ENTER_TOOLTIP);
|
||||
data = new GridData();
|
||||
data.horizontalAlignment = SWT.BEGINNING;
|
||||
data.grabExcessHorizontalSpace = true;
|
||||
data.horizontalIndent = 0;
|
||||
otherEncodingCombo.setLayoutData(data);
|
||||
|
||||
otherEncodingCombo.addSelectionListener(new SelectionAdapter(){
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
validateEncoding();
|
||||
}
|
||||
});
|
||||
|
||||
otherEncodingCombo.addKeyListener(new KeyAdapter(){
|
||||
public void keyReleased(KeyEvent e) {
|
||||
validateEncoding();
|
||||
}
|
||||
});
|
||||
|
||||
SystemWidgetHelpers.createLabel(composite_prompts, "", 2); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
doInitializeFields();
|
||||
|
||||
|
@ -778,6 +879,68 @@ public class SystemConnectionForm implements Listener, SelectionListener, Runnab
|
|||
|
||||
return composite_prompts; // composite;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the encoding group state.
|
||||
* @param useDefault whether to update the state with default option on. <code>true</code> if the default option
|
||||
* should be on, <code>false</code> if it should be off.
|
||||
*/
|
||||
private void updateEncodingGroupState(boolean useDefault) {
|
||||
remoteEncodingButton.setSelection(useDefault);
|
||||
otherEncodingButton.setSelection(!useDefault);
|
||||
|
||||
if (useDefault) {
|
||||
|
||||
if (defaultEncoding != null) {
|
||||
otherEncodingCombo.setText(defaultEncoding);
|
||||
}
|
||||
else {
|
||||
otherEncodingCombo.setText(System.getProperty("file.encoding")); //$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
|
||||
otherEncodingCombo.setEnabled(!useDefault);
|
||||
validateEncoding();
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the valid state of the encoding group.
|
||||
*/
|
||||
private SystemMessage validateEncoding() {
|
||||
boolean isValid = isEncodingValid();
|
||||
|
||||
errorMessage = null;
|
||||
|
||||
if (!isValid) {
|
||||
errorMessage = RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_ENCODING_NOT_SUPPORTED);
|
||||
}
|
||||
|
||||
showErrorMessage(errorMessage);
|
||||
setPageComplete();
|
||||
return errorMessage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the encoding is valid.
|
||||
* @return <code>true</code> if the encoding is valid, <code>false</code> otherwise.
|
||||
*/
|
||||
private boolean isEncodingValid() {
|
||||
return remoteEncodingButton.getSelection() || isEncodingValid(otherEncodingCombo.getText());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether or not the given encoding is valid.
|
||||
* @param encoding the encoding.
|
||||
* @return <code>true</code> if the encoding is valid, <code>false</code> otherwise.
|
||||
*/
|
||||
private boolean isEncodingValid(String encoding) {
|
||||
try {
|
||||
return Charset.isSupported(encoding);
|
||||
}
|
||||
catch (IllegalCharsetNameException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return control to recieve initial focus
|
||||
|
@ -995,6 +1158,31 @@ public class SystemConnectionForm implements Listener, SelectionListener, Runnab
|
|||
if (workOfflineCB != null) {
|
||||
workOfflineCB.setSelection(defaultWorkOffline);
|
||||
}
|
||||
|
||||
// the file encoding group
|
||||
if (addEncodingFields) {
|
||||
List encodings = IDEEncoding.getIDEEncodings();
|
||||
String[] encodingStrings = new String[encodings.size()];
|
||||
encodings.toArray(encodingStrings);
|
||||
otherEncodingCombo.setItems(encodingStrings);
|
||||
|
||||
// if the encoding is the same as the default encoding, then we want to choose the default encoding option
|
||||
if (isRemoteEncoding) {
|
||||
updateEncodingGroupState(true);
|
||||
}
|
||||
// otherwise choose the other encoding option
|
||||
else {
|
||||
otherEncodingCombo.setText(defaultEncoding);
|
||||
updateEncodingGroupState(false);
|
||||
}
|
||||
|
||||
ISystemRegistry sr = RSECorePlugin.getTheSystemRegistry();
|
||||
|
||||
// disable if any subsystem is connected
|
||||
if (!conn.getSystemType().getId().equalsIgnoreCase(IRSESystemType.SYSTEMTYPE_LOCAL_ID) && sr.isAnySubSystemConnected(conn)) {
|
||||
encodingGroup.setEnabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
verify(false);
|
||||
}
|
||||
|
@ -1231,4 +1419,54 @@ public class SystemConnectionForm implements Listener, SelectionListener, Runnab
|
|||
}
|
||||
pm.done();
|
||||
}
|
||||
|
||||
/**
|
||||
* Add fields to enable encoding for the host to be set. This form will not have any encoding fields unless this is called.
|
||||
*/
|
||||
public void addDefaultEncodingFields() {
|
||||
addEncodingFields = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the encoding that was specified. Only applies if encoding fields were added to this form.
|
||||
* @return the encoding that was specified. This will return <code>null</code> if the selection is to use the encoding from the remote system
|
||||
* but that encoding has not been obtained yet.
|
||||
* @see #addDefaultEncodingFields()
|
||||
*/
|
||||
public String getDefaultEncoding() {
|
||||
|
||||
if (addEncodingFields) {
|
||||
return getSelectedEncoding();
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the currently selected encoding.
|
||||
* @return the currently selected encoding.
|
||||
*/
|
||||
private String getSelectedEncoding() {
|
||||
if (remoteEncodingButton.getSelection()) {
|
||||
return defaultEncoding;
|
||||
}
|
||||
|
||||
return otherEncodingCombo.getText();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the encoding option is to use the encoding of the remote system. Only applies if encoding fields were added to this form.
|
||||
* @return <code>true</code> if the encoding option is to use the encoding of the remote system, <code>false</code> if the user specified the encoding.
|
||||
* @see #addDefaultEncodingFields()
|
||||
*/
|
||||
public boolean isEncodingRemoteDefault() {
|
||||
|
||||
if (addEncodingFields) {
|
||||
return remoteEncodingButton.getSelection();
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -684,6 +684,10 @@ Contributors:
|
|||
<LevelOne>Failed to connect to the daemon on %1 using port %2 with an unexpected exception</LevelOne>
|
||||
<LevelTwo>%3</LevelTwo>
|
||||
</Message>
|
||||
<Message ID="1244" Indicator="E">
|
||||
<LevelOne>The selected encoding is not supported.</LevelOne>
|
||||
<LevelTwo></LevelTwo>
|
||||
</Message>
|
||||
|
||||
<!-- universal find files pattern verification -->
|
||||
<Message ID="1250" Indicator="E">
|
||||
|
|
Loading…
Add table
Reference in a new issue