Search in sources :

Example 16 with ListLoadResult

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

the class AccountView method getAccountsGrid.

private Grid<GwtAccount> getAccountsGrid() {
    // 
    // Column Configuration
    ColumnConfig column = null;
    List<ColumnConfig> configs = new ArrayList<ColumnConfig>();
    column = new ColumnConfig("status", 30);
    column.setAlignment(HorizontalAlignment.CENTER);
    GridCellRenderer<GwtAccount> setStatusIcon = new GridCellRenderer<GwtAccount>() {

        public String render(GwtAccount model, String property, ColumnData config, int rowIndex, int colIndex, ListStore<GwtAccount> employeeList, Grid<GwtAccount> grid) {
            return "<image src=\"eclipse/org/eclipse/kapua/app/console/icon/green.gif\" width=\"12\" height=\"12\" style=\"vertical-align: bottom\" title=\"" + MSGS.enabled() + "\"/>";
        }
    };
    column.setRenderer(setStatusIcon);
    configs.add(column);
    column = new ColumnConfig("name", 120);
    column.setHeader(MSGS.accountTableName());
    column.setWidth(150);
    configs.add(column);
    column = new ColumnConfig("modifiedOnFormatted", MSGS.accountTableModifiedOn(), 130);
    column.setAlignment(HorizontalAlignment.CENTER);
    configs.add(column);
    m_columnModel = new ColumnModel(configs);
    // rpc data proxy
    RpcProxy<ListLoadResult<GwtAccount>> proxy = new RpcProxy<ListLoadResult<GwtAccount>>() {

        @Override
        protected void load(Object loadConfig, AsyncCallback<ListLoadResult<GwtAccount>> callback) {
            gwtAccountService.findChildren(m_currentSession.getSelectedAccount().getId(), false, callback);
        }
    };
    // grid loader
    m_accountLoader = new BaseListLoader<ListLoadResult<GwtAccount>>(proxy);
    SwappableListStore<GwtAccount> store = new SwappableListStore<GwtAccount>(m_accountLoader);
    store.setKeyProvider(new ModelKeyProvider<GwtAccount>() {

        public String getKey(GwtAccount gwtAccount) {
            return String.valueOf(gwtAccount.getId());
        }
    });
    // 
    // Grid
    m_grid = new Grid<GwtAccount>(store, m_columnModel);
    m_grid.setBorders(false);
    m_grid.setStateful(false);
    m_grid.setLoadMask(true);
    m_grid.setStripeRows(true);
    m_grid.setTrackMouseOver(false);
    m_grid.setAutoExpandColumn("name");
    m_grid.mask(MSGS.loading());
    m_grid.getView().setAutoFill(true);
    GridView gridView = m_grid.getView();
    gridView.setEmptyText(MSGS.accountTableNoAccounts());
    m_accountLoader.addLoadListener(new DataLoadListener(m_grid));
    GridSelectionModel<GwtAccount> selectionModel = new GridSelectionModel<GwtAccount>();
    selectionModel.setSelectionMode(SelectionMode.SINGLE);
    m_grid.setSelectionModel(selectionModel);
    m_grid.getSelectionModel().addSelectionChangedListener(new SelectionChangedListener<GwtAccount>() {

        @Override
        public void selectionChanged(SelectionChangedEvent<GwtAccount> se) {
            // Manage buttons
            if (se.getSelectedItem() != null) {
                m_editButton.setEnabled(m_currentSession.hasAccountUpdatePermission());
                m_deleteButton.setEnabled(m_currentSession.hasAccountDeletePermission());
            } else {
                m_editButton.setEnabled(false);
                m_deleteButton.setEnabled(false);
            }
            // Set account on tabs
            if (se.getSelectedItem() != null) {
                m_accountTabs.setAccount(m_grid.getSelectionModel().getSelectedItem());
            }
        }
    });
    // 
    // populate with initial status
    updateAccountGrid(null);
    return m_grid;
}
Also used : ColumnConfig(com.extjs.gxt.ui.client.widget.grid.ColumnConfig) Grid(com.extjs.gxt.ui.client.widget.grid.Grid) AsyncCallback(com.google.gwt.user.client.rpc.AsyncCallback) ArrayList(java.util.ArrayList) ColumnData(com.extjs.gxt.ui.client.widget.grid.ColumnData) RpcProxy(com.extjs.gxt.ui.client.data.RpcProxy) ListStore(com.extjs.gxt.ui.client.store.ListStore) SwappableListStore(org.eclipse.kapua.app.console.client.util.SwappableListStore) SwappableListStore(org.eclipse.kapua.app.console.client.util.SwappableListStore) GwtAccount(org.eclipse.kapua.app.console.shared.model.GwtAccount) GridSelectionModel(com.extjs.gxt.ui.client.widget.grid.GridSelectionModel) ListLoadResult(com.extjs.gxt.ui.client.data.ListLoadResult) GridCellRenderer(com.extjs.gxt.ui.client.widget.grid.GridCellRenderer) ColumnModel(com.extjs.gxt.ui.client.widget.grid.ColumnModel) GridView(com.extjs.gxt.ui.client.widget.grid.GridView)

