Search in sources :

Example 21 with SafeHtml

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);
}
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 22 with SafeHtml

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);
}
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 23 with SafeHtml

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);
            }
        });
    }
}
Also used : ModelData(com.extjs.gxt.ui.client.data.ModelData) SafeHtml(com.google.gwt.safehtml.shared.SafeHtml)

Example 24 with SafeHtml

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()));
        }
    }
}
Also used : SchemaImporterV3(org.activityinfo.ui.client.page.config.design.importer.SchemaImporterV3) PastedTable(org.activityinfo.ui.client.component.importDialog.model.source.PastedTable) SafeHtml(com.google.gwt.safehtml.shared.SafeHtml) FormClass(org.activityinfo.model.form.FormClass) FormTreePrettyPrinter(org.activityinfo.model.formTree.FormTreePrettyPrinter) FormTreeBuilder(org.activityinfo.model.formTree.FormTreeBuilder) Test(org.junit.Test)

Example 25 with SafeHtml

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);
}
Also used : ImageResource(com.google.gwt.resources.client.ImageResource) SafeHtml(com.google.gwt.safehtml.shared.SafeHtml) ArrayList(java.util.ArrayList)

Aggregations

SafeHtml (com.google.gwt.safehtml.shared.SafeHtml)125 Test (org.junit.Test)34 ImageResource (com.google.gwt.resources.client.ImageResource)25 SafeHtmlBuilder (com.google.gwt.safehtml.shared.SafeHtmlBuilder)24 UpdateColumnAuditLogEntry (org.drools.workbench.models.guided.dtable.shared.auditlog.UpdateColumnAuditLogEntry)14 BaseColumnFieldDiff (org.drools.workbench.models.guided.dtable.shared.model.BaseColumnFieldDiff)14 Column (com.google.gwt.user.cellview.client.Column)12 AbstractTextColumn (org.ovirt.engine.ui.common.widget.table.column.AbstractTextColumn)9 ArrayList (java.util.ArrayList)8 GwtTestTest (com.googlecode.gwt.test.GwtTestTest)7 Cell (com.google.gwt.cell.client.Cell)6 HTML (com.google.gwt.user.client.ui.HTML)6 DTCellValue52 (org.drools.workbench.models.guided.dtable.shared.model.DTCellValue52)6 ConfirmDialog (org.eclipse.che.ide.api.dialogs.ConfirmDialog)6 TextColumn (com.google.gwt.user.cellview.client.TextColumn)5 LinkedHashMap (java.util.LinkedHashMap)5 Element (com.google.gwt.dom.client.Element)4 Map (java.util.Map)4 ConfirmCallback (org.eclipse.che.ide.api.dialogs.ConfirmCallback)4 ClickableTextCell (com.google.gwt.cell.client.ClickableTextCell)3