Example usage for com.google.gwt.safehtml.shared SafeHtmlBuilder toSafeHtml

List of usage examples for com.google.gwt.safehtml.shared SafeHtmlBuilder toSafeHtml

Introduction

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

Prototype

public SafeHtml toSafeHtml() 

Source Link

Document

Returns the safe HTML accumulated in the builder as a SafeHtml .

Usage

From source file:edu.arizona.biosemantics.gxt.theme.green.client.sliced.mask.SlicedMaskAppearance.java

License:sencha.com license

@Override
public void mask(XElement parent, String message) {
    XElement mask = XElement.createElement("div");
    mask.setClassName(resources.style().mask());
    parent.appendChild(mask);/*  ww w. j a va2  s.  com*/

    XElement box = null;
    if (message != null) {
        SafeHtmlBuilder sb = new SafeHtmlBuilder();
        SafeHtml content = template.template(resources.style(), SafeHtmlUtils.htmlEscape(message));
        frame.render(sb, Frame.EMPTY_FRAME, content);
        box = XDOM.create(sb.toSafeHtml()).cast();
        parent.appendChild(box);
    }

    if (GXT.isIE() && !(GXT.isIE7()) && "auto".equals(parent.getStyle().getHeight())) {
        mask.setSize(parent.getOffsetWidth(), parent.getOffsetHeight());
    }

    if (box != null) {
        box.updateZIndex(0);
        box.center(parent);
    }
}

From source file:fr.mncc.sandbox.client.layouts.photogallery.PhotoGalleryLayout.java

License:Open Source License

private void fillLayout() {
    SafeHtmlBuilder safeHtmlBuilder = new SafeHtmlBuilder();
    for (int i = 0; i < images_.size(); i++) {
        safeHtmlBuilder.append(createImageWrapper(images_.get(i)));
    }/*from www .j a  v  a 2  s .  c  o  m*/
    wrapper.setInnerSafeHtml(safeHtmlBuilder.toSafeHtml());
}

From source file:fr.onevu.gwt.uibinder.test.client.UiRendererUi.java

License:Apache License

public SafeHtml render(String value, String valueTwice) {
    SafeHtmlBuilder sb = new SafeHtmlBuilder();
    getRenderer().render(sb, new Foo(value), new Foo(valueTwice));
    return sb.toSafeHtml();
}

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 av a 2 s . co  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  w  w.ja  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();/* w  w w  .  ja  v a 2  s  . c o 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 av a2  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.data.BaseRenderer.java

License:Apache License

@Override
@SuppressWarnings("unchecked")
public TableData drawColumn(TableRow row, Context context, T rowValue, Column<T, ?> column, int beforeIndex,
        boolean visible) {
    TableData data = null;/*from  ww w  .  j ava  2s .  c  om*/
    if (row != null && rowValue != null) {
        data = row.getColumn(beforeIndex);
        if (data == null) {
            data = new TableData();
            row.insert(data, beforeIndex);
        } else {
            data.clear();
        }

        Div wrapper = new Div();

        // Render the column cell
        if (column instanceof WidgetColumn) {
            wrapper.setStyleName(TableCssName.WIDGET_CELL);
            wrapper.add(((WidgetColumn) column).render(context, rowValue));
        } else {
            SafeHtmlBuilder sb = new SafeHtmlBuilder();
            column.render(context, rowValue, sb);
            wrapper.getElement().setInnerHTML(sb.toSafeHtml().asString());
            wrapper.setStyleName(TableCssName.CELL);
        }

        data.add(wrapper);

        data.setId("col" + beforeIndex);
        data.setDataTitle(column.getName());
        HideOn hideOn = column.getHideOn();
        if (hideOn != null) {
            data.setHideOn(hideOn);
        }
        TextAlign textAlign = column.getTextAlign();
        if (textAlign != null) {
            data.setTextAlign(textAlign);
        }
        if (column.isNumeric()) {
            data.addStyleName(TableCssName.NUMERIC);
        }

        // Apply the style properties
        Style style = data.getElement().getStyle();
        Map<StyleName, String> styleProps = column.getStyleProperties();
        if (styleProps != null) {
            styleProps.forEach((s, v) -> style.setProperty(s.styleName(), v));
        }

        // Hide if defined as not visible
        // This can be the case when a header is toggled off.
        if (!visible) {
            data.$this().hide();
        }
    }
    return data;
}

