Search in sources :

Example 16 with SafeHtmlBuilder

use of com.google.gwt.safehtml.shared.SafeHtmlBuilder 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 17 with SafeHtmlBuilder

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

the class SVNStatusRenderer method render.

@Override
public SafeHtml render(String str) {
    if (str.length() != 1)
        return SafeHtmlUtils.fromString(str);
    ImageResource2x img = imgForStatus(str.charAt(0));
    if (img == null)
        return SafeHtmlUtils.fromString(str);
    SafeHtmlBuilder builder = new SafeHtmlBuilder();
    builder.append(SafeHtmlUtils.fromTrustedString("<span " + "class=\"" + ctRes_.cellTableStyle().status() + "\" " + "title=\"" + SafeHtmlUtils.htmlEscape(descForStatus(str)) + "\">"));
    builder.append(img.getSafeHtml());
    builder.appendHtmlConstant("</span>");
    return builder.toSafeHtml();
}
Also used : ImageResource2x(org.rstudio.core.client.resources.ImageResource2x) SafeHtmlBuilder(com.google.gwt.safehtml.shared.SafeHtmlBuilder)

Example 18 with SafeHtmlBuilder

use of com.google.gwt.safehtml.shared.SafeHtmlBuilder in project kie-wb-common by kiegroup.

the class NotificationMessageUtilsTest method testCanvasValidationMessage.

@Test
public void testCanvasValidationMessage() {
    final RuleViolation ruleViolation = mock(RuleViolation.class);
    final CanvasViolation canvasViolation = mock(CanvasViolation.class);
    when(canvasViolation.getViolationType()).thenReturn(Violation.Type.ERROR);
    when(canvasViolation.getRuleViolation()).thenReturn(ruleViolation);
    when(ruleViolation.getViolationType()).thenReturn(Violation.Type.ERROR);
    when(ruleViolation.getViolationType()).thenReturn(Violation.Type.ERROR);
    final Iterable<CanvasViolation> violations = Collections.singletonList(canvasViolation);
    when(translationService.getValue(eq("aKey"))).thenReturn("aValue");
    when(translationService.getViolationMessage(eq(canvasViolation))).thenReturn("cv1");
    String message = NotificationMessageUtils.getCanvasValidationsErrorMessage(translationService, "aKey", violations);
    message = new SafeHtmlBuilder().appendEscapedLines(message).toSafeHtml().asString();
    assertEquals("aValue." + HTML_NEW_LINE + "R" + COLON + HTML_NEW_LINE + OPEN_BRA + "1" + CLOSE_BRA + "(ERROR) " + "cv1" + HTML_NEW_LINE, message);
}
Also used : CanvasViolation(org.kie.workbench.common.stunner.core.client.command.CanvasViolation) RuleViolation(org.kie.workbench.common.stunner.core.rule.RuleViolation) SafeHtmlBuilder(com.google.gwt.safehtml.shared.SafeHtmlBuilder) Test(org.junit.Test)

Example 19 with SafeHtmlBuilder

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

the class EnumEditorTextCellTests method testRenderDisabled.

@Test
public void testRenderDisabled() {
    context = new Cell.Context(0, 0, new EnumRow("A raw value"));
    final SafeHtmlBuilder safeHtmlBuilder = mock(SafeHtmlBuilder.class);
    cell.render(context, "Fact", safeHtmlBuilder);
    verify(cell, never()).doRender(eq(context), eq("Fact"), eq(safeHtmlBuilder));
    verify(safeHtmlBuilder, times(1)).append(safeHtmlArgumentCaptor.capture());
    final SafeHtml safeHtml = safeHtmlArgumentCaptor.getValue();
    assertEquals("cellContent(disabled, invalidDefinitionDisabled, Fact)", safeHtml.asString());
}
Also used : SafeHtml(com.google.gwt.safehtml.shared.SafeHtml) SafeHtmlBuilder(com.google.gwt.safehtml.shared.SafeHtmlBuilder) Cell(com.google.gwt.cell.client.Cell) Test(org.junit.Test)

Example 20 with SafeHtmlBuilder

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

the class EnumEditorTextCellTests method testRenderEnabled.

@Test
public void testRenderEnabled() {
    context = new Cell.Context(0, 0, new EnumRow("Fact", "field", "['a', 'b']"));
    final SafeHtmlBuilder sb = mock(SafeHtmlBuilder.class);
    cell.render(context, "Fact", sb);
    verify(cell, times(1)).doRender(eq(context), eq("Fact"), eq(sb));
}
Also used : SafeHtmlBuilder(com.google.gwt.safehtml.shared.SafeHtmlBuilder) Cell(com.google.gwt.cell.client.Cell) Test(org.junit.Test)

Aggregations

SafeHtmlBuilder (com.google.gwt.safehtml.shared.SafeHtmlBuilder)142 SafeHtml (com.google.gwt.safehtml.shared.SafeHtml)26 Test (org.junit.Test)18 Column (com.google.gwt.user.cellview.client.Column)17 Cell (com.google.gwt.cell.client.Cell)14 BaseColumnFieldDiff (org.drools.workbench.models.guided.dtable.shared.model.BaseColumnFieldDiff)12 Context (com.google.gwt.cell.client.Cell.Context)7 MenuItem (com.google.gwt.user.client.ui.MenuItem)7 NativeEvent (com.google.gwt.dom.client.NativeEvent)6 Command (com.google.gwt.user.client.Command)6 ArrayList (java.util.ArrayList)6 ValueUpdater (com.google.gwt.cell.client.ValueUpdater)5 GWT (com.google.gwt.core.client.GWT)5 Element (com.google.gwt.dom.client.Element)5 AbstractCell (com.google.gwt.cell.client.AbstractCell)4 ClickableTextCell (com.google.gwt.cell.client.ClickableTextCell)4 TextCell (com.google.gwt.cell.client.TextCell)4 ScheduledCommand (com.google.gwt.core.client.Scheduler.ScheduledCommand)4 ImageResource (com.google.gwt.resources.client.ImageResource)4 Map (java.util.Map)4