List of usage examples for com.google.gwt.safehtml.shared SafeHtmlBuilder append
public SafeHtmlBuilder append(SafeHtml html)
From source file:org.roda.wui.client.main.Menu.java
private MenuItem customMenuItem(String icon, String label, String styleNames, MenuBar subMenu, ScheduledCommand command) {/* www . ja v a 2 s .com*/ SafeHtmlBuilder b = new SafeHtmlBuilder(); String iconHTML = "<i class='" + icon + "'></i>"; b.append(SafeHtmlUtils.fromSafeConstant(iconHTML)); if (label != null) b.append(SafeHtmlUtils.fromSafeConstant(label)); MenuItem menuItem; if (subMenu != null) { menuItem = new MenuItem(b.toSafeHtml(), subMenu); } else if (command != null) { menuItem = new MenuItem(b.toSafeHtml(), command); } else { menuItem = new MenuItem(b.toSafeHtml()); } menuItem.addStyleName("menu-item"); menuItem.addStyleName(styleNames); return menuItem; }
From source file:org.roda.wui.client.main.Menu.java
private void setLanguageMenu() { String locale = LocaleInfo.getCurrentLocale().getLocaleName(); // Getting supported languages and their display name Map<String, String> supportedLanguages = new HashMap<>(); for (String localeName : LocaleInfo.getAvailableLocaleNames()) { if (!"default".equals(localeName)) { supportedLanguages.put(localeName, LocaleInfo.getLocaleNativeDisplayName(localeName)); }/*from w ww . j a va 2s. c om*/ } languagesMenu.clearItems(); for (final Entry<String, String> entry : supportedLanguages.entrySet()) { final String key = entry.getKey(); final String value = entry.getValue(); if (key.equals(locale)) { SafeHtmlBuilder b = new SafeHtmlBuilder(); String iconHTML = "<i class='fa fa-check'></i>"; b.append(SafeHtmlUtils.fromSafeConstant(value)); b.append(SafeHtmlUtils.fromSafeConstant(iconHTML)); MenuItem languageMenuItem = new MenuItem(b.toSafeHtml()); languageMenuItem.addStyleName("menu-item-language-selected"); languageMenuItem.addStyleName("menu-item-language"); languagesMenu.addItem(languageMenuItem); selectedLanguage = value; } else { MenuItem languageMenuItem = new MenuItem(SafeHtmlUtils.fromSafeConstant(value), new ScheduledCommand() { @Override public void execute() { JavascriptUtils.changeLocale(key); } }); languagesMenu.addItem(languageMenuItem); languageMenuItem.addStyleName("menu-item-language"); } } }
From source file:org.rstudio.core.client.cellview.LinkColumn.java
License:Open Source License
public LinkColumn(final ListDataProvider<T> dataProvider, final OperationWithInput<T> onClicked, final boolean alwaysUnderline) { super(new ClickableTextCell() { // render anchor using custom styles. detect selection and // add selected style to invert text color @Override//ww w . j a v a 2 s . c o m protected void render(Context context, SafeHtml value, SafeHtmlBuilder sb) { if (value != null) { Styles styles = RESOURCES.styles(); StringBuilder div = new StringBuilder(); div.append("<div class=\""); div.append(styles.link() + " "); div.append(ThemeResources.INSTANCE.themeStyles().handCursor()); if (alwaysUnderline) div.append(" " + styles.linkUnderlined()); div.append("\">"); sb.appendHtmlConstant(div.toString()); sb.append(value); sb.appendHtmlConstant("</div>"); } } // click event which occurs on the actual package link div // results in showing help for that package @Override public void onBrowserEvent(Context context, Element parent, String value, NativeEvent event, ValueUpdater<String> valueUpdater) { super.onBrowserEvent(context, parent, value, event, valueUpdater); if ("click".equals(event.getType())) { // verify that the click was on the package link JavaScriptObject evTarget = event.getEventTarget().cast(); if (Element.is(evTarget) && Element.as(evTarget).getClassName().startsWith(RESOURCES.styles().link())) { int idx = context.getIndex(); if (idx >= 0 && idx < dataProvider.getList().size()) onClicked.execute(dataProvider.getList().get(idx)); } } } }); }
From source file:org.rstudio.core.client.cellview.TriStateCheckboxCell.java
License:Open Source License
@Override public void render(Context context, Boolean value, SafeHtmlBuilder sb) { ImageResource img;/*from w ww. j a va 2s . c om*/ if (value == null) img = RES.checkboxIndeterminate(); else if (value) img = RES.checkboxOn(); else img = RES.checkboxOff(); sb.append(SafeHtmlUtils.fromTrustedString(AbstractImagePrototype.create(img).getHTML())); }
From source file:org.rstudio.core.client.SafeHtmlUtil.java
License:Open Source License
public static void appendDiv(SafeHtmlBuilder sb, String style, String textContent) { sb.append(createOpenTag("div", "class", style)); sb.appendEscaped(textContent);//from w ww . j a v a2s. c o m sb.appendHtmlConstant("</div>"); }
From source file:org.rstudio.core.client.SafeHtmlUtil.java
License:Open Source License
public static void appendDiv(SafeHtmlBuilder sb, String style, SafeHtml htmlContent) { sb.append(createOpenTag("div", "class", style)); sb.append(htmlContent);/* ww w . j a v a2 s. co m*/ sb.appendHtmlConstant("</div>"); }
From source file:org.rstudio.core.client.SafeHtmlUtil.java
License:Open Source License
public static void appendSpan(SafeHtmlBuilder sb, String style, String textContent) { sb.append(SafeHtmlUtil.createOpenTag("span", "class", style)); sb.appendEscaped(textContent);/* w ww . j a v a 2 s. c o m*/ sb.appendHtmlConstant("</span>"); }
From source file:org.rstudio.core.client.SafeHtmlUtil.java
License:Open Source License
public static void appendSpan(SafeHtmlBuilder sb, String style, SafeHtml htmlContent) { sb.append(SafeHtmlUtil.createOpenTag("span", "class", style)); sb.append(htmlContent);/*from w w w . j a v a2 s. c o m*/ sb.appendHtmlConstant("</span>"); }
From source file:org.rstudio.core.client.SafeHtmlUtil.java
License:Open Source License
public static void appendImage(SafeHtmlBuilder sb, String style, ImageResource image) { sb.append(SafeHtmlUtil.createOpenTag("img", "class", style, "src", image.getSafeUri().asString())); sb.appendHtmlConstant("</img>"); }
From source file:org.rstudio.studio.client.rsconnect.ui.DirEntryCheckBox.java
License:Open Source License
public DirEntryCheckBox(String path) { // create the appropriate filesystem object for the path FileSystemItem fsi = null;/*w ww .j a va2 s.c o m*/ if (path.endsWith("/")) { path = path.substring(0, path.length() - 1); fsi = FileSystemItem.createDir(path); } else { fsi = FileSystemItem.createFile(path); } path_ = path; // add an icon representing the file ImageResource icon = RStudioGinjector.INSTANCE.getFileTypeRegistry().getIconForFile(fsi); SafeHtmlBuilder hb = new SafeHtmlBuilder(); hb.append(AbstractImagePrototype.create(icon).getSafeHtml()); // insert the file/dir name into the checkbox hb.appendEscaped(path_); checkbox_ = new CheckBox(hb.toSafeHtml()); initWidget(checkbox_); }