Search in sources :

Example 11 with ListLoadResult

use of com.extjs.gxt.ui.client.data.ListLoadResult in project kura by eclipse.

the class PortForwardingConfigTab method initGrid.

private void initGrid() {
    // 
    // Column Configuration
    ColumnConfig column = null;
    List<ColumnConfig> configs = new ArrayList<ColumnConfig>();
    column = new ColumnConfig("inboundInterface", MSGS.firewallPortForwardInboundInterface(), 80);
    column.setAlignment(HorizontalAlignment.CENTER);
    configs.add(column);
    column = new ColumnConfig("outboundInterface", MSGS.firewallPortForwardOutboundInterface(), 80);
    column.setAlignment(HorizontalAlignment.CENTER);
    configs.add(column);
    column = new ColumnConfig("address", MSGS.firewallPortForwardAddress(), 120);
    column.setAlignment(HorizontalAlignment.CENTER);
    configs.add(column);
    column = new ColumnConfig("protocol", MSGS.firewallPortForwardProtocol(), 60);
    column.setAlignment(HorizontalAlignment.CENTER);
    configs.add(column);
    column = new ColumnConfig("inPort", MSGS.firewallPortForwardInPort(), 60);
    column.setAlignment(HorizontalAlignment.CENTER);
    configs.add(column);
    column = new ColumnConfig("outPort", MSGS.firewallPortForwardOutPort(), 60);
    column.setAlignment(HorizontalAlignment.CENTER);
    configs.add(column);
    column = new ColumnConfig("masquerade", MSGS.firewallPortForwardMasquerade(), 60);
    column.setAlignment(HorizontalAlignment.CENTER);
    configs.add(column);
    column = new ColumnConfig("permittedNetwork", MSGS.firewallPortForwardPermittedNetwork(), 120);
    column.setAlignment(HorizontalAlignment.CENTER);
    configs.add(column);
    column = new ColumnConfig("permittedMAC", MSGS.firewallPortForwardPermittedMac(), 120);
    column.setAlignment(HorizontalAlignment.CENTER);
    configs.add(column);
    column = new ColumnConfig("sourcePortRange", MSGS.firewallPortForwardSourcePortRange(), 120);
    column.setAlignment(HorizontalAlignment.CENTER);
    configs.add(column);
    // rpc data proxy
    RpcProxy<ListLoadResult<GwtFirewallPortForwardEntry>> proxy = new RpcProxy<ListLoadResult<GwtFirewallPortForwardEntry>>() {

        @Override
        protected void load(Object loadConfig, final AsyncCallback<ListLoadResult<GwtFirewallPortForwardEntry>> callback) {
            gwtXSRFService.generateSecurityToken(new AsyncCallback<GwtXSRFToken>() {

                @Override
                public void onFailure(Throwable ex) {
                    FailureHandler.handle(ex);
                }

                @Override
                public void onSuccess(GwtXSRFToken token) {
                    gwtNetworkService.findDeviceFirewallPortForwards(token, callback);
                }
            });
        }
    };
    m_loader = new BaseListLoader<ListLoadResult<GwtFirewallPortForwardEntry>>(proxy);
    m_loader.setSortDir(SortDir.DESC);
    m_loader.setSortField("inPort");
    m_loader.setRemoteSort(true);
    SwappableListStore<GwtFirewallPortForwardEntry> m_store = new SwappableListStore<GwtFirewallPortForwardEntry>(m_loader);
    m_store.setKeyProvider(new ModelKeyProvider<GwtFirewallPortForwardEntry>() {

        public String getKey(GwtFirewallPortForwardEntry portForwardEntry) {
            return portForwardEntry.getInPort().toString();
        }
    });
    m_grid = new Grid<GwtFirewallPortForwardEntry>(m_store, new ColumnModel(configs));
    m_grid.setBorders(false);
    m_grid.setStateful(false);
    m_grid.setLoadMask(true);
    m_grid.setStripeRows(true);
    m_grid.setAutoExpandColumn("inPort");
    m_grid.getView().setAutoFill(true);
    // m_grid.getView().setEmptyText(MSGS.deviceTableNoDevices());
    m_loader.addLoadListener(new DataLoadListener(m_grid));
    GridSelectionModel<GwtFirewallPortForwardEntry> selectionModel = new GridSelectionModel<GwtFirewallPortForwardEntry>();
    selectionModel.setSelectionMode(SelectionMode.SINGLE);
    m_grid.setSelectionModel(selectionModel);
    m_grid.getSelectionModel().addSelectionChangedListener(new SelectionChangedListener<GwtFirewallPortForwardEntry>() {

        @Override
        public void selectionChanged(SelectionChangedEvent<GwtFirewallPortForwardEntry> se) {
            m_selectedEntry = se.getSelectedItem();
            if (m_selectedEntry != null) {
                m_editButton.setEnabled(true);
                m_deleteButton.setEnabled(true);
            } else {
                m_editButton.setEnabled(false);
                m_deleteButton.setEnabled(false);
            }
        }
    });
}
Also used : ColumnConfig(com.extjs.gxt.ui.client.widget.grid.ColumnConfig) AsyncCallback(com.google.gwt.user.client.rpc.AsyncCallback) ArrayList(java.util.ArrayList) GwtXSRFToken(org.eclipse.kura.web.shared.model.GwtXSRFToken) RpcProxy(com.extjs.gxt.ui.client.data.RpcProxy) SwappableListStore(org.eclipse.kura.web.client.util.SwappableListStore) GwtFirewallPortForwardEntry(org.eclipse.kura.web.shared.model.GwtFirewallPortForwardEntry) GridSelectionModel(com.extjs.gxt.ui.client.widget.grid.GridSelectionModel) ListLoadResult(com.extjs.gxt.ui.client.data.ListLoadResult) ColumnModel(com.extjs.gxt.ui.client.widget.grid.ColumnModel)

