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));
}
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;
}
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);
}
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);
}
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;
}
Aggregations