use of com.extjs.gxt.ui.client.widget.layout.FormLayout in project kura by eclipse.
the class NatForm method onRender.
protected void onRender(Element parent, int index) {
super.onRender(parent, index);
setId("nat-form");
FormData formData = new FormData("-30");
m_formPanel = new FormPanel();
m_formPanel.setFrame(false);
m_formPanel.setBodyBorder(true);
m_formPanel.setHeaderVisible(false);
m_formPanel.setScrollMode(Scroll.AUTOY);
m_formPanel.setLayout(new FlowLayout());
FieldSet fieldSet = new FieldSet();
fieldSet.setHeading(MSGS.firewallNatFormInformation());
FormLayout layoutAccount = new FormLayout();
layoutAccount.setLabelWidth(LABEL_WIDTH_FORM);
fieldSet.setLayout(layoutAccount);
//
// input interface name
//
final LabelField inInterfaceNameLabel = new LabelField();
inInterfaceNameLabel.setName("inInterfaceNameLabel");
inInterfaceNameLabel.setFieldLabel(MSGS.firewallNatFormInInterfaceName());
inInterfaceNameLabel.setLabelSeparator(":");
fieldSet.add(inInterfaceNameLabel, formData);
final TextField<String> inInterfaceNameField = new TextField<String>();
inInterfaceNameField.setAllowBlank(false);
inInterfaceNameField.setName("inInterfaceName");
inInterfaceNameField.setFieldLabel(MSGS.firewallNatFormInInterfaceName());
inInterfaceNameField.setToolTip(MSGS.firewallNatFormInputInterfaceToolTip());
inInterfaceNameField.setValidator(new TextFieldValidator(inInterfaceNameField, FieldType.ALPHANUMERIC));
inInterfaceNameField.addPlugin(m_dirtyPlugin);
fieldSet.add(inInterfaceNameField, formData);
//
// output interface name
//
final LabelField outInterfaceNameLabel = new LabelField();
outInterfaceNameLabel.setName("outInterfaceNameLabel");
outInterfaceNameLabel.setFieldLabel(MSGS.firewallNatFormOutInterfaceName());
outInterfaceNameLabel.setLabelSeparator(":");
fieldSet.add(outInterfaceNameLabel, formData);
final TextField<String> outInterfaceNameField = new TextField<String>();
outInterfaceNameField.setAllowBlank(false);
outInterfaceNameField.setName("outInterfaceName");
outInterfaceNameField.setFieldLabel(MSGS.firewallNatFormOutInterfaceName());
outInterfaceNameField.setToolTip(MSGS.firewallNatFormOutputInterfaceToolTip());
outInterfaceNameField.setValidator(new TextFieldValidator(outInterfaceNameField, FieldType.ALPHANUMERIC));
outInterfaceNameField.addPlugin(m_dirtyPlugin);
fieldSet.add(outInterfaceNameField, formData);
//
// protocol
//
final LabelField protocolLabel = new LabelField();
protocolLabel.setName("protocolLabel");
protocolLabel.setFieldLabel(MSGS.firewallNatFormProtocol());
protocolLabel.setLabelSeparator(":");
fieldSet.add(protocolLabel, formData);
final SimpleComboBox<String> protocolCombo = new SimpleComboBox<String>();
protocolCombo.setName("protocolCombo");
protocolCombo.setFieldLabel(MSGS.firewallNatFormProtocol());
protocolCombo.setEditable(false);
protocolCombo.setTypeAhead(true);
protocolCombo.setTriggerAction(TriggerAction.ALL);
protocolCombo.setToolTip(MSGS.firewallNatFormProtocolToolTip());
for (GwtFirewallNatProtocol protocol : GwtFirewallNatProtocol.values()) {
protocolCombo.add(protocol.name());
}
protocolCombo.setSimpleValue(GwtFirewallNatProtocol.tcp.name());
fieldSet.add(protocolCombo, formData);
//
// Source Network
//
final LabelField sourceNetworkLabel = new LabelField();
sourceNetworkLabel.setName("sourceNetworkLabel");
sourceNetworkLabel.setFieldLabel(MSGS.firewallNatFormSourceNetwork());
sourceNetworkLabel.setLabelSeparator(":");
fieldSet.add(sourceNetworkLabel, formData);
final TextField<String> sourceNetworkField = new TextField<String>();
sourceNetworkField.setAllowBlank(true);
sourceNetworkField.setName("address");
sourceNetworkField.setFieldLabel(MSGS.firewallNatFormSourceNetwork());
sourceNetworkField.setToolTip(MSGS.firewallNatFormSourceNetworkToolTip());
sourceNetworkField.setValidator(new TextFieldValidator(sourceNetworkField, FieldType.NETWORK));
sourceNetworkField.addPlugin(m_dirtyPlugin);
fieldSet.add(sourceNetworkField, formData);
//
// Destination Network
//
final LabelField destinationNetworkLabel = new LabelField();
destinationNetworkLabel.setName("destinationNetworkLabel");
destinationNetworkLabel.setFieldLabel(MSGS.firewallNatFormDestinationNetwork());
destinationNetworkLabel.setLabelSeparator(":");
fieldSet.add(destinationNetworkLabel, formData);
final TextField<String> destinationNetworkField = new TextField<String>();
destinationNetworkField.setAllowBlank(true);
destinationNetworkField.setName("address");
destinationNetworkField.setFieldLabel(MSGS.firewallNatFormDestinationNetwork());
destinationNetworkField.setToolTip(MSGS.firewallNatFormDestinationNetworkToolTip());
destinationNetworkField.setValidator(new TextFieldValidator(destinationNetworkField, FieldType.NETWORK));
destinationNetworkField.addPlugin(m_dirtyPlugin);
fieldSet.add(destinationNetworkField, formData);
//
// masquerade
//
final LabelField masqueradeLabel = new LabelField();
masqueradeLabel.setName("masqueradeLabel");
masqueradeLabel.setFieldLabel(MSGS.firewallNatFormMasquerade());
masqueradeLabel.setLabelSeparator(":");
fieldSet.add(masqueradeLabel, formData);
final SimpleComboBox<String> masqueradeCombo = new SimpleComboBox<String>();
masqueradeCombo.setName("masqueradeCombo");
masqueradeCombo.setFieldLabel(MSGS.firewallNatFormMasquerade());
masqueradeCombo.setEditable(false);
masqueradeCombo.setTypeAhead(true);
masqueradeCombo.setTriggerAction(TriggerAction.ALL);
masqueradeCombo.setToolTip(MSGS.firewallNatFormMasqueradingToolTip());
for (GwtFirewallNatMasquerade masquerade : GwtFirewallNatMasquerade.values()) {
masqueradeCombo.add(masquerade.name());
}
masqueradeCombo.setSimpleValue(GwtFirewallNatMasquerade.yes.name());
fieldSet.add(masqueradeCombo, formData);
// add the fieldSet to the panel
m_formPanel.add(fieldSet);
// disable the labels
inInterfaceNameLabel.setVisible(false);
outInterfaceNameLabel.setVisible(false);
protocolLabel.setVisible(false);
sourceNetworkLabel.setVisible(false);
destinationNetworkLabel.setVisible(false);
masqueradeLabel.setVisible(false);
m_status = new Status();
m_status.setBusy(MSGS.waitMsg());
m_status.hide();
m_status.setAutoWidth(true);
m_formPanel.setButtonAlign(HorizontalAlignment.LEFT);
m_formPanel.getButtonBar().add(m_status);
m_formPanel.getButtonBar().add(new FillToolItem());
m_formPanel.addButton(new Button(MSGS.submitButton(), new SelectionListener<ButtonEvent>() {
@Override
public void componentSelected(ButtonEvent ce) {
// make sure all visible fields are valid before performing the action
for (Field<?> field : m_formPanel.getFields()) {
if (field.isVisible() && !field.isValid()) {
return;
}
}
// we need to add a new row to the open ports table
if (m_existingEntry == null) {
// create a new entry
m_newEntry = new GwtFirewallNatEntry();
m_newEntry.setInInterface(inInterfaceNameField.getValue());
m_newEntry.setOutInterface(outInterfaceNameField.getValue());
m_newEntry.setProtocol(protocolCombo.getValue().getValue());
m_newEntry.setSourceNetwork(sourceNetworkField.getValue());
m_newEntry.setDestinationNetwork(destinationNetworkField.getValue());
m_newEntry.setMasquerade(masqueradeCombo.getValue().getValue());
} else {
m_existingEntry = new GwtFirewallNatEntry();
m_existingEntry.setInInterface(inInterfaceNameField.getValue());
m_existingEntry.setOutInterface(outInterfaceNameField.getValue());
m_existingEntry.setProtocol(protocolCombo.getValue().getValue());
m_existingEntry.setSourceNetwork(sourceNetworkField.getValue());
m_existingEntry.setDestinationNetwork(destinationNetworkField.getValue());
m_existingEntry.setMasquerade(masqueradeCombo.getValue().getValue());
}
m_isCanceled = false;
hide();
}
}));
m_formPanel.addButton(new Button(MSGS.cancelButton(), new SelectionListener<ButtonEvent>() {
@Override
public void componentSelected(ButtonEvent ce) {
m_isCanceled = true;
hide();
}
}));
m_formPanel.setButtonAlign(HorizontalAlignment.CENTER);
// populate if necessary
if (m_existingEntry != null) {
// inInterfaceNameLabel.setValue(m_existingEntry.getInInterface());
inInterfaceNameField.setValue(m_existingEntry.getInInterface());
inInterfaceNameField.setOriginalValue(m_existingEntry.getInInterface());
outInterfaceNameLabel.setValue(m_existingEntry.getOutInterface());
outInterfaceNameField.setValue(m_existingEntry.getOutInterface());
outInterfaceNameField.setOriginalValue(m_existingEntry.getOutInterface());
protocolCombo.setSimpleValue(m_existingEntry.getProtocol());
sourceNetworkLabel.setValue(m_existingEntry.getSourceNetwork());
sourceNetworkField.setValue(m_existingEntry.getSourceNetwork());
sourceNetworkField.setOriginalValue(m_existingEntry.getSourceNetwork());
destinationNetworkLabel.setValue(m_existingEntry.getDestinationNetwork());
destinationNetworkField.setValue(m_existingEntry.getDestinationNetwork());
destinationNetworkField.setOriginalValue(m_existingEntry.getDestinationNetwork());
masqueradeCombo.setSimpleValue(m_existingEntry.getMasquerade());
}
add(m_formPanel);
}
use of com.extjs.gxt.ui.client.widget.layout.FormLayout in project kura by eclipse.
the class ModemGpsConfigTab method onRender.
protected void onRender(Element parent, int index) {
Log.debug("ModemGpsConfigTab - onRender()");
super.onRender(parent, index);
setLayout(new FitLayout());
setId("network-modem-gps");
FormData formData = new FormData();
formData.setWidth(250);
m_formPanel = new FormPanel();
m_formPanel.setFrame(false);
m_formPanel.setBodyBorder(false);
m_formPanel.setHeaderVisible(false);
m_formPanel.setLayout(new FlowLayout());
m_formPanel.setStyleAttribute("min-width", "775px");
m_formPanel.setStyleAttribute("padding-left", "30px");
FieldSet fieldSet = new FieldSet();
FormLayout layoutAccount = new FormLayout();
layoutAccount.setLabelWidth(Constants.LABEL_WIDTH_FORM);
fieldSet.setLayout(layoutAccount);
fieldSet.setBorders(false);
//
// Tool Tip Box
//
toolTipField.setText(defaultToolTip);
fieldSet.add(toolTipField);
m_enableGpsRadioTrue = new Radio();
m_enableGpsRadioTrue.setBoxLabel(MSGS.trueLabel());
m_enableGpsRadioTrue.setItemId("true");
m_enableGpsRadioTrue.addListener(Events.OnMouseOver, new MouseOverListener(MSGS.netModemToolTipEnableGps()));
m_enableGpsRadioFalse = new Radio();
m_enableGpsRadioFalse.setBoxLabel(MSGS.falseLabel());
m_enableGpsRadioFalse.setItemId("false");
m_enableGpsRadioFalse.addListener(Events.OnMouseOver, new MouseOverListener(MSGS.netModemToolTipEnableGps()));
m_enableGpsRadioGroup = new RadioGroup();
m_enableGpsRadioGroup.setName("modemEnableGps");
m_enableGpsRadioGroup.setFieldLabel(MSGS.netModemEnableGps());
m_enableGpsRadioGroup.add(m_enableGpsRadioTrue);
m_enableGpsRadioGroup.add(m_enableGpsRadioFalse);
m_enableGpsRadioGroup.addPlugin(m_dirtyPlugin);
// m_enableGpsRadioGroup.setStyleAttribute("margin-top", Constants.LABEL_MARGIN_TOP_SEPARATOR);
fieldSet.add(m_enableGpsRadioGroup, formData);
m_formPanel.add(fieldSet);
m_formPanel.setScrollMode(Scroll.AUTO);
add(m_formPanel);
setScrollMode(Scroll.AUTOX);
m_initialized = true;
}
use of com.extjs.gxt.ui.client.widget.layout.FormLayout in project kura by eclipse.
the class TcpIpConfigTab method onRender.
protected void onRender(Element parent, int index) {
super.onRender(parent, index);
setLayout(new FitLayout());
setId("network-tcpip");
FormData formData = new FormData();
formData.setWidth(250);
m_formPanel = new FormPanel();
m_formPanel.setFrame(false);
m_formPanel.setBodyBorder(false);
m_formPanel.setHeaderVisible(false);
m_formPanel.setLayout(new FlowLayout());
m_formPanel.setStyleAttribute("min-width", "775px");
m_formPanel.setStyleAttribute("padding-left", "30px");
m_fieldSet = new FieldSet();
FormLayout layoutAccount = new FormLayout();
layoutAccount.setLabelWidth(Constants.LABEL_WIDTH_FORM);
m_fieldSet.setLayout(layoutAccount);
m_fieldSet.setBorders(false);
//
// Enabled
//
initializeStatusListStore();
//
// Tool Tip Box
//
toolTipField.setText(defaultToolTip);
m_fieldSet.add(toolTipField);
//
// Status Combo
//
m_statusCombo = new ComboBox<GwtNetIfStatusModel>();
m_statusCombo.setName("comboStatus");
m_statusCombo.setDisplayField(GwtNetIfStatusModel.NAME);
m_statusCombo.setFieldLabel(MSGS.netIPv4Status());
m_statusCombo.setEditable(false);
m_statusCombo.setStore(m_statusListStore);
m_statusCombo.setTemplate(getTemplate());
m_statusCombo.setTypeAhead(true);
m_statusCombo.setTriggerAction(TriggerAction.ALL);
m_statusCombo.setValue(m_statusListStore.findModel(GwtNetIfStatusModel.STATUS, GwtNetIfStatus.netIPv4StatusDisabled.name()));
m_statusCombo.addSelectionChangedListener(new SelectionChangedListener<GwtNetIfStatusModel>() {
@Override
public void selectionChanged(SelectionChangedEvent<GwtNetIfStatusModel> se) {
m_netInterfaceConfigTabs.adjustInterfaceTabs();
refreshForm();
// Check for other WAN interfaces if current interface is changed to WAN
if (isWanEnabled()) {
m_formPanel.mask(MSGS.waiting());
gwtNetworkService.findNetInterfaceConfigurations(new AsyncCallback<ListLoadResult<GwtNetInterfaceConfig>>() {
public void onFailure(Throwable caught) {
m_formPanel.unmask();
;
}
public void onSuccess(ListLoadResult<GwtNetInterfaceConfig> result) {
for (GwtNetInterfaceConfig config : result.getData()) {
if (config.getStatusEnum().equals(GwtNetIfStatus.netIPv4StatusEnabledWAN) && !config.getName().equals(m_selectNetIfConfig.getName())) {
m_statusCombo.fireEvent(Events.Invalid);
}
}
m_formPanel.unmask();
;
}
});
} else {
FormUtils.removeWarningFieldIcon(m_statusCombo);
}
}
});
m_statusCombo.addStyleName("kura-combobox");
m_statusCombo.addPlugin(m_dirtyPlugin);
m_statusCombo.addPlugin(m_warningPlugin);
m_fieldSet.add(m_statusCombo, formData);
//
// Configure IP
//
m_configureCombo = new SimpleComboBox<String>();
m_configureCombo.setName("comboConfigure");
m_configureCombo.setFieldLabel(MSGS.netIPv4Configure());
m_configureCombo.setEditable(false);
m_configureCombo.setTypeAhead(true);
m_configureCombo.setTriggerAction(TriggerAction.ALL);
m_configureCombo.setStyleAttribute("margin-top", Constants.LABEL_MARGIN_TOP_SEPARATOR);
// show account status combo box
for (GwtNetIfConfigMode mode : GwtNetIfConfigMode.values()) {
m_configureCombo.add(MessageUtils.get(mode.name()));
}
if ((m_selectNetIfConfig != null) && (m_selectNetIfConfig.getHwTypeEnum() == GwtNetIfType.MODEM)) {
m_statusListStore.remove(m_statusListStore.findModel(GwtNetIfStatusModel.STATUS, GwtNetIfStatus.netIPv4StatusEnabledLAN.name()));
}
m_configureCombo.setSimpleValue(MessageUtils.get(GwtNetIfConfigMode.netIPv4ConfigModeDHCP.name()));
m_configureCombo.addSelectionChangedListener(new SelectionChangedListener<SimpleComboValue<String>>() {
@Override
public void selectionChanged(SelectionChangedEvent<SimpleComboValue<String>> se) {
m_netInterfaceConfigTabs.adjustInterfaceTabs();
refreshForm();
}
});
m_configureCombo.addListener(Events.OnMouseOver, new MouseOverListener(MSGS.netIPv4ToolTipConfigure()));
m_configureCombo.addStyleName("kura-combobox");
m_configureCombo.addPlugin(m_dirtyPlugin);
m_fieldSet.add(m_configureCombo, formData);
//
// IP Address
//
m_ipAddressField = new TextField<String>();
m_ipAddressField.setAllowBlank(true);
m_ipAddressField.setName("ipAddress");
m_ipAddressField.setFieldLabel(MSGS.netIPv4Address());
m_ipAddressField.setRegex(IPV4_REGEX);
m_ipAddressField.getMessages().setRegexText(MSGS.netIPv4InvalidAddress());
m_ipAddressField.addPlugin(m_dirtyPlugin);
m_ipAddressField.addListener(Events.OnMouseOver, new MouseOverListener(MSGS.netIPv4ToolTipAddress()));
m_ipAddressField.addStyleName("kura-textfield");
m_fieldSet.add(m_ipAddressField, formData);
//
// Subnet mask
//
m_subnetMaskField = new TextField<String>();
m_subnetMaskField.setAllowBlank(true);
m_subnetMaskField.setName("subnetMask");
m_subnetMaskField.setFieldLabel(MSGS.netIPv4SubnetMask());
m_subnetMaskField.setRegex(IPV4_REGEX);
m_subnetMaskField.getMessages().setRegexText(MSGS.netIPv4InvalidAddress());
m_subnetMaskField.addListener(Events.OnMouseOver, new MouseOverListener(MSGS.netIPv4ToolTipSubnetMask()));
m_subnetMaskField.addStyleName("kura-textfield");
m_subnetMaskField.addPlugin(m_dirtyPlugin);
m_fieldSet.add(m_subnetMaskField, formData);
//
// Gateway
//
m_gatewayField = new TextField<String>();
m_gatewayField.setAllowBlank(true);
m_gatewayField.setName("gateway");
m_gatewayField.setFieldLabel(MSGS.netIPv4Gateway());
m_gatewayField.setRegex(IPV4_REGEX);
m_gatewayField.getMessages().setRegexText(MSGS.netIPv4InvalidAddress());
m_gatewayField.addListener(Events.OnMouseOver, new MouseOverListener(MSGS.netIPv4ToolTipGateway()));
m_gatewayField.addStyleName("kura-textfield");
m_gatewayField.addPlugin(m_dirtyPlugin);
m_fieldSet.add(m_gatewayField, formData);
//
// Renew DHCP Lease
//
Button renewDHCP = new Button(MSGS.netIPv4RenewDHCPLease(), // no image
null, new SelectionListener<ButtonEvent>() {
@Override
public void componentSelected(ButtonEvent ce) {
gwtXSRFService.generateSecurityToken(new AsyncCallback<GwtXSRFToken>() {
@Override
public void onFailure(Throwable ex) {
FailureHandler.handle(ex);
}
@Override
public void onSuccess(GwtXSRFToken token) {
gwtNetworkService.renewDhcpLease(token, m_selectNetIfConfig.getName(), new AsyncCallback<Void>() {
public void onSuccess(Void result) {
update();
Log.debug("successfully renewed DHCP lease");
}
public void onFailure(Throwable caught) {
Log.debug("caught: " + caught.toString());
FailureHandler.handle(caught);
}
});
}
});
}
});
m_renewDHCPButton = new AdapterField(renewDHCP);
m_renewDHCPButton.setId("net-ipv4-renew-dhcp");
m_renewDHCPButton.setLabelSeparator("");
m_renewDHCPButton.addListener(Events.OnMouseOver, new MouseOverListener(MSGS.netIPv4ToolTipRenew()));
FormData formDataButton = new FormData();
formDataButton.setWidth(150);
m_renewDHCPButton.addPlugin(m_dirtyPlugin);
m_fieldSet.add(m_renewDHCPButton, formDataButton);
//
// DNS read-only (for DHCP)
//
m_dnsReadOnlyField = new TextArea();
m_dnsReadOnlyField.setAllowBlank(true);
m_dnsReadOnlyField.setName("dnsReadOnlyServers");
m_dnsReadOnlyField.setFieldLabel(MSGS.netIPv4DNSServers());
m_dnsReadOnlyField.setEnabled(false);
m_dnsReadOnlyField.setHeight("1.5em");
m_dnsReadOnlyField.setStyleAttribute("margin-top", Constants.LABEL_MARGIN_TOP_SEPARATOR);
m_dnsReadOnlyField.setStyleAttribute("margin-bottom", "0px");
m_dnsReadOnlyField.addListener(Events.OnMouseOver, new MouseOverListener(MSGS.netIPv4ToolTipDns()));
m_fieldSet.add(m_dnsReadOnlyField, formData);
//
// DNS
//
m_dnsField = new TextArea();
m_dnsField.setAllowBlank(true);
m_dnsField.setName("dnsServers");
m_dnsField.setFieldLabel(MSGS.netIPv4DNSServers());
m_dnsField.setRegex("((" + IPV4_REGEX + ")[\\s,;\\n\\r\\t]*)+");
m_dnsField.getMessages().setRegexText(MSGS.netIPv4InvalidAddress());
m_dnsField.addListener(Events.OnMouseOver, new MouseOverListener(MSGS.netIPv4ToolTipDns()));
m_dnsField.addListener(Events.OnChange, new Listener<FieldEvent>() {
// Hide the DNS entry from the DHCP server if a custom DNS entry is added
public void handleEvent(FieldEvent be) {
TextArea t = (TextArea) be.getField();
if (t.getValue() == null || t.getValue().isEmpty()) {
showReadOnlyDns();
} else {
hideReadOnlyDns();
}
}
});
m_dnsField.addPlugin(m_dirtyPlugin);
m_fieldSet.add(m_dnsField, formData);
//
// Search Domains
//
m_domainsField = new TextArea();
m_domainsField.setAllowBlank(true);
m_domainsField.setName("searchDomains");
m_domainsField.setFieldLabel(MSGS.netIPv4SearchDomains());
m_domainsField.setStyleAttribute("margin-top", Constants.LABEL_MARGIN_TOP_SEPARATOR);
m_domainsField.addPlugin(m_dirtyPlugin);
m_fieldSet.add(m_domainsField, formData);
m_formPanel.add(m_fieldSet);
add(m_formPanel);
setScrollMode(Scroll.AUTO);
m_initialized = true;
}
use of com.extjs.gxt.ui.client.widget.layout.FormLayout in project kura by eclipse.
the class DeviceConfigPanel method paintConfig.
private void paintConfig() {
LayoutContainer lcAction = new LayoutContainer();
lcAction.setLayout(new BorderLayout());
lcAction.setBorders(true);
lcAction.setSize(475, -1);
add(lcAction);
// center panel: action form
BorderLayoutData centerData = new BorderLayoutData(LayoutRegion.CENTER, .75F);
centerData.setSplit(false);
centerData.setMargins(new Margins(0, 0, 0, 0));
FormData formData = new FormData("-20");
formData.setMargins(new Margins(0, 10, 0, 0));
if (!UserAgentUtils.isIE()) {
m_actionFormPanel = new FormPanel();
m_actionFormPanel.setId("config-panel-id");
m_actionFormPanel.setFrame(false);
m_actionFormPanel.setBodyBorder(false);
m_actionFormPanel.setHeaderVisible(false);
m_actionFormPanel.setLabelWidth(Constants.LABEL_WIDTH_CONFIG_FORM);
m_actionFormPanel.setStyleAttribute("padding", "0px");
m_actionFormPanel.setScrollMode(Scroll.AUTO);
m_actionFormPanel.setLayout(new FlowLayout());
m_actionFormPanel.addListener(Events.Render, new Listener<BaseEvent>() {
public void handleEvent(BaseEvent be) {
NodeList<Element> nl = m_actionFormPanel.getElement().getElementsByTagName("form");
if (nl.getLength() > 0) {
Element elemForm = nl.getItem(0);
elemForm.setAttribute("autocomplete", "off");
}
}
});
m_actionFormPanel.getElement().setAttribute("autocomplete", "off");
}
m_actionFieldSet = new FieldSet();
m_actionFieldSet.setId("configuration-form");
m_actionFieldSet.setBorders(false);
m_actionFieldSet.setStyleAttribute("padding", "0px");
m_actionFieldSet.setScrollMode(Scroll.AUTO);
if (m_configComponent.getComponentDescription() != null && m_configComponent.getComponentDescription().trim().length() > 0) {
m_actionFieldSet.addText(m_configComponent.getComponentDescription());
}
FormLayout layout = new FormLayout();
layout.setLabelWidth(Constants.LABEL_WIDTH_CONFIG_FORM);
m_actionFieldSet.setLayout(layout);
Field<?> field = null;
for (GwtConfigParameter param : m_configComponent.getParameters()) {
if (param.getCardinality() == 0 || param.getCardinality() == 1 || param.getCardinality() == -1) {
field = paintConfigParameter(param);
} else {
field = paintMultiFieldConfigParameter(param);
}
m_actionFieldSet.add(field, formData);
}
if (!UserAgentUtils.isIE()) {
m_actionFormPanel.add(m_actionFieldSet, formData);
lcAction.add(m_actionFormPanel, centerData);
} else {
lcAction.add(m_actionFieldSet, centerData);
}
}
use of com.extjs.gxt.ui.client.widget.layout.FormLayout in project kura by eclipse.
the class PackageInstallDialog method onRender.
@Override
protected void onRender(Element parent, int pos) {
super.onRender(parent, pos);
setLayout(new FitLayout());
setBodyBorder(false);
setModal(true);
setButtons("");
setScrollMode(Scroll.AUTO);
setHideOnButtonClick(false);
setSize(400, 175);
m_tabsPanel = new TabPanel();
m_tabsPanel.setPlain(true);
m_tabsPanel.setBorders(false);
//
// File upload tab
m_formPanelFile = new FormPanel();
m_formPanelFile.setFrame(false);
m_formPanelFile.setHeaderVisible(false);
m_formPanelFile.setBodyBorder(false);
m_formPanelFile.setAction(m_actionUrl + "/upload");
m_formPanelFile.setEncoding(Encoding.MULTIPART);
m_formPanelFile.setMethod(Method.POST);
m_formPanelFile.setButtonAlign(HorizontalAlignment.CENTER);
m_formPanelFile.setStyleAttribute("padding-right", "0px");
m_formPanelFile.addListener(Events.Submit, new Listener<FormEvent>() {
public void handleEvent(FormEvent be) {
String htmlResponse = be.getResultHtml();
if (htmlResponse == null || htmlResponse.isEmpty()) {
MessageBox.info(MSGS.information(), MSGS.fileUploadSuccess(), null);
} else {
MessageBox.info(MSGS.information(), MSGS.fileUploadFailure(), null);
}
hide();
}
});
FieldSet fileFieldSet = new FieldSet();
fileFieldSet.setBorders(false);
fileFieldSet.setStyleAttribute("padding", "0px");
FormLayout fileFormLayout = new FormLayout();
fileFormLayout.setLabelWidth(Constants.LABEL_WIDTH_FORM_SMALL);
fileFieldSet.setLayout(fileFormLayout);
m_fileUploadField = new FileUploadField();
m_fileUploadField.setAllowBlank(false);
m_fileUploadField.setName("uploadedFile");
m_fileUploadField.setFieldLabel(MSGS.fileLabel());
if (m_hiddenFields != null) {
for (HiddenField<?> hf : m_hiddenFields) {
fileFieldSet.add(hf);
}
}
FormData fileFormData = new FormData("-20");
fileFormData.setMargins(new Margins(0, 0, 0, 0));
fileFieldSet.add(m_fileUploadField, fileFormData);
m_formPanelFile.add(fileFieldSet, fileFormData);
m_tabFile = new TabItem(MSGS.fileLabel());
m_tabFile.setBorders(true);
m_tabFile.setLayout(new FormLayout());
m_tabFile.add(m_formPanelFile);
m_tabsPanel.add(m_tabFile);
//
// xsrfToken Hidden field
//
gwtXSRFService.generateSecurityToken(new AsyncCallback<GwtXSRFToken>() {
@Override
public void onFailure(Throwable ex) {
FailureHandler.handle(ex);
}
@Override
public void onSuccess(GwtXSRFToken token) {
xsrfTokenFieldFile.setValue(token.getToken());
xsrfTokenFieldUrl.setValue(token.getToken());
}
});
xsrfTokenFieldFile = new HiddenField<String>();
xsrfTokenFieldFile.setId("xsrfToken");
xsrfTokenFieldFile.setName("xsrfToken");
xsrfTokenFieldFile.setValue("");
m_formPanelFile.add(xsrfTokenFieldFile);
//
//
// Download URL tab
m_formPanelUrl = new FormPanel();
m_formPanelUrl.setFrame(false);
m_formPanelUrl.setHeaderVisible(false);
m_formPanelUrl.setBodyBorder(false);
m_formPanelUrl.setAction(m_actionUrl + "/url");
m_formPanelUrl.setMethod(Method.POST);
m_formPanelUrl.setStyleAttribute("padding-right", "0px");
m_formPanelUrl.addListener(Events.Submit, new Listener<FormEvent>() {
public void handleEvent(FormEvent be) {
String htmlResponse = be.getResultHtml();
if (htmlResponse == null || htmlResponse.isEmpty()) {
MessageBox.info(MSGS.information(), MSGS.fileDownloadSuccess(), null);
} else {
String errMsg = htmlResponse;
int startIdx = htmlResponse.indexOf("<pre>");
int endIndex = htmlResponse.indexOf("</pre>");
if (startIdx != -1 && endIndex != -1) {
errMsg = htmlResponse.substring(startIdx + 5, endIndex);
}
MessageBox.alert(MSGS.error(), MSGS.fileDownloadFailure() + ": " + errMsg, null);
}
hide();
}
});
FieldSet urlFieldSet = new FieldSet();
urlFieldSet.setBorders(false);
urlFieldSet.setStyleAttribute("padding", "0px");
FormLayout urlFormLayout = new FormLayout();
urlFormLayout.setLabelWidth(Constants.LABEL_WIDTH_FORM_SMALL);
urlFieldSet.setLayout(urlFormLayout);
m_textFieldUrl = new TextField<String>();
m_textFieldUrl.setAllowBlank(false);
m_textFieldUrl.setName("packageUrl");
m_textFieldUrl.setFieldLabel(MSGS.urlLabel());
FormData urlFormData = new FormData("-20");
urlFormData.setMargins(new Margins(0, 0, 0, 0));
urlFieldSet.add(m_textFieldUrl, urlFormData);
if (m_hiddenFields != null) {
for (HiddenField<?> hf : m_hiddenFields) {
urlFieldSet.add(hf);
}
}
m_formPanelUrl.add(urlFieldSet, urlFormData);
//
// xsrfToken Hidden field
//
xsrfTokenFieldUrl = new HiddenField<String>();
xsrfTokenFieldUrl.setId("xsrfToken");
xsrfTokenFieldUrl.setName("xsrfToken");
xsrfTokenFieldUrl.setValue("");
m_formPanelUrl.add(xsrfTokenFieldUrl);
//
m_tabUrl = new TabItem(MSGS.urlLabel());
m_tabUrl.setBorders(true);
m_tabUrl.setLayout(new FormLayout());
m_tabUrl.add(m_formPanelUrl);
m_tabsPanel.add(m_tabUrl);
add(m_tabsPanel);
}
Aggregations