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:org.eclipse.che.plugin.languageserver.ide.editor.codeassist.CompletionItemBasedCompletionProposal.java

License:Open Source License

@Override
public String getDisplayString() {
    SafeHtmlBuilder builder = new SafeHtmlBuilder();

    String label = completionItem.getLabel();
    int pos = 0;/* ww  w.j a  v  a2s . c  om*/
    for (Match highlight : highlights) {
        if (highlight.getStart() == highlight.getEnd()) {
            continue;
        }

        if (pos < highlight.getStart()) {
            appendPlain(builder, label.substring(pos, highlight.getStart()));
        }

        appendHighlighted(builder, label.substring(highlight.getStart(), highlight.getEnd()));
        pos = highlight.getEnd();
    }

    if (pos < label.length()) {
        appendPlain(builder, label.substring(pos));
    }

    if (completionItem.getDetail() != null) {
        appendDetail(builder, completionItem.getDetail());
    }

    return builder.toSafeHtml().asString();
}

From source file:org.fourthline.konto.client.KontoEntryPoint.java

License:Open Source License

protected void enableDemo() {
    final PopupPanel panel = new PopupPanel(true, true);
    panel.setGlassEnabled(true);//w w  w . j a va2 s  . co  m

    VerticalPanel msgPanel = new VerticalPanel();
    SafeHtmlBuilder msg = new SafeHtmlBuilder();
    msg.appendHtmlConstant("<p>").appendEscaped("This is a demo instance of Konto.").appendHtmlConstant("</p>");
    msg.appendHtmlConstant("<p>").appendEscaped("You can make any changes you like.")
            .appendHtmlConstant("</p>");
    msg.appendHtmlConstant("<p>").appendEscaped("This instance will reset itself every hour.")
            .appendHtmlConstant("</p>");

    msgPanel.add(new HTMLPanel(msg.toSafeHtml()));

    panel.add(msgPanel);
    panel.setWidth("250px");
    panel.setHeight("120px");
    panel.setPopupPosition(Window.getClientWidth() / 2 - 250, Window.getClientHeight() / 2 - 120);
    panel.show();
}

From source file:org.glom.web.client.ui.details.DetailsCell.java

License:Open Source License

