Search in sources :

Example 1 with GwtFirewallNatMasquerade

use of org.eclipse.kura.web.shared.model.GwtFirewallNatMasquerade 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());
    }
}
Also used : GwtFirewallNatMasquerade(org.eclipse.kura.web.shared.model.GwtFirewallNatMasquerade) GwtFirewallNatProtocol(org.eclipse.kura.web.shared.model.GwtFirewallNatProtocol)

Example 2 with GwtFirewallNatMasquerade

use of org.eclipse.kura.web.shared.model.GwtFirewallNatMasquerade in project kura by eclipse.

the class PortForwardingTabUi method setModalFieldsValues.

private void setModalFieldsValues(final GwtFirewallPortForwardEntry existingEntry) {
    // set ListBoxes
    this.protocol.clear();
    for (GwtNetProtocol prot : GwtNetProtocol.values()) {
        this.protocol.addItem(prot.name());
    }
    this.enable.clear();
    for (GwtFirewallNatMasquerade masquerade : GwtFirewallNatMasquerade.values()) {
        this.enable.addItem(masquerade.name());
    }
    // populate Existing Values
    if (existingEntry != null) {
        this.input.setText(existingEntry.getInboundInterface());
        this.output.setText(existingEntry.getOutboundInterface());
        this.lan.setText(existingEntry.getAddress());
        this.external.setText(String.valueOf(existingEntry.getOutPort()));
        this.internal.setText(String.valueOf(existingEntry.getInPort()));
        this.permittedNw.setText(existingEntry.getPermittedNetwork());
        this.permittedMac.setText(existingEntry.getPermittedMAC());
        this.source.setText(existingEntry.getSourcePortRange());
        for (int i = 0; i < this.protocol.getItemCount(); i++) {
            if (existingEntry.getProtocol().equals(this.protocol.getItemText(i))) {
                this.protocol.setSelectedIndex(i);
                break;
            }
        }
        for (int i = 0; i < this.enable.getItemCount(); i++) {
            if (existingEntry.getMasquerade().equals(this.enable.getItemText(i))) {
                this.enable.setSelectedIndex(i);
                break;
            }
        }
    } else {
        this.input.reset();
        this.output.reset();
        this.lan.reset();
        this.external.reset();
        this.internal.reset();
        this.permittedNw.reset();
        this.permittedMac.reset();
        this.source.reset();
        this.protocol.setSelectedIndex(0);
        this.enable.setSelectedIndex(0);
    }
}
Also used : GwtFirewallNatMasquerade(org.eclipse.kura.web.shared.model.GwtFirewallNatMasquerade) GwtNetProtocol(org.eclipse.kura.web.shared.model.GwtNetProtocol)

Example 3 with GwtFirewallNatMasquerade

use of org.eclipse.kura.web.shared.model.GwtFirewallNatMasquerade in project kura by eclipse.

the class PortForwardForm method onRender.

