use of com.google.gwt.safehtml.shared.SafeHtml 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.google.gwt.safehtml.shared.SafeHtml 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.google.gwt.safehtml.shared.SafeHtml in project activityinfo by bedatadriven.
the class DbEditor method promptDeleteSelection.
private void promptDeleteSelection() {
ModelData selected = tree.getSelectionModel().getSelectedItem();
if (!(selected instanceof EntityDTO)) {
return;
}
EntityDTO selectedEntity = (EntityDTO) selected;
if (selectedEntity instanceof FolderDTO && treeStore.getChildCount(selectedEntity) != 0) {
MessageBox.alert(I18N.CONSTANTS.delete(), I18N.CONSTANTS.folderNotEmpty(), null);
return;
}
SafeHtml message = confirmationMessage(selectedEntity);
if (message == null) {
deleteEntity(selectedEntity);
} else {
MessageBox.confirm(SafeHtmlUtils.fromString(I18N.CONSTANTS.confirmDeletion()), message, event -> {
if (event.getButtonClicked().getItemId().equals(Dialog.YES)) {
deleteEntity(selectedEntity);
}
});
}
}
use of com.google.gwt.safehtml.shared.SafeHtml in project activityinfo by bedatadriven.
the class SchemaCsvWriterV3Test method importSurveyForm.
@Test
public void importSurveyForm() {
PastedTable pastedTable = new PastedTable(expectedSurveyExport);
SchemaImporterV3 importer = new SchemaImporterV3(database.getId(), null, null);
assertTrue("columns found", importer.parseColumns(pastedTable));
boolean success = importer.processRows();
for (SafeHtml warning : importer.getWarnings()) {
System.out.println(warning);
}
assertTrue(success);
List<FormClass> formClasses = importer.toSave();
formClassProvider.addAll(formClasses);
FormTreeBuilder treeBuilder = new FormTreeBuilder(formClassProvider);
FormTreePrettyPrinter prettyPrinter = new FormTreePrettyPrinter();
for (FormClass formClass : formClasses) {
if (!formClass.isSubForm()) {
prettyPrinter.printTree(treeBuilder.queryTree(formClass.getId()));
}
}
}
use of com.google.gwt.safehtml.shared.SafeHtml in project ovirt-engine by oVirt.
the class VmTypeColumn method getRenderedValue.
public static SafeHtml getRenderedValue(VM vm) {
List<SafeHtml> images = new ArrayList<>();
if (vm.getVmPoolId() == null) {
VmTypeConfig config = VmTypeConfig.from(vm.getVmType(), vm.isStateless(), vm.isNextRunConfigurationExists());
images.add(getImageSafeHtml(config.getImageResource()));
} else {
ImageResource img = getPoolVmImageResource(vm.getVmType(), vm.isNextRunConfigurationExists());
images.add(getImageSafeHtml(img));
}
if (vm.isHostedEngine()) {
images.add(getImageSafeHtml(resources.mgmtNetwork()));
}
return images.isEmpty() ? null : MultiImageColumnHelper.getValue(images);
}
Aggregations