Search in sources :

Example 1 with ListStore

use of com.extjs.gxt.ui.client.store.ListStore in project activityinfo by bedatadriven.

the class LocationFilterPanel method createList.

private void createList() {
    ListLoader filterLoader = new BaseListLoader(new LocationProxy());
    ListStore<LocationDTO> filterComboboxStore = new ListStore<>(filterLoader);
    filterCombobox = new ComboBox<>();
    filterCombobox.setEmptyText(I18N.CONSTANTS.searchForLocationToAdd());
    filterCombobox.setDisplayField("name");
    filterCombobox.setStore(filterComboboxStore);
    filterCombobox.setUseQueryCache(false);
    filterCombobox.setTypeAhead(true);
    filterCombobox.setTypeAheadDelay(120);
    filterCombobox.setQueryDelay(100);
    filterCombobox.addSelectionChangedListener(new SelectionChangedListener<LocationDTO>() {

        @Override
        public void selectionChanged(SelectionChangedEvent<LocationDTO> se) {
            if (se.getSelectedItem() != null && !store.contains(se.getSelectedItem())) {
                store.add(se.getSelectedItem());
                filterToolBar.setApplyFilterEnabled(true);
                // reset typed filter
                filterCombobox.setRawValue("");
            }
        }
    });
    listView = new ListView<>();
    listView.setStore(store);
    listView.setDisplayProperty("name");
    listView.setSelectionModel(listSelectionModel);
    add(filterCombobox, new RowData(1, -1));
    add(listView, new RowData(1, 1));
}
Also used : ListStore(com.extjs.gxt.ui.client.store.ListStore) RowData(com.extjs.gxt.ui.client.widget.layout.RowData) LocationDTO(org.activityinfo.legacy.shared.model.LocationDTO)

Example 2 with ListStore

use of com.extjs.gxt.ui.client.store.ListStore in project activityinfo by bedatadriven.

the class DbProjectGrid method createGridAndAddToContainer.

@Override
protected Grid<ProjectDTO> createGridAndAddToContainer(Store store) {
    grid = new Grid<ProjectDTO>((ListStore) store, createColumnModel());
    grid.setAutoExpandColumn("description");
    grid.setLoadMask(true);
    setLayout(new FitLayout());
    add(grid);
    return grid;
}
Also used : ProjectDTO(org.activityinfo.legacy.shared.model.ProjectDTO) ListStore(com.extjs.gxt.ui.client.store.ListStore) FitLayout(com.extjs.gxt.ui.client.widget.layout.FitLayout)

Example 3 with ListStore

use of com.extjs.gxt.ui.client.store.ListStore in project activityinfo by bedatadriven.

the class DbTargetGrid method createColumnModel.

protected ColumnModel createColumnModel() {
    List<ColumnConfig> columns = new ArrayList<ColumnConfig>();
    ColumnConfig projectColumn = new ColumnConfig("projectId", messages.project(), 150);
    projectColumn.setRenderer(new GridCellRenderer() {

        @Override
        public SafeHtml render(ModelData modelData, String s, ColumnData columnData, int i, int i1, ListStore listStore, Grid grid) {
            SafeHtmlBuilder sb = new SafeHtmlBuilder();
            Integer id = modelData.get(s);
            if (id != null) {
                ProjectDTO project = db.getProjectById(id);
                if (project != null) {
                    sb.appendEscaped(project.getName());
                }
            }
            return sb.toSafeHtml();
        }
    });
    ColumnConfig partnerColumn = new ColumnConfig("partnerId", messages.partner(), 150);
    partnerColumn.setRenderer(new GridCellRenderer() {

        @Override
        public SafeHtml render(ModelData modelData, String s, ColumnData columnData, int i, int i1, ListStore listStore, Grid grid) {
            SafeHtmlBuilder sb = new SafeHtmlBuilder();
            Integer id = modelData.get(s);
            if (id != null) {
                PartnerDTO partner = db.getPartnerById(id);
                if (partner != null) {
                    sb.appendEscaped(partner.getName());
                }
            }
            return sb.toSafeHtml();
        }
    });
    columns.add(new ColumnConfig("name", messages.name(), 150));
    columns.add(projectColumn);
    columns.add(partnerColumn);
    columns.add(new TimePeriodColumn("timePeriod", messages.timePeriod(), 300));
    return new ColumnModel(columns);
}
Also used : ProjectDTO(org.activityinfo.legacy.shared.model.ProjectDTO) ModelData(com.extjs.gxt.ui.client.data.ModelData) PartnerDTO(org.activityinfo.legacy.shared.model.PartnerDTO) SafeHtml(com.google.gwt.safehtml.shared.SafeHtml) ArrayList(java.util.ArrayList) SafeHtmlBuilder(com.google.gwt.safehtml.shared.SafeHtmlBuilder) ListStore(com.extjs.gxt.ui.client.store.ListStore) TimePeriodColumn(org.activityinfo.ui.client.page.common.columns.TimePeriodColumn)

