use of com.google.gwt.safehtml.shared.SafeHtmlBuilder 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.SafeHtmlBuilder in project activityinfo by bedatadriven.
the class MultilineRenderer method render.
@Override
public SafeHtml render(T item) {
SafeHtmlBuilder builder = new SafeHtmlBuilder();
render(item, builder);
return builder.toSafeHtml();
}
use of com.google.gwt.safehtml.shared.SafeHtmlBuilder in project gwt-material by GwtMaterialDesign.
the class CodeHelper method parseCode.
public static SafeHtml parseCode(String code) {
SafeHtmlBuilder builder = new SafeHtmlBuilder();
String[] splitted = code.replaceAll("\\\\s", " ").split("\\\\n\\s?");
String[] arr$ = splitted;
int len$ = splitted.length;
for (int i$ = 0; i$ < len$; ++i$) {
String s = arr$[i$];
builder.append(SafeHtmlUtils.fromTrustedString(SafeHtmlUtils.htmlEscapeAllowEntities(s)));
builder.appendHtmlConstant("<br>");
}
return builder.toSafeHtml();
}
use of com.google.gwt.safehtml.shared.SafeHtmlBuilder in project ovirt-engine by oVirt.
the class GlusterConfigAwareCell method render.
@Override
public void render(Context context, GlusterGeoRepSessionConfiguration value, SafeHtmlBuilder sb) {
List<String> allowedValues = value.getAllowedValues();
boolean isValuesConstrained = isValueConstrained(allowedValues);
SafeHtmlBuilder sbDelegate = new SafeHtmlBuilder();
if (isValuesConstrained) {
setOptions(allowedValues);
delegate.render(context, value.getDefaultValue(), sbDelegate);
} else {
textInputCell.render(context, value.getDefaultValue(), sbDelegate);
}
sb.append(sbDelegate.toSafeHtml());
}
use of com.google.gwt.safehtml.shared.SafeHtmlBuilder in project ovirt-engine by oVirt.
the class ListModelListBoxCell method render.
@SuppressWarnings("unchecked")
@Override
public void render(Context context, ListModel value, SafeHtmlBuilder sb, String id) {
setOptions(value);
SafeHtmlBuilder sbDelegate = new SafeHtmlBuilder();
delegate.render(context, renderer.render((T) value.getSelectedItem()), sbDelegate);
String select = sbDelegate.toSafeHtml().asString();
// $NON-NLS-1$ //$NON-NLS-2$
select = select.replaceFirst(PATTERN_SELECT, PATTERN_SELECT + " id=\"" + id + "\"");
if (value.getIsChangable()) {
sb.append(SafeHtmlUtils.fromTrustedString(select));
} else {
sb.appendHtmlConstant(select.replaceFirst(PATTERN_SELECT, REPLACEMENT_SELECT));
}
}
Aggregations