Example 12 with ListLoadResult

use of com.extjs.gxt.ui.client.data.ListLoadResult in project kura by eclipse.

the class OpenPortsConfigTab method initOpenPortsGrid.

private void initOpenPortsGrid() {
    // 
    // Column Configuration
    ColumnConfig column = null;
    List<ColumnConfig> configs = new ArrayList<ColumnConfig>();
    column = new ColumnConfig("portRange", MSGS.firewallOpenPort(), 100);
    column.setAlignment(HorizontalAlignment.CENTER);
    configs.add(column);
    column = new ColumnConfig("protocol", MSGS.firewallOpenPortProtocol(), 100);
    column.setAlignment(HorizontalAlignment.CENTER);
    configs.add(column);
    column = new ColumnConfig("permittedNetwork", MSGS.firewallOpenPortPermittedNetwork(), 130);
    column.setAlignment(HorizontalAlignment.CENTER);
    configs.add(column);
    column = new ColumnConfig("permittedInterfaceName", MSGS.firewallOpenPortPermittedInterfaceName(), 130);
    column.setAlignment(HorizontalAlignment.CENTER);
    configs.add(column);
    column = new ColumnConfig("unpermittedInterfaceName", MSGS.firewallOpenPortUnpermittedInterfaceName(), 130);
    column.setAlignment(HorizontalAlignment.CENTER);
    configs.add(column);
    column = new ColumnConfig("permittedMAC", MSGS.firewallOpenPortPermittedMac(), 130);
    column.setAlignment(HorizontalAlignment.CENTER);
    configs.add(column);
    column = new ColumnConfig("sourcePortRange", MSGS.firewallOpenPortSourcePortRange(), 130);
    column.setAlignment(HorizontalAlignment.CENTER);
    configs.add(column);
    // rpc data proxy
    RpcProxy<ListLoadResult<GwtFirewallOpenPortEntry>> proxy = new RpcProxy<ListLoadResult<GwtFirewallOpenPortEntry>>() {

        @Override
        protected void load(Object loadConfig, final AsyncCallback<ListLoadResult<GwtFirewallOpenPortEntry>> callback) {
            gwtXSRFService.generateSecurityToken(new AsyncCallback<GwtXSRFToken>() {

                @Override
                public void onFailure(Throwable ex) {
                    FailureHandler.handle(ex);
                }

                @Override
                public void onSuccess(GwtXSRFToken token) {
                    gwtNetworkService.findDeviceFirewallOpenPorts(token, callback);
                }
            });
        }
    };
    m_openPortsLoader = new BaseListLoader<ListLoadResult<GwtFirewallOpenPortEntry>>(proxy);
    m_openPortsLoader.setSortDir(SortDir.DESC);
    m_openPortsLoader.setSortField("port");
    m_openPortsLoader.setRemoteSort(true);
    SwappableListStore<GwtFirewallOpenPortEntry> m_store = new SwappableListStore<GwtFirewallOpenPortEntry>(m_openPortsLoader);
    m_store.setKeyProvider(new ModelKeyProvider<GwtFirewallOpenPortEntry>() {

        public String getKey(GwtFirewallOpenPortEntry openPortEntry) {
            return openPortEntry.getPortRange();
        }
    });
    m_grid = new Grid<GwtFirewallOpenPortEntry>(m_store, new ColumnModel(configs));
    m_grid.setBorders(false);
    m_grid.setStateful(false);
    m_grid.setLoadMask(true);
    m_grid.setStripeRows(true);
    m_grid.setAutoExpandColumn("portRange");
    m_grid.getView().setAutoFill(true);
    // m_grid.getView().setEmptyText(MSGS.deviceTableNoDevices());
    m_openPortsLoader.addLoadListener(new DataLoadListener(m_grid));
    GridSelectionModel<GwtFirewallOpenPortEntry> selectionModel = new GridSelectionModel<GwtFirewallOpenPortEntry>();
    selectionModel.setSelectionMode(SelectionMode.SINGLE);
    m_grid.setSelectionModel(selectionModel);
    m_grid.getSelectionModel().addSelectionChangedListener(new SelectionChangedListener<GwtFirewallOpenPortEntry>() {

        @Override
        public void selectionChanged(SelectionChangedEvent<GwtFirewallOpenPortEntry> se) {
            m_selectedEntry = se.getSelectedItem();
            if (m_selectedEntry != null) {
                m_editButton.setEnabled(true);
                m_deleteButton.setEnabled(true);
            } else {
                m_editButton.setEnabled(false);
                m_deleteButton.setEnabled(false);
            }
        }
    });
}
Also used : ColumnConfig(com.extjs.gxt.ui.client.widget.grid.ColumnConfig) AsyncCallback(com.google.gwt.user.client.rpc.AsyncCallback) ArrayList(java.util.ArrayList) GwtXSRFToken(org.eclipse.kura.web.shared.model.GwtXSRFToken) RpcProxy(com.extjs.gxt.ui.client.data.RpcProxy) SwappableListStore(org.eclipse.kura.web.client.util.SwappableListStore) GwtFirewallOpenPortEntry(org.eclipse.kura.web.shared.model.GwtFirewallOpenPortEntry) GridSelectionModel(com.extjs.gxt.ui.client.widget.grid.GridSelectionModel) ListLoadResult(com.extjs.gxt.ui.client.data.ListLoadResult) ColumnModel(com.extjs.gxt.ui.client.widget.grid.ColumnModel)

