Example usage for com.google.gwt.safehtml.shared SafeHtmlUtils fromSafeConstant

List of usage examples for com.google.gwt.safehtml.shared SafeHtmlUtils fromSafeConstant

Introduction

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

Prototype

public static SafeHtml fromSafeConstant(String s) 

Source Link

Document

Returns a SafeHtml constructed from a safe string, i.e., without escaping the string.

Usage

From source file:org.roda.wui.client.common.utils.HtmlSnippetUtils.java

public static SafeHtml getLogEntryComponent(LogEntry entry, List<FacetFieldResult> facets) {
    String html = null;/*from ww  w  .  j a va2 s  . c  om*/
    if (facets != null) {
        for (FacetFieldResult ffr : facets) {
            if ("actionComponent".equalsIgnoreCase(ffr.getField()) && ffr.getValues() != null) {
                for (FacetValue fv : ffr.getValues()) {
                    if (fv.getValue().equalsIgnoreCase(entry.getActionComponent())) {
                        html = fv.getLabel();
                        break;
                    }

                }
            }
            if (html != null) {
                break;
            }
        }
    }
    if (html == null) {
        html = entry.getActionComponent();
    }
    return SafeHtmlUtils.fromSafeConstant(html);
}

From source file:org.roda.wui.client.ingest.process.PluginParameterPanel.java

private void createSelectAipLayout() {
    Label parameterName = new Label(parameter.getName());
    final HorizontalPanel editPanel = new HorizontalPanel();
    final FlowPanel aipPanel = new FlowPanel();
    final Button button = new Button(messages.pluginAipIdButton());
    final FlowPanel buttonsPanel = new FlowPanel();
    final Anchor editButton = new Anchor(SafeHtmlUtils.fromSafeConstant("<i class=\"fa fa-edit\"></i>"));
    final Anchor removeButton = new Anchor(SafeHtmlUtils.fromSafeConstant("<i class=\"fa fa-remove\"></i>"));

    buttonsPanel.add(editButton);/* w  w w  .  ja  v  a 2s  .  com*/
    buttonsPanel.add(removeButton);

    ClickHandler editClickHandler = new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            SelectAipDialog selectAipDialog = new SelectAipDialog(parameter.getName(), false);
            selectAipDialog.setSingleSelectionMode();
            selectAipDialog.showAndCenter();
            selectAipDialog.addValueChangeHandler(new ValueChangeHandler<IndexedAIP>() {

                @Override
                public void onValueChange(ValueChangeEvent<IndexedAIP> event) {
                    IndexedAIP aip = event.getValue();

                    Label itemTitle = new Label();
                    HTMLPanel itemIconHtmlPanel = DescriptionLevelUtils
                            .getElementLevelIconHTMLPanel(aip.getLevel());
                    itemIconHtmlPanel.addStyleName("itemIcon");
                    itemTitle.setText(aip.getTitle() != null ? aip.getTitle() : aip.getId());
                    itemTitle.addStyleName("itemText");

                    aipPanel.clear();
                    aipPanel.add(itemIconHtmlPanel);
                    aipPanel.add(itemTitle);

                    editPanel.add(aipPanel);
                    editPanel.add(buttonsPanel);

                    editPanel.setCellWidth(aipPanel, "100%");

                    editPanel.setVisible(true);
                    button.setVisible(false);

                    value = aip.getId();
                }
            });
        }
    };

    ClickHandler removeClickHandler = new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            editPanel.setVisible(false);
            button.setVisible(true);

            value = null;
        }
    };

    button.addClickHandler(editClickHandler);
    editButton.addClickHandler(editClickHandler);
    removeButton.addClickHandler(removeClickHandler);

    layout.add(parameterName);
    layout.add(button);
    layout.add(editPanel);

    parameterName.addStyleName("form-label");
    aipPanel.addStyleName("itemPanel");
    button.addStyleName("form-button btn btn-play");
    buttonsPanel.addStyleName("itemButtonsPanel");
    editButton.addStyleName("toolbarLink toolbarLinkSmall");
    removeButton.addStyleName("toolbarLink toolbarLinkSmall");
}

From source file:org.roda.wui.client.ingest.process.ShowJob.java

