List of usage examples for com.google.gwt.safehtml.shared SafeHtmlBuilder SafeHtmlBuilder
public SafeHtmlBuilder()
From source file:org.eclipse.che.ide.ext.debugger.client.debug.DebuggerViewImpl.java
License:Open Source License
@Inject protected DebuggerViewImpl(PartStackUIResources partStackUIResources, DebuggerResources resources, DebuggerLocalizationConstant locale, Resources coreRes, VariableTreeNodeRenderer.Resources rendererResources, DtoFactory dtoFactory, DebuggerViewImplUiBinder uiBinder) { super(partStackUIResources); this.locale = locale; this.res = resources; this.coreRes = coreRes; this.dtoFactory = dtoFactory; setContentWidget(uiBinder.createAndBindUi(this)); TableElement breakPointsElement = Elements.createTableElement(); breakPointsElement.setAttribute("style", "width: 100%"); SimpleList.ListEventDelegate<Breakpoint> breakpointListEventDelegate = new SimpleList.ListEventDelegate<Breakpoint>() { public void onListItemClicked(Element itemElement, Breakpoint itemData) { breakpoints.getSelectionModel().setSelectedItem(itemData); }/*from www . ja v a 2 s . c o m*/ public void onListItemDoubleClicked(Element listItemBase, Breakpoint itemData) { // TODO: implement 'go to breakpoint source' feature } }; SimpleList.ListItemRenderer<Breakpoint> breakpointListItemRenderer = new SimpleList.ListItemRenderer<Breakpoint>() { @Override public void render(Element itemElement, Breakpoint itemData) { TableCellElement label = Elements.createTDElement(); SafeHtmlBuilder sb = new SafeHtmlBuilder(); // Add icon sb.appendHtmlConstant("<table><tr><td>"); SVGResource icon = res.breakpoint(); if (icon != null) { sb.appendHtmlConstant("<img src=\"" + icon.getSafeUri().asString() + "\">"); } sb.appendHtmlConstant("</td>"); // Add title sb.appendHtmlConstant("<td>"); String path = itemData.getPath(); sb.appendEscaped(path.substring(path.lastIndexOf("/") + 1) + " - [line: " + String.valueOf(itemData.getLineNumber() + 1) + "]"); sb.appendHtmlConstant("</td></tr></table>"); label.setInnerHTML(sb.toSafeHtml().asString()); itemElement.appendChild(label); } @Override public Element createElement() { return Elements.createTRElement(); } }; breakpoints = SimpleList.create((SimpleList.View) breakPointsElement, coreRes.defaultSimpleListCss(), breakpointListItemRenderer, breakpointListEventDelegate); this.breakpointsPanel.add(breakpoints); this.variables = Tree.create(rendererResources, new VariableNodeDataAdapter(), new VariableTreeNodeRenderer(rendererResources)); this.variables.setTreeEventHandler(new Tree.Listener<DebuggerVariable>() { @Override public void onNodeAction(@NotNull TreeNodeElement<DebuggerVariable> node) { } @Override public void onNodeClosed(@NotNull TreeNodeElement<DebuggerVariable> node) { selectedVariable = null; } @Override public void onNodeContextMenu(int mouseX, int mouseY, @NotNull TreeNodeElement<DebuggerVariable> node) { } @Override public void onNodeDragStart(@NotNull TreeNodeElement<DebuggerVariable> node, @NotNull MouseEvent event) { } @Override public void onNodeDragDrop(@NotNull TreeNodeElement<DebuggerVariable> node, @NotNull MouseEvent event) { } @Override public void onNodeExpanded(@NotNull final TreeNodeElement<DebuggerVariable> node) { selectedVariable = node; delegate.onSelectedVariableElement(selectedVariable.getData()); delegate.onExpandVariablesTree(); } @Override public void onNodeSelected(@NotNull TreeNodeElement<DebuggerVariable> node, @NotNull SignalEvent event) { selectedVariable = node; delegate.onSelectedVariableElement(selectedVariable.getData()); } @Override public void onRootContextMenu(int mouseX, int mouseY) { } @Override public void onRootDragDrop(@NotNull MouseEvent event) { } @Override public void onKeyboard(@NotNull KeyboardEvent event) { } }); this.variablesPanel.add(variables); minimizeButton.ensureDebugId("debugger-minimizeBut"); }
From source file:org.eclipse.che.ide.ext.git.client.branch.BranchViewImpl.java
License:Open Source License
/** Create presenter. */ @Inject//from w ww .j a v a2s. co m protected BranchViewImpl(GitResources resources, GitLocalizationConstant locale, org.eclipse.che.ide.Resources coreRes, DialogFactory dialogFactory) { this.res = resources; this.locale = locale; this.dialogFactory = dialogFactory; this.ensureDebugId("git-branches-window"); Widget widget = ourUiBinder.createAndBindUi(this); this.setTitle(locale.branchTitle()); this.setWidget(widget); TableElement breakPointsElement = Elements.createTableElement(); breakPointsElement.setAttribute("style", "width: 100%"); SimpleList.ListEventDelegate<Branch> listBranchesDelegate = new SimpleList.ListEventDelegate<Branch>() { public void onListItemClicked(Element itemElement, Branch itemData) { branches.getSelectionModel().setSelectedItem(itemData); delegate.onBranchSelected(itemData); } public void onListItemDoubleClicked(Element listItemBase, Branch itemData) { } }; SimpleList.ListItemRenderer<Branch> listBranchesRenderer = new SimpleList.ListItemRenderer<Branch>() { @Override public void render(Element itemElement, Branch itemData) { TableCellElement label = Elements.createTDElement(); SafeHtmlBuilder sb = new SafeHtmlBuilder(); sb.appendHtmlConstant("<table><tr><td>"); sb.appendHtmlConstant("<div id=\"" + UIObject.DEBUG_ID_PREFIX + "git-branches-" + itemData.getDisplayName() + "\">"); sb.appendEscaped(itemData.getDisplayName()); sb.appendHtmlConstant("</td>"); if (itemData.isActive()) { SVGResource icon = res.currentBranch(); sb.appendHtmlConstant("<td><img src=\"" + icon.getSafeUri().asString() + "\"></td>"); } sb.appendHtmlConstant("</tr></table>"); label.setInnerHTML(sb.toSafeHtml().asString()); itemElement.appendChild(label); } @Override public Element createElement() { return Elements.createTRElement(); } }; branches = SimpleList.create((SimpleList.View) breakPointsElement, coreRes.defaultSimpleListCss(), listBranchesRenderer, listBranchesDelegate); this.branchesPanel.add(branches); createButtons(); }
From source file:org.eclipse.che.ide.ext.git.client.compare.branchList.BranchListViewImpl.java
License:Open Source License
@Inject protected BranchListViewImpl(GitResources resources, GitLocalizationConstant locale, org.eclipse.che.ide.Resources coreRes) { this.res = resources; this.locale = locale; this.ensureDebugId("git-compare-branch-window"); Widget widget = uiBinder.createAndBindUi(this); this.setTitle(locale.compareWithBranchTitle()); this.setWidget(widget); TableElement tableElement = Elements.createTableElement(); tableElement.setAttribute("style", "width: 100%"); SimpleList.ListEventDelegate<Branch> listBranchesDelegate = new SimpleList.ListEventDelegate<Branch>() { public void onListItemClicked(Element itemElement, Branch itemData) { branches.getSelectionModel().setSelectedItem(itemData); delegate.onBranchSelected(itemData); }/* ww w . j a v a2 s .co m*/ public void onListItemDoubleClicked(Element listItemBase, Branch itemData) { delegate.onCompareClicked(); } }; SimpleList.ListItemRenderer<Branch> listBranchesRenderer = new SimpleList.ListItemRenderer<Branch>() { @Override public void render(Element itemElement, Branch itemData) { TableCellElement label = Elements.createTDElement(); SafeHtmlBuilder sb = new SafeHtmlBuilder(); sb.appendHtmlConstant("<table><tr><td>"); sb.appendHtmlConstant("<div id=\"" + UIObject.DEBUG_ID_PREFIX + "git-compare-branch-" + itemData.getDisplayName() + "\">"); sb.appendEscaped(itemData.getDisplayName()); sb.appendHtmlConstant("</td>"); if (itemData.isActive()) { SVGResource icon = res.currentBranch(); sb.appendHtmlConstant("<td><img src=\"" + icon.getSafeUri().asString() + "\"></td>"); } sb.appendHtmlConstant("</tr></table>"); label.setInnerHTML(sb.toSafeHtml().asString()); itemElement.appendChild(label); } @Override public Element createElement() { return Elements.createTRElement(); } }; branches = SimpleList.create((SimpleList.View) tableElement, coreRes.defaultSimpleListCss(), listBranchesRenderer, listBranchesDelegate); this.branchesPanel.add(branches); createButtons(); }
From source file:org.eclipse.che.ide.ext.git.client.compare.changedList.ChangedListViewImpl.java
License:Open Source License
@Inject protected ChangedListViewImpl(GitResources resources, GitLocalizationConstant locale, NodesResources nodesResources) { this.res = resources; this.locale = locale; this.nodesResources = nodesResources; DockLayoutPanel widget = uiBinder.createAndBindUi(this); this.setTitle(locale.changeListTitle()); this.setWidget(widget); NodeStorage nodeStorage = new NodeStorage(new NodeUniqueKeyProvider() { @NotNull//from ww w . j ava2 s . c o m @Override public String getKey(@NotNull Node item) { if (item instanceof HasStorablePath) { return ((HasStorablePath) item).getStorablePath(); } else { return String.valueOf(item.hashCode()); } } }); NodeLoader nodeLoader = new NodeLoader(Collections.<NodeInterceptor>emptySet()); tree = new Tree(nodeStorage, nodeLoader); tree.getSelectionModel().setSelectionMode(SelectionModel.Mode.SINGLE); tree.getSelectionModel().addSelectionChangedHandler(new SelectionChangedEvent.SelectionChangedHandler() { @Override public void onSelectionChanged(SelectionChangedEvent event) { List<Node> selection = event.getSelection(); if (!selection.isEmpty()) { delegate.onNodeSelected(event.getSelection().get(0)); } else { delegate.onNodeNotSelected(); } } }); changedFilesPanel.add(tree); createButtons(); SafeHtmlBuilder shb = new SafeHtmlBuilder(); shb.appendHtmlConstant("<table height =\"20\">"); shb.appendHtmlConstant("<tr height =\"3\"></tr><tr>"); shb.appendHtmlConstant("<td width =\"20\" bgcolor =\"dodgerBlue\"></td>"); shb.appendHtmlConstant("<td>modified</td>"); shb.appendHtmlConstant("<td width =\"20\" bgcolor =\"red\"></td>"); shb.appendHtmlConstant("<td>deleted</td>"); shb.appendHtmlConstant("<td width =\"20\" bgcolor =\"green\"></td>"); shb.appendHtmlConstant("<td>added</td>"); shb.appendHtmlConstant("<td width =\"20\" bgcolor =\"purple\"></td>"); shb.appendHtmlConstant("<td>copied</td>"); shb.appendHtmlConstant("</tr></table>"); getFooter().add(new HTML(shb.toSafeHtml())); }
From source file:org.eclipse.che.ide.ext.git.client.compare.changeslist.ChangesListViewImpl.java
License:Open Source License
@Inject protected ChangesListViewImpl(GitLocalizationConstant locale) { this.locale = locale; this.setTitle(locale.changeListTitle()); createButtons();//from w ww . j a v a2s . c o m SafeHtmlBuilder shb = new SafeHtmlBuilder(); shb.appendHtmlConstant("<table height =\"20\">"); shb.appendHtmlConstant("<tr height =\"3\"></tr><tr>"); shb.appendHtmlConstant("<td width =\"20\" bgcolor =\"dodgerBlue\"></td>"); shb.appendHtmlConstant("<td>modified</td>"); shb.appendHtmlConstant("<td width =\"20\" bgcolor =\"red\"></td>"); shb.appendHtmlConstant("<td>deleted</td>"); shb.appendHtmlConstant("<td width =\"20\" bgcolor =\"green\"></td>"); shb.appendHtmlConstant("<td>added</td>"); shb.appendHtmlConstant("<td width =\"20\" bgcolor =\"purple\"></td>"); shb.appendHtmlConstant("<td>copied</td>"); shb.appendHtmlConstant("</tr></table>"); getFooter().add(new HTML(shb.toSafeHtml())); }
From source file:org.eclipse.che.ide.ext.github.client.importer.page.GithubImporterPageViewImpl.java
License:Open Source License
/** * Creates table what contains list of available repositories. * * @param resources/*www. j av a 2 s.c o m*/ */ private void createRepositoriesTable(final Resources resources, GitHubLocalizationConstant locale) { repositories = new CellTable<>(15, resources); Column<ProjectData, ImageResource> iconColumn = new Column<ProjectData, ImageResource>( new ImageResourceCell()) { @Override public ImageResource getValue(ProjectData item) { return null; } }; Column<ProjectData, SafeHtml> repositoryColumn = new Column<ProjectData, SafeHtml>(new SafeHtmlCell()) { @Override public SafeHtml getValue(final ProjectData item) { return SafeHtmlUtils.fromString(item.getName()); } }; Column<ProjectData, SafeHtml> descriptionColumn = new Column<ProjectData, SafeHtml>(new SafeHtmlCell()) { @Override public SafeHtml getValue(final ProjectData item) { return new SafeHtmlBuilder().appendHtmlConstant("<span>").appendEscaped(item.getDescription()) .appendHtmlConstant("</span>").toSafeHtml(); } }; repositories.addColumn(iconColumn, SafeHtmlUtils.fromSafeConstant("<br/>")); repositories.setColumnWidth(iconColumn, 28, Style.Unit.PX); repositories.addColumn(repositoryColumn, locale.samplesListRepositoryColumn()); repositories.addColumn(descriptionColumn, locale.samplesListDescriptionColumn()); // don't show loading indicator repositories.setLoadingIndicator(null); final SingleSelectionModel<ProjectData> selectionModel = new SingleSelectionModel<>(); selectionModel.addSelectionChangeHandler(new SelectionChangeEvent.Handler() { @Override public void onSelectionChange(SelectionChangeEvent event) { ProjectData selectedObject = selectionModel.getSelectedObject(); delegate.onRepositorySelected(selectedObject); } }); repositories.setSelectionModel(selectionModel); }
From source file:org.eclipse.che.ide.ext.java.jdi.client.debug.DebuggerViewImpl.java
License:Open Source License
@Inject protected DebuggerViewImpl(PartStackUIResources partStackUIResources, JavaRuntimeResources resources, JavaRuntimeLocalizationConstant locale, Resources coreRes, VariableTreeNodeRenderer.Resources rendererResources, DtoFactory dtoFactory, DebuggerViewImplUiBinder uiBinder) { super(partStackUIResources); this.locale = locale; this.res = resources; this.coreRes = coreRes; this.dtoFactory = dtoFactory; setContentWidget(uiBinder.createAndBindUi(this)); TableElement breakPointsElement = Elements.createTableElement(); breakPointsElement.setAttribute("style", "width: 100%"); SimpleList.ListEventDelegate<Breakpoint> breakpointListEventDelegate = new SimpleList.ListEventDelegate<Breakpoint>() { public void onListItemClicked(Element itemElement, Breakpoint itemData) { breakpoints.getSelectionModel().setSelectedItem(itemData); }/*from w w w . java 2s.com*/ public void onListItemDoubleClicked(Element listItemBase, Breakpoint itemData) { // TODO: implement 'go to breakpoint source' feature } }; SimpleList.ListItemRenderer<Breakpoint> breakpointListItemRenderer = new SimpleList.ListItemRenderer<Breakpoint>() { @Override public void render(Element itemElement, Breakpoint itemData) { TableCellElement label = Elements.createTDElement(); SafeHtmlBuilder sb = new SafeHtmlBuilder(); // Add icon sb.appendHtmlConstant("<table><tr><td>"); SVGResource icon = res.breakpoint(); if (icon != null) { sb.appendHtmlConstant("<img src=\"" + icon.getSafeUri().asString() + "\">"); } sb.appendHtmlConstant("</td>"); // Add title sb.appendHtmlConstant("<td>"); sb.appendEscaped( itemData.getPath() + " - [line: " + String.valueOf(itemData.getLineNumber() + 1) + "]"); sb.appendHtmlConstant("</td></tr></table>"); label.setInnerHTML(sb.toSafeHtml().asString()); itemElement.appendChild(label); } @Override public Element createElement() { return Elements.createTRElement(); } }; breakpoints = SimpleList.create((SimpleList.View) breakPointsElement, coreRes.defaultSimpleListCss(), breakpointListItemRenderer, breakpointListEventDelegate); this.breakpointsPanel.add(breakpoints); this.variables = Tree.create(rendererResources, new VariableNodeDataAdapter(), new VariableTreeNodeRenderer(rendererResources)); this.variables.setTreeEventHandler(new Tree.Listener<DebuggerVariable>() { @Override public void onNodeAction(@NotNull TreeNodeElement<DebuggerVariable> node) { } @Override public void onNodeClosed(@NotNull TreeNodeElement<DebuggerVariable> node) { selectedVariable = null; } @Override public void onNodeContextMenu(int mouseX, int mouseY, @NotNull TreeNodeElement<DebuggerVariable> node) { } @Override public void onNodeDragStart(@NotNull TreeNodeElement<DebuggerVariable> node, @NotNull MouseEvent event) { } @Override public void onNodeDragDrop(@NotNull TreeNodeElement<DebuggerVariable> node, @NotNull MouseEvent event) { } @Override public void onNodeExpanded(@NotNull final TreeNodeElement<DebuggerVariable> node) { selectedVariable = node; delegate.onSelectedVariableElement(selectedVariable.getData()); delegate.onExpandVariablesTree(); } @Override public void onNodeSelected(@NotNull TreeNodeElement<DebuggerVariable> node, @NotNull SignalEvent event) { selectedVariable = node; delegate.onSelectedVariableElement(selectedVariable.getData()); } @Override public void onRootContextMenu(int mouseX, int mouseY) { } @Override public void onRootDragDrop(@NotNull MouseEvent event) { } @Override public void onKeyboard(@NotNull KeyboardEvent event) { } }); this.variablesPanel.add(variables); minimizeButton.ensureDebugId("debugger-minimizeBut"); }
From source file:org.eclipse.che.ide.ext.runner.client.tabs.console.panel.MessageBuilder.java
License:Open Source License
/** @return an instance of {@link SafeHtml} with all given information */ @Nonnull//from w ww .j a va 2s .com public SafeHtml build() { SafeHtmlBuilder builder = new SafeHtmlBuilder().appendHtmlConstant("<pre style='margin:0px;'>"); StringBuilder prefixes = new StringBuilder(); for (Iterator<MessageType> iterator = types.iterator(); iterator.hasNext();) { MessageType type = iterator.next(); if (UNDEFINED.equals(type)) { builder.append(SimpleHtmlSanitizer.sanitizeHtml(message)); } else { String prefix = type.getPrefix(); builder.appendHtmlConstant("[<span style='color:" + type.getColor() + ";'>") .appendHtmlConstant("<b>" + prefix.replaceAll("[\\[\\]]", "") + "</b></span>]"); prefixes.append(prefix); if (iterator.hasNext()) { prefixes.append(' '); } } } builder.append(SimpleHtmlSanitizer.sanitizeHtml(message.substring(prefixes.length()))); return builder.appendHtmlConstant("</pre>").toSafeHtml(); }
From source file:org.eclipse.che.ide.ext.svn.client.commit.diff.DiffViewerPresenter.java
License:Open Source License
private void colorizeDiff(StringBuilder colorized, String origin) { for (String line : Splitter.on("\n").splitToList(origin)) { final String prefix = line.substring(0, 1); final String sanitizedLine = new SafeHtmlBuilder().appendEscaped(line).toSafeHtml().asString(); colorized.append("<span style=\"color:") .append(lineRules.containsKey(prefix) ? lineRules.get(prefix) : "#dbdbdb").append(";\">") .append(sanitizedLine).append("</span>").append("\n"); }// w ww.j a va 2 s . c om }
From source file:org.eclipse.che.ide.extension.builder.client.console.BuilderConsoleViewImpl.java
License:Open Source License
/** {@inheritDoc} */ @Override//from w ww . j a v a 2s . c o m public void printFF(char ch) { if (consoleArea.getWidgetCount() > 0) { final Widget firstWidget = consoleArea.getWidget(0); if (!firstWidget.getElement().getId().equals(FULL_LOGS_WIDGET_ID)) { consoleArea.insert(getFullLogsWidget(getFullLogsLink()), 0); } } final HTML html = new InlineHTML(); final SafeHtml safeHtml = new SafeHtmlBuilder().appendHtmlConstant("<span>") .append(SimpleHtmlSanitizer.sanitizeHtml(String.valueOf(ch))).appendHtmlConstant("</span>") .toSafeHtml(); html.setHTML(safeHtml); html.getElement().getStyle().setPaddingLeft(2, Style.Unit.PX); consoleArea.add(html); }