Search in sources :

Example 66 with SafeHtml

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

the class ChunkContextToolbar method createMenuItemForType.

private MenuItem createMenuItemForType(final AppCommand command, final String chunkType) {
    SafeHtml menuHTML = new SafeHtmlBuilder().appendHtmlConstant(command.getMenuHTML(false)).toSafeHtml();
    MenuItem menuItem = new MenuItem(menuHTML, new Command() {

        public void execute() {
            host_.switchChunk(chunkType);
        }
    });
    return menuItem;
}
Also used : AppCommand(org.rstudio.core.client.command.AppCommand) Command(com.google.gwt.user.client.Command) SafeHtml(com.google.gwt.safehtml.shared.SafeHtml) MenuItem(com.google.gwt.user.client.ui.MenuItem) SafeHtmlBuilder(com.google.gwt.safehtml.shared.SafeHtmlBuilder)

Example 67 with SafeHtml

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

the class SearchControl method initializeCellAutocompleteWidget.

private void initializeCellAutocompleteWidget() {
    final AbstractSafeHtmlRenderer<NodeMarker> renderer = new AbstractSafeHtmlRenderer<NodeMarker>() {

        @Override
        public SafeHtml render(final NodeMarker marker) {
            final SafeHtmlBuilder builder = new SafeHtmlBuilder();
            final String search = m_inputBox.getValue();
            builder.appendHtmlConstant("<div class=\"autocomplete-label\">");
            builder.appendHtmlConstant(marker.getNodeLabel());
            builder.appendHtmlConstant("</div>");
            String additionalSearchInfo = null;
            if (search != null && (search.contains(":") || search.contains("="))) {
                final String searchKey = search.replaceAll("[\\:\\=].*$", "").toLowerCase();
                LOG.info("searchKey = " + searchKey);
                final Map<String, String> props = marker.getProperties();
                if ("category".equals(searchKey) || "categories".equals(searchKey)) {
                    final String catString = props.get("categories");
                    if (catString != null) {
                        additionalSearchInfo = catString;
                    }
                }
                for (final Map.Entry<String, String> entry : props.entrySet()) {
                    final String key = entry.getKey().toLowerCase();
                    final Object value = entry.getValue();
                    if (key.equals(searchKey) && m_labels.containsKey(key)) {
                        additionalSearchInfo = m_labels.get(key) + ": " + value;
                        break;
                    }
                }
            }
            if (additionalSearchInfo != null) {
                builder.appendHtmlConstant("<div class=\"autocomplete-additional-info\">").appendHtmlConstant(additionalSearchInfo).appendHtmlConstant("</div>");
            }
            return builder.toSafeHtml();
        }
    };
    final AbstractSafeHtmlCell<NodeMarker> cell = new AbstractSafeHtmlCell<NodeMarker>(renderer, "keydown", "click", "dblclick", "touchstart") {

        @Override
        public void onBrowserEvent(final Context context, final com.google.gwt.dom.client.Element parent, final NodeMarker value, final NativeEvent event, final ValueUpdater<NodeMarker> valueUpdater) {
            LOG.info("SearchControl.AutocompleteCell.onBrowserEvent(): context = " + context + ", parent = " + parent + ", value = " + value + ", event = " + event);
            if (m_stateManager.handleAutocompleteEvent(event)) {
                super.onBrowserEvent(context, parent, value, event, valueUpdater);
            }
        }

        @Override
        protected void render(final Context context, final SafeHtml data, final SafeHtmlBuilder builder) {
            builder.appendHtmlConstant("<div class=\"autocomplete-entry\">");
            if (data != null) {
                builder.append(data);
            }
            builder.appendHtmlConstant("</div>");
        }
    };
    m_autoComplete = new CellList<NodeMarker>(cell);
    m_autoComplete.setSelectionModel(m_selectionModel);
    m_autoComplete.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.BOUND_TO_SELECTION);
    m_autoComplete.setVisible(false);
    m_autoComplete.addStyleName("search-autocomplete");
    setIdIfMissing(m_autoComplete, "searchControl.autoComplete");
}
Also used : AbstractSafeHtmlRenderer(com.google.gwt.text.shared.AbstractSafeHtmlRenderer) SafeHtml(com.google.gwt.safehtml.shared.SafeHtml) Element(com.google.gwt.user.client.Element) SafeHtmlBuilder(com.google.gwt.safehtml.shared.SafeHtmlBuilder) JSNodeMarker(org.opennms.features.vaadin.nodemaps.internal.gwt.client.JSNodeMarker) NodeMarker(org.opennms.features.vaadin.nodemaps.internal.gwt.client.NodeMarker) ValueUpdater(com.google.gwt.cell.client.ValueUpdater) AbstractSafeHtmlCell(com.google.gwt.cell.client.AbstractSafeHtmlCell) HashMap(java.util.HashMap) Map(java.util.Map) NativeEvent(com.google.gwt.dom.client.NativeEvent)

