new ButtonField("Show Options", Field.FIELD_HCENTER
| ButtonField.CONSUME_CLICK);
_optionsBtn.setChangeListener(this);
_optionsHidden = true;
add(new SeparatorField());
// Region to layout "Connect" and "Show Options" buttons side by side
final HorizontalFieldManager hfmBtns =
new HorizontalFieldManager(Field.FIELD_HCENTER);
hfmBtns.add(connectBtn);
hfmBtns.add(_optionsBtn);
add(hfmBtns);
add(new SeparatorField());
_labelConnectionOpt = new LabelField("Connection Settings [optional]");
// Connection mode
final String[] connectionModes = { "READ", "WRITE", "READ/WRITE" };
_connectionMode =
new ObjectChoiceField(" Connection Mode: ", connectionModes, 2);
// Connection timeout
_timeoutSupported = new CheckboxField(" Support timeouts", false);
_connectionTimeout =
new BasicEditField("Connection timeout: ", "", 6,
BasicEditField.FILTER_INTEGER);
// Connection security settings for tls/ssl
_endToEndRequired =
new CheckboxField(" tls/ssl end to end required", false);
_endToEndDesired =
new CheckboxField(" tls/ssl end to end desired", false);
// Connection retry options
_labelRetriesOpt = new LabelField("Retry options [optional]");
_timeLimit =
new BasicEditField(" Time Limit for Connections: ", "0", 6,
BasicEditField.FILTER_INTEGER);
_attemptsLimit =
new BasicEditField(" Attempts Limit: ", "0", 4,
BasicEditField.FILTER_INTEGER);
_retryFactor =
new BasicEditField(" Retry Factor: ", "0", 6,
BasicEditField.FILTER_INTEGER);
// Transport selection
final String[] transportNames =
{ "none", "TCP Cellular", "Wap", "Wap2", "Mds", "Bis B",
"TCP Wifi" };
// Preferred transport types option
_transportSelection =
new CheckboxField("Preferred Transport Types [Optional]", false);
_transportSelection.setChangeListener(new FieldChangeListener() {
public void fieldChanged(final Field field, final int context) {
if (_transportSelection.getChecked()) {
// Transport selection check box is checked. Enable drop
// downs for choosing the preferred transport.
_order1.setEditable(true);
_order2.setEditable(true);
_order3.setEditable(true);
_order4.setEditable(true);
_order5.setEditable(true);
_order6.setEditable(true);
} else {
// Transport selection check box is not checked. Disable
// drop
// downs for choosing the preferred transport and set them
// to
// "none".
_order1.setSelectedIndex(0);
_order1.setEditable(false);
_order2.setSelectedIndex(0);
_order2.setEditable(false);
_order3.setSelectedIndex(0);
_order3.setEditable(false);
_order4.setSelectedIndex(0);
_order4.setEditable(false);
_order5.setSelectedIndex(0);
_order5.setEditable(false);
_order6.setSelectedIndex(0);
_order6.setEditable(false);
}
}
});
// Initialize preferred transport types option.
// By default disable the options.
_order1 = new ObjectChoiceField("First:", transportNames);
_order1.setEditable(false);
_order2 = new ObjectChoiceField("Second:", transportNames);
_order2.setEditable(false);
_order3 = new ObjectChoiceField("Third:", transportNames);
_order3.setEditable(false);
_order4 = new ObjectChoiceField("Forth:", transportNames);
_order4.setEditable(false);
_order5 = new ObjectChoiceField("Fifth:", transportNames);
_order5.setEditable(false);
_order6 = new ObjectChoiceField("Sixth:", transportNames);
_order6.setEditable(false);
// Initialize disallowed transport types check boxes
_labelDisallowedTrasnports =
new LabelField("Disallowed Transport Types [optional]:");
_disallowDirectTCP = new CheckboxField("TCP Cellular", false);
_disallowWap = new CheckboxField("Wap", false);
_disallowWap2 = new CheckboxField("Wap2", false);
_disallowMds = new CheckboxField("Mds", false);
_disallowBisB = new CheckboxField("Bis B", false);
_disallowWifi = new CheckboxField("TCP Wifi", false);
// Initialize TCP Cellular transport options
_labelTcpCellular = new LabelField("TCP Cellular Options [optional]:");
_tcpApn = new EditField(" APN: ", "");
_tcpApnUser = new EditField(" Username: ", "");
_tcpApnPassword = new EditField(" Password: ", "");
// Initialize WAP transport options
_labelWap = new LabelField("WAP Options [optional]:");
_wapGatewayApn = new EditField(" Gateway APN: ", "");
_wapGatewayIp = new EditField(" Gateway IP: ", "");
_wapGatewayPort = new EditField(" Gateway Port: ", "");
_wapSourceIp = new EditField(" Source IP: ", "");
_wapSourcePort = new EditField(" Source Port: ", "");
_wapUser = new EditField(" Username: ", "");
_wapPassword = new EditField(" Password: ", "");
_wapEnableWTLS = new CheckboxField(" Enable WTLS", false);
// Initialize BisB transport options
_labelBisB = new LabelField("BisB Options [mandatory for BisB]");
_bisBConnectionType = new EditField(" Connection Type: ", "");
// Add options to a VerticalFieldManager
_optionFieldsManager = new VerticalFieldManager();
_optionFieldsManager.add(_labelConnectionOpt);
_optionFieldsManager.add(_connectionMode);
_optionFieldsManager.add(_timeoutSupported);
_optionFieldsManager.add(_endToEndRequired);
_optionFieldsManager.add(_endToEndDesired);
_optionFieldsManager.add(_connectionTimeout);
_optionFieldsManager.add(new SeparatorField());
_optionFieldsManager.add(_labelRetriesOpt);
_optionFieldsManager.add(_timeLimit);
_optionFieldsManager.add(_attemptsLimit);
_optionFieldsManager.add(_retryFactor);
_optionFieldsManager.add(new SeparatorField());
_optionFieldsManager.add(_transportSelection);
_optionFieldsManager.add(_order1);
_optionFieldsManager.add(_order2);
_optionFieldsManager.add(_order3);
_optionFieldsManager.add(_order4);
_optionFieldsManager.add(_order5);
_optionFieldsManager.add(_order6);
_optionFieldsManager.add(new SeparatorField());
_optionFieldsManager.add(_labelDisallowedTrasnports);
_optionFieldsManager.add(_disallowDirectTCP);
_optionFieldsManager.add(_disallowWap);
_optionFieldsManager.add(_disallowWap2);
_optionFieldsManager.add(_disallowMds);
_optionFieldsManager.add(_disallowBisB);
_optionFieldsManager.add(_disallowWifi);
_optionFieldsManager.add(new SeparatorField());
_optionFieldsManager.add(_labelTcpCellular);
_optionFieldsManager.add(_tcpApn);
_optionFieldsManager.add(_tcpApnUser);
_optionFieldsManager.add(_tcpApnPassword);
_optionFieldsManager.add(new SeparatorField());
_optionFieldsManager.add(_labelWap);
_optionFieldsManager.add(_wapGatewayApn);
_optionFieldsManager.add(_wapGatewayIp);
_optionFieldsManager.add(_wapGatewayPort);
_optionFieldsManager.add(_wapUser);
_optionFieldsManager.add(_wapPassword);
_optionFieldsManager.add(_wapSourceIp);
_optionFieldsManager.add(_wapSourcePort);
_optionFieldsManager.add(_wapEnableWTLS);
_optionFieldsManager.add(new SeparatorField());
_optionFieldsManager.add(_labelBisB);
_optionFieldsManager.add(_bisBConnectionType);
_uiApp = UiApplication.getUiApplication();