From source file:gwtquery.plugins.droppable.client.celltablesample.CellTableSample.java

License:Apache License

/**
 * This method create the CellTable for the contacts
 *//*  w w w  .  ja  v a 2s. c  om*/
private void createDragAndDropCellTable() {

    // Create a DragAndDropCellTable.
    cellTable = new DragAndDropCellTable<ContactInfo>(ContactDatabase.ContactInfo.KEY_PROVIDER);
    // Create a Pager to control the table.
    SimplePager.Resources pagerResources = GWT.create(SimplePager.Resources.class);
    pager = new SimplePager(TextLocation.CENTER, pagerResources, false, 0, true);
    pager.setDisplay(cellTable);

    // Add a selection model so we can select cells.
    final MultiSelectionModel<ContactInfo> selectionModel = new MultiSelectionModel<ContactInfo>(
            ContactDatabase.ContactInfo.KEY_PROVIDER);
    cellTable.setSelectionModel(selectionModel);

    // Attach a column sort handler to the ListDataProvider to sort the list.
    ListHandler<ContactInfo> sortHandler = new ListHandler<ContactInfo>(
            ContactDatabase.get().getDataProvider().getList());
    cellTable.addColumnSortHandler(sortHandler);

    // Initialize the columns.
    initTableColumns(selectionModel, sortHandler);

    // Add the CellList to the adapter in the database.
    ContactDatabase.get().addDataDisplay(cellTable);

    // fill the helper when the drag operation start
    cellTable.addDragStartHandler(new DragStartEventHandler() {

        public void onDragStart(DragStartEvent event) {
            ContactInfo contact = event.getDraggableData();
            Element helper = event.getHelper();
            SafeHtmlBuilder sb = new SafeHtmlBuilder();
            // reuse the contact cell to render the inner html of the drag helper.
            new ContactCell(Resource.INSTANCE.contact()).render(null, contact, sb);
            helper.setInnerHTML(sb.toSafeHtml().asString());

        }
    });

}

From source file:gwtquery.plugins.droppable.client.datagridsample.DataGridSample.java

License:Apache License

/**
 * This method create the DataGrid for the contacts
 *///w w w  .j  a  va2  s .com
private void createDragAndDropDataGrid() {

    // Create a DragAndDropDataGrid.
    dataGrid = new DragAndDropDataGrid<ContactInfo>(20, ContactDatabase.ContactInfo.KEY_PROVIDER);
    // Create a Pager to control the table.
    SimplePager.Resources pagerResources = GWT.create(SimplePager.Resources.class);
    pager = new SimplePager(TextLocation.CENTER, pagerResources, false, 0, true);
    pager.setDisplay(dataGrid);

    // Add a selection model so we can select cells.
    final MultiSelectionModel<ContactInfo> selectionModel = new MultiSelectionModel<ContactInfo>(
            ContactDatabase.ContactInfo.KEY_PROVIDER);
    dataGrid.setSelectionModel(selectionModel);

    // Attach a column sort handler to the ListDataProvider to sort the list.
    ListHandler<ContactInfo> sortHandler = new ListHandler<ContactInfo>(
            ContactDatabase.get().getDataProvider().getList());
    dataGrid.addColumnSortHandler(sortHandler);

    // Initialize the columns.
    initTableColumns(selectionModel, sortHandler);

    // Add the CellList to the adapter in the database.
    ContactDatabase.get().addDataDisplay(dataGrid);

    // fill the helper when the drag operation start
    dataGrid.addDragStartHandler(new DragStartEventHandler() {

        public void onDragStart(DragStartEvent event) {
            ContactInfo contact = event.getDraggableData();
            Element helper = event.getHelper();
            SafeHtmlBuilder sb = new SafeHtmlBuilder();
            // reuse the contact cell to render the inner html of the drag helper.
            new ContactCell(Resource.INSTANCE.contact()).render(null, contact, sb);
            helper.setInnerHTML(sb.toSafeHtml().asString());

        }
    });

}