protected void onRender(Element parent, int index) {
    super.onRender(parent, index);
    setId("firewall-port-forwarding-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.firewallPortForwardFormInformation());
    FormLayout layoutAccount = new FormLayout();
    layoutAccount.setLabelWidth(LABEL_WIDTH_FORM);
    fieldSet.setLayout(layoutAccount);
    // 
    // in-bound interface
    // 
    final LabelField inboundInterfaceLabel = new LabelField();
    inboundInterfaceLabel.setName("inboundInterfaceLabel");
    inboundInterfaceLabel.setFieldLabel(MSGS.firewallPortForwardFormInboundInterface());
    inboundInterfaceLabel.setLabelSeparator(":");
    fieldSet.add(inboundInterfaceLabel, formData);
    final TextField<String> inboundInterfaceField = new TextField<String>();
    inboundInterfaceField.setAllowBlank(false);
    inboundInterfaceField.setName("interfaceName");
    inboundInterfaceField.setFieldLabel(MSGS.firewallPortForwardFormInboundInterface());
    inboundInterfaceField.setToolTip(MSGS.firewallPortForwardFormInboundInterfaceToolTip());
    inboundInterfaceField.setValidator(new TextFieldValidator(inboundInterfaceField, FieldType.ALPHANUMERIC));
    fieldSet.add(inboundInterfaceField, formData);
    // 
    // out-bound interface
    // 
    final LabelField outboundInterfaceLabel = new LabelField();
    outboundInterfaceLabel.setName("inboundInterfaceLabel");
    outboundInterfaceLabel.setFieldLabel(MSGS.firewallPortForwardFormOutboundInterface());
    outboundInterfaceLabel.setLabelSeparator(":");
    fieldSet.add(outboundInterfaceLabel, formData);
    final TextField<String> outboundInterfaceField = new TextField<String>();
    outboundInterfaceField.setAllowBlank(false);
    outboundInterfaceField.setName("interfaceName");
    outboundInterfaceField.setFieldLabel(MSGS.firewallPortForwardFormOutboundInterface());
    outboundInterfaceField.setToolTip(MSGS.firewallPortForwardFormOutboundInterfaceToolTip());
    outboundInterfaceField.setValidator(new TextFieldValidator(outboundInterfaceField, FieldType.ALPHANUMERIC));
    fieldSet.add(outboundInterfaceField, formData);
    // 
    // address
    // 
    final LabelField addressLabel = new LabelField();
    addressLabel.setName("addressLabel");
    addressLabel.setFieldLabel(MSGS.firewallPortForwardFormAddress());
    addressLabel.setLabelSeparator(":");
    fieldSet.add(addressLabel, formData);
    final TextField<String> addressField = new TextField<String>();
    addressField.setAllowBlank(false);
    addressField.setName("address");
    addressField.setFieldLabel(MSGS.firewallPortForwardFormAddress());
    addressField.setToolTip(MSGS.firewallPortForwardFormLanAddressToolTip());
    addressField.setValidator(new TextFieldValidator(addressField, FieldType.IPv4_ADDRESS));
    fieldSet.add(addressField, formData);
    // 
    // protocol
    // 
    final LabelField protocolLabel = new LabelField();
    protocolLabel.setName("protocolLabel");
    protocolLabel.setFieldLabel(MSGS.firewallPortForwardFormProtocol());
    protocolLabel.setLabelSeparator(":");
    fieldSet.add(protocolLabel, formData);
    final SimpleComboBox<String> protocolCombo = new SimpleComboBox<String>();
    protocolCombo.setName("protocolCombo");
    protocolCombo.setFieldLabel(MSGS.firewallPortForwardFormProtocol());
    protocolCombo.setEditable(false);
    protocolCombo.setTypeAhead(true);
    protocolCombo.setTriggerAction(TriggerAction.ALL);
    protocolCombo.setToolTip(MSGS.firewallPortForwardFormProtocolToolTip());
    for (GwtNetProtocol protocol : GwtNetProtocol.values()) {
        protocolCombo.add(protocol.name());
    }
    protocolCombo.setSimpleValue(GwtNetProtocol.tcp.name());
    fieldSet.add(protocolCombo, formData);
    // 
    // in port number
    // 
    final LabelField inPortLabel = new LabelField();
    inPortLabel.setName("inPortLabel");
    inPortLabel.setFieldLabel(MSGS.firewallPortForwardFormInPort());
    inPortLabel.setLabelSeparator(":");
    fieldSet.add(inPortLabel, formData);
    final TextField<String> inPortField = new TextField<String>();
    inPortField.setAllowBlank(false);
    inPortField.setName("inPort");
    inPortField.setFieldLabel(MSGS.firewallPortForwardFormInPort());
    inPortField.setToolTip(MSGS.firewallPortForwardFormExternalPortToolTip());
    inPortField.setValidator(new TextFieldValidator(inPortField, FieldType.NUMERIC));
    fieldSet.add(inPortField, formData);
    // 
    // out port number
    // 
    final LabelField outPortLabel = new LabelField();
    outPortLabel.setName("outPortLabel");
    outPortLabel.setFieldLabel(MSGS.firewallPortForwardFormOutPort());
    outPortLabel.setLabelSeparator(":");
    fieldSet.add(outPortLabel, formData);
    final TextField<String> outPortField = new TextField<String>();
    outPortField.setAllowBlank(false);
    outPortField.setName("outPort");
    outPortField.setFieldLabel(MSGS.firewallPortForwardFormOutPort());
    outPortField.setToolTip(MSGS.firewallPortForwardFormInternalPortToolTip());
    outPortField.setValidator(new TextFieldValidator(outPortField, FieldType.NUMERIC));
    fieldSet.add(outPortField, 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.firewallPortForwardFormMasqueradingToolTip());
    for (GwtFirewallNatMasquerade masquerade : GwtFirewallNatMasquerade.values()) {
        masqueradeCombo.add(masquerade.name());
    }
    masqueradeCombo.setSimpleValue(GwtFirewallNatMasquerade.no.name());
    fieldSet.add(masqueradeCombo, formData);
    // 
    // permitted network
    // 
    final LabelField permittedNetworkLabel = new LabelField();
    permittedNetworkLabel.setName("permittedNetworkLabel");
    permittedNetworkLabel.setFieldLabel(MSGS.firewallPortForwardFormPermittedNetwork());
    permittedNetworkLabel.setLabelSeparator(":");
    fieldSet.add(permittedNetworkLabel, formData);
    final TextField<String> permittedNetworkField = new TextField<String>();
    permittedNetworkField.setAllowBlank(true);
    permittedNetworkField.setName("permittedNetwork");
    permittedNetworkField.setFieldLabel(MSGS.firewallPortForwardFormPermittedNetwork());
    permittedNetworkField.setToolTip(MSGS.firewallPortForwardFormPermittedNetworkToolTip());
    permittedNetworkField.setValidator(new TextFieldValidator(permittedNetworkField, FieldType.NETWORK));
    fieldSet.add(permittedNetworkField, formData);
    // 
    // permitted MAC
    // 
    final LabelField permittedMacLabel = new LabelField();
    permittedMacLabel.setName("permittedMacLabel");
    permittedMacLabel.setFieldLabel(MSGS.firewallPortForwardFormPermittedMac());
    permittedMacLabel.setLabelSeparator(":");
    fieldSet.add(permittedMacLabel, formData);
    final TextField<String> permittedMacField = new TextField<String>();
    permittedMacField.setAllowBlank(true);
    permittedMacField.setName("permittedMac");
    permittedMacField.setFieldLabel(MSGS.firewallPortForwardFormPermittedMac());
    permittedMacField.setToolTip(MSGS.firewallPortForwardFormPermittedMacAddressToolTip());
    permittedMacField.setValidator(new TextFieldValidator(permittedMacField, FieldType.MAC_ADDRESS));
    fieldSet.add(permittedMacField, formData);
    // 
    // source port range
    // 
    final LabelField sourcePortRangeLabel = new LabelField();
    sourcePortRangeLabel.setName("sourcePortRangeLabel");
    sourcePortRangeLabel.setFieldLabel(MSGS.firewallPortForwardFormSourcePortRange());
    sourcePortRangeLabel.setLabelSeparator(":");
    fieldSet.add(sourcePortRangeLabel, formData);
    final TextField<String> sourcePortRangeField = new TextField<String>();
    sourcePortRangeField.setAllowBlank(true);
    sourcePortRangeField.setName("sourcePortRange");
    sourcePortRangeField.setFieldLabel(MSGS.firewallPortForwardFormSourcePortRange());
    sourcePortRangeField.setToolTip(MSGS.firewallPortForwardFormSourcePortRangeToolTip());
    sourcePortRangeField.setValidator(new TextFieldValidator(sourcePortRangeField, FieldType.PORT_RANGE));
    fieldSet.add(sourcePortRangeField, formData);
    // add the fieldSet to the panel
    m_formPanel.add(fieldSet);
    // disable the labels
    inboundInterfaceLabel.setVisible(false);
    outboundInterfaceLabel.setVisible(false);
    addressLabel.setVisible(false);
    protocolLabel.setVisible(false);
    inPortLabel.setVisible(false);
    outPortLabel.setVisible(false);
    masqueradeLabel.setVisible(false);
    permittedNetworkLabel.setVisible(false);
    permittedMacLabel.setVisible(false);
    sourcePortRangeLabel.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 GwtFirewallPortForwardEntry();
                m_newEntry.setInboundInterface(inboundInterfaceField.getValue());
                m_newEntry.setOutboundInterface(outboundInterfaceField.getValue());
                m_newEntry.setAddress(addressField.getValue());
                m_newEntry.setProtocol(protocolCombo.getValue().getValue());
                m_newEntry.setInPort(Integer.parseInt(inPortField.getValue()));
                m_newEntry.setOutPort(Integer.parseInt(outPortField.getValue()));
                m_newEntry.setMasquerade(masqueradeCombo.getValue().getValue());
                m_newEntry.setPermittedNetwork(permittedNetworkField.getValue());
                m_newEntry.setPermittedMAC(permittedMacField.getValue());
                m_newEntry.setSourcePortRange(sourcePortRangeField.getValue());
                if (m_newEntry.getPermittedMAC() != null) {
                    MessageBox.alert(MSGS.firewallPortForwardFormNotification(), MSGS.firewallPortForwardFormNotificationMacFiltering(), null);
                }
            } else {
                // update the current entry
                m_existingEntry = new GwtFirewallPortForwardEntry();
                m_existingEntry.setInboundInterface(inboundInterfaceField.getValue());
                m_existingEntry.setOutboundInterface(outboundInterfaceField.getValue());
                m_existingEntry.setAddress(addressField.getValue());
                m_existingEntry.setProtocol(protocolCombo.getValue().getValue());
                m_existingEntry.setInPort(Integer.parseInt(inPortField.getValue()));
                m_existingEntry.setOutPort(Integer.parseInt(outPortField.getValue()));
                m_existingEntry.setMasquerade(masqueradeCombo.getValue().getValue());
                m_existingEntry.setPermittedNetwork(permittedNetworkField.getValue());
                m_existingEntry.setPermittedMAC(permittedMacField.getValue());
                m_existingEntry.setSourcePortRange(sourcePortRangeField.getValue());
                if (m_existingEntry.getPermittedMAC() != null) {
                    MessageBox.alert(MSGS.firewallPortForwardFormNotification(), MSGS.firewallPortForwardFormNotificationMacFiltering(), null);
                }
            }
            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) {
        inboundInterfaceLabel.setValue(m_existingEntry.getInboundInterface());
        inboundInterfaceField.setValue(m_existingEntry.getInboundInterface());
        inboundInterfaceField.setOriginalValue(m_existingEntry.getInboundInterface());
        outboundInterfaceLabel.setValue(m_existingEntry.getOutboundInterface());
        outboundInterfaceField.setValue(m_existingEntry.getOutboundInterface());
        outboundInterfaceField.setOriginalValue(m_existingEntry.getOutboundInterface());
        addressLabel.setValue(m_existingEntry.getAddress());
        addressField.setValue(m_existingEntry.getAddress());
        addressField.setOriginalValue(m_existingEntry.getAddress());
        protocolLabel.setValue(m_existingEntry.getProtocol());
        protocolCombo.setSimpleValue(m_existingEntry.getProtocol());
        inPortLabel.setValue(m_existingEntry.getInPort());
        inPortField.setValue(m_existingEntry.getInPort().toString());
        inPortField.setOriginalValue(m_existingEntry.getInPort().toString());
        outPortField.setValue(m_existingEntry.getOutPort().toString());
        outPortField.setOriginalValue(m_existingEntry.getOutPort().toString());
        masqueradeCombo.setSimpleValue(m_existingEntry.getMasquerade());
        permittedNetworkField.setValue(m_existingEntry.getPermittedNetwork());
        permittedNetworkField.setOriginalValue(m_existingEntry.getPermittedNetwork());
        permittedMacField.setValue(m_existingEntry.getPermittedMAC());
        permittedMacField.setOriginalValue(m_existingEntry.getPermittedMAC());
        sourcePortRangeField.setValue(m_existingEntry.getSourcePortRange());
        sourcePortRangeField.setOriginalValue(m_existingEntry.getSourcePortRange());
    }
    add(m_formPanel);
}
Also used : FormData(com.extjs.gxt.ui.client.widget.layout.FormData) FormLayout(com.extjs.gxt.ui.client.widget.layout.FormLayout) Status(com.extjs.gxt.ui.client.widget.Status) SimpleComboBox(com.extjs.gxt.ui.client.widget.form.SimpleComboBox) FlowLayout(com.extjs.gxt.ui.client.widget.layout.FlowLayout) GwtFirewallNatMasquerade(org.eclipse.kura.web.shared.model.GwtFirewallNatMasquerade) GwtNetProtocol(org.eclipse.kura.web.shared.model.GwtNetProtocol) FieldSet(com.extjs.gxt.ui.client.widget.form.FieldSet) FormPanel(com.extjs.gxt.ui.client.widget.form.FormPanel) GwtFirewallPortForwardEntry(org.eclipse.kura.web.shared.model.GwtFirewallPortForwardEntry) Button(com.extjs.gxt.ui.client.widget.button.Button) ButtonEvent(com.extjs.gxt.ui.client.event.ButtonEvent) TextField(com.extjs.gxt.ui.client.widget.form.TextField) TextFieldValidator(org.eclipse.kura.web.client.util.TextFieldValidator) LabelField(com.extjs.gxt.ui.client.widget.form.LabelField) FillToolItem(com.extjs.gxt.ui.client.widget.toolbar.FillToolItem) SelectionListener(com.extjs.gxt.ui.client.event.SelectionListener)

