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:edu.arizona.biosemantics.gxt.theme.green.client.base.widget.Css3DatePickerAppearance.java

License:sencha.com license

@Override
public void renderMonthPicker(SafeHtmlBuilder sb, DatePickerMessages messages, String[] monthNames) {
    sb.appendHtmlConstant("<div class=" + style.monthPicker() + "><table border=0 cellspacing=0>");

    for (int i = 0; i < 6; i++) {
        sb.appendHtmlConstant("<tr><td class='" + style.monthPickerItem() + " " + style.month() + "'><a class="
                + style.monthPickerItemInner() + " href=#>");
        sb.appendHtmlConstant(monthNames[i]);
        sb.appendHtmlConstant("</a></td>");
        sb.appendHtmlConstant("<td class='" + style.monthPickerItem() + " " + style.month() + " "
                + style.monthSep() + "'><a class=" + style.monthPickerItemInner() + " href=#>");
        sb.appendHtmlConstant(monthNames[i + 6]);
        sb.appendHtmlConstant("</a></td>");
        if (i == 0) {
            sb.appendHtmlConstant("<td class=" + style.yearButton() + " align=center>");
            sb.appendHtmlConstant("<div class=" + style.leftYearIcon() + "></div>");
            sb.appendHtmlConstant("</td><td class='" + style.yearButton() + "' align=center>");
            sb.appendHtmlConstant("<div class=" + style.rightYearIcon() + "></div>");
            sb.appendHtmlConstant("</td></tr>");
        } else {/*  w  w w.  j a v  a  2  s  .  com*/
            sb.appendHtmlConstant("<td class='" + style.monthPickerItem() + " " + style.year() + "'><a class="
                    + style.monthPickerItemInner() + " href='#'></a></td><td class='" + style.monthPickerItem()
                    + " " + style.year() + "'><a class=" + style.monthPickerItemInner()
                    + " href='#'></a></td></tr>");
        }
    }

    sb.appendHtmlConstant("<tr class=" + style.monthButtons() + "><td colspan='4'>");
    sb.appendHtmlConstant("<div class=" + style.ok() + "></div>");
    sb.appendHtmlConstant("<div class=" + style.cancel() + "></div>");
    sb.appendHtmlConstant("</td></tr></table></div>");
}

From source file:edu.arizona.biosemantics.gxt.theme.green.client.sliced.button.SlicedButtonCellAppearance.java

License:sencha.com license

