Search in sources :

Example 6 with SafeHtml

use of com.google.gwt.safehtml.shared.SafeHtml in project rstudio by rstudio.

the class MarkerSetsToolbarButton method updateAvailableMarkerSets.

public void updateAvailableMarkerSets(String[] sets) {
    ToolbarPopupMenu menu = getMenu();
    menu.clearItems();
    for (final String set : sets) {
        // command for selection
        Scheduler.ScheduledCommand cmd = new Scheduler.ScheduledCommand() {

            @Override
            public void execute() {
                ValueChangeEvent.fire(MarkerSetsToolbarButton.this, set);
            }
        };
        SafeHtml menuHTML = new SafeHtmlBuilder().appendHtmlConstant(set).toSafeHtml();
        menu.addItem(new MenuItem(menuHTML, cmd));
    }
}
Also used : ToolbarPopupMenu(org.rstudio.core.client.widget.ToolbarPopupMenu) ScrollableToolbarPopupMenu(org.rstudio.core.client.widget.ScrollableToolbarPopupMenu) Scheduler(com.google.gwt.core.client.Scheduler) SafeHtml(com.google.gwt.safehtml.shared.SafeHtml) MenuItem(com.google.gwt.user.client.ui.MenuItem) SafeHtmlBuilder(com.google.gwt.safehtml.shared.SafeHtmlBuilder)

Example 7 with SafeHtml

use of com.google.gwt.safehtml.shared.SafeHtml in project blogwt by billy1380.

the class MetaNotificationsPage method modes.

SafeHtml modes(List<NotificationModeType> modes) {
    SafeHtmlBuilder b = new SafeHtmlBuilder();
    boolean first = true;
    for (NotificationModeType t : Arrays.stream(NotificationModeType.values()).sorted((l, r) -> l.toString().compareTo(r.toString())).collect(Collectors.toList())) {
        if (!first) {
            b.appendEscaped(" ");
        } else {
            first = false;
        }
        b.appendEscaped(t.toString() + "(");
        if (modes == null || !modes.contains(t)) {
            b.append(PagesPageTemplates.INSTANCE.no());
        } else {
            b.append(PagesPageTemplates.INSTANCE.yes());
        }
        b.appendEscaped(")");
    }
    return b.toSafeHtml();
}
Also used : Arrays(java.util.Arrays) MetaNotificationController(com.willshex.blogwt.client.controller.MetaNotificationController) NotificationModeType(com.willshex.blogwt.shared.api.datatype.NotificationModeType) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) LoadingPanel(com.willshex.blogwt.client.part.LoadingPanel) UiHandler(com.google.gwt.uibinder.client.UiHandler) PagerHelper(com.willshex.blogwt.shared.helper.PagerHelper) GWT(com.google.gwt.core.client.GWT) PageType(com.willshex.blogwt.shared.page.PageType) UiBinder(com.google.gwt.uibinder.client.UiBinder) SafeHtmlBuilder(com.google.gwt.safehtml.shared.SafeHtmlBuilder) PagesPageTemplates(com.willshex.blogwt.client.page.admin.PagesPage.PagesPageTemplates) Page(com.willshex.blogwt.client.page.Page) Button(com.google.gwt.user.client.ui.Button) UiHelper(com.willshex.blogwt.client.helper.UiHelper) Collectors(java.util.stream.Collectors) MetaNotification(com.willshex.blogwt.shared.api.datatype.MetaNotification) List(java.util.List) Widget(com.google.gwt.user.client.ui.Widget) TextColumn(com.google.gwt.user.cellview.client.TextColumn) Column(com.google.gwt.user.cellview.client.Column) NoneFoundPanel(com.willshex.blogwt.client.part.NoneFoundPanel) UiField(com.google.gwt.uibinder.client.UiField) SimplePager(com.willshex.blogwt.client.part.SimplePager) CellTable(com.google.gwt.user.cellview.client.CellTable) PageTypeHelper(com.willshex.blogwt.client.helper.PageTypeHelper) SafeHtml(com.google.gwt.safehtml.shared.SafeHtml) BootstrapGwtCellTable(com.willshex.blogwt.client.part.BootstrapGwtCellTable) NotificationModeType(com.willshex.blogwt.shared.api.datatype.NotificationModeType) SafeHtmlBuilder(com.google.gwt.safehtml.shared.SafeHtmlBuilder)