Example 4 with ListStore

use of com.extjs.gxt.ui.client.store.ListStore in project activityinfo by bedatadriven.

the class DbUserEditor method createGrid.

private void createGrid() {
    loader = new BasePagingLoader<>(new UserProxy());
    loader.setRemoteSort(true);
    store = new ListStore<>(loader);
    store.setKeyProvider(model -> model.getEmail());
    store.addListener(Store.Update, event -> {
        setModified(!store.getModifiedRecords().isEmpty());
    });
    final List<ColumnConfig> columns = new ArrayList<ColumnConfig>();
    columns.add(new ColumnConfig("name", I18N.CONSTANTS.name(), 100));
    columns.add(new ColumnConfig("email", I18N.CONSTANTS.email(), 150));
    columns.add(new ColumnConfig("partner.name", I18N.CONSTANTS.partner(), 150));
    ColumnConfig folderColumn = new ColumnConfig("category", I18N.CONSTANTS.folders(), 150);
    folderColumn.setSortable(false);
    folderColumn.setRenderer(new GridCellRenderer() {

        @Override
        public SafeHtml render(ModelData modelData, String s, ColumnData columnData, int i, int i1, ListStore listStore, Grid grid) {
            if (modelData instanceof UserPermissionDTO) {
                UserPermissionDTO permission = (UserPermissionDTO) modelData;
                if (permission.hasFolderLimitation()) {
                    SafeHtmlBuilder html = new SafeHtmlBuilder();
                    boolean needsComma = false;
                    for (FolderDTO folder : permission.getFolders()) {
                        if (needsComma) {
                            html.appendHtmlConstant(", ");
                        }
                        html.appendEscaped(folder.getName());
                        needsComma = true;
                    }
                    return html.toSafeHtml();
                }
            }
            return ALL_CATEGORIES;
        }
    });
    columns.add(folderColumn);
    PermissionCheckConfig allowView = new PermissionCheckConfig(PermissionType.VIEW.name(), I18N.CONSTANTS.allowView(), 75);
    allowView.setDataIndex(PermissionType.VIEW.getDtoPropertyName());
    allowView.setToolTip(I18N.CONSTANTS.allowViewLong());
    columns.add(allowView);
    PermissionCheckConfig allowEdit = new PermissionCheckConfig(PermissionType.EDIT.name(), I18N.CONSTANTS.allowEdit(), 75);
    allowEdit.setDataIndex(PermissionType.EDIT.getDtoPropertyName());
    allowEdit.setToolTip(I18N.CONSTANTS.allowEditLong());
    columns.add(allowEdit);
    PermissionCheckConfig allowViewAll = new PermissionCheckConfig(PermissionType.VIEW_ALL.name(), I18N.CONSTANTS.allowViewAll(), 75);
    allowViewAll.setDataIndex(PermissionType.VIEW_ALL.getDtoPropertyName());
    allowViewAll.setToolTip(I18N.CONSTANTS.allowViewAllLong());
    columns.add(allowViewAll);
    PermissionCheckConfig allowEditAll = new PermissionCheckConfig(PermissionType.EDIT_ALL.name(), I18N.CONSTANTS.allowEditAll(), 75);
    allowEditAll.setDataIndex(PermissionType.EDIT_ALL.getDtoPropertyName());
    allowEditAll.setToolTip(I18N.CONSTANTS.allowEditAllLong());
    columns.add(allowEditAll);
    PermissionCheckConfig allowManageUsers = null;
    allowManageUsers = new PermissionCheckConfig(PermissionType.MANAGE_USERS.name(), I18N.CONSTANTS.allowManageUsers(), 150);
    allowManageUsers.setDataIndex(PermissionType.MANAGE_USERS.getDtoPropertyName());
    columns.add(allowManageUsers);
    PermissionCheckConfig allowManageAllUsers = new PermissionCheckConfig(PermissionType.MANAGE_ALL_USERS.name(), I18N.CONSTANTS.manageAllUsers(), 150);
    allowManageAllUsers.setDataIndex(PermissionType.MANAGE_ALL_USERS.getDtoPropertyName());
    columns.add(allowManageAllUsers);
    // only users with the right to design them selves can change the design
    // attribute
    PermissionCheckConfig allowDesign = new PermissionCheckConfig(PermissionType.DESIGN.name(), I18N.CONSTANTS.allowDesign(), 75);
    allowDesign.setDataIndex(PermissionType.DESIGN.getDtoPropertyName());
    allowDesign.setToolTip(I18N.CONSTANTS.allowDesignLong());
    columns.add(allowDesign);
    grid = new Grid<>(store, new ColumnModel(columns));
    grid.setLoadMask(true);
    grid.setSelectionModel(new GridSelectionModel<>());
    grid.getSelectionModel().addSelectionChangedListener(new SelectionChangedListener<UserPermissionDTO>() {

        @Override
        public void selectionChanged(SelectionChangedEvent<UserPermissionDTO> se) {
            onSelectionChanged(se.getSelectedItem());
        }
    });
    grid.addListener(Events.DoubleClick, new Listener<GridEvent<UserPermissionDTO>>() {

        @Override
        public void handleEvent(GridEvent<UserPermissionDTO> event) {
            actions.edit(event.getModel());
        }
    });
    grid.addPlugin(allowEdit);
    grid.addPlugin(allowViewAll);
    grid.addPlugin(allowEditAll);
    grid.addPlugin(allowManageUsers);
    grid.addPlugin(allowManageAllUsers);
    grid.addPlugin(allowDesign);
    add(grid);
}
Also used : SafeHtml(com.google.gwt.safehtml.shared.SafeHtml) ArrayList(java.util.ArrayList) ListStore(com.extjs.gxt.ui.client.store.ListStore) SafeHtmlBuilder(com.google.gwt.safehtml.shared.SafeHtmlBuilder)

