use of org.eclipse.kura.web.shared.model.GwtFirewallNatProtocol in project kura by eclipse.
the class NatTabUi method setModalFieldsLabels.
private void setModalFieldsLabels() {
// set Labels
this.labelInput.setText(MSGS.firewallNatFormInInterfaceName() + "*");
this.labelOutput.setText(MSGS.firewallNatFormOutInterfaceName() + "*");
this.labelProtocol.setText(MSGS.firewallNatFormProtocol());
this.labelSource.setText(MSGS.firewallNatFormSourceNetwork());
this.labelDestination.setText(MSGS.firewallNatFormDestinationNetwork());
this.labelEnable.setText(MSGS.firewallNatFormMasquerade());
this.submit.setText(MSGS.submitButton());
this.cancel.setText(MSGS.cancelButton());
// set ListBox
this.protocol.clear();
for (GwtFirewallNatProtocol prot : GwtFirewallNatProtocol.values()) {
this.protocol.addItem(prot.name());
}
this.enable.clear();
for (GwtFirewallNatMasquerade masquerade : GwtFirewallNatMasquerade.values()) {
this.enable.addItem(masquerade.name());
}
}
use of org.eclipse.kura.web.shared.model.GwtFirewallNatProtocol 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);
}
Aggregations