Example 8 with SafeHtml

use of com.google.gwt.safehtml.shared.SafeHtml in project blogwt by billy1380.

the class UsersPage method createColumns.

/**
 * create columns
 */
private void createColumns() {
    Column<User, String> avatar = new Column<User, String>(UiHelper.IMAGE_PROTOTYPE) {

        @Override
        public String getValue(User object) {
            return object.avatar + "?s=" + UserHelper.AVATAR_HEADER_SIZE + "&default=retro";
        }
    };
    tblUsers.setColumnWidth(avatar, 20.0, Unit.PX);
    TextColumn<User> username = new TextColumn<User>() {

        @Override
        public String getValue(User object) {
            return object.username;
        }
    };
    TextColumn<User> name = new TextColumn<User>() {

        @Override
        public String getValue(User object) {
            return UserHelper.name(object);
        }
    };
    Column<User, SafeHtml> email = new Column<User, SafeHtml>(UiHelper.SAFE_HTML_PROTOTYPE) {

        @Override
        public SafeHtml getValue(User object) {
            return UsersPageTemplates.INSTANCE.emailLink(object.email, UserHelper.emailDescription(object));
        }
    };
    TextColumn<User> lastLoggedIn = new TextColumn<User>() {

        @Override
        public String getValue(User object) {
            return DateTimeHelper.ago(object.lastLoggedIn);
        }
    };
    Column<User, SafeHtml> edit = new Column<User, SafeHtml>(UiHelper.SAFE_HTML_PROTOTYPE) {

        @Override
        public SafeHtml getValue(User object) {
            return UiHelper.TEMPLATES.xsEdit(PageTypeHelper.asHref(PageType.ChangeDetailsPageType, "id", object.id.toString()));
        }
    };
    tblUsers.setColumnWidth(edit, 1.0, Unit.PX);
    Column<User, String> suspend = new Column<User, String>(UiHelper.ACTION_PROTOTYPE) {

        @Override
        public String getValue(User object) {
            return UserHelper.isSuspended(object) ? "unsuspend" : "suspend";
        }
    };
    suspend.setFieldUpdater(new FieldUpdater<User, String>() {

        @Override
        public void update(int index, User object, String value) {
            boolean suspended = UserHelper.isSuspended(object);
            if (suspended) {
                UserController.get().unsuspendUser(object);
            } else {
                if (Window.confirm("Are you sure you want to suspend " + object.username + "'s account indefinitely?")) {
                    UserController.get().suspendUser(object);
                }
            }
        }
    });
    tblUsers.setColumnWidth(suspend, 1.0, Unit.PX);
    Column<User, String> admin = new Column<User, String>(UiHelper.ACTION_PROTOTYPE) {

        @Override
        public String getValue(User object) {
            return "admin";
        }
    };
    final Role adminRole = RoleHelper.createFullAdmin();
    admin.setFieldUpdater(new FieldUpdater<User, String>() {

        @Override
        public void update(int index, User object, String value) {
            if (Window.confirm("Are you sure you want to make " + object.username + " a " + adminRole.name + "?")) {
                UserController.get().assignUserRoles(object, adminRole);
            }
        }
    });
    tblUsers.setColumnWidth(admin, 1.0, Unit.PX);
    tblUsers.addColumn(avatar);
    tblUsers.addColumn(username, "Username");
    tblUsers.addColumn(name, "Name");
    tblUsers.addColumn(email, "E-mail");
    tblUsers.addColumn(lastLoggedIn, "Last seen");
    tblUsers.addColumn(edit);
    tblUsers.addColumn(admin);
    tblUsers.addColumn(suspend);
}
Also used : Role(com.willshex.blogwt.shared.api.datatype.Role) User(com.willshex.blogwt.shared.api.datatype.User) TextColumn(com.google.gwt.user.cellview.client.TextColumn) Column(com.google.gwt.user.cellview.client.Column) SafeHtml(com.google.gwt.safehtml.shared.SafeHtml) TextColumn(com.google.gwt.user.cellview.client.TextColumn)

