Java Code Examples for com.google.gwt.safehtml.shared.SafeHtmlBuilder#toSafeHtml()

The following examples show how to use com.google.gwt.safehtml.shared.SafeHtmlBuilder#toSafeHtml() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CellTreeNodeView.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
public void replaceChildren(List<C> values, int start, SelectionModel<? super C> selectionModel, boolean stealFocus) {
  // Render the children.
  SafeHtmlBuilder sb = new SafeHtmlBuilder();
  render(sb, values, 0, selectionModel);

  Map<Object, CellTreeNodeView<?>> savedViews = saveChildState(values, start);

  nodeView.tree.isRefreshing = true;
  SafeHtml html = sb.toSafeHtml();
  Element newChildren = AbstractHasData.convertToElements(nodeView.tree, getTmpElem(), html);
  AbstractHasData.replaceChildren(nodeView.tree, childContainer, newChildren, start, html);
  nodeView.tree.isRefreshing = false;

  loadChildState(values, start, savedViews);
}
 
Example 2
Source File: StaticHelp.java    From core with GNU Lesser General Public License v2.1 6 votes vote down vote up
static SafeHtml unmanaged() {
    // TODO I18n or take from DMR
    SafeHtmlBuilder builder = new SafeHtmlBuilder();
    builder.appendHtmlConstant("<table class='help-attribute-descriptions'>");
    addHelpTextRow(builder, "Path:",
            Console.CONSTANTS.unmanagedDeploymentPathDescription());
    addHelpTextRow(builder, "Relative To:",
            Console.CONSTANTS.unmanagedDeploymentRelativeToDescription());
    addHelpTextRow(builder, "Is Archive?:",
            Console.CONSTANTS.unmanagedDeploymentArchiveDescription());
    addHelpTextRow(builder, "Name:", Console.CONSTANTS.deploymentNameDescription());
    addHelpTextRow(builder, "Runtime Name:",
            Console.CONSTANTS.deploymentRuntimeNameDescription());
    if (Console.getBootstrapContext().isStandalone()) {
        addHelpTextRow(builder, "Enable:",
                Console.CONSTANTS.deploymentEnabledDescription());
    }
    return builder.toSafeHtml();
}
 
Example 3
Source File: ModelBrowserView.java    From core with GNU Lesser General Public License v2.1 6 votes vote down vote up
private void addChildrenTypes(ModelTreeItem rootItem, List<ModelNode> modelNodes) {

        rootItem.removeItems();

        final ChildInformation childInformation = parseChildrenTypes(modelNodes);

        for(String child : childInformation.getNames())
        {
            final ModelNode address = getNodeAddress(rootItem, child);

            SafeHtmlBuilder html = new SafeHtmlBuilder();
            html.appendHtmlConstant("<i class='icon-folder-close-alt'></i>&nbsp;");
            html.appendEscaped(child);
            TreeItem childItem = new ModelTreeItem(html.toSafeHtml(), child, address, childInformation.isSingleton(child));
            childItem.addItem(new PlaceholderItem());
            rootItem.addItem(childItem);
            rootItem.updateChildInfo(childInformation);
        }

        rootItem.setState(true);
    }
 
Example 4
Source File: CodeHelper.java    From gwt-material with Apache License 2.0 5 votes vote down vote up
public static SafeHtml parseCode(String code) {
    SafeHtmlBuilder builder = new SafeHtmlBuilder();
    String[] splitted = code.replaceAll("\\\\s", " ").split("\\\\n\\s?");
    String[] arr$ = splitted;
    int len$ = splitted.length;

    for (int i$ = 0; i$ < len$; ++i$) {
        String s = arr$[i$];
        builder.append(SafeHtmlUtils.fromTrustedString(SafeHtmlUtils.htmlEscapeAllowEntities(s)));
        builder.appendHtmlConstant("<br>");
    }

    return builder.toSafeHtml();
}
 
Example 5
Source File: StaticHelpPanel.java    From core with GNU Lesser General Public License v2.1 5 votes vote down vote up
public StaticHelpPanel(String helpText) {

        SafeHtmlBuilder builder = new SafeHtmlBuilder();
        builder.appendHtmlConstant("<div class='help-attribute-descriptions' style='padding-left:10px;'>");
        builder.appendHtmlConstant(helpText);
        builder.appendHtmlConstant("</div>");
        this.helpText = builder.toSafeHtml();
    }
 
Example 6
Source File: WebServiceDescriptions.java    From core with GNU Lesser General Public License v2.1 5 votes vote down vote up
public static SafeHtml getEndpointDescription()
{
    SafeHtmlBuilder html = new SafeHtmlBuilder();
    html.appendHtmlConstant("<ul>");
    html.appendHtmlConstant("<li>");
    html.appendEscaped("context: Webservice endpoint context.") ;
    html.appendHtmlConstant("<li>");
    html.appendEscaped("class: Webservice implementation class.") ;
    html.appendHtmlConstant("<li>");
    html.appendEscaped("type: Webservice endpoint type.") ;
    html.appendHtmlConstant("<li>");
    html.appendEscaped("wsdl-url:Webservice endpoint WSDL URL.") ;
    html.appendHtmlConstant("</ul>");
    return html.toSafeHtml();
}
 
