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;
}
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);
}
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(" ");
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);
}
}
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());
}
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();
}
Aggregations