Example 9 with SafeHtml

use of com.google.gwt.safehtml.shared.SafeHtml in project drools-wb by kiegroup.

the class IssuePresenter method clear.

public void clear() {
    view.setIssueTitle("");
    view.setExplanation(new SafeHtml() {

        @Override
        public String asString() {
            return "";
        }
    });
    view.setLines("");
    view.hideLines();
}
Also used : SafeHtml(com.google.gwt.safehtml.shared.SafeHtml)

Example 10 with SafeHtml

use of com.google.gwt.safehtml.shared.SafeHtml in project drools-wb by kiegroup.

the class AuditLogViewImpl method setup.

public void setup() {
    // BZ-996917: Use a the gwtboostrap style "row-fluid" to allow display some events in the same row.
    eventTypes.setStyleName(Styles.ROW);
    // Fill panel with available events.
    for (Map.Entry<String, Boolean> e : auditLog.getAuditLogFilter().getAcceptedTypes().entrySet()) {
        eventTypes.add(makeEventTypeCheckBox(e.getKey(), e.getValue()));
    }
    // Create the GWT Cell Table as events container.
    // BZ-996942: Set custom width and table css style.
    events = new CellTable<>();
    events.setWidth("100%");
    events.addStyleName(Styles.TABLE);
    dlp = new ListDataProvider<AuditLogEntry>() {

        @Override
        public void setList(final List<AuditLogEntry> listToWrap) {
            super.setList(listToWrap);
            cellTablePagination.rebuild(pager);
        }
    };
    dlp.addDataDisplay(events);
    AuditLogEntrySummaryColumn summaryColumn = new AuditLogEntrySummaryColumn(style.auditLogDetailLabel(), style.auditLogDetailValue());
    AuditLogEntryCommentColumn commentColumn = new AuditLogEntryCommentColumn();
    events.addColumn(summaryColumn);
    events.addColumn(commentColumn);
    events.setColumnWidth(summaryColumn, 60.0, Unit.PCT);
    events.setColumnWidth(commentColumn, 40.0, Unit.PCT);
    // If the current user is not an Administrator include the delete comment column
    if (identity.getRoles().contains(new RoleImpl(AppRoles.ADMIN.getName()))) {
        AuditLogEntryDeleteCommentColumn deleteCommentColumn = new AuditLogEntryDeleteCommentColumn();
        deleteCommentColumn.setFieldUpdater((int index, AuditLogEntry row, SafeHtml value) -> {
            row.setDeleted(true);
            dlp.setList(filterDeletedEntries(auditLog));
            dlp.refresh();
        });
        events.addColumn(deleteCommentColumn);
        events.setColumnWidth(commentColumn, 35.0, Unit.PCT);
        events.setColumnWidth(deleteCommentColumn, 5.0, Unit.PCT);
    }
    events.setEmptyTableWidget(new Label(GuidedDecisionTableConstants.INSTANCE.DecisionTableAuditLogNoEntries()));
    events.setKeyboardPagingPolicy(KeyboardPagingPolicy.CHANGE_PAGE);
    events.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.DISABLED);
    events.setPageSize(PAGE_SIZE);
    // Configure the simple pager.
    pager.setDisplay(events);
    pager.setPageSize(PAGE_SIZE);
    // Add the table to the container.
    eventsContainer.add(events);
}
Also used : SafeHtml(com.google.gwt.safehtml.shared.SafeHtml) RoleImpl(org.jboss.errai.security.shared.api.RoleImpl) Label(org.gwtbootstrap3.client.ui.Label) AuditLogEntry(org.drools.workbench.models.datamodel.auditlog.AuditLogEntry) Map(java.util.Map)

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