@Override
public void render(final ButtonCell<C> cell, Context context, C value, SafeHtmlBuilder sb) {
    String constantHtml = cell.getHTML();
    boolean hasConstantHtml = constantHtml != null && constantHtml.length() != 0;
    boolean isBoolean = value != null && value instanceof Boolean;
    // is a boolean always a toggle button?
    String text = hasConstantHtml ? cell.getText()
            : (value != null && !isBoolean) ? SafeHtmlUtils.htmlEscape(value.toString()) : "";

    ImageResource icon = cell.getIcon();
    IconAlign iconAlign = cell.getIconAlign();

    String cls = style.button();/*from ww w .  j a va 2  s  .  co  m*/
    String arrowCls = "";
    if (cell.getMenu() != null) {

        if (cell instanceof SplitButtonCell) {
            switch (cell.getArrowAlign()) {
            case RIGHT:
                arrowCls = style.split();
                break;
            case BOTTOM:
                arrowCls = style.splitBottom();
                break;
            default:
                // empty
            }

        } else {
            switch (cell.getArrowAlign()) {
            case RIGHT:
                arrowCls = style.arrow();
                break;
            case BOTTOM:
                arrowCls = style.arrowBottom();
                break;
            }
        }

    }

    ButtonScale scale = cell.getScale();

    switch (scale) {
    case SMALL:
        cls += " " + style.small();
        break;
    case MEDIUM:
        cls += " " + style.medium();
        break;
    case LARGE:
        cls += " " + style.large();
        break;
    default:
        // empty
    }

    SafeStylesBuilder stylesBuilder = new SafeStylesBuilder();

    int width = -1;

    if (cell.getWidth() != -1) {
        int w = cell.getWidth();
        if (w < cell.getMinWidth()) {
            w = cell.getMinWidth();
        }
        stylesBuilder.appendTrustedString("width:" + w + "px;");
        cls += " " + style.hasWidth() + " x-has-width";
        width = w;
    } else {

        if (cell.getMinWidth() != -1) {
            TextMetrics.get().bind(style.text());
            int length = TextMetrics.get().getWidth(text);
            length += 6; // frames

            if (icon != null) {
                switch (iconAlign) {
                case LEFT:
                case RIGHT:
                    length += icon.getWidth();
                    break;
                default:
                    // empty
                }
            }
        }
    }

    final int height = cell.getHeight();
    if (height != -1) {
        stylesBuilder.appendTrustedString("height:" + height + "px;");
    }

    if (icon != null) {
        switch (iconAlign) {
        case TOP:
            arrowCls += " " + style.iconTop();
            break;
        case BOTTOM:
            arrowCls += " " + style.iconBottom();
            break;
        case LEFT:
            arrowCls += " " + style.iconLeft();
            break;
        case RIGHT:
            arrowCls += " " + style.iconRight();
            break;
        }

    } else {
        arrowCls += " " + style.noIcon();
    }

    // toggle button
    if (value == Boolean.TRUE) {
        cls += " " + frame.pressedClass();
    }

    sb.append(templates.outer(cls, new SafeStylesBuilder().toSafeStyles()));

    SafeHtmlBuilder inside = new SafeHtmlBuilder();

    String innerWrap = arrowCls;
    if (GXT.isIE6() || GXT.isIE7()) {
        arrowCls += " " + CommonStyles.get().inlineBlock();
    }

    inside.appendHtmlConstant("<div class='" + innerWrap + "'>");
    inside.appendHtmlConstant("<table cellpadding=0 cellspacing=0 class='" + style.mainTable() + "'>");

    boolean hasText = text != null && !text.equals("");

    if (icon != null) {
        switch (iconAlign) {
        case LEFT:
            inside.appendHtmlConstant("<tr>");
            writeIcon(inside, icon, height);
            if (hasText) {
                int w = width - (icon != null ? icon.getWidth() : 0) - 4;
                writeText(inside, text, w, height);
            }
            inside.appendHtmlConstant("</tr>");
            break;
        case RIGHT:
            inside.appendHtmlConstant("<tr>");
            if (hasText) {
                int w = width - (icon != null ? icon.getWidth() : 0) - 4;
                writeText(inside, text, w, height);
            }
            writeIcon(inside, icon, height);
            inside.appendHtmlConstant("</tr>");
            break;
        case TOP:
            inside.appendHtmlConstant("<tr>");
            writeIcon(inside, icon, height);
            inside.appendHtmlConstant("</tr>");
            if (hasText) {
                inside.appendHtmlConstant("<tr>");
                writeText(inside, text, width, height);
                inside.appendHtmlConstant("</tr>");
            }
            break;
        case BOTTOM:
            if (hasText) {
                inside.appendHtmlConstant("<tr>");
                writeText(inside, text, width, height);
                inside.appendHtmlConstant("</tr>");
            }
            inside.appendHtmlConstant("<tr>");
            writeIcon(inside, icon, height);
            inside.appendHtmlConstant("</tr>");
            break;
        }

    } else {
        inside.appendHtmlConstant("<tr>");
        if (text != null) {
            writeText(inside, text, width, height);
        }
        inside.appendHtmlConstant("</tr>");
    }
    inside.appendHtmlConstant("</table>");
    inside.appendHtmlConstant("</div>");

    frame.render(sb,
            new Frame.FrameOptions(0, CommonStyles.get().noFocusOutline(), stylesBuilder.toSafeStyles()),
            inside.toSafeHtml());

    sb.appendHtmlConstant("</div>");

}

From source file:eu.riscoss.client.rdr.ContactCell.java

License:Apache License