Example 4 with GwtFirewallNatMasquerade

use of org.eclipse.kura.web.shared.model.GwtFirewallNatMasquerade 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);
}
Also used : FormData(com.extjs.gxt.ui.client.widget.layout.FormData) FormLayout(com.extjs.gxt.ui.client.widget.layout.FormLayout) Status(com.extjs.gxt.ui.client.widget.Status) SimpleComboBox(com.extjs.gxt.ui.client.widget.form.SimpleComboBox) FlowLayout(com.extjs.gxt.ui.client.widget.layout.FlowLayout) GwtFirewallNatMasquerade(org.eclipse.kura.web.shared.model.GwtFirewallNatMasquerade) FieldSet(com.extjs.gxt.ui.client.widget.form.FieldSet) FormPanel(com.extjs.gxt.ui.client.widget.form.FormPanel) Button(com.extjs.gxt.ui.client.widget.button.Button) ButtonEvent(com.extjs.gxt.ui.client.event.ButtonEvent) GwtFirewallNatEntry(org.eclipse.kura.web.shared.model.GwtFirewallNatEntry) GwtFirewallNatProtocol(org.eclipse.kura.web.shared.model.GwtFirewallNatProtocol) TextField(com.extjs.gxt.ui.client.widget.form.TextField) TextFieldValidator(org.eclipse.kura.web.client.util.TextFieldValidator) LabelField(com.extjs.gxt.ui.client.widget.form.LabelField) FillToolItem(com.extjs.gxt.ui.client.widget.toolbar.FillToolItem) SelectionListener(com.extjs.gxt.ui.client.event.SelectionListener)