Example 7
Source File: RBACUtil.java    From core with GNU Lesser General Public License v2.1 5 votes vote down vote up
public static SafeHtml dump(SecurityContext sc) {
    SafeHtmlBuilder html = new SafeHtmlBuilder();

    SecurityContextImpl context = (SecurityContextImpl)sc; // parent context

    html.appendHtmlConstant("<hr/><b>Child Contexts:</b> <br/>");
    html.appendHtmlConstant("<ul>");
    for (AddressTemplate address : context.getResourceAddresses()) {
        html.appendHtmlConstant("<li><i>").appendEscaped(address.toString()).appendHtmlConstant("</i></li>");
        String activeKey = context.getActiveKey(address);

        html.appendHtmlConstant("<ul>");
        for (String key : context.getConstraintsKeys(address)) {
            if(key.equals(activeKey))
                html.appendHtmlConstant("<li><b>").appendEscaped(key).appendHtmlConstant("</b></li>");
            else
                html.appendHtmlConstant("<li>").appendEscaped(key).appendHtmlConstant("</li>");
        }
        html.appendHtmlConstant("</ul>");

    }

    html.appendHtmlConstant("</ul>");

    writeContext(html, context);

    return html.toSafeHtml();
}
 
Example 8
Source File: StaticHelp.java    From core with GNU Lesser General Public License v2.1 5 votes vote down vote up
static SafeHtml replace() {
    // TODO I18n or take from DMR
    SafeHtmlBuilder builder = new SafeHtmlBuilder();
    builder.appendHtmlConstant("<table class='help-attribute-descriptions'>");
    addHelpTextRow(builder, "Name:", Console.CONSTANTS.deploymentNameDescription());
    addHelpTextRow(builder, "Runtime Name:",
            Console.CONSTANTS.deploymentRuntimeNameDescription());
    return builder.toSafeHtml();
}
 
Example 9
Source File: StaticHelp.java    From core with GNU Lesser General Public License v2.1 5 votes vote down vote up
static SafeHtml deployment() {
    // TODO I18n or take from DMR
    SafeHtmlBuilder builder = new SafeHtmlBuilder();
    builder.appendHtmlConstant("<table class='help-attribute-descriptions'>");
    addHelpTextRow(builder, "Name:", Console.CONSTANTS.deploymentNameDescription());
    addHelpTextRow(builder, "Runtime Name:",
            Console.CONSTANTS.deploymentRuntimeNameDescription());
    addHelpTextRow(builder, "Enable:",
            Console.CONSTANTS.deploymentEnabledDescription());
    return builder.toSafeHtml();
}
 
Example 10
Source File: Header.java    From core with GNU Lesser General Public License v2.1 5 votes vote down vote up
private Widget getLinksSection() {
    linksPane = new HTMLPanel(createLinks());
    linksPane.getElement().setId("header-links-section");
    linksPane.getElement().setAttribute("role", "menubar");
    linksPane.getElement().setAttribute("aria-controls", "main-content-area");

    for (final ToplevelTabs.Config tlt : toplevelTabs) {
        final String id = "header-" + tlt.getToken();

        SafeHtmlBuilder html = new SafeHtmlBuilder();
        html.appendHtmlConstant("<div class='header-link-label'>");
        html.appendHtmlConstant("<span role='menuitem'>");
        html.appendHtmlConstant(tlt.getTitle());
        html.appendHtmlConstant("</span>");
        html.appendHtmlConstant("</div>");
        HTML widget = new HTML(html.toSafeHtml());
        widget.setStyleName("fill-layout");

        widget.addClickHandler(new ClickHandler() {
            @Override
            public void onClick(ClickEvent event) {
                // navigate either child directly or parent if revealed the first time
                /*boolean hasChild = perspectiveStore.hasChild(tlt.getToken());
                String token = hasChild ?
                        perspectiveStore.getChild(tlt.getToken()) : tlt.getToken();
                boolean updateToken = hasChild ? true : tlt.isUpdateToken();*/

                String token = tlt.getToken();
                placeManager.revealPlace(
                        new PlaceRequest.Builder().nameToken(token).build(), tlt.isUpdateToken()
                );
            }
        });
        linksPane.add(widget, id);

    }

    return linksPane;
}
 
Example 11
Source File: StackedBar.java    From core with GNU Lesser General Public License v2.1 4 votes vote down vote up
public Widget asWidget() {

        SafeHtmlBuilder builder = new SafeHtmlBuilder();

        builder.appendHtmlConstant("<div id='"+ outerId +"'><div id='"+innerId+"'/></div>");

        panel = new HTMLPanel(builder.toSafeHtml());

        Element outerElement = panel.getElementById(outerId);
        outerElement.addClassName("stacked-bar-total");
        outerElement.setAttribute("style", "width:100%");
        outerElement.setAttribute("cssText", "width:100%!important");


        Element innerElement = panel.getElementById(innerId);
        innerElement.addClassName("stacked-bar-actual");
        innerElement.setInnerText(label);

        return panel;
    }
 