@Override
public void render(Context context, EntityInfo value, SafeHtmlBuilder sb) {
    // Value can be null, so do a null check..
    if (value == null) {
        return;/*from ww  w .j  a  va  2s .c om*/
    }

    //      sb.appendHtmlConstant("<table><tr><td style='font-size:95%;'>");
    sb.appendHtmlConstant("<a class='gwt-Anchor' href='javascript:'>");
    sb.appendEscaped(value.getName());
    sb.appendHtmlConstant("</a>");
    //      sb.appendHtmlConstant("</td></tr></table>");
}

From source file:fr.mncc.gwttoolbox.datagrid.client.cells.RewritableCell.java

License:Open Source License

@Override
public void render(com.google.gwt.cell.client.Cell.Context context, Double value, SafeHtmlBuilder sb) {
    if (value != null) {
        sb.appendHtmlConstant("<span id=" + "cell" + value + "></span>");
        rewriteCell(value);//  www. j  a  va 2  s. c  om
    }
}

From source file:fr.mncc.gwttoolbox.datagrid.client.columns.ButtonColumn.java

License:Open Source License

public ButtonColumn(final String tooltip) {
    super(new ButtonCell() {

        @Override//from ww  w .  ja va  2s  .  co  m
        public void render(Context context, SafeHtml data, SafeHtmlBuilder sb) {
            sb.appendHtmlConstant("<button type=\"button\" tabindex=\"-1\" title=\"" + tooltip + "\">");
            if (data != null) {
                sb.append(data);
            }
            sb.appendHtmlConstant("</button>");
        }
    });
}

From source file:gov.nist.appvet.gwt.client.gui.table.appslist.AppsListPagingDataGrid.java

License:Open Source License