public void setData(final DataItem dataItem) {
    detailsData.clear();/* ww  w .j av  a  2  s.co  m*/

    if (dataItem == null) {
        return;
    }

    Formatting formatting = layoutItem.getFormatting();

    // FIXME use the cell renderers from the list view to render the information here
    switch (this.dataType) {
    case TYPE_BOOLEAN:
        final CheckBox checkBox = new CheckBox();
        checkBox.setValue(dataItem.getBoolean());
        checkBox.addClickHandler(new ClickHandler() {

            @Override
            public void onClick(final ClickEvent event) {
                // don't let users change the checkbox
                checkBox.setValue(dataItem.getBoolean());
            }
        });
        detailsData.add(checkBox);
        break;
    case TYPE_NUMERIC:
        if (formatting == null) {
            GWT.log("setData(): formatting is null");
            formatting = new Formatting(); // To avoid checks later.
        }
        final NumericFormat numericFormat = formatting.getNumericFormat();
        final NumberFormat gwtNumberFormat = Utils.getNumberFormat(numericFormat);

        // set the foreground color to red if the number is negative and this is requested
        if (numericFormat.getUseAltForegroundColorForNegatives() && dataItem.getNumber() < 0) {
            // The default alternative color in libglom is red.
            detailsData.getElement().getStyle()
                    .setColor(NumericFormat.getAlternativeColorForNegativesAsHTMLColor());
        }

        final String currencyCode = StringUtils.isEmpty(numericFormat.getCurrencySymbol()) ? ""
                : numericFormat.getCurrencySymbol().trim() + " ";
        detailsLabel.setText(currencyCode + gwtNumberFormat.format(dataItem.getNumber()));
        detailsData.add(detailsLabel);
        break;
    case TYPE_DATE:
    case TYPE_TIME:
    case TYPE_TEXT:
        final String text = StringUtils.defaultString(dataItem.getText());

        // Deal with multiline text differently than single line text.
        if ((formatting != null) && (formatting.getTextFormatMultilineHeightLines() > 1)) {
            detailsData.getElement().getStyle().setOverflow(Overflow.AUTO);
            // Convert '\n' to <br/> escaping the data so that it won't be rendered as HTML.
            try {
                // JavaScript requires the charsetName to be "UTF-8". CharsetName values that work in Java (such as
                // "UTF8") will not work when compiled to JavaScript.
                final String utf8NewLine = new String(new byte[] { 0x0A }, "UTF-8");
                final String[] lines = text.split(utf8NewLine);
                final SafeHtmlBuilder sb = new SafeHtmlBuilder();
                for (final String line : lines) {
                    sb.append(SafeHtmlUtils.fromString(line));
                    sb.append(SafeHtmlUtils.fromSafeConstant("<br/>"));
                }

                // Manually add the HTML to the detailsData container.
                final DivElement div = Document.get().createDivElement();
                div.setInnerHTML(sb.toSafeHtml().asString());
                detailsData.getElement().appendChild(div);

                // Expand the width of detailsData if a vertical scrollbar has been placed on the inside of the
                // detailsData container.
                final int scrollBarWidth = detailsData.getOffsetWidth() - div.getOffsetWidth();
                if (scrollBarWidth > 0) {
                    // A vertical scrollbar is on the inside.
                    detailsData.setWidth((detailsData.getOffsetWidth() + scrollBarWidth + 4) + "px");
                }

                // TODO Add horizontal scroll bars when detailsData expands beyond its container.

            } catch (final UnsupportedEncodingException e) {
                // If the new String() line throws an exception, don't try to add the <br/> tags. This is unlikely
                // to happen but we should do something if it does.
                detailsLabel.setText(text);
                detailsData.add(detailsLabel);
            }

        } else {
            final SingleLineText textPanel = new SingleLineText(text);
            detailsData.add(textPanel);
        }
        break;
    case TYPE_IMAGE:
        final Image image = new Image();
        final String imageDataUrl = dataItem.getImageDataUrl();
        if (imageDataUrl != null) {
            image.setUrl(imageDataUrl);

            // Set an arbitrary default size:
            // image.setPixelSize(200, 200);
        }

        detailsData.add(image);
        break;
    default:
        break;
    }

    this.dataItem = dataItem;

    // enable the navigation button if it's safe
    if (openButton != null && openButtonHandlerReg != null && this.dataItem != null) {
        openButton.setEnabled(true);
    }

}

From source file:org.glom.web.client.ui.details.RelatedListTable.java

License:Open Source License

private static int initializeExepectedHeight() {
    // TODO Use a real RelatedListTable instead of building one manually. It's probably better to do this when
    // RelatedListTables are created in Portal instead of DetailsActivity.

    // This table simulates a related list with one row containing a Text cell and a Button cell.
    final SafeHtmlBuilder tableBuilder = new SafeHtmlBuilder();
    tableBuilder.append(SafeHtmlUtils.fromSafeConstant(
            "<table class=\"data-list\"><thead><tr><th>TH</th><th>BH</th></tr></thead><tbody>"));
    for (int i = 0; i < MAX_TABLE_ROWS; i++) {
        tableBuilder.append(SafeHtmlUtils
                .fromSafeConstant("<tr><td>T</td><td><button type=\"button\">B</button></td></tr>"));
    }//from w  w  w. j a v a 2  s . co m
    tableBuilder.append(SafeHtmlUtils.fromSafeConstant("</tbody></head>"));
    final HTML table = new HTML(tableBuilder.toSafeHtml());

    // The pager
    final SimplePager pager = new SimplePager();
    pager.addStyleName("pager");

    // Pack the table and pager as they are found in the details view.
    final FlowPanel group = new FlowPanel();
    group.setStyleName("group");
    final FlowPanel subgroup = new FlowPanel();
    subgroup.setStyleName("portal");
    subgroup.add(table);
    subgroup.add(pager);
    group.add(subgroup);

    // Calculate the height similar to Utils.getWidgetHeight().
    final Document doc = Document.get();
    com.google.gwt.dom.client.Element div = doc.createDivElement();
    div.getStyle().setVisibility(Visibility.HIDDEN);
    div.appendChild(group.getElement().<com.google.gwt.dom.client.Element>cast());
    doc.getBody().appendChild(div);
    final int relatedListTableHeight = group.getElement().getFirstChildElement().getOffsetHeight();

    // remove the div from the from the document
    doc.getBody().removeChild(div);
    div = null;

    return relatedListTableHeight;
}

