Search in sources :

Example 6 with GroupingView

use of com.extjs.gxt.ui.client.widget.grid.GroupingView 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 7 with GroupingView

use of com.extjs.gxt.ui.client.widget.grid.GroupingView in project kapua by eclipse.

the class DeviceTabProfile method onRender.

protected void onRender(Element parent, int index) {
    super.onRender(parent, index);
    setLayout(new FitLayout());
    setBorders(false);
    ContentPanel tabProfileContentPanel = new ContentPanel();
    tabProfileContentPanel.setLayout(new FitLayout());
    tabProfileContentPanel.setBorders(false);
    tabProfileContentPanel.setBodyBorder(false);
    tabProfileContentPanel.setHeaderVisible(false);
    tabProfileContentPanel.setTopComponent(getToolbar());
    RpcProxy<ListLoadResult<GwtGroupedNVPair>> proxy = new RpcProxy<ListLoadResult<GwtGroupedNVPair>>() {

        @Override
        protected void load(Object loadConfig, final AsyncCallback<ListLoadResult<GwtGroupedNVPair>> callback) {
            if (m_selectedDevice != null) {
                gwtDeviceService.findDeviceProfile(m_selectedDevice.getScopeId(), m_selectedDevice.getClientId(), callback);
            }
        }
    };
    m_loader = new BaseListLoader<ListLoadResult<GwtGroupedNVPair>>(proxy);
    m_loader.addLoadListener(new DataLoadListener());
    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);
    GridCellRenderer<GwtGroupedNVPair> renderer = new GridCellRenderer<GwtGroupedNVPair>() {

        @Override
        public Object render(GwtGroupedNVPair model, String property, ColumnData config, int rowIndex, int colIndex, ListStore<GwtGroupedNVPair> store, Grid<GwtGroupedNVPair> grid) {
            if (model.getName().equals("devLastEventOn") && model.getValue().compareTo("N/A") != 0) {
                return DateUtils.formatDateTime(new Date(Long.parseLong(model.getValue())));
            }
            return model.getValue();
        }
    };
    value.setRenderer(renderer);
    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);
    view.setEmptyText(MSGS.deviceNoDeviceSelected());
    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.disableTextSelection(false);
    tabProfileContentPanel.add(m_grid);
    add(tabProfileContentPanel);
    m_initialized = true;
}
Also used : ColumnConfig(com.extjs.gxt.ui.client.widget.grid.ColumnConfig) AsyncCallback(com.google.gwt.user.client.rpc.AsyncCallback) Grid(com.extjs.gxt.ui.client.widget.grid.Grid) ArrayList(java.util.ArrayList) ColumnData(com.extjs.gxt.ui.client.widget.grid.ColumnData) GwtGroupedNVPair(org.eclipse.kapua.app.console.shared.model.GwtGroupedNVPair) Date(java.util.Date) ContentPanel(com.extjs.gxt.ui.client.widget.ContentPanel) RpcProxy(com.extjs.gxt.ui.client.data.RpcProxy) ListLoadResult(com.extjs.gxt.ui.client.data.ListLoadResult) ListStore(com.extjs.gxt.ui.client.store.ListStore) GridCellRenderer(com.extjs.gxt.ui.client.widget.grid.GridCellRenderer) 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)

Aggregations

ListLoadResult (com.extjs.gxt.ui.client.data.ListLoadResult)7 ColumnConfig (com.extjs.gxt.ui.client.widget.grid.ColumnConfig)7 ColumnModel (com.extjs.gxt.ui.client.widget.grid.ColumnModel)7 GroupingView (com.extjs.gxt.ui.client.widget.grid.GroupingView)7 AsyncCallback (com.google.gwt.user.client.rpc.AsyncCallback)7 ArrayList (java.util.ArrayList)7 RpcProxy (com.extjs.gxt.ui.client.data.RpcProxy)6 FitLayout (com.extjs.gxt.ui.client.widget.layout.FitLayout)5 GwtGroupedNVPair (org.eclipse.kura.web.shared.model.GwtGroupedNVPair)5 GwtXSRFToken (org.eclipse.kura.web.shared.model.GwtXSRFToken)5 ContentPanel (com.extjs.gxt.ui.client.widget.ContentPanel)2 Grid (com.extjs.gxt.ui.client.widget.grid.Grid)2 GwtGroupedNVPair (org.eclipse.kapua.app.console.shared.model.GwtGroupedNVPair)2 El (com.extjs.gxt.ui.client.core.El)1 ModelData (com.extjs.gxt.ui.client.data.ModelData)1 BaseEvent (com.extjs.gxt.ui.client.event.BaseEvent)1 ButtonEvent (com.extjs.gxt.ui.client.event.ButtonEvent)1 ComponentEvent (com.extjs.gxt.ui.client.event.ComponentEvent)1 KeyListener (com.extjs.gxt.ui.client.event.KeyListener)1 GroupingStore (com.extjs.gxt.ui.client.store.GroupingStore)1