@Override
public void initTableColumns(DataGrid<T> dataGrid, ListHandler<T> sortHandler) {

    //--------------------------- App ID -----------------------------------
    final Column<T, String> appIdColumn = new Column<T, String>(new TextCell()) {

        @Override/*from  w  w w  .  j  a  v  a  2 s. c o  m*/
        public String getValue(T object) {
            return ((AppInfoGwt) object).appId;
        }

    };
    appIdColumn.setSortable(true);
    sortHandler.setComparator(appIdColumn, new Comparator<T>() {

        @Override
        public int compare(T o1, T o2) {
            return ((AppInfoGwt) o1).appId.compareTo(((AppInfoGwt) o2).appId);
        }

    });
    appIdColumn.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);
    dataGrid.addColumn(appIdColumn, "ID");
    dataGrid.setColumnWidth(appIdColumn, "60px");

    //--------------------------- App Icon ---------------------------------
    final SafeHtmlCell iconCell = new SafeHtmlCell();
    final Column<T, SafeHtml> iconColumn = new Column<T, SafeHtml>(iconCell) {

        @Override
        public SafeHtml getValue(T object) {
            final SafeHtmlBuilder sb = new SafeHtmlBuilder();
            final String appId = ((AppInfoGwt) object).appId;
            final AppStatus appStatus = ((AppInfoGwt) object).appStatus;
            if (appStatus == null) {
                log.warning("App status is null");
                return sb.toSafeHtml();
            } else {
                log.info("App status in table is: " + appStatus.name());
            }
            if (appStatus == AppStatus.REGISTERING) {
                iconVersion++;
                final String iconPath = appVetHostUrl + "/appvet_images/default.png?v" + iconVersion;
                sb.appendHtmlConstant("<img width=\"20\" src=\"" + iconPath + "\" alt=\"\" />");
            } else if (appStatus == AppStatus.PENDING) {
                final String iconPath = appVetHostUrl + "/appvet_images/default.png";
                sb.appendHtmlConstant("<img width=\"20\" src=\"" + iconPath + "\" alt=\"\" />");
            } else if (appStatus == AppStatus.PROCESSING) {
                iconVersion++;
                final String iconPath = appVetHostUrl + "/appvet_images/" + appId + ".png?v" + iconVersion;
                sb.appendHtmlConstant("<img width=\"20\" src=\"" + iconPath + "\" alt=\"\" />");
            } else {
                iconVersion++;
                final String iconPath = appVetHostUrl + "/appvet_images/" + appId + ".png";
                sb.appendHtmlConstant("<img width=\"20\" src=\"" + iconPath + "\" alt=\"\" />");
            }
            return sb.toSafeHtml();
        }

    };
    iconColumn.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);
    iconColumn.setSortable(false);
    dataGrid.addColumn(iconColumn, "");
    dataGrid.setColumnWidth(iconColumn, "25px");

    //------------------------- App Name -----------------------------------
    final Column<T, String> appNameColumn = new Column<T, String>(new TextCell()) {

        @Override
        public String getValue(T object) {
            return ((AppInfoGwt) object).appName;
        }

    };
    appNameColumn.setSortable(true);
    sortHandler.setComparator(appNameColumn, new Comparator<T>() {

        @Override
        public int compare(T o1, T o2) {
            return ((AppInfoGwt) o1).appName.compareTo(((AppInfoGwt) o2).appName);
        }

    });
    appNameColumn.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);
    dataGrid.addColumn(appNameColumn, "App");
    dataGrid.setColumnWidth(appNameColumn, "127px");

    //----------------------------- Status ---------------------------------
    final SafeHtmlCell statusCell = new SafeHtmlCell();
    final Column<T, SafeHtml> statusColumn = new Column<T, SafeHtml>(statusCell) {

        @Override
        public SafeHtml getValue(T object) {
            final SafeHtmlBuilder sb = new SafeHtmlBuilder();
            final AppStatus appStatus = ((AppInfoGwt) object).appStatus;
            String statusHtml = null;
            if (appStatus == AppStatus.ERROR) {
                statusHtml = "<div id=\"error\" style='color: red'>ERROR</div>";
            } else if (appStatus == AppStatus.WARNING) {
                statusHtml = "<div id=\"warning\" style='color: orange'>" + appStatus + "</div>";
            } else if (appStatus == AppStatus.PASS) {
                statusHtml = "<div id=\"endorsed\" style='color: green'>" + appStatus + "</div>";
            } else if (appStatus == AppStatus.FAIL) {
                statusHtml = "<div id=\"error\" style='color: red'>FAIL</div>";
            } else {
                statusHtml = "<div id=\"error\" style='color: black'>" + appStatus.name() + "</div>";
            }
            sb.appendHtmlConstant(statusHtml);
            return sb.toSafeHtml();
        }

    };
    statusColumn.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);
    statusColumn.setSortable(true);
    sortHandler.setComparator(statusColumn, new Comparator<T>() {

        @Override
        public int compare(T o1, T o2) {
            return ((AppInfoGwt) o1).appStatus.compareTo(((AppInfoGwt) o2).appStatus);
        }

    });
    dataGrid.addColumn(statusColumn, "Status");
    dataGrid.setColumnWidth(statusColumn, "60px");

    //--------------------------- Submitter -------------------------------
    final Column<T, String> submitterColumn = new Column<T, String>(new TextCell()) {

        @Override
        public String getValue(T object) {
            return ((AppInfoGwt) object).userName;
        }

    };
    submitterColumn.setSortable(true);
    sortHandler.setComparator(submitterColumn, new Comparator<T>() {

        @Override
        public int compare(T o1, T o2) {
            return ((AppInfoGwt) o1).userName.compareTo(((AppInfoGwt) o2).userName);
        }

    });
    submitterColumn.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);
    dataGrid.addColumn(submitterColumn, "User");
    dataGrid.setColumnWidth(submitterColumn, "60px");

    //--------------------------- Submit Time ------------------------------
    final Column<T, String> submitTimeColumn = new Column<T, String>(new TextCell()) {

        @Override
        public String getValue(T object) {

            final AppInfoGwt appInfo = (AppInfoGwt) object;
            final Date date = new Date(appInfo.submitTime);
            final String dateString = dateTimeFormat.format(date);
            return dateString;
        }

    };
    submitTimeColumn.setSortable(true);
    sortHandler.setComparator(submitTimeColumn, new Comparator<T>() {

        @Override
        public int compare(T o1, T o2) {
            final AppInfoGwt appInfo1 = (AppInfoGwt) o1;
            final Date date1 = new Date(appInfo1.submitTime);
            final String dateString1 = dateTimeFormat.format(date1);
            final AppInfoGwt appInfo2 = (AppInfoGwt) o2;
            final Date date2 = new Date(appInfo2.submitTime);
            final String dateString2 = dateTimeFormat.format(date2);
            return dateString1.compareTo(dateString2);
        }

    });
    submitTimeColumn.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);
    dataGrid.addColumn(submitTimeColumn, "Date/Time");
    dataGrid.setColumnWidth(submitTimeColumn, "100px");
}

