Search in sources :

Example 1 with GwtFirewallNatProtocol

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

Example 2 with GwtFirewallNatProtocol

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