Example 17 with ListLoadResult

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

the class DeviceForm method onRender.

protected void onRender(Element parent, int index) {
    super.onRender(parent, index);
    FormData formData = new FormData("-20");
    m_formPanel = new FormPanel();
    m_formPanel.setFrame(false);
    m_formPanel.setBodyBorder(false);
    m_formPanel.setHeaderVisible(false);
    m_formPanel.setWidth(310);
    m_formPanel.setScrollMode(Scroll.AUTOY);
    m_formPanel.setStyleAttribute("padding-bottom", "0px");
    m_formPanel.setLayout(new FlowLayout());
    // Device general info fieldset
    FieldSet fieldSet = new FieldSet();
    FormLayout layout = new FormLayout();
    layout.setLabelWidth(Constants.LABEL_WIDTH_DEVICE_FORM);
    fieldSet.setLayout(layout);
    fieldSet.setHeading(MSGS.deviceFormFieldsetGeneralInfo());
    // Device Client ID
    clientIdLabel = new LabelField();
    clientIdLabel.setFieldLabel(MSGS.deviceFormClientID());
    clientIdLabel.setLabelSeparator(":");
    clientIdLabel.setWidth(225);
    fieldSet.add(clientIdLabel, formData);
    clientIdField = new TextField<String>();
    clientIdField.setAllowBlank(false);
    clientIdField.setName("clientID");
    clientIdField.setFieldLabel(MSGS.deviceFormClientID());
    clientIdField.setValidator(new TextFieldValidator(clientIdField, FieldType.DEVICE_CLIENT_ID));
    clientIdField.setWidth(225);
    fieldSet.add(clientIdField, formData);
    // Display name
    displayNameField = new TextField<String>();
    displayNameField.setAllowBlank(true);
    displayNameField.setName("displayName");
    displayNameField.setFieldLabel(MSGS.deviceFormDisplayName());
    displayNameField.setWidth(225);
    fieldSet.add(displayNameField, formData);
    // Device Status
    statusCombo = new SimpleComboBox<GwtDeviceQueryPredicates.GwtDeviceStatus>();
    statusCombo.setName("status");
    statusCombo.setFieldLabel(MSGS.deviceFormStatus());
    statusCombo.setEditable(false);
    statusCombo.setTriggerAction(TriggerAction.ALL);
    statusCombo.setEmptyText(MSGS.deviceFilteringPanelStatusEmptyText());
    statusCombo.add(GwtDeviceQueryPredicates.GwtDeviceStatus.ENABLED);
    statusCombo.add(GwtDeviceQueryPredicates.GwtDeviceStatus.DISABLED);
    fieldSet.add(statusCombo, formData);
    // Tag fieldset
    FieldSet fieldSetTags = new FieldSet();
    FormLayout layoutTags = new FormLayout();
    layoutTags.setLabelWidth(Constants.LABEL_WIDTH_DEVICE_FORM);
    fieldSetTags.setLayout(layoutTags);
    fieldSetTags.setHeading(MSGS.deviceFormFieldsetTags());
    ContentPanel panel = new ContentPanel();
    panel.setBorders(false);
    panel.setBodyBorder(false);
    panel.setHeaderVisible(false);
    panel.setLayout(new RowLayout(Orientation.HORIZONTAL));
    panel.setBodyStyle("background-color:transparent");
    panel.setHeight(35);
    // Device Custom attributes fieldset
    FormLayout layoutSecurityOptions = new FormLayout();
    layoutSecurityOptions.setLabelWidth(Constants.LABEL_WIDTH_DEVICE_FORM);
    FieldSet fieldSetSecurityOptions = new FieldSet();
    fieldSetSecurityOptions.setLayout(layoutSecurityOptions);
    fieldSetSecurityOptions.setHeading(MSGS.deviceFormFieldsetSecurityOptions());
    // Provisioned Credentials Tight
    credentialsTightCombo = new SimpleComboBox<String>();
    credentialsTightCombo.setName("provisionedCredentialsTight");
    credentialsTightCombo.setEditable(false);
    credentialsTightCombo.setTypeAhead(false);
    credentialsTightCombo.setAllowBlank(false);
    credentialsTightCombo.setFieldLabel(MSGS.deviceFormProvisionedCredentialsTight());
    credentialsTightCombo.setToolTip(MSGS.deviceFormProvisionedCredentialsTightTooltip());
    credentialsTightCombo.setTriggerAction(TriggerAction.ALL);
    fieldSetSecurityOptions.add(credentialsTightCombo, formData);
    credentialsTightCombo.add(GwtDeviceCredentialsTight.INHERITED.getLabel());
    credentialsTightCombo.add(GwtDeviceCredentialsTight.LOOSE.getLabel());
    credentialsTightCombo.add(GwtDeviceCredentialsTight.STRICT.getLabel());
    credentialsTightCombo.setSimpleValue(GwtDeviceCredentialsTight.INHERITED.getLabel());
    // Device User
    RpcProxy<ListLoadResult<GwtUser>> deviceUserProxy = new RpcProxy<ListLoadResult<GwtUser>>() {

        @Override
        protected void load(Object loadConfig, AsyncCallback<ListLoadResult<GwtUser>> callback) {
            gwtUserService.findAll(m_currentSession.getSelectedAccount().getId(), callback);
        }
    };
    BaseListLoader<ListLoadResult<GwtUser>> deviceUserLoader = new BaseListLoader<ListLoadResult<GwtUser>>(deviceUserProxy);
    ListStore<GwtUser> deviceUserStore = new ListStore<GwtUser>(deviceUserLoader);
    deviceUserCombo = new ComboBox<GwtUser>();
    deviceUserCombo.setName("deviceUserCombo");
    deviceUserCombo.setEditable(false);
    deviceUserCombo.setTypeAhead(false);
    deviceUserCombo.setAllowBlank(false);
    deviceUserCombo.setFieldLabel(MSGS.deviceFormDeviceUser());
    deviceUserCombo.setTriggerAction(TriggerAction.ALL);
    deviceUserCombo.setStore(deviceUserStore);
    deviceUserCombo.setDisplayField("username");
    deviceUserCombo.setValueField("id");
    fieldSetSecurityOptions.add(deviceUserCombo, formData);
    // Allow credential change
    allowCredentialsChangeCheckbox = new CheckBox();
    allowCredentialsChangeCheckbox.setName("allowNewUnprovisionedDevicesCheckbox");
    allowCredentialsChangeCheckbox.setFieldLabel(MSGS.deviceFormAllowCredentialsChange());
    allowCredentialsChangeCheckbox.setToolTip(MSGS.deviceFormAllowCredentialsChangeTooltip());
    allowCredentialsChangeCheckbox.setBoxLabel("");
    fieldSetSecurityOptions.add(allowCredentialsChangeCheckbox, formData);
    // Device Custom attributes fieldset
    FieldSet fieldSetCustomAttributes = new FieldSet();
    FormLayout layoutCustomAttributes = new FormLayout();
    layoutCustomAttributes.setLabelWidth(Constants.LABEL_WIDTH_DEVICE_FORM);
    fieldSetCustomAttributes.setLayout(layoutCustomAttributes);
    fieldSetCustomAttributes.setHeading(MSGS.deviceFormFieldsetCustomAttributes());
    // Custom Attribute #1
    customAttribute1Field = new TextField<String>();
    customAttribute1Field.setName("customAttribute1");
    customAttribute1Field.setFieldLabel("* " + MSGS.deviceFormCustomAttribute1());
    customAttribute1Field.setWidth(225);
    fieldSetCustomAttributes.add(customAttribute1Field, formData);
    // Custom Attribute #2
    customAttribute2Field = new TextField<String>();
    customAttribute2Field.setName("customAttribute2");
    customAttribute2Field.setFieldLabel("* " + MSGS.deviceFormCustomAttribute2());
    customAttribute2Field.setWidth(225);
    fieldSetCustomAttributes.add(customAttribute2Field, formData);
    // Custom Attribute #3
    customAttribute3Field = new TextField<String>();
    customAttribute3Field.setName("customAttribute3");
    customAttribute3Field.setFieldLabel("* " + MSGS.deviceFormCustomAttribute3());
    customAttribute3Field.setWidth(225);
    fieldSetCustomAttributes.add(customAttribute3Field, formData);
    // Custom Attribute #4
    customAttribute4Field = new TextField<String>();
    customAttribute4Field.setName("customAttribute4");
    customAttribute4Field.setFieldLabel("* " + MSGS.deviceFormCustomAttribute4());
    customAttribute4Field.setWidth(225);
    fieldSetCustomAttributes.add(customAttribute4Field, formData);
    // Custom Attribute #5
    customAttribute5Field = new TextField<String>();
    customAttribute5Field.setName("customAttribute5");
    customAttribute5Field.setFieldLabel("* " + MSGS.deviceFormCustomAttribute5());
    customAttribute5Field.setWidth(225);
    fieldSetCustomAttributes.add(customAttribute5Field, formData);
    // Optlock
    optlock = new NumberField();
    optlock.setName("optlock");
    optlock.setEditable(false);
    optlock.setVisible(false);
    fieldSet.add(optlock, formData);
    m_formPanel.add(fieldSet);
    m_formPanel.add(fieldSetTags);
    m_formPanel.add(fieldSetSecurityOptions);
    m_formPanel.add(fieldSetCustomAttributes);
    m_formPanel.setButtonAlign(HorizontalAlignment.CENTER);
    Button submitButton = new Button(MSGS.deviceFormSubmitButton());
    submitButton.addListener(Events.OnClick, new Listener<BaseEvent>() {

        @Override
        public void handleEvent(BaseEvent be) {
            // make sure all visible fields are valid before performing the action
            for (Field<?> field : m_formPanel.getFields()) {
                if (field.isVisible() && !field.isValid()) {
                    MessageBox.alert(MSGS.error(), MSGS.formErrors(), null);
                    return;
                }
            }
            if (m_selectedDevice == null) {
                final GwtDeviceCreator gwtDeviceCreator = new GwtDeviceCreator();
                gwtDeviceCreator.setScopeId(m_currentSession.getSelectedAccount().getId());
                gwtDeviceCreator.setClientId(clientIdField.getValue());
                gwtDeviceCreator.setDisplayName(displayNameField.getValue());
                // Security Options
                gwtDeviceCreator.setGwtCredentialsTight(credentialsTightCombo.getSimpleValue());
                gwtDeviceCreator.setGwtPreferredUserId(deviceUserCombo.getValue().getId());
                // Custom attributes
                gwtDeviceCreator.setCustomAttribute1(unescapeValue(customAttribute1Field.getValue()));
                gwtDeviceCreator.setCustomAttribute2(unescapeValue(customAttribute2Field.getValue()));
                gwtDeviceCreator.setCustomAttribute3(unescapeValue(customAttribute3Field.getValue()));
                gwtDeviceCreator.setCustomAttribute4(unescapeValue(customAttribute4Field.getValue()));
                gwtDeviceCreator.setCustomAttribute5(unescapeValue(customAttribute5Field.getValue()));
                // 
                // Getting XSRF token
                gwtXSRFService.generateSecurityToken(new AsyncCallback<GwtXSRFToken>() {

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

                    @Override
                    public void onSuccess(GwtXSRFToken token) {
                        gwtDeviceService.createDevice(token, gwtDeviceCreator, new AsyncCallback<GwtDevice>() {

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

                            public void onSuccess(final GwtDevice gwtDevice) {
                                // 
                                // Getting XSRF token
                                gwtXSRFService.generateSecurityToken(new AsyncCallback<GwtXSRFToken>() {

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

                                    @Override
                                    public void onSuccess(GwtXSRFToken token) {
                                        hide();
                                        ConsoleInfo.display(MSGS.info(), MSGS.deviceUpdateSuccess());
                                    }
                                });
                            }
                        });
                    }
                });
            } else // Edit
            {
                // General info
                m_selectedDevice.setDisplayName(unescapeValue(displayNameField.getValue()));
                m_selectedDevice.setGwtDeviceStatus(statusCombo.getSimpleValue().name());
                // Security Options
                m_selectedDevice.setCredentialsTight(GwtDeviceCredentialsTight.getEnumFromLabel(credentialsTightCombo.getSimpleValue()).name());
                m_selectedDevice.setCredentialsAllowChange(allowCredentialsChangeCheckbox.getValue());
                m_selectedDevice.setDeviceUserId(deviceUserCombo.getValue().getId());
                // Custom attributes
                m_selectedDevice.setCustomAttribute1(unescapeValue(customAttribute1Field.getValue()));
                m_selectedDevice.setCustomAttribute2(unescapeValue(customAttribute2Field.getValue()));
                m_selectedDevice.setCustomAttribute3(unescapeValue(customAttribute3Field.getValue()));
                m_selectedDevice.setCustomAttribute4(unescapeValue(customAttribute4Field.getValue()));
                m_selectedDevice.setCustomAttribute5(unescapeValue(customAttribute5Field.getValue()));
                // Optlock
                m_selectedDevice.setOptlock(optlock.getValue().intValue());
                // 
                // Getting XSRF token
                gwtXSRFService.generateSecurityToken(new AsyncCallback<GwtXSRFToken>() {

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

                    @Override
                    public void onSuccess(GwtXSRFToken token) {
                        gwtDeviceService.updateAttributes(token, m_selectedDevice, new AsyncCallback<GwtDevice>() {

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

                            public void onSuccess(GwtDevice gwtDevice) {
                                // 
                                // Getting XSRF token
                                gwtXSRFService.generateSecurityToken(new AsyncCallback<GwtXSRFToken>() {

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

                                    @Override
                                    public void onSuccess(GwtXSRFToken token) {
                                        hide();
                                        ConsoleInfo.display(MSGS.info(), m_selectedDevice == null ? MSGS.deviceCreationSuccess() : MSGS.deviceUpdateSuccess());
                                    }
                                });
                            }
                        });
                    }
                });
            }
        }
    });
    Button cancelButton = new Button(MSGS.deviceFormCancelButton());
    cancelButton.addListener(Events.OnClick, new Listener<BaseEvent>() {

        @Override
        public void handleEvent(BaseEvent be) {
            hide();
        }
    });
    m_formPanel.addButton(submitButton);
    m_formPanel.addButton(cancelButton);
    add(m_formPanel);
    // Hide components according to NEW/EDIT mode
    makeNewEditAppearance();
    // Populate fields if we are in EDIT mode
    if (m_selectedDevice != null) {
        populateFields();
    }
}
Also used : FlowLayout(com.extjs.gxt.ui.client.widget.layout.FlowLayout) GwtDeviceCreator(org.eclipse.kapua.app.console.shared.model.GwtDeviceCreator) AsyncCallback(com.google.gwt.user.client.rpc.AsyncCallback) BaseListLoader(com.extjs.gxt.ui.client.data.BaseListLoader) GwtXSRFToken(org.eclipse.kapua.app.console.shared.model.GwtXSRFToken) RpcProxy(com.extjs.gxt.ui.client.data.RpcProxy) ListStore(com.extjs.gxt.ui.client.store.ListStore) Field(com.extjs.gxt.ui.client.widget.form.Field) TextField(com.extjs.gxt.ui.client.widget.form.TextField) LabelField(com.extjs.gxt.ui.client.widget.form.LabelField) NumberField(com.extjs.gxt.ui.client.widget.form.NumberField) FieldSet(com.extjs.gxt.ui.client.widget.form.FieldSet) GwtDevice(org.eclipse.kapua.app.console.shared.model.GwtDevice) Button(com.extjs.gxt.ui.client.widget.button.Button) RowLayout(com.extjs.gxt.ui.client.widget.layout.RowLayout) LabelField(com.extjs.gxt.ui.client.widget.form.LabelField) FormData(com.extjs.gxt.ui.client.widget.layout.FormData) FormLayout(com.extjs.gxt.ui.client.widget.layout.FormLayout) BaseEvent(com.extjs.gxt.ui.client.event.BaseEvent) NumberField(com.extjs.gxt.ui.client.widget.form.NumberField) ContentPanel(com.extjs.gxt.ui.client.widget.ContentPanel) ListLoadResult(com.extjs.gxt.ui.client.data.ListLoadResult) FormPanel(com.extjs.gxt.ui.client.widget.form.FormPanel) CheckBox(com.extjs.gxt.ui.client.widget.form.CheckBox) GwtUser(org.eclipse.kapua.app.console.shared.model.GwtUser) TextFieldValidator(org.eclipse.kapua.app.console.client.util.TextFieldValidator)