private void update() {
    // set end date
    dateEndedLabel.setVisible(job.getEndDate() != null);
    dateEnded.setVisible(job.getEndDate() != null);
    if (job.getEndDate() != null) {
        dateEnded.setText(dateTimeFormat.format(job.getEndDate()));
    }/*from w w  w  .  jav a2  s  .c om*/

    // set duration
    duration.setText(Humanize.durationInDHMS(job.getStartDate(), job.getEndDate(), DHMSFormat.LONG));

    // set state
    status.setHTML(HtmlSnippetUtils.getJobStateHtml(job));

    // set state details
    boolean hasStateDetails = StringUtils.isNotBlank(job.getStateDetails());
    stateDetailsLabel.setVisible(hasStateDetails);
    stateDetailsValue.setVisible(hasStateDetails);
    if (hasStateDetails) {
        stateDetailsValue.setText(job.getStateDetails());
    }

    // set counters
    SafeHtmlBuilder b = new SafeHtmlBuilder();
    b.append(SafeHtmlUtils.fromSafeConstant("<span class='label-default'>"));
    b.append(messages.showJobProgressCompletionPercentage(job.getJobStats().getCompletionPercentage()));
    b.append(SafeHtmlUtils.fromSafeConstant("</span>"));
    if (job.getJobStats().getSourceObjectsCount() > 0) {
        b.append(SafeHtmlUtils.fromSafeConstant("&nbsp;<span class='label-default'>"));
        b.append(messages.showJobProgressTotalCount(job.getJobStats().getSourceObjectsCount()));
        b.append(SafeHtmlUtils.fromSafeConstant("</span>"));
    }
    if (job.getJobStats().getSourceObjectsProcessedWithSuccess() > 0) {
        b.append(SafeHtmlUtils.fromSafeConstant("&nbsp;<span class='label-success'>"));
        b.append(messages
                .showJobProgressSuccessfulCount(job.getJobStats().getSourceObjectsProcessedWithSuccess()));
        b.append(SafeHtmlUtils.fromSafeConstant("</span>"));
    }
    if (job.getJobStats().getSourceObjectsProcessedWithFailure() > 0) {
        b.append(SafeHtmlUtils.fromSafeConstant("&nbsp;<span class='label-danger'>"));
        b.append(messages.showJobProgressFailedCount(job.getJobStats().getSourceObjectsProcessedWithFailure()));
        b.append(SafeHtmlUtils.fromSafeConstant("</span>"));
    }
    if (job.getJobStats().getSourceObjectsBeingProcessed() > 0) {
        b.append(SafeHtmlUtils.fromSafeConstant("&nbsp;<span class='label-info'>"));
        b.append(messages.showJobProgressProcessingCount(job.getJobStats().getSourceObjectsBeingProcessed()));
        b.append(SafeHtmlUtils.fromSafeConstant("</span>"));
    }
    if (job.getJobStats().getSourceObjectsWaitingToBeProcessed() > 0) {
        b.append(SafeHtmlUtils.fromSafeConstant("&nbsp;<span class='label-warning'>"));
        b.append(
                messages.showJobProgressWaitingCount(job.getJobStats().getSourceObjectsWaitingToBeProcessed()));
        b.append(SafeHtmlUtils.fromSafeConstant("</span>"));
    }

    progress.setHTML(b.toSafeHtml());

    buttonStop.setText(messages.stopButton());
    buttonStop.setVisible(!job.isInFinalState());
    buttonStop.setEnabled(!job.isStopping());

    buttonAppraisal.setText(messages.appraisalTitle() + " ("
            + job.getJobStats().getOutcomeObjectsWithManualIntervention() + ")");
    buttonAppraisal.setVisible(job.getJobStats().getOutcomeObjectsWithManualIntervention() > 0);

    scheduleUpdateStatus();
}

From source file:org.roda.wui.client.ingest.transfer.TransferUpload.java

private void updateUploadForm() {
    String uploadUrl = getUploadUrl();

    if (uploadUrl != null) {
        SafeHtml html = SafeHtmlUtils.fromSafeConstant(
                "<form id='upload' method='post' action='" + uploadUrl + "' enctype='multipart/form-data'>"
                        + "<div id='drop'><h4>" + messages.ingestTransferUploadDropHere() + "</h4><a>"
                        + messages.ingestTransferUploadBrowseFiles() + "</a>" + "<input title='"
                        + RodaConstants.API_PARAM_UPLOAD + "' type='file' name='"
                        + RodaConstants.API_PARAM_UPLOAD + "' multiple='true' />" + " </div>"
                        + "<input title='hiddenSubmit' type='submit' hidden/> </form>");

        uploadForm.setHTML(html);//ww  w  . j a  v a 2  s . co m
        uploadList.setHTML(SafeHtmlUtils.fromSafeConstant("<ul id='upload-list'></ul>"));

        uploadForm.addDomHandler(new DragOverHandler() {

            @Override
            public void onDragOver(DragOverEvent event) {
                uploadForm.addStyleName(DRAGOVER);
            }
        }, DragOverEvent.getType());

        uploadForm.addDomHandler(new DragLeaveHandler() {

            @Override
            public void onDragLeave(DragLeaveEvent event) {
                uploadForm.removeStyleName(DRAGOVER);
            }
        }, DragLeaveEvent.getType());

        uploadForm.addDomHandler(new DropHandler() {

            @Override
            public void onDrop(DropEvent event) {
                uploadForm.removeStyleName(DRAGOVER);
            }
        }, DropEvent.getType());

        JavascriptUtils.runMiniUploadForm();
    } else {
        uploadForm.setHTML(SafeHtmlUtils.EMPTY_SAFE_HTML);
    }
}