From source file:org.glom.web.client.ui.list.ListTable.java

License:Open Source License

@Override
protected void onLoad() {

    /*//  w  ww .j a  v a  2  s  .co  m
     * Set the width of the navigation button column to be as small as possible.
     */
    // The navigationButtonColumn width will be null if it hasn't been set. This indicates that the column width
    // hasn't been disabled with the hideNavigationButtons() method or been set with this method. The width of the
    // navigation button column shouldn't be changed once it's set.
    if (navigationButtonColumn != null && cellTable.getColumnWidth(navigationButtonColumn) == null) {

        // Use the NavigationButtonCell to get the button HTML and find the width. I'm doing this because the
        // CellTable widget is highly dynamic and there's no way to guarantee that we can access the navigation
        // button HTML by using the actual CellTable.
        final String buttonLabel = navigationButtonColumn.getValue(new DataItem[2]); // a hack to get the button
        // label
        final SafeHtmlBuilder buttonBuilder = new SafeHtmlBuilder();
        navigationButtonColumn.getCell().render(null, buttonLabel, buttonBuilder);
        Element navigationButton = new HTML(buttonBuilder.toSafeHtml()).getElement().getFirstChildElement();

        // Calculate the width similar to Utils.getWidgetHeight().
        final Document doc = Document.get();
        navigationButton.getStyle().setVisibility(Visibility.HIDDEN);
        doc.getBody().appendChild(navigationButton);
        final int buttonWidth = navigationButton.getOffsetWidth();

        // remove the div from the from the document
        doc.getBody().removeChild(navigationButton);
        navigationButton = null;

        // set the width
        if (buttonWidth > 0) {
            cellTable.setColumnWidth(navigationButtonColumn, buttonWidth + 6, Unit.PX);
            navigationButtonColumn.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
        }
    }
}

From source file:org.greatlogic.gxtexamples.client.glgwt.GLGridWidget.java

License:Apache License

private void resizeColumnToFit(final int columnIndex) {
    final ColumnConfig<GLRecord, ?> columnConfig = _grid.getColumnModel().getColumn(columnIndex);
    final TextMetrics textMetrics = TextMetrics.get();
    textMetrics.bind(_grid.getView().getHeader().getAppearance().styles().head());
    int maxWidth = textMetrics.getWidth(columnConfig.getHeader().asString()) + 15; // extra is for the dropdown arrow
    if (_listStore.size() > 0) {
        textMetrics.bind(_grid.getView().getCell(0, 1));
        for (final GLRecord record : _listStore.getAll()) {
            final Object value = columnConfig.getValueProvider().getValue(record);
            if (value != null) {
                String valueAsString;
                if (columnConfig.getCell() instanceof DateCell) {
                    final DateCell dateCell = (DateCell) columnConfig.getCell();
                    final SafeHtmlBuilder sb = new SafeHtmlBuilder();
                    dateCell.render(null, (Date) value, sb);
                    valueAsString = sb.toSafeHtml().asString();
                } else {
                    valueAsString = value.toString();
                }// w ww . ja  v a 2s  .  c  o m
                final int width = textMetrics.getWidth(valueAsString) + 12;
                maxWidth = width > maxWidth ? width : maxWidth;
            }
        }
        for (final Store<GLRecord>.Record record : _listStore.getModifiedRecords()) {
            final int width = textMetrics.getWidth(record.getValue(columnConfig.getValueProvider()) //
                    .toString()) + 12;
            maxWidth = width > maxWidth ? width : maxWidth;
        }
    }
    columnConfig.setWidth(maxWidth);
    if (_checkBoxSet.contains(columnConfig)) {
        centerCheckBox(columnConfig);
    }
}

