List of usage examples for com.google.gwt.safehtml.shared SafeHtmlBuilder appendEscaped
public SafeHtmlBuilder appendEscaped(String text)
From source file:org.rstudio.core.client.widget.ShortcutInfoPanel.java
License:Open Source License
protected Widget getShortcutContent() { SafeHtmlBuilder sb = new SafeHtmlBuilder(); List<ShortcutInfo> shortcuts = ShortcutManager.INSTANCE.getActiveShortcutInfo(); String[][] groupNames = { new String[] { "Tabs/Panes", "Files", "Console" }, new String[] { "Source Navigation", "Execute" }, new String[] { "Source Editor", "Debug" }, new String[] { "Source Control", "Build", "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; }/*from w ww. j a va 2s . co m*/ 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>"); } sb.appendHtmlConstant("</td>"); } sb.appendHtmlConstant("</td></tr></table>"); HTMLPanel panel = new HTMLPanel(sb.toSafeHtml()); return panel; }
From source file:org.rstudio.studio.client.common.presentation.SlideNavigationPresenter.java
License:Open Source License
@Override public void onSlideNavigationChanged(SlideNavigationChangedEvent event) { slideNavigation_ = event.getNavigation(); SlideNavigationMenu navigationMenu = view_.getNavigationMenu(); navigationMenu.clear();// w w w . j a v a 2s .co m 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); } }
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;/*from w w w . j av a2 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_); }
From source file:org.rstudio.studio.client.workbench.views.connections.ui.NewConnectionSnippetHost.java
License:Open Source License
private void showFailure(String error) { VerticalPanel verticalPanel = new VerticalPanel(); verticalPanel.addStyleName(RES.styles().dialogMessagePanel()); SafeHtmlBuilder safeHtmlBuilder = new SafeHtmlBuilder(); safeHtmlBuilder.appendHtmlConstant("<b>Failure.</b> "); safeHtmlBuilder.appendEscaped(error); verticalPanel.add(new HTML(safeHtmlBuilder.toSafeHtml())); MessageDialog dlg = new MessageDialog(MessageDialog.ERROR, "Test Results", verticalPanel); dlg.addButton("OK", new Operation() { @Override//www . ja v a 2s . c o m public void execute() { } }, true, false); dlg.showModal(); }
From source file:org.rstudio.studio.client.workbench.views.environment.view.EnvironmentObjectDisplay.java
License:Open Source License
public EnvironmentObjectDisplay(Host host, EnvironmentObjectsObserver observer, String environmentName) { super(EnvironmentObjects.MAX_ENVIRONMENT_OBJECTS, RObjectEntry.KEY_PROVIDER); observer_ = observer;/*from w w w.j a v a 2s . com*/ host_ = host; environmentStyle_ = EnvironmentResources.INSTANCE.environmentStyle(); environmentStyle_.ensureInjected(); environmentName_ = environmentName; filterRenderer_ = new AbstractSafeHtmlRenderer<String>() { @Override public SafeHtml render(String str) { SafeHtmlBuilder sb = new SafeHtmlBuilder(); boolean hasMatch = false; String filterText = host_.getFilterText(); if (filterText.length() > 0) { int idx = str.toLowerCase().indexOf(filterText); if (idx >= 0) { hasMatch = true; sb.appendEscaped(str.substring(0, idx)); sb.appendHtmlConstant("<span class=\"" + environmentStyle_.filterMatch() + "\">"); sb.appendEscaped(str.substring(idx, idx + filterText.length())); sb.appendHtmlConstant("</span>"); sb.appendEscaped(str.substring(idx + filterText.length(), str.length())); } } if (!hasMatch) sb.appendEscaped(str); return sb.toSafeHtml(); } }; }
From source file:org.rstudio.studio.client.workbench.views.output.find.FindOutputPane.java
License:Open Source License
@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()); }
From source file:org.rstudio.studio.client.workbench.views.source.editors.text.TextEditingTarget.java
License:Open Source License
private MenuItem createMenuItemForType(final TextFileType type) { SafeHtmlBuilder labelBuilder = new SafeHtmlBuilder(); labelBuilder.appendEscaped(type.getLabel()); MenuItem menuItem = new MenuItem(labelBuilder.toSafeHtml(), new Command() { public void execute() { docUpdateSentinel_.changeFileType(type.getTypeId(), new SaveProgressIndicator(null, type, null)); Scheduler.get().scheduleDeferred(new ScheduledCommand() { @Override/*from w w w .j ava 2 s . c o m*/ public void execute() { focus(); } }); } }); return menuItem; }
From source file:org.rstudio.studio.client.workbench.views.source.editors.text.TextEditingTarget.java
License:Open Source License
private MenuItem addFunctionsToMenu(StatusBarPopupMenu menu, final JsArray<Scope> funcs, String indent, Scope defaultFunction, boolean includeNoFunctionsMessage) { MenuItem defaultMenuItem = null; if (funcs.length() == 0 && includeNoFunctionsMessage) { String type = fileType_.canExecuteChunks() ? "chunks" : "functions"; MenuItem noFunctions = new MenuItem("(No " + type + " defined)", false, (Command) null); noFunctions.setEnabled(false);// ww w. j av a2 s .c o m noFunctions.getElement().addClassName("disabled"); menu.addItem(noFunctions); } for (int i = 0; i < funcs.length(); i++) { final Scope func = funcs.get(i); String childIndent = indent; if (!StringUtil.isNullOrEmpty(func.getLabel())) { SafeHtmlBuilder labelBuilder = new SafeHtmlBuilder(); labelBuilder.appendHtmlConstant(indent); labelBuilder.appendEscaped(func.getLabel()); final MenuItem menuItem = new MenuItem(labelBuilder.toSafeHtml(), new Command() { public void execute() { docDisplay_.navigateToPosition(toSourcePosition(func), true); } }); menu.addItem(menuItem); childIndent = indent + " "; if (defaultFunction != null && defaultMenuItem == null && func.getLabel().equals(defaultFunction.getLabel()) && func.getPreamble().getRow() == defaultFunction.getPreamble().getRow() && func.getPreamble().getColumn() == defaultFunction.getPreamble().getColumn()) { defaultMenuItem = menuItem; } } MenuItem childDefaultMenuItem = addFunctionsToMenu(menu, func.getChildren(), childIndent, defaultMenuItem == null ? defaultFunction : null, false); if (childDefaultMenuItem != null) defaultMenuItem = childDefaultMenuItem; } return defaultMenuItem; }
From source file:org.rstudio.studio.client.workbench.views.source.editors.text.TextEditingTargetPresentationHelper.java
License:Open Source License
public void buildSlideMenu(final String path, boolean isDirty, final EditingTarget editor, final CommandWithArg<StatusBarPopupRequest> onCompleted) { // rpc response handler SimpleRequestCallback<SlideNavigation> requestCallback = new SimpleRequestCallback<SlideNavigation>() { @Override/*from w w w.j a v a 2 s . c o m*/ public void onResponseReceived(SlideNavigation slideNavigation) { // create the menu and make sure we have some slides to return StatusBarPopupMenu menu = new StatusBarPopupMenu(); if (slideNavigation.getTotalSlides() == 0) { onCompleted.execute(new StatusBarPopupRequest(menu, null)); return; } MenuItem defaultMenuItem = null; int length = slideNavigation.getItems().length(); for (int i = 0; i < length; i++) { SlideNavigationItem item = slideNavigation.getItems().get(i); String title = item.getTitle(); if (StringUtil.isNullOrEmpty(title)) title = "(Untitled Slide)"; StringBuilder indentBuilder = new StringBuilder(); for (int level = 0; level < item.getIndent(); level++) indentBuilder.append(" "); SafeHtmlBuilder labelBuilder = new SafeHtmlBuilder(); labelBuilder.appendHtmlConstant(indentBuilder.toString()); labelBuilder.appendEscaped(title); final int targetSlide = i; final MenuItem menuItem = new MenuItem(labelBuilder.toSafeHtml(), new Command() { public void execute() { navigateToSlide(editor, targetSlide); } }); menu.addItem(menuItem); // see if this is the default menu item if (defaultMenuItem == null && item.getLine() >= (docDisplay_.getSelectionStart().getRow())) { defaultMenuItem = menuItem; } } StatusBarPopupRequest request = new StatusBarPopupRequest(menu, defaultMenuItem); onCompleted.execute(request); } }; // send code over the wire if we are dirty if (isDirty) { server_.getSlideNavigationForCode(docDisplay_.getCode(), FileSystemItem.createFile(path).getParentPathString(), requestCallback); } else { server_.getSlideNavigationForFile(path, requestCallback); } }
From source file:org.rstudio.studio.client.workbench.views.source.editors.text.ui.NewRMarkdownDialog.java
License:Open Source License
private Widget createFormatOption(String name, String description) { HTMLPanel formatWrapper = new HTMLPanel(""); formatWrapper.setStyleName(style.outputFormat()); SafeHtmlBuilder sb = new SafeHtmlBuilder(); sb.appendHtmlConstant("<span class=\"" + style.outputFormatName() + "\">"); sb.appendEscaped(name); sb.appendHtmlConstant("</span>"); RadioButton button = new RadioButton("DefaultOutputFormat", sb.toSafeHtml().asString(), true); button.addStyleName(style.outputFormatChoice()); formatOptions_.add(button);/*w w w .ja va 2 s. c o m*/ formatWrapper.add(button); Label label = new Label(description); label.setStyleName(style.outputFormatDetails()); formatWrapper.add(label); return formatWrapper; }