Example usage for com.google.gwt.safehtml.shared SafeHtmlBuilder appendHtmlConstant

List of usage examples for com.google.gwt.safehtml.shared SafeHtmlBuilder appendHtmlConstant

Introduction

In this page you can find the example usage for com.google.gwt.safehtml.shared SafeHtmlBuilder appendHtmlConstant.

Prototype

public SafeHtmlBuilder appendHtmlConstant(String html) 

Source Link

Document

Appends a compile-time-constant string, which will not be escaped.

Usage

From source file:org.eclipse.che.ide.command.toolbar.commands.button.ExecuteCommandButtonFactory.java

License:Open Source License

/** Returns {@link FontAwesome} icon for the given goal. */
private SafeHtml getIconForGoal(CommandGoal goal) {
    final SafeHtmlBuilder safeHtmlBuilder = new SafeHtmlBuilder();

    if (goal.equals(runGoal)) {
        safeHtmlBuilder.appendHtmlConstant(FontAwesome.PLAY);
    } else if (goal.equals(debugGoal)) {
        safeHtmlBuilder.appendHtmlConstant(FontAwesome.BUG);
    }/*w w w  .  j  a v a2 s  . c  om*/

    return safeHtmlBuilder.toSafeHtml();
}

From source file:org.eclipse.che.ide.command.toolbar.CommandToolbarPresenter.java

License:Open Source License

private void initButtons() {
    final SafeHtmlBuilder safeHtmlBuilder = new SafeHtmlBuilder();
    safeHtmlBuilder.appendHtmlConstant(FontAwesome.LIST);

    openCommandsPaletteButton = toolbarButtonsFactory.createOpenPaletteButton(safeHtmlBuilder.toSafeHtml());
}

From source file:org.eclipse.che.ide.command.toolbar.processes.ProcessWidget.java

License:Open Source License

private ActionButton createStopButton(Process process, StopProcessHandler handler) {
    final SafeHtmlBuilder safeHtmlBuilder = new SafeHtmlBuilder();
    safeHtmlBuilder.appendHtmlConstant(FontAwesome.STOP);

    final ActionButton button = new ActionButton(safeHtmlBuilder.toSafeHtml());
    button.addClickHandler(event -> handler.onStopProcess(process));
    button.ensureDebugId("dropdown-processes-stop");

    Tooltip.create((Element) button.getElement(), BOTTOM, MIDDLE, "Stop");

    return button;
}

From source file:org.eclipse.che.ide.command.toolbar.processes.ProcessWidget.java

License:Open Source License

private ActionButton createRerunButton(Process process, RerunProcessHandler handler) {
    final SafeHtmlBuilder safeHtmlBuilder = new SafeHtmlBuilder();
    safeHtmlBuilder.appendHtmlConstant(FontAwesome.REPEAT);

    final ActionButton button = new ActionButton(safeHtmlBuilder.toSafeHtml());
    button.addClickHandler(event -> handler.onRerunProcess(process));
    button.ensureDebugId("dropdown-processes-rerun");

    Tooltip.create((Element) button.getElement(), BOTTOM, MIDDLE, "Re-run");

    return button;
}

From source file:org.eclipse.che.ide.ext.datasource.client.common.AlignableColumnHeader.java

License:Open Source License

private static SafeHtml getSafeHtml(final String text, final HorizontalAlignmentConstant alignment) {
    SafeHtmlBuilder safeBuilder = new SafeHtmlBuilder();
    boolean needCloseTag = false;
    if (HasHorizontalAlignment.ALIGN_RIGHT.equals(alignment)) {
        safeBuilder.appendHtmlConstant("<p style=\"text-align:right;\">");
        needCloseTag = true;/*www. j  a va 2s .  c o  m*/
    } else if (HasHorizontalAlignment.ALIGN_CENTER.equals(alignment)) {
        safeBuilder.appendHtmlConstant("<p style=\"text-align:center;\">");
        needCloseTag = true;
    }
    safeBuilder.appendEscaped(text);
    if (needCloseTag) {
        safeBuilder.appendHtmlConstant("</p>");
    }
    return safeBuilder.toSafeHtml();
}

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   w  ww. 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// ww w. j  a v a 2 s .c om
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);
        }//w  w w .ja va  2 s  .  c o  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   w  ww  .  j ava 2 s.  co  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();/*w ww .  j ava2  s. 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()));
}