Example 13 with ListLoadResult

use of com.extjs.gxt.ui.client.data.ListLoadResult in project kura by eclipse.

the class TcpIpConfigTab method onRender.

protected void onRender(Element parent, int index) {
    super.onRender(parent, index);
    setLayout(new FitLayout());
    setId("network-tcpip");
    FormData formData = new FormData();
    formData.setWidth(250);
    m_formPanel = new FormPanel();
    m_formPanel.setFrame(false);
    m_formPanel.setBodyBorder(false);
    m_formPanel.setHeaderVisible(false);
    m_formPanel.setLayout(new FlowLayout());
    m_formPanel.setStyleAttribute("min-width", "775px");
    m_formPanel.setStyleAttribute("padding-left", "30px");
    m_fieldSet = new FieldSet();
    FormLayout layoutAccount = new FormLayout();
    layoutAccount.setLabelWidth(Constants.LABEL_WIDTH_FORM);
    m_fieldSet.setLayout(layoutAccount);
    m_fieldSet.setBorders(false);
    // 
    // Enabled
    // 
    initializeStatusListStore();
    // 
    // Tool Tip Box
    // 
    toolTipField.setText(defaultToolTip);
    m_fieldSet.add(toolTipField);
    // 
    // Status Combo
    // 
    m_statusCombo = new ComboBox<GwtNetIfStatusModel>();
    m_statusCombo.setName("comboStatus");
    m_statusCombo.setDisplayField(GwtNetIfStatusModel.NAME);
    m_statusCombo.setFieldLabel(MSGS.netIPv4Status());
    m_statusCombo.setEditable(false);
    m_statusCombo.setStore(m_statusListStore);
    m_statusCombo.setTemplate(getTemplate());
    m_statusCombo.setTypeAhead(true);
    m_statusCombo.setTriggerAction(TriggerAction.ALL);
    m_statusCombo.setValue(m_statusListStore.findModel(GwtNetIfStatusModel.STATUS, GwtNetIfStatus.netIPv4StatusDisabled.name()));
    m_statusCombo.addSelectionChangedListener(new SelectionChangedListener<GwtNetIfStatusModel>() {

        @Override
        public void selectionChanged(SelectionChangedEvent<GwtNetIfStatusModel> se) {
            m_netInterfaceConfigTabs.adjustInterfaceTabs();
            refreshForm();
            // Check for other WAN interfaces if current interface is changed to WAN
            if (isWanEnabled()) {
                m_formPanel.mask(MSGS.waiting());
                gwtNetworkService.findNetInterfaceConfigurations(new AsyncCallback<ListLoadResult<GwtNetInterfaceConfig>>() {

                    public void onFailure(Throwable caught) {
                        m_formPanel.unmask();
                        ;
                    }

                    public void onSuccess(ListLoadResult<GwtNetInterfaceConfig> result) {
                        for (GwtNetInterfaceConfig config : result.getData()) {
                            if (config.getStatusEnum().equals(GwtNetIfStatus.netIPv4StatusEnabledWAN) && !config.getName().equals(m_selectNetIfConfig.getName())) {
                                m_statusCombo.fireEvent(Events.Invalid);
                            }
                        }
                        m_formPanel.unmask();
                        ;
                    }
                });
            } else {
                FormUtils.removeWarningFieldIcon(m_statusCombo);
            }
        }
    });
    m_statusCombo.addStyleName("kura-combobox");
    m_statusCombo.addPlugin(m_dirtyPlugin);
    m_statusCombo.addPlugin(m_warningPlugin);
    m_fieldSet.add(m_statusCombo, formData);
    // 
    // Configure IP
    // 
    m_configureCombo = new SimpleComboBox<String>();
    m_configureCombo.setName("comboConfigure");
    m_configureCombo.setFieldLabel(MSGS.netIPv4Configure());
    m_configureCombo.setEditable(false);
    m_configureCombo.setTypeAhead(true);
    m_configureCombo.setTriggerAction(TriggerAction.ALL);
    m_configureCombo.setStyleAttribute("margin-top", Constants.LABEL_MARGIN_TOP_SEPARATOR);
    // show account status combo box
    for (GwtNetIfConfigMode mode : GwtNetIfConfigMode.values()) {
        m_configureCombo.add(MessageUtils.get(mode.name()));
    }
    if ((m_selectNetIfConfig != null) && (m_selectNetIfConfig.getHwTypeEnum() == GwtNetIfType.MODEM)) {
        m_statusListStore.remove(m_statusListStore.findModel(GwtNetIfStatusModel.STATUS, GwtNetIfStatus.netIPv4StatusEnabledLAN.name()));
    }
    m_configureCombo.setSimpleValue(MessageUtils.get(GwtNetIfConfigMode.netIPv4ConfigModeDHCP.name()));
    m_configureCombo.addSelectionChangedListener(new SelectionChangedListener<SimpleComboValue<String>>() {

        @Override
        public void selectionChanged(SelectionChangedEvent<SimpleComboValue<String>> se) {
            m_netInterfaceConfigTabs.adjustInterfaceTabs();
            refreshForm();
        }
    });
    m_configureCombo.addListener(Events.OnMouseOver, new MouseOverListener(MSGS.netIPv4ToolTipConfigure()));
    m_configureCombo.addStyleName("kura-combobox");
    m_configureCombo.addPlugin(m_dirtyPlugin);
    m_fieldSet.add(m_configureCombo, formData);
    // 
    // IP Address
    // 
    m_ipAddressField = new TextField<String>();
    m_ipAddressField.setAllowBlank(true);
    m_ipAddressField.setName("ipAddress");
    m_ipAddressField.setFieldLabel(MSGS.netIPv4Address());
    m_ipAddressField.setRegex(IPV4_REGEX);
    m_ipAddressField.getMessages().setRegexText(MSGS.netIPv4InvalidAddress());
    m_ipAddressField.addPlugin(m_dirtyPlugin);
    m_ipAddressField.addListener(Events.OnMouseOver, new MouseOverListener(MSGS.netIPv4ToolTipAddress()));
    m_ipAddressField.addStyleName("kura-textfield");
    m_fieldSet.add(m_ipAddressField, formData);
    // 
    // Subnet mask
    // 
    m_subnetMaskField = new TextField<String>();
    m_subnetMaskField.setAllowBlank(true);
    m_subnetMaskField.setName("subnetMask");
    m_subnetMaskField.setFieldLabel(MSGS.netIPv4SubnetMask());
    m_subnetMaskField.setRegex(IPV4_REGEX);
    m_subnetMaskField.getMessages().setRegexText(MSGS.netIPv4InvalidAddress());
    m_subnetMaskField.addListener(Events.OnMouseOver, new MouseOverListener(MSGS.netIPv4ToolTipSubnetMask()));
    m_subnetMaskField.addStyleName("kura-textfield");
    m_subnetMaskField.addPlugin(m_dirtyPlugin);
    m_fieldSet.add(m_subnetMaskField, formData);
    // 
    // Gateway
    // 
    m_gatewayField = new TextField<String>();
    m_gatewayField.setAllowBlank(true);
    m_gatewayField.setName("gateway");
    m_gatewayField.setFieldLabel(MSGS.netIPv4Gateway());
    m_gatewayField.setRegex(IPV4_REGEX);
    m_gatewayField.getMessages().setRegexText(MSGS.netIPv4InvalidAddress());
    m_gatewayField.addListener(Events.OnMouseOver, new MouseOverListener(MSGS.netIPv4ToolTipGateway()));
    m_gatewayField.addStyleName("kura-textfield");
    m_gatewayField.addPlugin(m_dirtyPlugin);
    m_fieldSet.add(m_gatewayField, formData);
    // 
    // Renew DHCP Lease
    // 
    Button renewDHCP = new Button(MSGS.netIPv4RenewDHCPLease(), // no image
    null, new SelectionListener<ButtonEvent>() {

        @Override
        public void componentSelected(ButtonEvent ce) {
            gwtXSRFService.generateSecurityToken(new AsyncCallback<GwtXSRFToken>() {

                @Override
                public void onFailure(Throwable ex) {
                    FailureHandler.handle(ex);
                }

                @Override
                public void onSuccess(GwtXSRFToken token) {
                    gwtNetworkService.renewDhcpLease(token, m_selectNetIfConfig.getName(), new AsyncCallback<Void>() {

                        public void onSuccess(Void result) {
                            update();
                            Log.debug("successfully renewed DHCP lease");
                        }

                        public void onFailure(Throwable caught) {
                            Log.debug("caught: " + caught.toString());
                            FailureHandler.handle(caught);
                        }
                    });
                }
            });
        }
    });
    m_renewDHCPButton = new AdapterField(renewDHCP);
    m_renewDHCPButton.setId("net-ipv4-renew-dhcp");
    m_renewDHCPButton.setLabelSeparator("");
    m_renewDHCPButton.addListener(Events.OnMouseOver, new MouseOverListener(MSGS.netIPv4ToolTipRenew()));
    FormData formDataButton = new FormData();
    formDataButton.setWidth(150);
    m_renewDHCPButton.addPlugin(m_dirtyPlugin);
    m_fieldSet.add(m_renewDHCPButton, formDataButton);
    // 
    // DNS read-only (for DHCP)
    // 
    m_dnsReadOnlyField = new TextArea();
    m_dnsReadOnlyField.setAllowBlank(true);
    m_dnsReadOnlyField.setName("dnsReadOnlyServers");
    m_dnsReadOnlyField.setFieldLabel(MSGS.netIPv4DNSServers());
    m_dnsReadOnlyField.setEnabled(false);
    m_dnsReadOnlyField.setHeight("1.5em");
    m_dnsReadOnlyField.setStyleAttribute("margin-top", Constants.LABEL_MARGIN_TOP_SEPARATOR);
    m_dnsReadOnlyField.setStyleAttribute("margin-bottom", "0px");
    m_dnsReadOnlyField.addListener(Events.OnMouseOver, new MouseOverListener(MSGS.netIPv4ToolTipDns()));
    m_fieldSet.add(m_dnsReadOnlyField, formData);
    // 
    // DNS
    // 
    m_dnsField = new TextArea();
    m_dnsField.setAllowBlank(true);
    m_dnsField.setName("dnsServers");
    m_dnsField.setFieldLabel(MSGS.netIPv4DNSServers());
    m_dnsField.setRegex("((" + IPV4_REGEX + ")[\\s,;\\n\\r\\t]*)+");
    m_dnsField.getMessages().setRegexText(MSGS.netIPv4InvalidAddress());
    m_dnsField.addListener(Events.OnMouseOver, new MouseOverListener(MSGS.netIPv4ToolTipDns()));
    m_dnsField.addListener(Events.OnChange, new Listener<FieldEvent>() {

        // Hide the DNS entry from the DHCP server if a custom DNS entry is added
        public void handleEvent(FieldEvent be) {
            TextArea t = (TextArea) be.getField();
            if (t.getValue() == null || t.getValue().isEmpty()) {
                showReadOnlyDns();
            } else {
                hideReadOnlyDns();
            }
        }
    });
    m_dnsField.addPlugin(m_dirtyPlugin);
    m_fieldSet.add(m_dnsField, formData);
    // 
    // Search Domains
    // 
    m_domainsField = new TextArea();
    m_domainsField.setAllowBlank(true);
    m_domainsField.setName("searchDomains");
    m_domainsField.setFieldLabel(MSGS.netIPv4SearchDomains());
    m_domainsField.setStyleAttribute("margin-top", Constants.LABEL_MARGIN_TOP_SEPARATOR);
    m_domainsField.addPlugin(m_dirtyPlugin);
    m_fieldSet.add(m_domainsField, formData);
    m_formPanel.add(m_fieldSet);
    add(m_formPanel);
    setScrollMode(Scroll.AUTO);
    m_initialized = true;
}
Also used : FlowLayout(com.extjs.gxt.ui.client.widget.layout.FlowLayout) TextArea(com.extjs.gxt.ui.client.widget.form.TextArea) AsyncCallback(com.google.gwt.user.client.rpc.AsyncCallback) SimpleComboValue(com.extjs.gxt.ui.client.widget.form.SimpleComboValue) GwtXSRFToken(org.eclipse.kura.web.shared.model.GwtXSRFToken) FieldSet(com.extjs.gxt.ui.client.widget.form.FieldSet) Button(com.extjs.gxt.ui.client.widget.button.Button) GwtNetInterfaceConfig(org.eclipse.kura.web.shared.model.GwtNetInterfaceConfig) GwtNetIfStatusModel(org.eclipse.kura.web.shared.model.GwtNetIfStatusModel) FitLayout(com.extjs.gxt.ui.client.widget.layout.FitLayout) GwtNetIfConfigMode(org.eclipse.kura.web.shared.model.GwtNetIfConfigMode) FormData(com.extjs.gxt.ui.client.widget.layout.FormData) FormLayout(com.extjs.gxt.ui.client.widget.layout.FormLayout) FieldEvent(com.extjs.gxt.ui.client.event.FieldEvent) AdapterField(com.extjs.gxt.ui.client.widget.form.AdapterField) ListLoadResult(com.extjs.gxt.ui.client.data.ListLoadResult) FormPanel(com.extjs.gxt.ui.client.widget.form.FormPanel) ButtonEvent(com.extjs.gxt.ui.client.event.ButtonEvent)