Aggregations

GwtFirewallNatMasquerade (org.eclipse.kura.web.shared.model.GwtFirewallNatMasquerade)4 ButtonEvent (com.extjs.gxt.ui.client.event.ButtonEvent)2 SelectionListener (com.extjs.gxt.ui.client.event.SelectionListener)2 Status (com.extjs.gxt.ui.client.widget.Status)2 Button (com.extjs.gxt.ui.client.widget.button.Button)2 FieldSet (com.extjs.gxt.ui.client.widget.form.FieldSet)2 FormPanel (com.extjs.gxt.ui.client.widget.form.FormPanel)2 LabelField (com.extjs.gxt.ui.client.widget.form.LabelField)2 SimpleComboBox (com.extjs.gxt.ui.client.widget.form.SimpleComboBox)2 TextField (com.extjs.gxt.ui.client.widget.form.TextField)2 FlowLayout (com.extjs.gxt.ui.client.widget.layout.FlowLayout)2 FormData (com.extjs.gxt.ui.client.widget.layout.FormData)2 FormLayout (com.extjs.gxt.ui.client.widget.layout.FormLayout)2 FillToolItem (com.extjs.gxt.ui.client.widget.toolbar.FillToolItem)2 TextFieldValidator (org.eclipse.kura.web.client.util.TextFieldValidator)2 GwtFirewallNatProtocol (org.eclipse.kura.web.shared.model.GwtFirewallNatProtocol)2 GwtNetProtocol (org.eclipse.kura.web.shared.model.GwtNetProtocol)2 GwtFirewallNatEntry (org.eclipse.kura.web.shared.model.GwtFirewallNatEntry)1 GwtFirewallPortForwardEntry (org.eclipse.kura.web.shared.model.GwtFirewallPortForwardEntry)1