From source file:org.gss_project.gss.web.client.FileList.java

License:Open Source License

/**
 * Construct the file list widget. This entails setting up the widget
 * layout, fetching the number of files in the current folder from the
 * server and filling the local file cache of displayed files with data from
 * the server, as well./*  w w w .  j  a  v  a 2s  .  com*/
 *
 * @param _images
 */
public FileList(Images _images) {
    images = _images;
    DragAndDropCellTable.Resources resources = GWT.create(TableResources.class);
    ProvidesKey<FileResource> keyProvider = new ProvidesKey<FileResource>() {

        @Override
        public Object getKey(FileResource item) {
            return item.getUri();
        }

    };
    celltable = new DragAndDropCellTable<FileResource>(GSS.VISIBLE_FILE_COUNT, resources, keyProvider);

    DragAndDropColumn<FileResource, ImageResource> status = new DragAndDropColumn<FileResource, ImageResource>(
            new ImageResourceCell() {
                @Override
                public boolean handlesSelection() {
                    return false;
                }
            }) {
        @Override
        public ImageResource getValue(FileResource entity) {
            return getFileIcon(entity);
        }

    };
    celltable.addColumn(status, "");

    initDragOperation(status);
    final DragAndDropColumn<FileResource, SafeHtml> nameColumn = new DragAndDropColumn<FileResource, SafeHtml>(
            new SafeHtmlCell()) {

        @Override
        public SafeHtml getValue(FileResource object) {
            SafeHtmlBuilder sb = new SafeHtmlBuilder();
            sb.append(Templates.INSTANCE.filenameSpan(object.getName()));
            if (object.getContentType().endsWith("png") || object.getContentType().endsWith("gif")
                    || object.getContentType().endsWith("jpeg")) {
                sb.appendHtmlConstant("&nbsp;")
                        .append(Templates.INSTANCE.viewLink(
                                GSS.get().getTopPanel().getFileMenu().getDownloadURL(object),
                                object.getOwner() + " : " + object.getPath() + object.getName()));
            }

            return sb.toSafeHtml();
        }

    };
    initDragOperation(nameColumn);
    celltable.addColumn(nameColumn, nameHeader = new SortableHeader("Name"));
    allHeaders.add(nameHeader);
    //nameHeader.setSorted(true);
    //nameHeader.toggleReverseSort();
    nameHeader.setUpdater(new FileValueUpdater(nameHeader, "name"));
    celltable.redrawHeaders();

    SortableHeader aheader;
    DragAndDropColumn<FileResource, String> aColumn;
    celltable.addColumn(aColumn = new DragAndDropColumn<FileResource, String>(new TextCell()) {
        @Override
        public String getValue(FileResource object) {
            return GSS.get().findUserFullName(object.getOwner());
        }
    }, aheader = new SortableHeader("Owner"));
    initDragOperation(aColumn);
    allHeaders.add(aheader);
    aheader.setUpdater(new FileValueUpdater(aheader, "owner"));
    celltable.addColumn(aColumn = new DragAndDropColumn<FileResource, String>(new TextCell()) {
        @Override
        public String getValue(FileResource object) {
            // TODO Auto-generated method stub
            return object.getPath();
        }
    }, aheader = new SortableHeader("Path"));
    initDragOperation(aColumn);
    allHeaders.add(aheader);

    aheader.setUpdater(new FileValueUpdater(aheader, "path"));
    celltable.addColumn(aColumn = new DragAndDropColumn<FileResource, String>(new TextCell()) {
        @Override
        public String getValue(FileResource object) {
            if (object.isVersioned())
                return object.getVersion().toString();
            return "-";
        }
    }, aheader = new SortableHeader("Version"));
    initDragOperation(aColumn);
    allHeaders.add(aheader);
    aheader.setUpdater(new FileValueUpdater(aheader, "version"));
    celltable.addColumn(aColumn = new DragAndDropColumn<FileResource, String>(new TextCell()) {
        @Override
        public String getValue(FileResource object) {
            // TODO Auto-generated method stub
            return object.getFileSizeAsString();
        }
    }, aheader = new SortableHeader("Size"));
    initDragOperation(aColumn);
    allHeaders.add(aheader);
    aheader.setUpdater(new FileValueUpdater(aheader, "size"));
    celltable.addColumn(aColumn = new DragAndDropColumn<FileResource, String>(new TextCell()) {
        @Override
        public String getValue(FileResource object) {
            return formatter.format(object.getModificationDate());
        }
    }, aheader = new SortableHeader("Last Modified"));
    allHeaders.add(aheader);
    aheader.setUpdater(new FileValueUpdater(aheader, "date"));

    provider.addDataDisplay(celltable);
    celltable.addDragStopHandler(dragStop);
    celltable.addDragStartHandler(new DragStartEventHandler() {

        public void onDragStart(DragStartEvent event) {
            FileResource value = event.getDraggableData();

            com.google.gwt.dom.client.Element helper = event.getHelper();
            SafeHtmlBuilder sb = new SafeHtmlBuilder();
            sb.appendHtmlConstant("<b>");
            DisplayHelper.log(value.getName());
            if (getSelectedFiles().size() == 1)
                sb.appendEscaped(value.getName());
            else
                sb.appendEscaped(getSelectedFiles().size() + " files");
            sb.appendHtmlConstant("</b>");
            helper.setInnerHTML(sb.toSafeHtml().asString());

        }
    });

    VerticalPanel vp = new VerticalPanel();
    vp.setWidth("100%");
    pagerTop = new GssSimplePager(GssSimplePager.TextLocation.CENTER);
    pagerTop.setDisplay(celltable);
    uploadButtonTop = new Button("<span id='topMenu.file.upload'>"
            + AbstractImagePrototype.create(images.fileUpdate()).getHTML() + "&nbsp;Upload</span>");
    uploadButtonTop.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            new UploadFileCommand(null).execute();
        }
    });
    HorizontalPanel topPanel = new HorizontalPanel();
    topPanel.add(pagerTop);
    topPanel.add(uploadButtonTop);
    vp.add(topPanel);
    celltable.setWidth("100%");
    vp.add(celltable);
    pagerBottom = new GssSimplePager(GssSimplePager.TextLocation.CENTER);
    pagerBottom.setDisplay(celltable);
    HorizontalPanel bottomPanel = new HorizontalPanel();
    bottomPanel.add(pagerBottom);
    uploadButtonBottom = new Button("<span id='topMenu.file.upload'>"
            + AbstractImagePrototype.create(images.fileUpdate()).getHTML() + "&nbsp;Upload</span>");
    uploadButtonBottom.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            new UploadFileCommand(null).execute();
        }
    });
    bottomPanel.add(uploadButtonBottom);
    vp.add(bottomPanel);
    vp.setCellWidth(celltable, "100%");

    initWidget(vp);
    pagerBottom.setVisible(false);
    pagerTop.setVisible(false);

    celltable.setStyleName("gss-List");
    selectionModel = new MultiSelectionModel<FileResource>(keyProvider);

    Handler selectionHandler = new SelectionChangeEvent.Handler() {
        @Override
        public void onSelectionChange(com.google.gwt.view.client.SelectionChangeEvent event) {
            if (getSelectedFiles().size() == 1)
                GSS.get().setCurrentSelection(getSelectedFiles().get(0));
            else
                GSS.get().setCurrentSelection(getSelectedFiles());
        }
    };
    selectionModel.addSelectionChangeHandler(selectionHandler);

    celltable.setSelectionModel(selectionModel, GSSSelectionEventManager.<FileResource>createDefaultManager());
    celltable.setPageSize(GSS.VISIBLE_FILE_COUNT);

    //celltable.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.ENABLED);
    Scheduler.get().scheduleIncremental(new RepeatingCommand() {

        @Override
        public boolean execute() {
            return fetchRootFolder();
        }
    });
    sinkEvents(Event.ONCONTEXTMENU);
    sinkEvents(Event.ONMOUSEUP);
    sinkEvents(Event.ONMOUSEDOWN);
    sinkEvents(Event.ONCLICK);
    sinkEvents(Event.ONKEYDOWN);
    sinkEvents(Event.ONDBLCLICK);
    GSS.preventIESelection();
}

