Search in sources :

Example 16 with FillToolItem

use of com.extjs.gxt.ui.client.widget.toolbar.FillToolItem in project geo-platform by geosdi.

the class ShowFeaturesWidget method createStatusBar.

private void createStatusBar() {
    super.setButtonAlign(Style.HorizontalAlignment.LEFT);
    super.getButtonBar().add(this.statusBar);
    super.getButtonBar().add(new FillToolItem());
    super.addButton(getAllFeatureButton);
}
Also used : FillToolItem(com.extjs.gxt.ui.client.widget.toolbar.FillToolItem)

Example 17 with FillToolItem

use of com.extjs.gxt.ui.client.widget.toolbar.FillToolItem in project jahia by Jahia.

the class AclEditor method addNewAclPanel.

public void addNewAclPanel(final LayoutContainer c) {
    formPanel = new FormPanel();
    formPanel.setScrollMode(Style.Scroll.AUTO);
    grids = new ArrayList<Grid>();
    for (final String displayedRole : displayedRoles) {
        FieldSet fs = new FieldSet();
        fs.setHeadingHtml(acl.getRolesLabels().get(displayedRole));
        List<ColumnConfig> configs = new ArrayList<ColumnConfig>();
        final ColumnConfig principalType = new ColumnConfig("type", 30);
        principalType.setRenderer(new GridCellRenderer() {

            @Override
            public Object render(ModelData model, String property, ColumnData config, int rowIndex, int colIndex, ListStore store, Grid grid) {
                Character type = model.get(property);
                Image html;
                if (type.equals('u')) {
                    html = StandardIconsProvider.STANDARD_ICONS.user().createImage();
                } else {
                    html = StandardIconsProvider.STANDARD_ICONS.group().createImage();
                }
                return html;
            }
        });
        configs.add(principalType);
        final ColumnConfig displayName = new ColumnConfig("displayName", 100);
        displayName.setRenderer(new GridCellRenderer<PrincipalModelData>() {

            @Override
            public Object render(PrincipalModelData model, String property, ColumnData config, int rowIndex, int colIndex, ListStore store, Grid grid) {
                if (model.getRemoved()) {
                    return "<span class=\"markedForDeletion\">" + model.get(property) + "</span>";
                } else {
                    return model.get(property);
                }
            }
        });
        configs.add(displayName);
        final ColumnConfig removedColumnConfig = new ColumnConfig("removed", 50);
        removedColumnConfig.setRenderer(new GridCellRenderer<PrincipalModelData>() {

            @Override
            public Object render(final PrincipalModelData model, String property, ColumnData config, int rowIndex, int colIndex, final ListStore store, final Grid grid) {
                Button button = new Button();
                button.setBorders(false);
                button.setEnabled(!readOnly);
                if (!model.getRemoved()) {
                    button.setIcon(StandardIconsProvider.STANDARD_ICONS.delete());
                    button.setToolTip(getResource("label.remove"));
                    if (model.getInheritedFrom() != null && !model.getInheritedFrom().equals("") && !breakAllInheritance) {
                        button.addSelectionListener(new SelectionListener<ButtonEvent>() {

                            public void componentSelected(ButtonEvent event) {
                                // model.setInherited(false);
                                model.setRemoved(true);
                                grid.getView().refresh(false);
                                setDirty();
                            }
                        });
                    } else {
                        button.addSelectionListener(new SelectionListener<ButtonEvent>() {

                            public void componentSelected(ButtonEvent event) {
                                store.remove(model);
                                resizeGrid(grid);
                                setDirty();
                            }
                        });
                    }
                    return button;
                } else {
                    button.setIcon(StandardIconsProvider.STANDARD_ICONS.restore());
                    button.setToolTip(getResource("label.restore"));
                    button.addSelectionListener(new SelectionListener<ButtonEvent>() {

                        public void componentSelected(ButtonEvent event) {
                            // model.setInherited(true);
                            model.setRemoved(false);
                            grid.getView().refresh(false);
                            setDirty();
                        }
                    });
                    return button;
                }
            }
        });
        configs.add(removedColumnConfig);
        final ColumnConfig inheritedColumnConfig = new ColumnConfig("inheritedFrom", 300);
        inheritedColumnConfig.setRenderer(new GridCellRenderer<PrincipalModelData>() {

            @Override
            public Object render(final PrincipalModelData model, String property, ColumnData config, int rowIndex, int colIndex, final ListStore store, final Grid grid) {
                if (!breakAllInheritance) {
                    return model.getInheritedFrom();
                } else {
                    return "";
                }
            }
        });
        configs.add(inheritedColumnConfig);
        final ListStore<PrincipalModelData> listStore = stores.get(displayedRole);
        Grid<PrincipalModelData> g = new Grid<PrincipalModelData>(listStore, new ColumnModel(configs));
        g.getView().setAdjustForHScroll(false);
        g.setHideHeaders(true);
        g.setAutoExpandMax(1500);
        g.setAutoExpandColumn("displayName");
        grids.add(g);
        fs.add(g);
        final UserGroupAdder userGroupAdder = new UserGroupAdder(listStore, g);
        ToolBar toolBar = new ToolBar();
        Button addUsersToolItem = new Button(getAddUsersLabel());
        addUsersToolItem.addStyleName("button-add-users");
        addUsersToolItem.setIcon(StandardIconsProvider.STANDARD_ICONS.user());
        addUsersToolItem.setEnabled(!readOnly);
        addUsersToolItem.addSelectionListener(new SelectionListener<ButtonEvent>() {

            public void componentSelected(ButtonEvent event) {
                new UserGroupSelect(userGroupAdder, UserGroupSelect.VIEW_USERS, siteKey);
            }
        });
        toolBar.add(addUsersToolItem);
        addUsersToolItem = new Button(getAddGroupsLabel());
        addUsersToolItem.addStyleName("button-add-groups");
        addUsersToolItem.setIcon(StandardIconsProvider.STANDARD_ICONS.group());
        addUsersToolItem.setEnabled(!readOnly);
        addUsersToolItem.addSelectionListener(new SelectionListener<ButtonEvent>() {

            public void componentSelected(ButtonEvent event) {
                new UserGroupSelect(userGroupAdder, UserGroupSelect.VIEW_GROUPS, siteKey);
            }
        });
        toolBar.add(addUsersToolItem);
        fs.add(toolBar);
        formPanel.add(fs);
    }
    ToolBar toolBar = new ToolBar();
    toolBar.add(breakinheritanceItem);
    toolBar.add(new FillToolItem());
    toolBar.add(restoreButton);
    formPanel.setTopComponent(toolBar);
    c.add(formPanel);
    c.layout();
    Scheduler.get().scheduleDeferred(new Scheduler.ScheduledCommand() {

        @Override
        public void execute() {
            for (Grid grid : grids) {
                resizeGrid(grid);
            }
        }
    });
}
Also used : ModelData(com.extjs.gxt.ui.client.data.ModelData) BaseModelData(com.extjs.gxt.ui.client.data.BaseModelData) Scheduler(com.google.gwt.core.client.Scheduler) Image(com.google.gwt.user.client.ui.Image) ListStore(com.extjs.gxt.ui.client.store.ListStore) FieldSet(com.extjs.gxt.ui.client.widget.form.FieldSet) Button(com.extjs.gxt.ui.client.widget.button.Button) UserGroupSelect(org.jahia.ajax.gwt.client.widget.usergroup.UserGroupSelect) FormPanel(com.extjs.gxt.ui.client.widget.form.FormPanel) ButtonEvent(com.extjs.gxt.ui.client.event.ButtonEvent) ToolBar(com.extjs.gxt.ui.client.widget.toolbar.ToolBar) FillToolItem(com.extjs.gxt.ui.client.widget.toolbar.FillToolItem) SelectionListener(com.extjs.gxt.ui.client.event.SelectionListener)