Example 18 with ListLoadResult

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

the class DeviceTabBundles method initGrid.

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

        @Override
        protected void load(Object loadConfig, final AsyncCallback<ListLoadResult<GwtGroupedNVPair>> callback) {
            if (m_selectedDevice != null) {
                if (m_selectedDevice.isOnline()) {
                    gwtDeviceManagementService.findBundles(m_selectedDevice, callback);
                } else {
                    m_grid.getStore().removeAll();
                    m_grid.unmask();
                }
            }
        }
    };
    m_loader = new BaseListLoader<ListLoadResult<GwtGroupedNVPair>>(proxy);
    m_loader.addLoadListener(new DataLoadListener());
    m_store = new ListStore<GwtGroupedNVPair>(m_loader);
    ColumnConfig id = new ColumnConfig("id", MSGS.deviceBndId(), 10);
    ColumnConfig name = new ColumnConfig("name", MSGS.deviceBndName(), 50);
    ColumnConfig status = new ColumnConfig("statusLoc", MSGS.deviceBndState(), 20);
    ColumnConfig version = new ColumnConfig("version", MSGS.deviceBndVersion(), 20);
    List<ColumnConfig> config = new ArrayList<ColumnConfig>();
    config.add(id);
    config.add(name);
    config.add(status);
    config.add(version);
    ColumnModel cm = new ColumnModel(config);
    GridView view = new GridView();
    view.setForceFit(true);
    view.setEmptyText(MSGS.deviceNoDeviceSelectedOrOffline());
    m_grid = new Grid<GwtGroupedNVPair>(m_store, cm);
    m_grid.setView(view);
    m_grid.setBorders(false);
    m_grid.setLoadMask(true);
    m_grid.setStripeRows(true);
    GridSelectionModel<GwtGroupedNVPair> selectionModel = new GridSelectionModel<GwtGroupedNVPair>();
    selectionModel.setSelectionMode(SelectionMode.SINGLE);
    m_grid.setSelectionModel(selectionModel);
    m_grid.getSelectionModel().addSelectionChangedListener(new SelectionChangedListener<GwtGroupedNVPair>() {

        @Override
        public void selectionChanged(SelectionChangedEvent<GwtGroupedNVPair> se) {
            if (m_grid.getSelectionModel().getSelectedItem() != null) {
                GwtGroupedNVPair selectedBundle = m_grid.getSelectionModel().getSelectedItem();
                if ("bndActive".equals(selectedBundle.getStatus())) {
                    m_startButton.disable();
                    m_stopButton.enable();
                } else {
                    m_stopButton.disable();
                    m_startButton.enable();
                }
            }
        }
    });
}
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) GwtGroupedNVPair(org.eclipse.kapua.app.console.shared.model.GwtGroupedNVPair) 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) GridView(com.extjs.gxt.ui.client.widget.grid.GridView)

