com.google.gwt.dom.client.StyleElement Java Examples

The following examples show how to use com.google.gwt.dom.client.StyleElement. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ViewClientCriterion.java    From hawkbit with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Styles a multi-row selection with the number of elements.
 *
 * @param drag
 *            the current drag event holding the context.
 */
void setMultiRowDragDecoration(final VDragEvent drag) {
    final Widget widget = drag.getTransferable().getDragSource().getWidget();

    if (widget instanceof VScrollTable) {
        final VScrollTable table = (VScrollTable) widget;
        final int rowCount = table.selectedRowKeys.size();

        Element dragCountElement = Document.get().getElementById(SP_DRAG_COUNT);
        if (rowCount > 1 && table.selectedRowKeys.contains(table.focusedRow.getKey())) {
            if (dragCountElement == null) {
                dragCountElement = Document.get().createStyleElement();
                dragCountElement.setId(SP_DRAG_COUNT);
                final HeadElement head = HeadElement
                        .as(Document.get().getElementsByTagName(HeadElement.TAG).getItem(0));
                head.appendChild(dragCountElement);
            }
            final SafeHtml formattedCssStyle = getDraggableTemplate()
                    .multiSelectionStyle(determineActiveTheme(drag), String.valueOf(rowCount));
            final StyleElement dragCountStyleElement = StyleElement.as(dragCountElement);
            dragCountStyleElement.setInnerSafeHtml(formattedCssStyle);
        } else if (dragCountElement != null) {
            dragCountElement.removeFromParent();
        }
    }
}
 
Example #2
Source File: Tooltip.java    From jetpad-projectional-open-source with Apache License 2.0 6 votes vote down vote up
private static Registration injectCornerStyle(String id, Cell cell) {
  Color borderColor = cell.get(Cell.BORDER_COLOR);
  String border = borderColor == null ? "none" : "1px solid " + borderColor.toCssColor();
  Color backgroundColor = cell.get(Cell.BACKGROUND);
  String background = backgroundColor == null ? Color.WHITE.toCssColor() : backgroundColor.toCssColor();
  final StyleElement styleElement = StyleInjector.injectStylesheet("." + id
      + "::before { border-top: " + border + "; border-left: " + border + "; " +
      "background: linear-gradient(135deg, " + background + " 0%, " + background
      + " 70%, rgba(0,0,0,0) 71%, rgba(0,0,0,0) 100%) }");
  StyleInjector.flush();
  return new Registration() {
    @Override
    protected void doRemove() {
      styleElement.removeFromParent();
    }
  };
}
 
Example #3
Source File: ViewClientCriterionTest.java    From hawkbit with Eclipse Public License 1.0 5 votes vote down vote up
@Test
@Description("Check multi row drag decoration with a valid multi selection")
public void processMultiRowDragDecorationMultiSelection() {
    final ViewClientCriterion cut = new ViewClientCriterion();

    // prepare table
    final VScrollTable table = Mockito.spy(new VScrollTable());
    table.selectedRowKeys.add("one");
    table.selectedRowKeys.add("two");
    table.focusedRow = Mockito.mock(VScrollTable.VScrollTableBody.VScrollTableRow.class);
    when(table.focusedRow.getKey()).thenReturn("one");

    // prepare drag-event with table widget:
    final VDragEvent dragEvent = CriterionTestHelper.createMockedVDragEvent("thisId", table, "myTheme");
    dragEvent.getTransferable().getDragSource().getConnection().getUIConnector();

    // prepare document
    final Document document = Document.get();
    final StyleElement ele = Mockito.spy(StyleElement.class);
    when(ele.getTagName()).thenReturn(StyleElement.TAG);
    when(document.getElementById(ViewClientCriterion.SP_DRAG_COUNT)).thenReturn(ele);

    try {
        // act
        cut.setMultiRowDragDecoration(dragEvent);

        // assure that multi-row decoration for the table was processed
        verify(document).getElementById(ViewClientCriterion.SP_DRAG_COUNT);

        // assure that no multi selection was detected
        verify(ele).setInnerSafeHtml(any(SafeHtml.class));
    } finally {
        reset(Document.get());
    }
}