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

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

Introduction

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

Prototype

public static String htmlEscape(String s) 

Source Link

Document

HTML-escapes a string.

Usage

From source file:org.jbpm.console.ng.ht.forms.client.editors.taskform.popup.FormDisplayPopupPresenter.java

License:Apache License

@WorkbenchPartTitle
public String getTitle() {
    String title = createTitle();
    return SafeHtmlUtils.htmlEscape(title != null ? title : "");
}

From source file:org.jbpm.workbench.ht.client.editors.tasklogs.TaskLogsViewImpl.java

License:Apache License

@Override
public void setLogTextAreaText(final List<String> logs) {
    removeAllChildren(logTextArea);//w  w w  .j a va  2  s . c o m
    logs.forEach(log -> {
        HTMLElement li = getDocument().createElement("li");
        li.setTextContent(SafeHtmlUtils.htmlEscape(log));
        logTextArea.appendChild(li);
    });
}

From source file:org.kie.workbench.common.widgets.client.popups.project.ProjectConcurrentChangePopup.java

License:Apache License

public static ProjectConcurrentChangePopup newConcurrentUpdate(final Path project, final User identity,
        final Command onForceSave, final Command onCancel, final Command onReOpen) {

    final String message = ProjectConcurrentChangePopupConstants.INSTANCE.ConcurrentUpdate(identity != null
            ? SafeHtmlUtils.htmlEscape(identity.getIdentifier() != null ? identity.getIdentifier() : "")
            : null, project.toURI());//from   w  ww  .java  2s .  com

    return new ProjectConcurrentChangePopup(message, onForceSave, onCancel, onReOpen);
}

From source file:org.kie.workbench.common.widgets.client.popups.project.ProjectConcurrentChangePopup.java

License:Apache License

public static ProjectConcurrentChangePopup newConcurrentChange(final Path project, final User identity,
        final Command onIgnore, final Command onReOpen) {
    final String message = ProjectConcurrentChangePopupConstants.INSTANCE.ConcurrentChange(identity != null
            ? SafeHtmlUtils.htmlEscape(identity.getIdentifier() != null ? identity.getIdentifier() : "")
            : null, project.toURI());//from   w  ww  .  j  a va  2 s  .  c o m
    return new ProjectConcurrentChangePopup(message, onIgnore, onReOpen);
}

From source file:org.kino.client.CallbackWithFailureDialog.java

@Override
public void onFailure(Throwable caught) {

    CauseAlertBox box = new CauseAlertBox("",
            "<b>" + SafeHtmlUtils.htmlEscape(failureMsg) + "</b>",
            SafeHtmlUtils.htmlEscape(caught.getLocalizedMessage()));

    box.show();/*ww  w  . ja  va  2s . co  m*/

}

From source file:org.kino.client.monitoring.ComonProjectGrid.java