Example 5 with ListStore

use of com.extjs.gxt.ui.client.store.ListStore in project activityinfo by bedatadriven.

the class DbTargetGrid method createGridAndAddToContainer.

@Override
protected Grid<TargetDTO> createGridAndAddToContainer(Store store) {
    this.store = (ListStore<TargetDTO>) store;
    grid = new Grid<TargetDTO>((ListStore) store, createColumnModel());
    grid.setAutoExpandColumn("name");
    grid.setLoadMask(true);
    setLayout(new BorderLayout());
    add(grid, new BorderLayoutData(Style.LayoutRegion.CENTER));
    return grid;
}
Also used : ListStore(com.extjs.gxt.ui.client.store.ListStore) BorderLayout(com.extjs.gxt.ui.client.widget.layout.BorderLayout) BorderLayoutData(com.extjs.gxt.ui.client.widget.layout.BorderLayoutData) TargetDTO(org.activityinfo.legacy.shared.model.TargetDTO)

Aggregations

ListStore (com.extjs.gxt.ui.client.store.ListStore)6 SafeHtml (com.google.gwt.safehtml.shared.SafeHtml)2 SafeHtmlBuilder (com.google.gwt.safehtml.shared.SafeHtmlBuilder)2 ArrayList (java.util.ArrayList)2 ProjectDTO (org.activityinfo.legacy.shared.model.ProjectDTO)2 Loader (com.extjs.gxt.ui.client.data.Loader)1 ModelData (com.extjs.gxt.ui.client.data.ModelData)1 PagingLoader (com.extjs.gxt.ui.client.data.PagingLoader)1 BorderLayout (com.extjs.gxt.ui.client.widget.layout.BorderLayout)1 BorderLayoutData (com.extjs.gxt.ui.client.widget.layout.BorderLayoutData)1 FitLayout (com.extjs.gxt.ui.client.widget.layout.FitLayout)1 RowData (com.extjs.gxt.ui.client.widget.layout.RowData)1 PagingToolBar (com.extjs.gxt.ui.client.widget.toolbar.PagingToolBar)1 LocationDTO (org.activityinfo.legacy.shared.model.LocationDTO)1 PartnerDTO (org.activityinfo.legacy.shared.model.PartnerDTO)1 TargetDTO (org.activityinfo.legacy.shared.model.TargetDTO)1 TimePeriodColumn (org.activityinfo.ui.client.page.common.columns.TimePeriodColumn)1