From source file:org.gss_project.gss.web.client.SearchResults.java

License:Open Source License

/**
 * Construct the file list widget. This entails setting up the widget
 * layout, fetching the number of files in the current folder from the
 * server and filling the local file cache of displayed files with data from
 * the server, as well./*from w  w w .ja  v  a  2 s . c  o m*/
 *
 * @param _images
 */
public SearchResults(Images _images) {
    images = _images;
    DragAndDropCellTable.Resources resources = GWT.create(TableResources.class);
    ProvidesKey<FileResource> keyProvider = new ProvidesKey<FileResource>() {

        @Override
        public Object getKey(FileResource item) {
            return item.getUri();
        }

    };

    celltable = new DragAndDropCellTable<FileResource>(GSS.VISIBLE_FILE_COUNT, resources, keyProvider) {
        @Override
        protected void onBrowserEvent2(Event event) {
            /*if (DOM.eventGetType((Event) event) == Event.ONMOUSEDOWN && DOM.eventGetButton((Event) event) == NativeEvent.BUTTON_RIGHT){
               fireClickEvent((Element) event.getEventTarget().cast());               
            }*/
            super.onBrowserEvent2(event);
        }
    };
    provider.addDataDisplay(celltable);
    celltable.addDragStopHandler(dragStop);
    celltable.addDragStartHandler(new DragStartEventHandler() {

        public void onDragStart(DragStartEvent event) {
            FileResource value = event.getDraggableData();

            com.google.gwt.dom.client.Element helper = event.getHelper();
            SafeHtmlBuilder sb = new SafeHtmlBuilder();
            sb.appendHtmlConstant("<b>");
            DisplayHelper.log(value.getName());
            if (getSelectedFiles().size() == 1)
                sb.appendEscaped(value.getName());
            else
                sb.appendEscaped(getSelectedFiles().size() + " files");
            sb.appendHtmlConstant("</b>");
            helper.setInnerHTML(sb.toSafeHtml().asString());

        }
    });
    DragAndDropColumn<FileResource, ImageResource> status = new DragAndDropColumn<FileResource, ImageResource>(
            new ImageResourceCell() {
                @Override
                public boolean handlesSelection() {
                    return false;
                }
            }) {
        @Override
        public ImageResource getValue(FileResource entity) {
            return getFileIcon(entity);
        }

    };
    celltable.addColumn(status, "");

    initDragOperation(status);
    final DragAndDropColumn<FileResource, SafeHtml> nameColumn = new DragAndDropColumn<FileResource, SafeHtml>(
            new SafeHtmlCell()) {

        @Override
        public SafeHtml getValue(FileResource object) {
            SafeHtmlBuilder sb = new SafeHtmlBuilder();
            sb.append(FileList.Templates.INSTANCE.filenameSpan(object.getName()));
            if (object.getContentType().endsWith("png") || object.getContentType().endsWith("gif")
                    || object.getContentType().endsWith("jpeg")) {
                sb.appendHtmlConstant("&nbsp;")
                        .append(FileList.Templates.INSTANCE.viewLink(
                                GSS.get().getTopPanel().getFileMenu().getDownloadURL(object),
                                object.getOwner() + " : " + object.getPath() + object.getName()));
            }

            return sb.toSafeHtml();
        }

    };
    initDragOperation(nameColumn);
    celltable.addColumn(nameColumn, "Name");

    DragAndDropColumn<FileResource, String> aColumn;
    celltable.addColumn(aColumn = new DragAndDropColumn<FileResource, String>(new TextCell()) {
        @Override
        public String getValue(FileResource object) {
            return GSS.get().findUserFullName(object.getOwner());
        }
    }, "Owner");
    initDragOperation(aColumn);

    celltable.addColumn(aColumn = new DragAndDropColumn<FileResource, String>(new TextCell()) {
        @Override
        public String getValue(FileResource object) {
            if (object.isDeleted())
                return object.getPath() + " (In Trash)";
            return object.getPath();
        }
    }, "Path");
    initDragOperation(aColumn);

    celltable.addColumn(aColumn = new DragAndDropColumn<FileResource, String>(new TextCell()) {
        @Override
        public String getValue(FileResource object) {
            if (object.isVersioned())
                return object.getVersion().toString();
            return "-";
        }
    }, "Version");
    initDragOperation(aColumn);

    celltable.addColumn(aColumn = new DragAndDropColumn<FileResource, String>(new TextCell()) {
        @Override
        public String getValue(FileResource object) {
            // TODO Auto-generated method stub
            return object.getFileSizeAsString();
        }
    }, "Size");
    initDragOperation(aColumn);

    celltable.addColumn(aColumn = new DragAndDropColumn<FileResource, String>(new TextCell()) {
        @Override
        public String getValue(FileResource object) {
            return formatter.format(object.getModificationDate());
        }
    }, "Last Modified");

    VerticalPanel vp = new VerticalPanel();
    vp.setWidth("100%");
    celltable.setWidth("100%");
    vp.add(searchResults);
    searchResults.addStyleName("gss-searchLabel");
    pagerTop = new GssSimplePager(GssSimplePager.TextLocation.CENTER);
    pagerTop.setDisplay(celltable);
    vp.add(pagerTop);
    vp.add(celltable);
    pager = new GssSimplePager(GssSimplePager.TextLocation.CENTER);
    pager.setDisplay(celltable);
    //celltable.setPageSize(2);

    vp.add(pager);
    vp.setCellWidth(celltable, "100%");

    initWidget(vp);

    //initWidget(celltable);
    celltable.setStyleName("gss-List");
    selectionModel = new MultiSelectionModel<FileResource>();

    Handler selectionHandler = new SelectionChangeEvent.Handler() {
        @Override
        public void onSelectionChange(com.google.gwt.view.client.SelectionChangeEvent event) {
            if (getSelectedFiles().size() == 1)
                GSS.get().setCurrentSelection(getSelectedFiles().get(0));
            else
                GSS.get().setCurrentSelection(getSelectedFiles());
            //contextMenu.setFiles(getSelectedFiles());
        }
    };
    selectionModel.addSelectionChangeHandler(selectionHandler);

    celltable.setSelectionModel(selectionModel, GSSSelectionEventManager.<FileResource>createDefaultManager());
    celltable.setPageSize(GSS.VISIBLE_FILE_COUNT);
    celltable.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.ENABLED);
    Scheduler.get().scheduleIncremental(new RepeatingCommand() {

        @Override
        public boolean execute() {
            return fetchRootFolder();
        }
    });
    sinkEvents(Event.ONCONTEXTMENU);
    sinkEvents(Event.ONMOUSEUP);
    sinkEvents(Event.ONMOUSEDOWN);
    sinkEvents(Event.ONCLICK);
    sinkEvents(Event.ONKEYDOWN);
    sinkEvents(Event.ONDBLCLICK);
    GSS.preventIESelection();
}

From source file:org.gwt.dynamic.module.foo.client.FooContentView.java

License:MIT License

void setFooData(FooData fooData) {
    LOG.info("FooContentView.setFooData: fooData=" + fooData);
    SafeHtmlBuilder shb = new SafeHtmlBuilder();
    shb.appendHtmlConstant("<h1>").appendEscaped(fooData.getHeader()).appendHtmlConstant("</h1>");
    shb.appendHtmlConstant(fooData.getHtml());
    content.setHTML(shb.toSafeHtml());
    content.removeStyleName(style.loading());
}

From source file:org.gwtbootstrap3.client.ui.PageHeader.java

License:Apache License

private void render() {
    final SafeHtmlBuilder builder = new SafeHtmlBuilder();

    builder.appendHtmlConstant("<h1>");
    builder.appendEscaped(heading == null ? "" : heading);

    if (subText != null && !subText.isEmpty()) {
        builder.appendEscaped(" ");
        builder.appendHtmlConstant("<small>");
        builder.appendEscaped(subText);/*from  ww  w  . j  a v  a 2  s  . c om*/
        builder.appendHtmlConstant("</small>");
    }

    builder.appendHtmlConstant("</h1>");

    getElement().setInnerSafeHtml(builder.toSafeHtml());
}