public ComonProjectGrid() {

    final ListStore<MonitoringW.CommonProjectInfo> store = new ListStore<MonitoringW.CommonProjectInfo>(
            new ModelKeyProvider<MonitoringW.CommonProjectInfo>() {

                @Override/* www .  j ava2s  . c o m*/
                public String getKey(MonitoringW.CommonProjectInfo item) {
                    return String.valueOf(item.id);
                }
            });

    /* ColumnConfig<MonitoringW.CommonProjectInfo,MonitoringW.CommonProjectInfo> col_poster = new ColumnConfig<MonitoringW.CommonProjectInfo,MonitoringW.CommonProjectInfo>(new ValueProvider<MonitoringW.CommonProjectInfo,MonitoringW.CommonProjectInfo>() {
        @Override
        public MonitoringW.CommonProjectInfo getValue(MonitoringW.CommonProjectInfo object) {
             return object; 
        }
            
        @Override
        public void setValue(MonitoringW.CommonProjectInfo object, MonitoringW.CommonProjectInfo value) {  }
            
        @Override
        public String getPath() {
            return "poster";
        }
    },100,"?");*/

    ColumnConfig<MonitoringW.CommonProjectInfo, MonitoringW.CommonProjectInfo> col_name = new ColumnConfig<MonitoringW.CommonProjectInfo, MonitoringW.CommonProjectInfo>(
            new IdentityValueProvider<CommonProjectInfo>("name"), 250, "?");
    final ColumnConfig<MonitoringW.CommonProjectInfo, String> col_status = new ColumnConfig<MonitoringW.CommonProjectInfo, String>(
            new ReadOnlyValueProvider<MonitoringW.CommonProjectInfo, String>("status") {

                @Override
                public String getValue(MonitoringW.CommonProjectInfo object) {
                    return object.status;
                }
            }, 100, "?");

    ColumnConfig<MonitoringW.CommonProjectInfo, Double> col_percent = new ColumnConfig<MonitoringW.CommonProjectInfo, Double>(
            new ReadOnlyValueProvider<MonitoringW.CommonProjectInfo, Double>("percent") {

                @Override
                public Double getValue(MonitoringW.CommonProjectInfo object) {
                    return object.percent;
                }

            }, 100, "");

    ColumnConfig<MonitoringW.CommonProjectInfo, Integer> col_client_count = new ColumnConfig<MonitoringW.CommonProjectInfo, Integer>(
            new ReadOnlyValueProvider<MonitoringW.CommonProjectInfo, Integer>("client_count") {

                @Override
                public Integer getValue(CommonProjectInfo object) {
                    return object.client_count; //To change body of generated methods, choose Tools | Templates.
                }
            }, 50, "- /");

    /* ColumnConfig<MonitoringW.CommonProjectInfo,Integer> col_time_left = new ColumnConfig<MonitoringW.CommonProjectInfo, Integer>(new ValueProvider<MonitoringW.CommonProjectInfo,Integer>() {
            
        @Override
        public Integer getValue(MonitoringW.CommonProjectInfo object) {
             return  (Integer)object.time_left ;
        }
            
        @Override
        public void setValue(MonitoringW.CommonProjectInfo object, Integer value) {
                    
        }
            
        @Override
        public String getPath() {
            return "time_left";
        }
    },50,"? ?");*/
    ColumnConfig<MonitoringW.CommonProjectInfo, Date> col_time_create = new ColumnConfig<MonitoringW.CommonProjectInfo, Date>(
            new ValueProvider<MonitoringW.CommonProjectInfo, Date>() {

                @Override
                public Date getValue(MonitoringW.CommonProjectInfo object) {
                    return new Date(object.time_create);
                }

                @Override
                public void setValue(MonitoringW.CommonProjectInfo object, Date value) {

                }

                @Override
                public String getPath() {
                    return "time_total";
                }
            }, 150, " ??");

    List<ColumnConfig<MonitoringW.CommonProjectInfo, ?>> list = new ArrayList<ColumnConfig<MonitoringW.CommonProjectInfo, ?>>();
    list.add(new RowNumberer<MonitoringW.CommonProjectInfo>(
            new IdentityValueProvider<MonitoringW.CommonProjectInfo>()));
    //  list.add(col_poster);
    list.add(col_name);
    list.add(col_client_count);
    list.add(col_percent);
    list.add(col_status);
    list.add(col_time_create);
    col_name.setCell(new AbstractCell<CommonProjectInfo>() {
        @Override
        public void render(Cell.Context context, CommonProjectInfo value, SafeHtmlBuilder sb) {
            sb.appendHtmlConstant("<b>").appendEscaped(value.rus).appendHtmlConstant("</b><br>")
                    .appendEscaped(value.name == null ? "" : value.name);
        }
    });
    col_name.setComparator(new Comparator<CommonProjectInfo>() {

        @Override
        public int compare(CommonProjectInfo o1, CommonProjectInfo o2) {

            int res = o1.rus.compareTo(o2.rus);
            return res;
        }
    });
    col_status.setCell(new AbstractCell<String>() {

        @Override
        public void render(Cell.Context context, String value, SafeHtmlBuilder sb) {
            String text;
            if (value.equals("init"))
                text = "?";
            else if (value.equals("check"))
                text = "";
            else if (value.equals("ready"))
                text = "";
            else if (value.equals("error"))
                text = "";
            else
                text = "? ? ?? '" + value + "'";

            sb.appendEscaped(text);
        }
    });

    col_time_create.setCell(new DateCell(DateTimeFormat.getFormat("dd/MM/yyyy HH:mm:ss")));

    // list.add(col_error);

    // list.add(col_time_left);
    // list.add(col_time_total);
    /*AbstractCell<MonitoringW.CommonProjectInfo> imgCell = new AbstractCell<MonitoringW.CommonProjectInfo>(){
            
        @Override
        public void render(Cell.Context context, MonitoringW.CommonProjectInfo value, SafeHtmlBuilder sb) {
            sb.appendHtmlConstant("<img src='image_servlet?project_id="+ value.id+"&w=30&h=30' /> ");
            //super.render(context, value, sb);  .
        }
            
                 
                
    }; 
    col_poster.setCell(imgCell);*/

    ProgressBarCell progress = new ProgressBarCell();
    progress.setWidth(100 - 10);
    progress.setProgressText("{0} %");
    col_percent.setCell(progress);
    //new DateCell(DateTimeFormat.getFormat("MM/dd/yyyy")
    /*  TextButtonCell button = new TextButtonCell();
    button.setIcon(Resources.INSTANCE.search_48());
            
    col_poster.setCell(imgCell);
    col_percent.setCell(progress);
            
    */

    ColumnModel<MonitoringW.CommonProjectInfo> cm = new ColumnModel<MonitoringW.CommonProjectInfo>(list);

    grid = new Grid<MonitoringW.CommonProjectInfo>(store, cm);
    /*grid.addCellClickHandler(new CellClickEvent.CellClickHandler() {
            
        @Override
        public void onCellClick(CellClickEvent event) {
            int cellIndex = event.getCellIndex();
            if(!grid.getColumnModel().getColumn(cellIndex).equals(col_status)){
                return;
            }
            CommonProjectInfo selectedItem = grid.getSelectionModel().getSelectedItem();
             final PromptMessageBox box = new PromptMessageBox("Name", "Please enter your name:");
             box.getTextField().setReadOnly(true);
             box.getTextField().setValue(selectedItem.status);
             box.show();
            //Window.alert(selectedItem.status);
        }
    });*/

    grid.addDomHandler(new DoubleClickHandler() {

        @Override
        public void onDoubleClick(DoubleClickEvent event) {
            CommonProjectInfo item = grid.getSelectionModel().getSelectedItem();
            if (item == null)
                return;
            UrlBuilder urlb = Window.Location.createUrlBuilder();
            urlb.setParameter("project", item.id + "");
            Window.open(urlb.buildString(), "_blank", "");
        }
    }, DoubleClickEvent.getType());
    cm.addColumnWidthChangeHandler(new CellColumnResizer(grid, col_percent, progress));

    /* CallbackWithFailureDialog<ArrayList<MonitoringW.CommonProjectInfo>> asyncCallback = new CallbackWithFailureDialog<ArrayList<MonitoringW.CommonProjectInfo>>("? ?    ") {
        @Override
        public void onSuccess(ArrayList<MonitoringW.CommonProjectInfo> result) {
             store.replaceAll(result);
        }
    };*/
    //  GWTServiceAsync.instance.getCommonProjectInfo(asyncCallback);

    // System.out.println("visible grid:"+grid.isVisible());
    // System.out.println("visible grid deep:"+grid.isVisible(true));

    final CallbackWithFailureDialog<ArrayList<CommonProjectInfo>> callback = new CallbackWithFailureDialog<ArrayList<CommonProjectInfo>>(
            "? ?  ") {
        @Override
        public void onSuccess(ArrayList<CommonProjectInfo> result) {

            for (MonitoringW.CommonProjectInfo item : result) {
                MonitoringW.CommonProjectInfo findModelWithKey = store
                        .findModelWithKey(String.valueOf(item.id));
                if (findModelWithKey == null)
                    continue;
                findModelWithKey.percent = item.percent;
                findModelWithKey.time_left = item.time_left;
                findModelWithKey.time_create = item.time_create;
                findModelWithKey.status = item.status;
                if (item.status.equals("error")) {
                    Info.display("",
                            "<font color='red'>  "
                                    + SafeHtmlUtils.htmlEscape(findModelWithKey.name)
                                    + "  </font>");
                    grid.getStore().remove(findModelWithKey);
                }

            }
            grid.getStore()
                    .fireEvent(new StoreUpdateEvent<MonitoringW.CommonProjectInfo>(grid.getStore().getAll()));

            // if(grid.isVisible())

            updateStatusTimer.schedule(MonitoringW.TIMER_REFRESH_TIMEOUT);

        }
    };

    updateStatusTimer = new Timer() {
        @Override
        public void run() {

            //      logger.log(Level.INFO, "update_projects");

            status_request = GWTServiceAsync.instance.getCommonProjectInfo(callback);

        }
    };

    ToolBar bar = new ToolBar();

    TextButton but_refresh = new TextButton("", Resources.INSTANCE.refresh());
    bar.add(but_refresh);
    but_refresh.addSelectHandler(new SelectEvent.SelectHandler() {

        @Override
        public void onSelect(SelectEvent event) {
            loadData();
        }
    });
    final TextButton but_add = new TextButton(" ",
            Resources.INSTANCE.plus_16());
    but_add.setEnabled(false);
    bar.add(but_add);
    but_add.addSelectHandler(new SelectEvent.SelectHandler() {

        @Override
        public void onSelect(SelectEvent event) {

            final CommonProjectInfo item = grid.getSelectionModel().getSelectedItem();
            if (item == null)
                return;

            AddTheaterToExistedProjectDialog dlg = new AddTheaterToExistedProjectDialog(item.id) {

                @Override
                public void onAdd(int count) {
                    if (count == 0)
                        return;

                    // UPDATE CLIENT COUNT AND COMMON PERCENT!
                    super.onAdd(count); //To change body of generated methods, choose Tools | Templates.
                    int count_old = item.client_count;
                    double percent_old = item.percent;

                    item.client_count += count;
                    item.percent = (percent_old * count_old) / (count + count_old);
                    grid.getStore().update(item);
                }

            };
            dlg.show();
        }
    });
    final TextButton but_show_detail = new TextButton("", Resources.INSTANCE.search_16());
    bar.add(but_show_detail);
    but_show_detail.setEnabled(false);
    grid.getSelectionModel()
            .addSelectionChangedHandler(new SelectionChangedEvent.SelectionChangedHandler<CommonProjectInfo>() {
                @Override
                public void onSelectionChanged(SelectionChangedEvent<CommonProjectInfo> event) {
                    but_show_detail.setEnabled(grid.getSelectionModel().getSelectedItem() != null);
                    but_add.setEnabled(grid.getSelectionModel().getSelectedItem() != null);
                }
            });

    but_show_detail.addSelectHandler(new SelectEvent.SelectHandler() {

        @Override
        public void onSelect(SelectEvent event) {
            CommonProjectInfo item = grid.getSelectionModel().getSelectedItem();
            if (item == null)
                return;
            UrlBuilder urlb = Window.Location.createUrlBuilder();
            urlb.setParameter("project", item.id + "");
            Window.open(urlb.buildString(), "_blank", "");
        }
    });
    vert.add(bar, new VerticalLayoutContainer.VerticalLayoutData(1, -1));
    vert.add(grid, new VerticalLayoutContainer.VerticalLayoutData(1, 1));
    grid.getView().setEmptyText("? ?");

}