From source file:org.roda.wui.client.main.BreadcrumbItem.java

public BreadcrumbItem(String label, Command command) {
    this(SafeHtmlUtils.fromSafeConstant(label), label, command);
}

From source file:org.roda.wui.client.main.BreadcrumbItem.java

public BreadcrumbItem(String label, List<String> path) {
    this(SafeHtmlUtils.fromSafeConstant(label), label, path);
}

From source file:org.roda.wui.client.main.BreadcrumbUtils.java

private static BreadcrumbItem getBreadcrumbItem(final IndexedDIP dip) {
    SafeHtmlBuilder b = new SafeHtmlBuilder();
    // TODO get icon from config
    b.append(SafeHtmlUtils.fromSafeConstant("<i class='fa fa-play-circle-o'></i>"));
    b.append(SafeHtmlUtils.fromString(dip.getTitle()));
    SafeHtml label = b.toSafeHtml();/*w w w.j  av a 2  s  .co m*/

    return new BreadcrumbItem(label, dip.getTitle(), new Command() {

        @Override
        public void execute() {
            HistoryUtils.openBrowse(dip);
        }
    });
}

From source file:org.roda.wui.client.main.BreadcrumbUtils.java

private static BreadcrumbItem getBreadcrumbItem(final DIPFile dipFile) {
    SafeHtmlBuilder b = new SafeHtmlBuilder();
    // TODO get icon from config
    b.append(SafeHtmlUtils.fromSafeConstant("<i class='fa fa-play-circle'></i>"));
    b.append(SafeHtmlUtils.fromString(dipFile.getId()));
    SafeHtml label = b.toSafeHtml();//from  w w w.  java2s . c  o  m

    return new BreadcrumbItem(label, dipFile.getId(), new Command() {

        @Override
        public void execute() {
            HistoryUtils.openBrowse(dipFile);
        }
    });
}

From source file:org.roda.wui.client.main.Menu.java

private MenuItem customMenuItem(String icon, String label, String styleNames, MenuBar subMenu,
        ScheduledCommand command) {/*from  w  ww .  j a  v a  2  s . com*/
    SafeHtmlBuilder b = new SafeHtmlBuilder();
    String iconHTML = "<i class='" + icon + "'></i>";

    b.append(SafeHtmlUtils.fromSafeConstant(iconHTML));
    if (label != null)
        b.append(SafeHtmlUtils.fromSafeConstant(label));

    MenuItem menuItem;
    if (subMenu != null) {
        menuItem = new MenuItem(b.toSafeHtml(), subMenu);
    } else if (command != null) {
        menuItem = new MenuItem(b.toSafeHtml(), command);
    } else {
        menuItem = new MenuItem(b.toSafeHtml());
    }
    menuItem.addStyleName("menu-item");
    menuItem.addStyleName(styleNames);

    return menuItem;
}

From source file:org.roda.wui.client.main.Menu.java

private void setLanguageMenu() {
    String locale = LocaleInfo.getCurrentLocale().getLocaleName();

    // Getting supported languages and their display name
    Map<String, String> supportedLanguages = new HashMap<>();

    for (String localeName : LocaleInfo.getAvailableLocaleNames()) {
        if (!"default".equals(localeName)) {
            supportedLanguages.put(localeName, LocaleInfo.getLocaleNativeDisplayName(localeName));
        }/*from w w w  .  j av a 2s  .c o  m*/
    }

    languagesMenu.clearItems();

    for (final Entry<String, String> entry : supportedLanguages.entrySet()) {
        final String key = entry.getKey();
        final String value = entry.getValue();

        if (key.equals(locale)) {
            SafeHtmlBuilder b = new SafeHtmlBuilder();
            String iconHTML = "<i class='fa fa-check'></i>";

            b.append(SafeHtmlUtils.fromSafeConstant(value));
            b.append(SafeHtmlUtils.fromSafeConstant(iconHTML));

            MenuItem languageMenuItem = new MenuItem(b.toSafeHtml());
            languageMenuItem.addStyleName("menu-item-language-selected");
            languageMenuItem.addStyleName("menu-item-language");
            languagesMenu.addItem(languageMenuItem);
            selectedLanguage = value;
        } else {
            MenuItem languageMenuItem = new MenuItem(SafeHtmlUtils.fromSafeConstant(value),
                    new ScheduledCommand() {

                        @Override
                        public void execute() {
                            JavascriptUtils.changeLocale(key);
                        }
                    });
            languagesMenu.addItem(languageMenuItem);
            languageMenuItem.addStyleName("menu-item-language");
        }
    }
}