Example usage for com.google.gwt.dom.client Style setTop

List of usage examples for com.google.gwt.dom.client Style setTop

Introduction

In this page you can find the example usage for com.google.gwt.dom.client Style setTop.

Prototype

public void setTop(double value, Unit unit) 

Source Link

Usage

From source file:stroom.data.grid.client.ResizeHandle.java

License:Apache License

public boolean update(final NativeEvent event, final Heading heading) {
    if (heading != null) {
        final int childIndex = heading.getColIndex();
        final Element th = heading.getElement();
        final Element headerRow = th.getParentElement();

        // See if we are allowed to resize the previous column.
        boolean canResizePreviousColumn = false;
        if (childIndex > 0) {
            final ColSettings settings = colSettings.get(childIndex - 1);
            canResizePreviousColumn = settings.isResizable();
        }/*from  www  .  j  a v  a2s  . c o  m*/
        // See if we can resize this column.
        boolean canResizeThisColumn = false;
        final ColSettings settings = colSettings.get(childIndex);
        canResizeThisColumn = settings.isResizable();

        // If we can't resize this column or the previous one then return no
        // handle as no resize will be possible.
        if (canResizeThisColumn || canResizePreviousColumn) {
            final com.google.gwt.dom.client.Style resizeHandleStyle = getElement().getStyle();
            setHeaderRow(headerRow);

            final int clientX = event.getClientX();
            final int diffLeft = clientX - th.getAbsoluteLeft();
            final int diffRight = th.getAbsoluteRight() - clientX;

            if (diffLeft <= ResizeHandle.HANDLE_WIDTH && diffLeft < diffRight && canResizePreviousColumn) {
                // Show the resize handle on the left.
                resizeHandleStyle.setLeft(th.getAbsoluteLeft() - ResizeHandle.HALF_HANDLE_WIDTH, Unit.PX);
                setColNo(childIndex - 1);
            } else if (canResizeThisColumn) {
                // Show the resize handle on the right.
                resizeHandleStyle.setLeft(th.getAbsoluteRight() - ResizeHandle.HALF_HANDLE_WIDTH, Unit.PX);
                setColNo(childIndex);
            } else if (canResizePreviousColumn) {
                // Show the resize handle on the left.
                resizeHandleStyle.setLeft(th.getAbsoluteLeft() - ResizeHandle.HALF_HANDLE_WIDTH, Unit.PX);
                setColNo(childIndex - 1);
            }

            resizeHandleStyle.setTop(th.getAbsoluteTop(), Unit.PX);
            resizeHandleStyle.setHeight(th.getOffsetHeight(), Unit.PX);

            return true;
        }
    }

    return false;
}

From source file:stroom.pipeline.structure.client.view.PipelineElementRenderer2.java

License:Apache License

@Override
public void render(final TreeLayout<PipelineElement> treeLayout, final Bounds bounds,
        final PipelineElement item) {
    final boolean selected = selectionModel != null && selectionModel.isSelected(item);
    final PipelineElementBox pipelineElementBox = pipelineElementBoxFactory.create(item);
    pipelineElementBox.setSelected(selected);

    final Style style = pipelineElementBox.getElement().getStyle();
    style.setLeft(bounds.getX(), Unit.PX);
    style.setTop(bounds.getY(), Unit.PX);

    panel.add(pipelineElementBox);/*from www .  ja  v  a 2  s  .  co m*/
    boxes.add(pipelineElementBox);
}

From source file:stroom.pipeline.structure.client.view.PipelineTreePanel.java

License:Apache License

private void setAbsoluteLeftTop(final com.google.gwt.dom.client.Element element) {
    final Style style = element.getStyle();
    style.setPosition(Position.ABSOLUTE);
    style.setLeft(0, Unit.PX);//from  ww w. j a v  a  2s  .  c  om
    style.setTop(0, Unit.PX);
}

From source file:stroom.query.client.ExpressionItemRenderer.java

License:Apache License

@Override
public void render(final TreeLayout<ExpressionItem> treeLayout, final Bounds bounds,
        final ExpressionItem item) {
    final boolean selected = selectionModel != null && selectionModel.isSelected(item);
    ExpressionItem editing = null;//from  w  w  w  .j av  a  2  s  .  c  om
    if (selectionModel != null && selectionModel instanceof MySingleSelectionModel<?>) {
        editing = ((MySingleSelectionModel<ExpressionItem>) selectionModel).getSelectedObject();
    }
    if (editing == null || !editing.equals(editingItem)) {
        // Stop editing previous item.
        stopEditing();
    }

    final double height = 20;
    final double x = bounds.getX();
    final double y = bounds.getY() + ((bounds.getHeight() - height) / 2);

    final String text = getText(item);

    final ExpressionItemBox box = new ExpressionItemBox(treeLayout, item, selectionModel != null);
    final Style style = box.getElement().getStyle();
    style.setLeft(x, Unit.PX);
    style.setTop(y, Unit.PX);

    panel.add(box);
    boxes.add(box);

    Widget widget = null;

    if (editing != null) {
        if (editing.equals(item)) {
            if (editingItem == null) {
                if (item instanceof ExpressionOperator) {
                    final ExpressionOperator operator = (ExpressionOperator) item;
                    operatorEditor.startEdit(operator);
                } else if (item instanceof ExpressionTerm) {
                    final ExpressionTerm term = (ExpressionTerm) item;
                    termEditor.startEdit(term);
                }
                editingItem = editing;
            }

            if (item instanceof ExpressionOperator) {
                widget = operatorEditor;
            } else if (item instanceof ExpressionTerm) {
                widget = termEditor;
            }
        }
    } else {
        stopEditing();
    }

    if (widget == null) {
        widget = new Label(text, false);
    }

    box.setInnerWidget(widget);
    box.setSelected(selected);
}

From source file:stroom.query.client.ExpressionTreePanel.java

License:Apache License

private void setAbsoluteLeftTop(final Element element) {
    final Style style = element.getStyle();
    style.setPosition(Position.ABSOLUTE);
    style.setLeft(0, Unit.PX);/*from  w  w  w.j av a  2 s  .c o  m*/
    style.setTop(0, Unit.PX);
}

From source file:stroom.widget.htree.client.LayeredCanvas.java

License:Apache License

private Canvas createLayer(final String name) {
    Canvas canvas = Canvas.createIfSupported();
    if (canvas != null) {
        layerMap.put(name, canvas);//from w w  w  . j  a va  2s . c o m

        final Style style = canvas.getElement().getStyle();
        style.setPosition(Position.ABSOLUTE);
        style.setLeft(0, Unit.PX);
        style.setTop(0, Unit.PX);
        style.setWidth(width, Unit.PX);
        style.setHeight(height, Unit.PX);
        style.setOutlineStyle(OutlineStyle.NONE);
        canvas.setCoordinateSpaceWidth(width);
        canvas.setCoordinateSpaceHeight(height);

        add(canvas);
    }
    return canvas;
}