From source file:org.kino.client.theater.CreateThreaderDialog.java

final FieldLabel createLabel(Widget widget, String text, boolean important) {
    if (!important)
        return new FieldLabel(widget, text);
    else {//from  ww  w  .  j ava2s . c  o m
        FieldLabel lab = new FieldLabel(widget);
        lab.setHTML("<font color=red>*</font> " + SafeHtmlUtils.htmlEscape(text));
        return lab;

    }
}

From source file:org.lirazs.gbackbone.client.core.model.Model.java

License:Apache License

/**
 * // Get the HTML-escaped value of an attribute.
 escape(attr: string): string {/*from  w  w  w  .j a va  2 s.co  m*/
 return _.escape(this.get(attr));
 }
 */
public String escape(String attr) {
    return has(attr) ? SafeHtmlUtils.htmlEscape(getString(attr)) : "";
}

From source file:org.lucidj.browser.AbstractCell.java

License:Apache License

private Component build_left_panel() {
    left_panel = new CssLayout();
    left_panel.setWidth(32, Sizeable.Unit.PIXELS);
    left_panel.addStyleName("cell-panel-left");
    left_panel.setHeight(100, Sizeable.Unit.PERCENTAGE);

    String icon_url = "/VAADIN/~/formulas/impossible.png";
    String icon_title = "The Unknown";

    ComponentInterface component_interface = Aggregate.adapt(ComponentInterface.class, source_object);
    if (component_interface != null) {
        // If it is a valid component, displays its icon on the top left corner of the cell
        ComponentDescriptor descriptor = (ComponentDescriptor) component_interface
                .getProperty(ComponentDescriptor.DESCRIPTOR);

        if (descriptor != null) {
            icon_url = descriptor.getIconUrl();
            icon_title = descriptor.getIconTitle();
        }/*from   w  w  w  .j  a  va2  s  .  c o  m*/
    }

    String component_icon_html = "<img class='component-icon' src='" + icon_url + "' title='"
            + SafeHtmlUtils.htmlEscape(icon_title) + "'/>";
    component_icon = new Label(component_icon_html, ContentMode.HTML);
    left_panel.addComponent(component_icon);

    // Put the component in a D&D wrapper and allow dragging it
    final DragAndDropWrapper panel_dd_wrap = new DragAndDropWrapper(left_panel);
    panel_dd_wrap.setDragStartMode(DragAndDropWrapper.DragStartMode.COMPONENT_OTHER);
    panel_dd_wrap.setDragImageComponent(component_icon);
    panel_dd_wrap.addStyleName("no-horizontal-drag-hints");
    panel_dd_wrap.addStyleName("no-box-drag-hints");

    // Set the wrapper to wrap tightly around the component
    panel_dd_wrap.setHeight(100, Sizeable.Unit.PERCENTAGE);
    panel_dd_wrap.setWidthUndefined();
    panel_dd_wrap.setId("test");

    // Setup DD handlers for component insertion
    panel_dd_wrap.setData(this);
    panel_dd_wrap.setDropHandler(this);

    // While left_panel is kept in order to be customized, here we return D&D wrapper
    return (panel_dd_wrap);
}

