Search in sources :

Example 1 with TextReportElement

use of org.activityinfo.legacy.shared.reports.model.TextReportElement in project activityinfo by bedatadriven.

the class ElementWidget method renderStaticHtml.

private void renderStaticHtml() {
    String text = ((TextReportElement) model).getText();
    SplitResult lines = RegExp.compile("\r?\n").split(Strings.nullToEmpty(text));
    SafeHtmlBuilder html = new SafeHtmlBuilder();
    for (int i = 0; i < lines.length(); i++) {
        if (i > 0) {
            html.appendHtmlConstant("<br>");
        }
        html.appendEscaped(lines.get(i));
    }
    updateHtml(html.toSafeHtml().asString());
}
Also used : SplitResult(com.google.gwt.regexp.shared.SplitResult) SafeHtmlBuilder(com.google.gwt.safehtml.shared.SafeHtmlBuilder) TextReportElement(org.activityinfo.legacy.shared.reports.model.TextReportElement)

Example 2 with TextReportElement

use of org.activityinfo.legacy.shared.reports.model.TextReportElement in project activityinfo by bedatadriven.

the class ElementWidget method loadHtml.

private void loadHtml() {
    contentElement.setInnerHTML("");
    loadingElement.getStyle().setDisplay(Display.BLOCK);
    if (model instanceof TextReportElement) {
        renderStaticHtml();
    } else {
        dispatcher.execute(new RenderReportHtml(model), new AsyncCallback<HtmlResult>() {

            @Override
            public void onFailure(Throwable caught) {
            // TODO Auto-generated method stub
            }

            @Override
            public void onSuccess(HtmlResult result) {
                updateHtml(result.getHtml());
            }
        });
    }
}
Also used : HtmlResult(org.activityinfo.legacy.shared.command.result.HtmlResult) RenderReportHtml(org.activityinfo.legacy.shared.command.RenderReportHtml) TextReportElement(org.activityinfo.legacy.shared.reports.model.TextReportElement)

Example 3 with TextReportElement

use of org.activityinfo.legacy.shared.reports.model.TextReportElement in project activityinfo by bedatadriven.

the class GenerateDashboardElementHandler method execute.

@Override
public CommandResult execute(GenerateDashboardElement cmd, User user) throws CommandException {
    ReportDTO report = dispatcher.execute(new GetReportModel(cmd.getReportId()));
    if (report.getReport().getElements().isEmpty()) {
        return new TextReportElement("The report is empty");
    } else {
        ReportElement element = report.getReport().getElements().get(0);
        element.setContent(generator.generateElement(user, element, null, new DateRange()));
        return element;
    }
}
Also used : DateRange(org.activityinfo.legacy.shared.reports.model.DateRange) GetReportModel(org.activityinfo.legacy.shared.command.GetReportModel) ReportDTO(org.activityinfo.legacy.shared.model.ReportDTO) ReportElement(org.activityinfo.legacy.shared.reports.model.ReportElement) TextReportElement(org.activityinfo.legacy.shared.reports.model.TextReportElement) TextReportElement(org.activityinfo.legacy.shared.reports.model.TextReportElement)

Aggregations

TextReportElement (org.activityinfo.legacy.shared.reports.model.TextReportElement)3 SplitResult (com.google.gwt.regexp.shared.SplitResult)1 SafeHtmlBuilder (com.google.gwt.safehtml.shared.SafeHtmlBuilder)1 GetReportModel (org.activityinfo.legacy.shared.command.GetReportModel)1 RenderReportHtml (org.activityinfo.legacy.shared.command.RenderReportHtml)1 HtmlResult (org.activityinfo.legacy.shared.command.result.HtmlResult)1 ReportDTO (org.activityinfo.legacy.shared.model.ReportDTO)1 DateRange (org.activityinfo.legacy.shared.reports.model.DateRange)1 ReportElement (org.activityinfo.legacy.shared.reports.model.ReportElement)1