Search in sources :

Example 6 with ListLoadResult

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

the class StatusPanel method initStatusPanel.

private void initStatusPanel() {
    RpcProxy<ListLoadResult<GwtGroupedNVPair>> proxy = new RpcProxy<ListLoadResult<GwtGroupedNVPair>>() {

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

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

                @Override
                public void onSuccess(GwtXSRFToken token) {
                    gwtStatusService.getDeviceConfig(token, m_currentSession.isNetAdminAvailable(), new AsyncCallback<ListLoadResult<GwtGroupedNVPair>>() {

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

                        public void onSuccess(ListLoadResult<GwtGroupedNVPair> pairs) {
                            List<GwtGroupedNVPair> results = pairs.getData();
                            for (GwtGroupedNVPair result : results) {
                                if ("Connection Status".equals(result.getName())) {
                                    if ("CONNECTED".equals(result.getValue())) {
                                        m_connectDataServiceButton.disable();
                                        m_disconnectDataServiceButton.enable();
                                    } else {
                                        m_connectDataServiceButton.enable();
                                        m_disconnectDataServiceButton.disable();
                                    }
                                }
                            }
                            unmask();
                            callback.onSuccess(pairs);
                        }
                    });
                }
            });
        }
    };
    m_loader = new BaseListLoader<ListLoadResult<GwtGroupedNVPair>>(proxy);
    m_store = new GroupingStore<GwtGroupedNVPair>(m_loader);
    m_store.groupBy("groupLoc");
    m_store.setStoreSorter(new StoreSorter<GwtGroupedNVPair>(new Comparator<Object>() {

        public int compare(Object o1, Object o2) {
            if (o1 == null)
                o1 = new Integer(-1);
            else
                o1 = getIntFromString((String) o1);
            if (o2 == null)
                o2 = new Integer(-1);
            else
                o2 = getIntFromString((String) o2);
            return (Integer) o1 - (Integer) o2;
        }

        private Integer getIntFromString(String value) {
            if ("Cloud and Data Service".equals(value))
                return new Integer(0);
            else if ("Ethernet Settings".equals(value))
                return new Integer(1);
            else if ("Wireless Settings".equals(value))
                return new Integer(2);
            else if ("Cellular Settings".equals(value))
                return new Integer(3);
            else if ("Position Status".equals(value))
                return new Integer(4);
            else
                return new Integer(100);
        }
    }));
    ColumnConfig name = new ColumnConfig("name", MSGS.devicePropName(), 50);
    ColumnConfig value = new ColumnConfig("value", MSGS.devicePropValue(), 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);
    m_grid.setHideHeaders(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) Comparator(java.util.Comparator) 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)

Example 7 with ListLoadResult

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

the class NetworkInterfacesTable method initGrid.

private void initGrid() {
    // 
    // Column Configuration
    List<ColumnConfig> configs = new ArrayList<ColumnConfig>();
    ColumnConfig column = new ColumnConfig("name", MSGS.netInterfaceName(), 125);
    column.setAlignment(HorizontalAlignment.LEFT);
    column.setSortable(false);
    configs.add(column);
    // loader and store
    RpcProxy<ListLoadResult<GwtNetInterfaceConfig>> proxy = new RpcProxy<ListLoadResult<GwtNetInterfaceConfig>>() {

        @Override
        public void load(Object loadConfig, AsyncCallback<ListLoadResult<GwtNetInterfaceConfig>> callback) {
            gwtNetworkService.findNetInterfaceConfigurations(callback);
        }
    };
    m_loader = new BaseListLoader<ListLoadResult<GwtNetInterfaceConfig>>(proxy);
    m_loader.setRemoteSort(false);
    m_loader.setSortDir(SortDir.ASC);
    m_loader.setSortField("name");
    m_store = new ListStore<GwtNetInterfaceConfig>(m_loader);
    m_store.setStoreSorter(new StoreSorter<GwtNetInterfaceConfig>(new Comparator<Object>() {

        public int compare(Object o1, Object o2) {
            if (o1 == null) {
                o1 = new Integer(-1);
            } else {
                o1 = getIntFromName((String) o1);
            }
            if (o2 == null) {
                o2 = new Integer(-1);
            } else {
                o2 = getIntFromName((String) o2);
            }
            return (Integer) o1 - (Integer) o2;
        }

        private Integer getIntFromName(String name) {
            if ("lo".equals(name))
                return new Integer(1);
            else if ("eth0".equals(name))
                return new Integer(2);
            else if ("eth1".equals(name))
                return new Integer(3);
            else if (name.contains("eth"))
                return new Integer(4);
            else if ("wlan0".equals(name))
                return new Integer(10);
            else if ("ppp0".equals(name))
                return new Integer(20);
            else if (name.contains("ppp"))
                return new Integer(21);
            else
                return new Integer(100);
        }
    }));
    m_grid = new Grid<GwtNetInterfaceConfig>(m_store, new ColumnModel(configs));
    m_grid.setBorders(false);
    m_grid.setStateful(false);
    m_grid.setLoadMask(true);
    m_grid.setStripeRows(true);
    m_grid.setAutoExpandColumn("name");
    m_grid.getView().setAutoFill(true);
    m_grid.getView().setEmptyText(MSGS.netTableNoInterfaces());
    GridSelectionModel<GwtNetInterfaceConfig> selectionModel = new GridSelectionModel<GwtNetInterfaceConfig>();
    selectionModel.setSelectionMode(SelectionMode.SINGLE);
    m_grid.setSelectionModel(selectionModel);
    // 
    // on selection, complete the switch
    m_grid.getSelectionModel().addSelectionChangedListener(new SelectionChangedListener<GwtNetInterfaceConfig>() {

        @Override
        public void selectionChanged(SelectionChangedEvent<GwtNetInterfaceConfig> se) {
            GwtNetInterfaceConfig gwtNetIfConfig = se.getSelectedItem();
            if (gwtNetIfConfig != null) {
                m_selectedIfConfig = gwtNetIfConfig;
                m_netConfigTabs.setNetInterface(gwtNetIfConfig);
            }
        }
    });
    m_loader.addLoadListener(new DataLoadListener(m_netConfigTabs, m_grid));
}
Also used : 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) RpcProxy(com.extjs.gxt.ui.client.data.RpcProxy) Comparator(java.util.Comparator) ListLoadResult(com.extjs.gxt.ui.client.data.ListLoadResult) GwtNetInterfaceConfig(org.eclipse.kura.web.shared.model.GwtNetInterfaceConfig) ColumnModel(com.extjs.gxt.ui.client.widget.grid.ColumnModel)