Example 14 with ListLoadResult

use of com.extjs.gxt.ui.client.data.ListLoadResult in project kura by eclipse.

the class ThreadsTab method onRender.

protected void onRender(Element parent, int index) {
    super.onRender(parent, index);
    setLayout(new FitLayout());
    setId("device-threads");
    RpcProxy<ListLoadResult<GwtGroupedNVPair>> proxy = new RpcProxy<ListLoadResult<GwtGroupedNVPair>>() {

        @Override
        protected void load(Object loadConfig, final AsyncCallback<ListLoadResult<GwtGroupedNVPair>> callback) {
            gwtXSRFService.generateSecurityToken(new AsyncCallback<GwtXSRFToken>() {

                @Override
                public void onFailure(Throwable ex) {
                    FailureHandler.handle(ex);
                }

                @Override
                public void onSuccess(GwtXSRFToken token) {
                    gwtDeviceService.findThreads(token, new AsyncCallback<ListLoadResult<GwtGroupedNVPair>>() {

                        public void onSuccess(ListLoadResult<GwtGroupedNVPair> pairs) {
                            callback.onSuccess(pairs);
                        }

                        public void onFailure(Throwable caught) {
                            FailureHandler.handle(caught);
                        }
                    });
                }
            });
        }
    };
    m_loader = new BaseListLoader<ListLoadResult<GwtGroupedNVPair>>(proxy);
    m_store = new GroupingStore<GwtGroupedNVPair>(m_loader);
    m_store.groupBy("group");
    ColumnConfig name = new ColumnConfig("name", MSGS.deviceThreadName(), 50);
    ColumnConfig value = new ColumnConfig("value", MSGS.deviceThreadInfo(), 50);
    List<ColumnConfig> config = new ArrayList<ColumnConfig>();
    config.add(name);
    config.add(value);
    ColumnModel cm = new ColumnModel(config);
    GroupingView view = new GroupingView();
    view.setShowGroupedColumn(false);
    view.setForceFit(true);
    m_grid = new Grid<GwtGroupedNVPair>(m_store, cm);
    m_grid.setView(view);
    m_grid.setBorders(false);
    m_grid.setLoadMask(true);
    m_grid.setStripeRows(true);
    add(m_grid);
    m_initialized = true;
}
Also used : ColumnConfig(com.extjs.gxt.ui.client.widget.grid.ColumnConfig) AsyncCallback(com.google.gwt.user.client.rpc.AsyncCallback) ArrayList(java.util.ArrayList) GwtGroupedNVPair(org.eclipse.kura.web.shared.model.GwtGroupedNVPair) GwtXSRFToken(org.eclipse.kura.web.shared.model.GwtXSRFToken) RpcProxy(com.extjs.gxt.ui.client.data.RpcProxy) ListLoadResult(com.extjs.gxt.ui.client.data.ListLoadResult) ColumnModel(com.extjs.gxt.ui.client.widget.grid.ColumnModel) GroupingView(com.extjs.gxt.ui.client.widget.grid.GroupingView) FitLayout(com.extjs.gxt.ui.client.widget.layout.FitLayout)

