Search in sources :

Example 11 with SafeHtmlBuilder

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

the class ShortcutInfoPanel method getShortcutContent.

protected Widget getShortcutContent() {
    SafeHtmlBuilder sb = new SafeHtmlBuilder();
    List<ShortcutInfo> shortcuts = ShortcutManager.INSTANCE.getActiveShortcutInfo();
    String[][] groupNames = { new String[] { "Tabs", "Panes", "Files" }, new String[] { "Source Navigation", "Execute" }, new String[] { "Source Editor", "Debug" }, new String[] { "Source Control", "Build", "Console", "Terminal", "Other" } };
    int pctWidth = 100 / groupNames.length;
    sb.appendHtmlConstant("<table width='100%'><tr>");
    for (String[] colGroupNames : groupNames) {
        sb.appendHtmlConstant("<td width='" + pctWidth + "%'>");
        for (String colGroupName : colGroupNames) {
            sb.appendHtmlConstant("<h2>");
            sb.appendEscaped(colGroupName);
            sb.appendHtmlConstant("</h2><table>");
            for (int i = 0; i < shortcuts.size(); i++) {
                ShortcutInfo info = shortcuts.get(i);
                if (info.getDescription() == null || info.getShortcuts().size() == 0 || !info.getGroupName().equals(colGroupName)) {
                    continue;
                }
                sb.appendHtmlConstant("<tr><td><strong>");
                sb.appendHtmlConstant(StringUtil.joinStrings(info.getShortcuts(), ", "));
                sb.appendHtmlConstant("</strong></td><td>");
                sb.appendEscaped(info.getDescription());
                sb.appendHtmlConstant("</td></tr>");
            }
            sb.appendHtmlConstant("</table>");
            if (colGroupName == "Panes") {
                sb.appendHtmlConstant("<p>Add Shift to zoom (maximize) pane.</p>");
            }
        }
        sb.appendHtmlConstant("</td>");
    }
    sb.appendHtmlConstant("</td></tr></table>");
    HTMLPanel panel = new HTMLPanel(sb.toSafeHtml());
    return panel;
}
Also used : ShortcutInfo(org.rstudio.core.client.command.ShortcutInfo) SafeHtmlBuilder(com.google.gwt.safehtml.shared.SafeHtmlBuilder) HTMLPanel(com.google.gwt.user.client.ui.HTMLPanel)

Example 12 with SafeHtmlBuilder

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

the class ToolbarPopupMenuButton method addMenuItem.

public void addMenuItem(MenuBar subMenu, String label) {
    SafeHtmlBuilder html = new SafeHtmlBuilder();
    html.appendHtmlConstant("<span style=\"margin-left: 25px;\">");
    html.appendEscaped(label);
    html.appendHtmlConstant("</span>");
    getMenu().addItem(html.toSafeHtml(), subMenu);
}
Also used : SafeHtmlBuilder(com.google.gwt.safehtml.shared.SafeHtmlBuilder)

Example 13 with SafeHtmlBuilder

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

the class SlideNavigationPresenter method onSlideNavigationChanged.

@Override
public void onSlideNavigationChanged(SlideNavigationChangedEvent event) {
    slideNavigation_ = event.getNavigation();
    SlideNavigationMenu navigationMenu = view_.getNavigationMenu();
    navigationMenu.clear();
    if (slideNavigation_ != null) {
        JsArray<SlideNavigationItem> items = slideNavigation_.getItems();
        for (int i = 0; i < items.length(); i++) {
            // get slide
            final SlideNavigationItem item = items.get(i);
            // build html
            SafeHtmlBuilder menuHtml = new SafeHtmlBuilder();
            for (int j = 0; j < item.getIndent(); j++) menuHtml.appendHtmlConstant("&nbsp;&nbsp;&nbsp;");
            menuHtml.appendEscaped(item.getTitle());
            navigationMenu.addItem(new MenuItem(menuHtml.toSafeHtml(), new Command() {

                @Override
                public void execute() {
                    view_.navigate(item.getIndex());
                }
            }));
        }
        navigationMenu.setVisible(true);
        navigationMenu.setDropDownVisible(slideNavigation_.getItems().length() > 1);
    } else {
        navigationMenu.setVisible(false);
    }
}
Also used : Command(com.google.gwt.user.client.Command) MenuItem(com.google.gwt.user.client.ui.MenuItem) SafeHtmlBuilder(com.google.gwt.safehtml.shared.SafeHtmlBuilder) SlideNavigationItem(org.rstudio.studio.client.common.presentation.model.SlideNavigationItem)

Example 14 with SafeHtmlBuilder

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

the class FindOutputPane method updateSearchLabel.

@Override
public void updateSearchLabel(String query, String path) {
    SafeHtmlBuilder builder = new SafeHtmlBuilder();
    builder.appendEscaped("Results for ").appendHtmlConstant("<strong>").appendEscaped(query).appendHtmlConstant("</strong>").appendEscaped(" in ").appendEscaped(path);
    searchLabel_.getElement().setInnerHTML(builder.toSafeHtml().asString());
}
Also used : SafeHtmlBuilder(com.google.gwt.safehtml.shared.SafeHtmlBuilder)

Example 15 with SafeHtmlBuilder

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

the class FindResult method getLineHTML.

public final SafeHtml getLineHTML() {
    SafeHtmlBuilder out = new SafeHtmlBuilder();
    ArrayList<Integer> on = getMatchOns();
    ArrayList<Integer> off = getMatchOffs();
    ArrayList<Pair<Boolean, Integer>> parts = new ArrayList<Pair<Boolean, Integer>>();
    while (on.size() + off.size() > 0) {
        int onVal = on.size() == 0 ? Integer.MAX_VALUE : on.get(0);
        int offVal = off.size() == 0 ? Integer.MAX_VALUE : off.get(0);
        if (onVal <= offVal)
            parts.add(new Pair<Boolean, Integer>(true, on.remove(0)));
        else
            parts.add(new Pair<Boolean, Integer>(false, off.remove(0)));
    }
    String line = getLineValue();
    // Use a counter to ensure tags are balanced.
    int openTags = 0;
    for (int i = 0; i < line.length(); i++) {
        while (parts.size() > 0 && parts.get(0).second == i) {
            if (parts.remove(0).first) {
                out.appendHtmlConstant("<strong>");
                openTags++;
            } else if (openTags > 0) {
                out.appendHtmlConstant("</strong>");
                openTags--;
            }
        }
        out.append(line.charAt(i));
    }
    while (openTags > 0) {
        openTags--;
        out.appendHtmlConstant("</strong>");
    }
    return out.toSafeHtml();
}
Also used : JsArrayInteger(com.google.gwt.core.client.JsArrayInteger) ArrayList(java.util.ArrayList) SafeHtmlBuilder(com.google.gwt.safehtml.shared.SafeHtmlBuilder) Pair(org.rstudio.core.client.Pair)

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