From source file:org.lucidj.console.ConsoleRenderer.java

License:Apache License

public String format_as_html(String contents) {
    BufferedReader full_content = new BufferedReader(new StringReader(contents));
    ByteArrayOutputStream parsed_content = new ByteArrayOutputStream();
    // TODO: REQUEST FEATURE CHANGE ON jansi FOR OPTIONAL HTML FILTERING
    AnsiHtmlOutputStream html_content = new AnsiHtmlOutputStream(parsed_content);
    PrintStream content_out = new PrintStream(html_content);
    String line;//from   ww  w  .  j ava 2 s.c  o m

    try {
        while ((line = full_content.readLine()) != null) {
            int tag_pos = line.indexOf('|');
            int text_pos = line.indexOf('|', tag_pos + 1);

            if (tag_pos == -1 || text_pos == -1) {
                // Alien format is grey :)
                content_out.append("<font color='grey'>");
                content_out.append(SafeHtmlUtils.htmlEscape(line));
                content_out.append("<br/></font>");
            } else {
                // Native format, strip timestamp and color stderr accordingly
                String tag = line.substring(tag_pos + 1, text_pos).trim();
                int skip_format_space = line.charAt(text_pos + 1) == ' ' ? 1 : 0;
                String text = line.substring(text_pos + 1 + skip_format_space);
                String safe_text = SafeHtmlUtils.htmlEscape(text).replace("\\n", "<br/>");

                if (tag.equals(Stdio.STDERR)) {
                    content_out.append("<font color='red'>");
                }

                if (tag.equals(Stdio.HTML)) {
                    content_out.append(text);
                } else {
                    content_out.append(safe_text);
                }

                if (tag.equals(Stdio.STDERR)) {
                    content_out.append("</font>");
                }
            }
        }
    } catch (Exception ignore) {
    }
    ;

    return (parsed_content.toString());
}