Example 15 with ListLoadResult

use of com.extjs.gxt.ui.client.data.ListLoadResult in project kura by eclipse.

the class SnapshotsTab method initGrid.

private void initGrid() {
    List<ColumnConfig> columns = new ArrayList<ColumnConfig>();
    ColumnConfig column = new ColumnConfig("snapshotId", MSGS.deviceSnapshotId(), 25);
    column.setSortable(false);
    column.setAlignment(HorizontalAlignment.CENTER);
    columns.add(column);
    column = new ColumnConfig("createdOnFormatted", MSGS.deviceSnapshotCreatedOn(), 75);
    column.setSortable(false);
    column.setAlignment(HorizontalAlignment.LEFT);
    columns.add(column);
    // loader and store
    RpcProxy<ListLoadResult<GwtSnapshot>> proxy = new RpcProxy<ListLoadResult<GwtSnapshot>>() {

        @Override
        public void load(Object loadConfig, final AsyncCallback<ListLoadResult<GwtSnapshot>> callback) {
            gwtXSRFService.generateSecurityToken(new AsyncCallback<GwtXSRFToken>() {

                @Override
                public void onFailure(Throwable ex) {
                    FailureHandler.handle(ex);
                }

                @Override
                public void onSuccess(GwtXSRFToken token) {
                    gwtSnapshotService.findDeviceSnapshots(token, callback);
                }
            });
        }
    };
    m_loader = new BaseListLoader<ListLoadResult<GwtSnapshot>>(proxy);
    m_loader.setSortDir(SortDir.DESC);
    m_loader.setSortField("createdOnFormatted");
    m_loader.addLoadListener(new DataLoadListener());
    m_store = new ListStore<GwtSnapshot>(m_loader);
    m_grid = new Grid<GwtSnapshot>(m_store, new ColumnModel(columns));
    m_grid.setBorders(false);
    m_grid.setStateful(false);
    m_grid.setLoadMask(true);
    m_grid.setStripeRows(true);
    m_grid.setTrackMouseOver(false);
    m_grid.getView().setAutoFill(true);
    m_grid.getView().setEmptyText(MSGS.deviceSnapshotsNone());
    GridSelectionModel<GwtSnapshot> selectionModel = new GridSelectionModel<GwtSnapshot>();
    selectionModel.setSelectionMode(SelectionMode.SINGLE);
    m_grid.setSelectionModel(selectionModel);
    m_grid.getSelectionModel().addSelectionChangedListener(new SelectionChangedListener<GwtSnapshot>() {

        @Override
        public void selectionChanged(SelectionChangedEvent<GwtSnapshot> se) {
            if (se.getSelectedItem() != null) {
                m_downloadButton.setEnabled(true);
                m_rollbackButton.setEnabled(true);
            } else {
                m_downloadButton.setEnabled(false);
                m_rollbackButton.setEnabled(false);
            }
        }
    });
}
Also used : GwtSnapshot(org.eclipse.kura.web.shared.model.GwtSnapshot) ColumnConfig(com.extjs.gxt.ui.client.widget.grid.ColumnConfig) AsyncCallback(com.google.gwt.user.client.rpc.AsyncCallback) ArrayList(java.util.ArrayList) GridSelectionModel(com.extjs.gxt.ui.client.widget.grid.GridSelectionModel) GwtXSRFToken(org.eclipse.kura.web.shared.model.GwtXSRFToken) RpcProxy(com.extjs.gxt.ui.client.data.RpcProxy) ListLoadResult(com.extjs.gxt.ui.client.data.ListLoadResult) ColumnModel(com.extjs.gxt.ui.client.widget.grid.ColumnModel)