Example 68 with SafeHtml

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

the class IssuePresenterTest method testShow.

@Test
public void testShow() throws Exception {
    Issue issue = new Issue(Severity.WARNING, CheckType.REDUNDANT_ROWS, new HashSet<>(Arrays.asList(1, 2, 3)));
    screen.show(issue);
    verify(view).setIssueTitle("RedundantRows");
    ArgumentCaptor<SafeHtml> safeHtmlArgumentCaptor = ArgumentCaptor.forClass(SafeHtml.class);
    verify(view).setExplanation(safeHtmlArgumentCaptor.capture());
    assertEquals("<p>MissingRangeP1(1)</p>", safeHtmlArgumentCaptor.getValue().asString());
    verify(view).setLines("1, 2, 3");
}
Also used : Issue(org.drools.workbench.services.verifier.api.client.reporting.Issue) SafeHtml(com.google.gwt.safehtml.shared.SafeHtml) Test(org.junit.Test)

Example 69 with SafeHtml

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

the class IconCell method render.

@Override
public void render(Context context, String value, SafeHtmlBuilder sb) {
    if (value == null) {
        return;
    }
    SafeHtml rendered = templates.cell(value);
    sb.append(rendered);
}
Also used : SafeHtml(com.google.gwt.safehtml.shared.SafeHtml)

Example 70 with SafeHtml

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

the class SchemaImporterV2Test method doImport.

private UserDatabaseDTO doImport(String resourceName) throws IOException {
    Map<String, Object> dbProps = Maps.newHashMap();
    dbProps.put("name", "Syria");
    dbProps.put("countryId", 1);
    int databaseId = execute(new CreateEntity("UserDatabase", dbProps)).getNewId();
    SchemaDTO schema = execute(new GetSchema());
    UserDatabaseDTO db = schema.getDatabaseById(databaseId);
    if (db == null) {
        throw new AssertionError("database not created");
    }
    SchemaImporterV2 importer = new SchemaImporterV2(getDispatcher(), db, warningTemplates());
    importer.setProgressListener(new SchemaImporterV2.ProgressListener() {

        @Override
        public void submittingBatch(int batchNumber, int batchCount) {
            System.out.println("Submitting batch " + batchNumber + " of " + batchCount);
        }
    });
    boolean success = importer.parseColumns(source(resourceName));
    if (success) {
        importer.processRows();
    }
    for (SafeHtml warning : importer.getWarnings()) {
        System.err.println(warning);
    }
    if (!success) {
        throw new AssertionError("there were fatal errors");
    }
    importer.persist(new AsyncCallback<Void>() {

        @Override
        public void onSuccess(Void result) {
            System.out.println("Success");
        }

        @Override
        public void onFailure(Throwable caught) {
            throw new AssertionError(caught);
        }
    });
    return execute(new GetSchema()).getDatabaseById(databaseId);
}
Also used : CreateEntity(org.activityinfo.legacy.shared.command.CreateEntity) UserDatabaseDTO(org.activityinfo.legacy.shared.model.UserDatabaseDTO) SafeHtml(com.google.gwt.safehtml.shared.SafeHtml) SchemaDTO(org.activityinfo.legacy.shared.model.SchemaDTO) GetSchema(org.activityinfo.legacy.shared.command.GetSchema)

Aggregations

SafeHtml (com.google.gwt.safehtml.shared.SafeHtml)129 Test (org.junit.Test)38 ImageResource (com.google.gwt.resources.client.ImageResource)25 SafeHtmlBuilder (com.google.gwt.safehtml.shared.SafeHtmlBuilder)25 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)11 AbstractTextColumn (org.ovirt.engine.ui.common.widget.table.column.AbstractTextColumn)9 ArrayList (java.util.ArrayList)8 Cell (com.google.gwt.cell.client.Cell)7 GwtTestTest (com.googlecode.gwt.test.GwtTestTest)7 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 LinkedHashMap (java.util.LinkedHashMap)5 Map (java.util.Map)4 ConfirmCallback (org.eclipse.che.ide.api.dialogs.ConfirmCallback)4 ClickableTextCell (com.google.gwt.cell.client.ClickableTextCell)3 Element (com.google.gwt.dom.client.Element)3 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)3