Example 19 with ListLoadResult

use of com.extjs.gxt.ui.client.data.ListLoadResult 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)

Example 20 with ListLoadResult

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

the class UserManageForm method onRender.

protected void onRender(Element parent, int index) {
    super.onRender(parent, index);
    // 
    // Permission tab
    // 
    FormLayout permissionsLayout = new FormLayout();
    permissionsLayout.setLabelWidth(Constants.LABEL_WIDTH_FORM);
    permissionsFieldSet = new FieldSet();
    permissionsFieldSet.setBorders(false);
    permissionsFieldSet.setLayout(permissionsLayout);
    // permissions table columns
    List<ColumnConfig> configs = new ArrayList<ColumnConfig>();
    final CheckBoxSelectionModel<GwtUserPermission> sm = new CheckBoxSelectionModel<GwtUserPermission>();
    configs.add(sm.getColumn());
    ColumnConfig column = new ColumnConfig("accountPermission", MSGS.userPermissionsPermissionName(), 270);
    column.setAlignment(HorizontalAlignment.LEFT);
    configs.add(column);
    // Permissions table
    m_columnModel = new ColumnModel(configs);
    // 
    // Initial empty values
    List<GwtUserPermission> gwtUserPermissions = GwtUserPermission.getAllPermissions(m_accountId);
    MemoryProxy<List<GwtUserPermission>> proxy = new MemoryProxy<List<GwtUserPermission>>(gwtUserPermissions);
    ListLoader<ListLoadResult<ModelData>> loader = new BaseListLoader<ListLoadResult<ModelData>>(proxy);
    ListStore<GwtUserPermission> permissions = new ListStore<GwtUserPermission>(loader);
    loader.load();
    // Grid
    m_permisssionGrid = new EditorGrid<GwtUserPermission>(permissions, m_columnModel);
    m_permisssionGrid.setBorders(true);
    m_permisssionGrid.setStripeRows(true);
    m_permisssionGrid.getView().setAutoFill(true);
    m_permisssionGrid.setWidth(440);
    m_permisssionGrid.setHeight(374);
    m_permisssionGrid.setAutoExpandColumn("accountPermission");
    m_permisssionGrid.setSelectionModel(sm);
    m_permisssionGrid.addPlugin(sm);
    LabelField permissionsField = new LabelField();
    permissionsField.setFieldLabel(MSGS.userFormPermissions());
    permissionsFieldSet.add(permissionsField, formData);
    permissionsFieldSet.add(m_permisssionGrid, formData);
    m_tabUserPermission = new TabItem(MSGS.userFormAccess());
    m_tabUserPermission.setBorders(false);
    m_tabUserPermission.setStyleAttribute("background-color", "#E8E8E8");
    m_tabUserPermission.setScrollMode(Scroll.AUTOY);
    m_tabUserPermission.add(permissionsFieldSet);
    m_tabUserPermission.setLayout(new FitLayout());
    m_tabsPanel.add(m_tabUserPermission);
    add(m_formPanel);
}
Also used : FormLayout(com.extjs.gxt.ui.client.widget.layout.FormLayout) ModelData(com.extjs.gxt.ui.client.data.ModelData) GwtUserPermission(org.eclipse.kapua.app.console.shared.model.GwtUserPermission) CheckBoxSelectionModel(com.extjs.gxt.ui.client.widget.grid.CheckBoxSelectionModel) ColumnConfig(com.extjs.gxt.ui.client.widget.grid.ColumnConfig) ArrayList(java.util.ArrayList) MemoryProxy(com.extjs.gxt.ui.client.data.MemoryProxy) BaseListLoader(com.extjs.gxt.ui.client.data.BaseListLoader) ListLoadResult(com.extjs.gxt.ui.client.data.ListLoadResult) ListStore(com.extjs.gxt.ui.client.store.ListStore) TabItem(com.extjs.gxt.ui.client.widget.TabItem) FieldSet(com.extjs.gxt.ui.client.widget.form.FieldSet) ArrayList(java.util.ArrayList) List(java.util.List) ColumnModel(com.extjs.gxt.ui.client.widget.grid.ColumnModel) LabelField(com.extjs.gxt.ui.client.widget.form.LabelField) FitLayout(com.extjs.gxt.ui.client.widget.layout.FitLayout)

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