Aggregations

ListLoadResult (com.extjs.gxt.ui.client.data.ListLoadResult)22 AsyncCallback (com.google.gwt.user.client.rpc.AsyncCallback)21 ColumnConfig (com.extjs.gxt.ui.client.widget.grid.ColumnConfig)20 ColumnModel (com.extjs.gxt.ui.client.widget.grid.ColumnModel)20 ArrayList (java.util.ArrayList)20 RpcProxy (com.extjs.gxt.ui.client.data.RpcProxy)19 GwtXSRFToken (org.eclipse.kura.web.shared.model.GwtXSRFToken)12 GridSelectionModel (com.extjs.gxt.ui.client.widget.grid.GridSelectionModel)11 FitLayout (com.extjs.gxt.ui.client.widget.layout.FitLayout)8 GroupingView (com.extjs.gxt.ui.client.widget.grid.GroupingView)7 ListStore (com.extjs.gxt.ui.client.store.ListStore)6 ContentPanel (com.extjs.gxt.ui.client.widget.ContentPanel)5 Grid (com.extjs.gxt.ui.client.widget.grid.Grid)5 GwtGroupedNVPair (org.eclipse.kura.web.shared.model.GwtGroupedNVPair)5 FieldSet (com.extjs.gxt.ui.client.widget.form.FieldSet)4 ColumnData (com.extjs.gxt.ui.client.widget.grid.ColumnData)4 GridCellRenderer (com.extjs.gxt.ui.client.widget.grid.GridCellRenderer)4 GridView (com.extjs.gxt.ui.client.widget.grid.GridView)4 SwappableListStore (org.eclipse.kura.web.client.util.SwappableListStore)4 ModelData (com.extjs.gxt.ui.client.data.ModelData)3