Example 18 with FillToolItem

use of com.extjs.gxt.ui.client.widget.toolbar.FillToolItem 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 19 with FillToolItem

use of com.extjs.gxt.ui.client.widget.toolbar.FillToolItem 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)

Example 20 with FillToolItem

use of com.extjs.gxt.ui.client.widget.toolbar.FillToolItem in project kura by eclipse.

the class FileUploadDialog method createButtons.

@Override
protected void createButtons() {
    super.createButtons();
    m_status = new Status();
    m_status.setBusy(MSGS.waitMsg());
    m_status.hide();
    m_status.setAutoWidth(true);
    getButtonBar().add(m_status);
    getButtonBar().add(new FillToolItem());
    m_submitButton = new Button(MSGS.uploadButton());
    m_submitButton.addSelectionListener(new SelectionListener<ButtonEvent>() {

        @Override
        public void componentSelected(ButtonEvent ce) {
            submit();
        }
    });
    m_cancelButton = new Button(MSGS.cancelButton());
    m_cancelButton.addSelectionListener(new SelectionListener<ButtonEvent>() {

        @Override
        public void componentSelected(ButtonEvent ce) {
            hide();
        }
    });
    addButton(m_cancelButton);
    addButton(m_submitButton);
}
Also used : Status(com.extjs.gxt.ui.client.widget.Status) Button(com.extjs.gxt.ui.client.widget.button.Button) ButtonEvent(com.extjs.gxt.ui.client.event.ButtonEvent) FillToolItem(com.extjs.gxt.ui.client.widget.toolbar.FillToolItem)

Aggregations

FillToolItem (com.extjs.gxt.ui.client.widget.toolbar.FillToolItem)24 Button (com.extjs.gxt.ui.client.widget.button.Button)20 ButtonEvent (com.extjs.gxt.ui.client.event.ButtonEvent)18 Status (com.extjs.gxt.ui.client.widget.Status)12 SelectionListener (com.extjs.gxt.ui.client.event.SelectionListener)9 FormPanel (com.extjs.gxt.ui.client.widget.form.FormPanel)8 FieldSet (com.extjs.gxt.ui.client.widget.form.FieldSet)7 ToolBar (com.extjs.gxt.ui.client.widget.toolbar.ToolBar)7 LabelField (com.extjs.gxt.ui.client.widget.form.LabelField)6 FlowLayout (com.extjs.gxt.ui.client.widget.layout.FlowLayout)6 FormLayout (com.extjs.gxt.ui.client.widget.layout.FormLayout)6 TextField (com.extjs.gxt.ui.client.widget.form.TextField)5 FormData (com.extjs.gxt.ui.client.widget.layout.FormData)5 SeparatorToolItem (com.extjs.gxt.ui.client.widget.toolbar.SeparatorToolItem)4 SplitButton (com.extjs.gxt.ui.client.widget.button.SplitButton)3 NumberField (com.extjs.gxt.ui.client.widget.form.NumberField)3 SimpleComboBox (com.extjs.gxt.ui.client.widget.form.SimpleComboBox)3 ModelData (com.extjs.gxt.ui.client.data.ModelData)2 ComponentEvent (com.extjs.gxt.ui.client.event.ComponentEvent)2 MenuEvent (com.extjs.gxt.ui.client.event.MenuEvent)2