Example 8 with ListLoadResult

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

the class ProfileTab method onRender.

protected void onRender(Element parent, int index) {
    super.onRender(parent, index);
    setLayout(new FitLayout());
    setBorders(false);
    setId("device-profile");
    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.findDeviceConfiguration(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("groupLoc");
    ColumnConfig name = new ColumnConfig("nameLoc", MSGS.devicePropName(), 50);
    ColumnConfig value = new ColumnConfig("value", MSGS.devicePropValue(), 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 9 with ListLoadResult

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

the class SystemPropertiesTab method onRender.

protected void onRender(Element parent, int index) {
    super.onRender(parent, index);
    setLayout(new FitLayout());
    setId("device-system-properties");
    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.findSystemProperties(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("groupLoc");
    ColumnConfig name = new ColumnConfig("name", MSGS.devicePropName(), 50);
    ColumnConfig value = new ColumnConfig("value", MSGS.devicePropValue(), 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 10 with ListLoadResult

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

the class NatConfigTab method initGrid.

private void initGrid() {
    // 
    // Column Configuration
    ColumnConfig column = null;
    List<ColumnConfig> configs = new ArrayList<ColumnConfig>();
    column = new ColumnConfig("inInterface", MSGS.firewallNatInInterface(), 60);
    column.setAlignment(HorizontalAlignment.CENTER);
    configs.add(column);
    column = new ColumnConfig("outInterface", MSGS.firewallNatOutInterface(), 60);
    column.setAlignment(HorizontalAlignment.CENTER);
    configs.add(column);
    column = new ColumnConfig("protocol", MSGS.firewallNatProtocol(), 60);
    column.setAlignment(HorizontalAlignment.CENTER);
    configs.add(column);
    column = new ColumnConfig("sourceNetwork", MSGS.firewallNatSourceNetwork(), 120);
    column.setAlignment(HorizontalAlignment.CENTER);
    configs.add(column);
    column = new ColumnConfig("destinationNetwork", MSGS.firewallNatDestinationNetwork(), 120);
    column.setAlignment(HorizontalAlignment.CENTER);
    configs.add(column);
    column = new ColumnConfig("masquerade", MSGS.firewallNatMasquerade(), 60);
    column.setAlignment(HorizontalAlignment.CENTER);
    configs.add(column);
    // rpc data proxy
    RpcProxy<ListLoadResult<GwtFirewallNatEntry>> proxy = new RpcProxy<ListLoadResult<GwtFirewallNatEntry>>() {

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

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

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

        public String getKey(GwtFirewallNatEntry firewallNatEntry) {
            return firewallNatEntry.getInInterface();
        }
    });
    m_grid = new Grid<GwtFirewallNatEntry>(m_store, new ColumnModel(configs));
    m_grid.setBorders(false);
    m_grid.setStateful(false);
    m_grid.setLoadMask(true);
    m_grid.setStripeRows(true);
    m_grid.setAutoExpandColumn("inInterface");
    m_grid.getView().setAutoFill(true);
    m_loader.addLoadListener(new DataLoadListener(m_grid));
    GridSelectionModel<GwtFirewallNatEntry> selectionModel = new GridSelectionModel<GwtFirewallNatEntry>();
    selectionModel.setSelectionMode(SelectionMode.SINGLE);
    m_grid.setSelectionModel(selectionModel);
    m_grid.getSelectionModel().addSelectionChangedListener(new SelectionChangedListener<GwtFirewallNatEntry>() {

        @Override
        public void selectionChanged(SelectionChangedEvent<GwtFirewallNatEntry> 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) GridSelectionModel(com.extjs.gxt.ui.client.widget.grid.GridSelectionModel) ListLoadResult(com.extjs.gxt.ui.client.data.ListLoadResult) GwtFirewallNatEntry(org.eclipse.kura.web.shared.model.GwtFirewallNatEntry) 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