From source file:gov.nist.toolkit.xdstools2.client.tabs.simulatorControlTab.SimulatorControlTab.java

License:Creative Commons License

private void addButtonPanel(int row, int maxColumn, final SimulatorConfig config) {

    table.setHTML(0, maxColumn, "<b>Action</b>");
    table.getFlexCellFormatter().setStyleName(0, maxColumn, "lavenderTh");

    final SimId simId = config.getId();
    HorizontalPanel buttonPanel = new HorizontalPanel();
    buttonPanel.getElement().setId("scmButtonPanel");
    table.setWidget(row, maxColumn, buttonPanel);

    Image logImg = new Image("icons2/log-file-format-symbol.png");
    logImg.setTitle("View transaction logs");
    logImg.setAltText("A picture of a log book.");
    applyImgIconStyle(logImg);//w ww. j  a  v a  2 s  .c o  m
    logImg.addClickHandler(new ClickHandlerData<SimulatorConfig>(config) {
        @Override
        public void onClick(ClickEvent clickEvent) {
            SimulatorConfig config = getData();
            SimulatorMessageViewTab viewTab = new SimulatorMessageViewTab();
            viewTab.onTabLoad(config.getId());
        }
    });
    buttonPanel.add(logImg);

    Image pidImg = new Image("icons2/id.png");
    pidImg.setTitle("Patient ID Feed");
    pidImg.setAltText("An ID element.");
    applyImgIconStyle(pidImg);
    pidImg.addClickHandler(new ClickHandlerData<SimulatorConfig>(config) {
        @Override
        public void onClick(ClickEvent clickEvent) {
            SimulatorConfig config = getData();
            PidEditTab editTab = new PidEditTab(config);
            editTab.onTabLoad(true, "PIDEdit");
        }
    });
    buttonPanel.add(pidImg);

    if (ActorType.OD_RESPONDING_GATEWAY.getShortName().equals(config.getActorType())) {
        Image editRgImg = new Image("icons2/edit-rg.png");
        editRgImg.setTitle("Edit RG Simulator Configuration");
        editRgImg.setAltText("A pencil writing.");
        applyImgIconStyle(editRgImg);
        editRgImg.addClickHandler(new ClickHandlerData<SimulatorConfig>(config) {
            @Override
            public void onClick(ClickEvent clickEvent) {
                loadSimStatus();
                SimulatorConfig config = getData();

                // Generic state-less type simulators
                GenericQueryTab editTab = new EditTab(self, config);
                editTab.onTabLoad(true, "SimConfig");
            }
        });
        Image editOdImg = new Image("icons2/edit-od.png");
        editOdImg.setTitle("Edit ODDS Simulator Configuration");
        editOdImg.setAltText("A pencil writing.");
        applyImgIconStyle(editOdImg);
        editOdImg.addClickHandler(new ClickHandlerData<SimulatorConfig>(config) {
            @Override
            public void onClick(ClickEvent clickEvent) {
                loadSimStatus();
                SimulatorConfig config = getData();
                // This simulator requires content state initialization
                OddsEditTab editTab;
                editTab = new OddsEditTab(self, config);
                editTab.onTabLoad(true, "ODDS");
            }
        });
        buttonPanel.add(editRgImg);
        buttonPanel.add(editOdImg);

    } else {

        Image editImg = new Image("icons2/edit.png");
        editImg.setTitle("Edit Simulator Configuration");
        editImg.setAltText("A pencil writing.");
        applyImgIconStyle(editImg);
        editImg.addClickHandler(new ClickHandlerData<SimulatorConfig>(config) {
            @Override
            public void onClick(ClickEvent clickEvent) {
                loadSimStatus();
                SimulatorConfig config = getData();

                //                     GenericQueryTab editTab;
                if (ActorType.ONDEMAND_DOCUMENT_SOURCE.getShortName().equals(config.getActorType())) {
                    // This simulator requires content state initialization
                    OddsEditTab editTab;
                    editTab = new OddsEditTab(self, config);
                    editTab.onTabLoad(true, "ODDS");
                } else {
                    // Generic state-less type simulators
                    GenericQueryTab editTab = new EditTab(self, config);
                    editTab.onTabLoad(true, "SimConfig");
                }

            }
        });
        buttonPanel.add(editImg);
    }

    Image deleteImg = new Image("icons2/garbage.png");
    deleteImg.setTitle("Delete");
    deleteImg.setAltText("A garbage can.");
    applyImgIconStyle(deleteImg);

    final ClickHandlerData<SimulatorConfig> clickHandlerData = new ClickHandlerData<SimulatorConfig>(config) {
        @Override
        public void onClick(ClickEvent clickEvent) {
            SimulatorConfig config = getData();
            DeleteButtonClickHandler handler = new DeleteButtonClickHandler(self, config);
            handler.delete();
        }
    };

    deleteImg.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent clickEvent) {
            SimulatorConfigElement ele = config.getConfigEle(SimulatorProperties.locked);
            boolean locked = (ele == null) ? false : ele.asBoolean();
            if (locked) {
                if (PasswordManagement.isSignedIn) {
                    doDelete();
                } else {
                    PasswordManagement.addSignInCallback(signedInCallback);

                    new AdminPasswordDialogBox(simCtrlContainer);

                    return;
                }
            } else {
                doDelete();
            }

        }

        AsyncCallback<Boolean> signedInCallback = new AsyncCallback<Boolean>() {

            public void onFailure(Throwable ignored) {
            }

            public void onSuccess(Boolean ignored) {
                doDelete();
            }

        };

        private void doDelete() {
            VerticalPanel body = new VerticalPanel();
            body.add(new HTML("<p>Delete " + config.getId().toString() + "?</p>"));
            Button actionButton = new Button("Yes");
            actionButton.addClickHandler(clickHandlerData);
            SafeHtmlBuilder safeHtmlBuilder = new SafeHtmlBuilder();
            safeHtmlBuilder.appendHtmlConstant("<img src=\"icons2/garbage.png\" height=\"16\" width=\"16\"/>");
            safeHtmlBuilder.appendHtmlConstant("Confirm Delete Simulator");
            new PopupMessage(safeHtmlBuilder.toSafeHtml(), body, actionButton);
        }
    });

    buttonPanel.add(deleteImg);

    Image fileDownload = new Image("icons2/download.png");
    fileDownload.setTitle("Download Site File");
    fileDownload.setAltText("An XML document with a download arrow.");
    applyImgIconStyle(fileDownload);
    fileDownload.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent clickEvent) {
            Window.open("siteconfig/" + simId.toString(), "_blank", "");
        }
    });

    buttonPanel.add(fileDownload);

    // Flaticon credits
    // <div>Icons made by <a href="http://www.flaticon.com/authors/madebyoliver" title="Madebyoliver">Madebyoliver</a> from <a href="http://www.flaticon.com" title="Flaticon">www.flaticon.com</a> is licensed by <a href="http://creativecommons.org/licenses/by/3.0/" title="Creative Commons BY 3.0" target="_blank">CC 3.0 BY</a></div>
    // <div>Icons made by <a href="http://www.freepik.com" title="Freepik">Freepik</a> from <a href="http://www.flaticon.com" title="Flaticon">www.flaticon.com</a> is licensed by <a href="http://creativecommons.org/licenses/by/3.0/" title="Creative Commons BY 3.0" target="_blank">CC 3.0 BY</a></div>
    // <div>Icons made by <a href="http://www.flaticon.com/authors/retinaicons" title="Retinaicons">Retinaicons</a> from <a href="http://www.flaticon.com" title="Flaticon">www.flaticon.com</a> is licensed by <a href="http://creativecommons.org/licenses/by/3.0/" title="Creative Commons BY 3.0" target="_blank">CC 3.0 BY</a></div>
    // <div>Icons made by <a href="http://www.flaticon.com/authors/gregor-cresnar" title="Gregor Cresnar">Gregor Cresnar</a> from <a href="http://www.flaticon.com" title="Flaticon">www.flaticon.com</a> is licensed by <a href="http://creativecommons.org/licenses/by/3.0/" title="Creative Commons BY 3.0" target="_blank">CC 3.0 BY</a></div>
}