Example 12
Source File: ModelBrowserView.java    From core with GNU Lesser General Public License v2.1 4 votes vote down vote up
/**
 * Update root node. Basicaly a refresh of the tree.
 *
 * @param address
 * @param modelNodes
 */
public void updateRootTypes(ModelNode address, List<ModelNode> modelNodes) {

    deck.showWidget(CHILD_VIEW);
    tree.clear();
    descView.clearDisplay();
    formView.clearDisplay();
    offsetDisplay.clear();

    // IMPORTANT: when pin down is active, we need to consider the offset to calculate the real address
    addressOffset = address;
    nodeHeader.updateDescription(address);

    List<Property> offset = addressOffset.asPropertyList();
    if(offset.size()>0)
    {
        String parentName = offset.get(offset.size() - 1).getName();
        HTML parentTag = new HTML("<div class='gwt-ToggleButton gwt-ToggleButton-down' title='Remove Filter'>&nbsp;" + parentName + "&nbsp;<i class='icon-remove'></i></div>");
        parentTag.addClickHandler(new ClickHandler() {
            @Override
            public void onClick(ClickEvent event) {
                presenter.onPinTreeSelection(null);
            }
        });
        offsetDisplay.add(parentTag);
    }

    TreeItem rootItem = null;
    String rootTitle = null;
    String key = null;
    if(address.asList().isEmpty())
    {
        rootTitle = DEFAULT_ROOT;
        key = DEFAULT_ROOT;
    }
    else
    {
        List<ModelNode> tuples = address.asList();
        rootTitle = tuples.get(tuples.size() - 1).asProperty().getValue().asString();
        key = rootTitle;
    }

    SafeHtmlBuilder html = new SafeHtmlBuilder().appendEscaped(rootTitle);
    rootItem = new ModelTreeItem(html.toSafeHtml(), key, address, false);
    tree.addItem(rootItem);


    deck.showWidget(RESOURCE_VIEW);
    rootItem.setSelected(true);

    currentRootKey = key;

    addChildrenTypes((ModelTreeItem)rootItem, modelNodes);
}
 
Example 13
Source File: NoServerView.java    From core with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Override
public Widget createWidget() {

    header = new ContentHeaderLabel();


    SafeHtmlBuilder startServerDesc = new SafeHtmlBuilder();
    startServerDesc.appendEscaped("Start a server that can be monitored.").appendHtmlConstant("<p/>");

    ContentBox startServer = new ContentBox(
            UUID.uuid(), "Start Server",
            startServerDesc.toSafeHtml(),
            "Domain Overview", NameTokens.Topology
    );

    // ----

    SafeHtmlBuilder createServerDesc = new SafeHtmlBuilder();
    createServerDesc.appendEscaped("A server configuration does specify the overall configuration of a server. A server configuration can be started and perform work.").appendHtmlConstant("<p/>");

    ContentBox createServer = new ContentBox(
            UUID.uuid(), "Create Server",
            createServerDesc.toSafeHtml(),
            "Server Configurations", NameTokens.ServerPresenter
    );

    // -----

    SafeHtmlBuilder choseHostDesc = new SafeHtmlBuilder();
    choseHostDesc.appendEscaped("Only active servers can be monitored. Chose another host with active servers.").appendHtmlConstant("<p/>");


    hosts = new ComboPicker();
    Widget hWidget = hosts.asWidget();
    hWidget.getElement().setAttribute("style", "margin-bottom:10px");
    hWidget.getElement().addClassName("table-picker");

    VerticalPanel inner = new VerticalPanel();
    inner.setStyleName("fill-layout-width");
    inner.add(hWidget);
    inner.add(new DefaultButton("Proceed", new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            if(hosts.getSelectedValue()!=null && !hosts.getSelectedValue().equals(""))
            {

                circuit.dispatch(new HostSelection(hosts.getSelectedValue()));

                Scheduler.get().scheduleDeferred(new Scheduler.ScheduledCommand() {
                    @Override
                    public void execute() {
                        placeManager.revealPlace(new PlaceRequest(NameTokens.DomainRuntimePresenter));
                    }
                });
            }
        }
    }));

    choseHost = new ContentBox(
            UUID.uuid(), "Change Host",
            choseHostDesc.toSafeHtml(),
            inner
    );

    // -----

    SimpleLayout layout = new SimpleLayout()
            .setHeadlineWidget(header)
            .setPlain(true)
            .setDescription("You can only monitor active server instances. Either there is no server configured for this host, or no server instance is running.")
            .addContent("", choseHost)
            .addContent("", createServer)
            .addContent("", startServer);

    return layout.build();
}