From source file:gov.wa.wsdot.mobile.client.activities.trafficmap.restarea.RestAreaActivity.java

License:Open Source License

@Override
public void start(AcceptsOneWidget panel, final EventBus eventBus) {
    view = clientFactory.getRestAreaView();
    analytics = clientFactory.getAnalytics();
    accessibility = clientFactory.getAccessibility();
    this.eventBus = eventBus;
    view.setPresenter(this);

    Place place = clientFactory.getPlaceController().getWhere();

    if (place instanceof RestAreaPlace) {
        RestAreaPlace restAreaPlace = (RestAreaPlace) place;

        int restAreaId = Integer.valueOf(restAreaPlace.getId());

        String jsonString = AppBundle.INSTANCE.restAreaData().getText();
        RestAreaFeed restAreas = JsonUtils.safeEval(jsonString);

        view.setTitle("Safety Rest Area");

        SafeHtmlBuilder detailsHTMLBuilder = new SafeHtmlBuilder();

        detailsHTMLBuilder.appendEscaped(restAreas.getRestAreas().get(restAreaId).getRoute() + " - "
                + restAreas.getRestAreas().get(restAreaId).getLocation());

        detailsHTMLBuilder.appendHtmlConstant("<br>");

        detailsHTMLBuilder.appendEscaped("Milepost: " + restAreas.getRestAreas().get(restAreaId).getMilepost()
                + " - " + restAreas.getRestAreas().get(restAreaId).getDirection());

        view.setDetails(detailsHTMLBuilder.toSafeHtml());

        if (restAreas.getRestAreas().get(restAreaId).getNotes() == null) {
            view.hideNotesHeading();//from ww  w  . ja  v a2s  .  co m
            view.setNotes("");
        } else {
            view.showNotesHeading();
            view.setNotes(restAreas.getRestAreas().get(restAreaId).getNotes());
        }

        SafeHtmlBuilder amenitiesHTMLBuilder = new SafeHtmlBuilder();

        amenitiesHTMLBuilder.appendHtmlConstant("<ul>");
        for (int i = 0; i < restAreas.getRestAreas().get(restAreaId).getAmenities().length; i++) {
            amenitiesHTMLBuilder.appendHtmlConstant("<li>");
            amenitiesHTMLBuilder.appendEscaped(restAreas.getRestAreas().get(restAreaId).getAmenities()[i]);
            amenitiesHTMLBuilder.appendHtmlConstant("</li>");
        }

        if (restAreas.getRestAreas().get(restAreaId).getAmenities().length == 0) {
            view.hideAmenitiesHeading();
        } else {
            view.showAmenitiesHeading();
        }

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

        view.setAmenities(amenitiesHTMLBuilder.toSafeHtml());

        view.setLatLon(Double.valueOf(restAreas.getRestAreas().get(restAreaId).getLatitude()),
                Double.valueOf(restAreas.getRestAreas().get(restAreaId).getLongitude()));

        view.refresh();

    }

    panel.setWidget(view);
    accessibility.postScreenChangeNotification();
}

From source file:gwt.material.design.client.base.helper.CodeHelper.java

License:Apache License

public static SafeHtml parseCode(String code) {
    SafeHtmlBuilder builder = new SafeHtmlBuilder();
    String[] splitted = code.replaceAll("\\\\s", " ").split("\\\\n\\s?");
    String[] arr$ = splitted;//from w w w. j a  va 2  s.  c  o  m
    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();
}

From source file:gwt.material.design.client.base.MaterialButtonCell.java

License:Apache License

@SuppressWarnings("deprecation")
@Override//  ww  w.  j  a  v a 2 s  .  co  m
public void render(Context context, MaterialButton value, SafeHtmlBuilder sb) {
    sb.appendHtmlConstant(DOM.toString(value.getElement()));
}