Java Code Examples for com.google.gwt.dom.client.Style.setPosition()

The following are Jave code examples for showing how to use setPosition() of the com.google.gwt.dom.client.Style class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: empiria.player   File: LabelledImgContent.java   View Source Code Vote up 6 votes
private void alignWidget(Widget widget, Point anchorPoint, String horizontalAlign, String verticalAlign) {
    Style style = widget.getElement().getStyle();
    double xPos = anchorPoint.getX();
    double yPos = anchorPoint.getY();

    if ("center".equals(horizontalAlign)) {
        xPos -= widget.getOffsetWidth() / 2;
    } else if ("right".equals(horizontalAlign)) {
        xPos -= widget.getOffsetWidth();
    }

    if ("center".equals(verticalAlign)) {
        yPos -= widget.getOffsetHeight() / 2;
    } else if ("bottom".equals(verticalAlign)) {
        yPos -= widget.getOffsetHeight();
    }

    style.setPosition(Position.ABSOLUTE);
    style.setTop(yPos, Unit.PX);
    style.setLeft(xPos, Unit.PX);
}
 
Example 2
Project: empiria.player   File: PanelCache.java   View Source Code Vote up 6 votes
@Override
protected KeyValue<FlowPanel, FlowPanel> getElement(Integer index) {
    parent = panelFactory.getFlowPanel();
    FlowPanel childPanel = panelFactory.getFlowPanel();

    Style style = parent.getElement().getStyle();
    parent.getElement().setId(styleNames.QP_PAGE() + index.intValue());

    if (swipeType != SwipeType.DISABLED) {
        style.setPosition(Position.ABSOLUTE);
        style.setTop(0, Unit.PX);
        style.setLeft(WIDTH * index, Unit.PCT);
        style.setWidth(WIDTH, Unit.PCT);
    }

    childPanel.setHeight("100%");
    childPanel.setWidth("100%");
    parent.add(childPanel);
    return new KeyValue<FlowPanel, FlowPanel>(parent, childPanel);
}
 
Example 3
Project: empiria.player   File: MultiPageView.java   View Source Code Vote up 6 votes
public void setSwipeDisabled(boolean swipeDisabled) {
    Style style = controller.getStyle();
    Style elementStyle = getElement().getStyle();

    style.setWidth(controller.getWidth(), Unit.PCT);

    if (swipeDisabled) {
        style.clearPosition();
        style.clearTop();
        style.clearLeft();
        elementStyle.clearPosition();
    } else {
        style.setPosition(Position.ABSOLUTE);
        style.setTop(0, Unit.PX);
        style.setLeft(0, Unit.PX);
        elementStyle.setPosition(Position.RELATIVE);
    }

    setSwipeLength();
}
 
Example 4
Project: kie-docker-ci   File: NavigationDateItemView.java   View Source Code Vote up 6 votes
private void positionItems() {
    
    // Day text.
    final Style dayStyle = day.getElement().getStyle();
    dayStyle.setPosition(Style.Position.ABSOLUTE);
    dayStyle.setMarginTop( (ICON_SIZE / 2) * -1, Style.Unit.PX);
    dayStyle.setMarginLeft( ( ICON_SIZE / 2 ) + 10, Style.Unit.PX);

    // Month text.
    final Style monthStyle = month.getElement().getStyle();
    monthStyle.setPosition(Style.Position.ABSOLUTE);
    monthStyle.setMarginTop(25, Style.Unit.PX);
    monthStyle.setMarginLeft( ( ICON_SIZE / 2 ) + (month.getOffsetWidth() / 2), Style.Unit.PX);

    // Count number.
    final Style countStyle = countText.getElement().getStyle();
    countStyle.setPosition(Style.Position.ABSOLUTE);
    countStyle.setMarginTop(20, Style.Unit.PX);
    countStyle.setMarginLeft( ( ICON_SIZE - 20 ), Style.Unit.PX);
}
 
Example 5
Project: appformer   File: ResizableMovableHeader.java   View Source Code Vote up 6 votes
private SpanElement createSpanElement(final Cursor cursor,
                                      final double left,
                                      final double width) {
    final SpanElement span = document.createSpanElement();
    span.setAttribute("title",
                      title);
    final Style style = span.getStyle();
    style.setCursor(cursor);
    style.setPosition(Position.ABSOLUTE);
    style.setBottom(0,
                    PX);
    style.setHeight(source.getOffsetHeight(),
                    PX);
    style.setTop(source.getOffsetTop(),
                 PX);
    style.setWidth(width,
                   PX);
    style.setLeft(left,
                  PX);
    return span;
}
 
Example 6
Project: appformer   File: BaseDOMElement.java   View Source Code Vote up 6 votes
public BaseDOMElement(final W widget,
                      final GridLayer gridLayer,
                      final GridWidget gridWidget) {
    this.widget = widget;
    this.gridLayer = gridLayer;
    this.gridWidget = gridWidget;
    this.domElementContainer = gridLayer.getDomElementContainer();

    final Style style = widgetContainer.getElement().getStyle();
    style.setPosition(Style.Position.ABSOLUTE);

    //MouseEvents over absolutely positioned elements do not bubble through the DOM.
    //Consequentially Event Handlers on GridLayer do not receive notification of MouseMove
    //Events used during column resizing. Therefore we manually bubble events to GridLayer.
    setupDelegatingMouseDownHandler();
    setupDelegatingMouseMoveHandler();
    setupDelegatingMouseUpHandler();
    setupDelegatingClickHandler();
}
 
Example 7
Project: appformer   File: BaseDOMElement.java   View Source Code Vote up 6 votes
/**
 * Attach the DOMElement to the GWT container, if not already attached.
 */
public void attach() {
    final Iterator<Widget> itr = domElementContainer.iterator();
    while (itr.hasNext()) {
        if (itr.next().equals(widgetContainer)) {
            return;
        }
    }
    //When an Element is detached it's Position configuration is cleared, so reset it
    final Style style = widgetContainer.getElement().getStyle();
    style.setPosition(Style.Position.ABSOLUTE);
    style.setProperty("WebkitUserSelect",
                      "none");
    style.setProperty("MozUserSelect",
                      "none");
    style.setProperty("MsUserSelect",
                      "none");

    domElementContainer.add(widgetContainer);
}
 
Example 8
Project: empiria.player   File: MathModule.java   View Source Code Vote up 5 votes
private void placeGaps() {
    for (MathGap gap : getMathGaps()) {
        Widget gapContainer = gap.getContainer();
        Style gapStyle = gapContainer.getElement().getStyle();

        gapStyle.setTop(0, Unit.PX);
        gapStyle.setLeft(0, Unit.PX);
        gapStyle.setPosition(Position.ABSOLUTE);
    }
}
 
Example 9
Project: empiria.player   File: MathModule.java   View Source Code Vote up 5 votes
private void initializePanels() {
    applyIdAndClassToView(mainPanel);

    outerPanel.getElement().getStyle().setOverflow(Overflow.VISIBLE);
    gapsPanel.getElement().getStyle().setOverflow(Overflow.VISIBLE);

    Style mainPanelStyle = mainPanel.getElement().getStyle();
    mainPanelStyle.setPosition(Position.ABSOLUTE);
    mainPanelStyle.setTop(0, Unit.PX);
    mainPanelStyle.setLeft(0, Unit.PX);
}
 
Example 10
Project: empiria.player   File: VideoFullScreenHelper.java   View Source Code Vote up 5 votes
protected void resizeToFullScreen(Widget widget, Position position) {
    Style style = widget.getElement().getStyle();
    style.setPosition(position);
    style.setTop(0, Unit.PX);
    style.setLeft(0, Unit.PX);
    style.setWidth(100, Unit.PCT);
    style.setHeight(100, Unit.PCT);
}
 
Example 11
Project: empiria.player   File: PanelCache.java   View Source Code Vote up 5 votes
public void setSwipeType(SwipeType swipeType) {
    this.swipeType = swipeType;
    if (parent != null) {
        Style style = parent.getElement().getStyle();

        if (swipeType == SwipeType.DISABLED) {
            style.clearTop();
            style.clearPosition();
        } else {
            style.setTop(0, Unit.PX);
            style.setPosition(Position.ABSOLUTE);
        }
    }
}
 
Example 12
Project: calendar-component   File: DateCellDayItem.java   View Source Code Vote up 5 votes
public DateCellDayItem(DateCell dateCell, WeekGrid parent, CalendarItem calendarItem) {
    super();
    this.dateCell = dateCell;

    handlers = new LinkedList<>();

    setStylePrimaryName("v-calendar-event");

    setCalendarItem(calendarItem);

    weekGrid = parent;

    Style s = getElement().getStyle();
    if (calendarItem.getStyleName().length() > 0) {
        addStyleDependentName(calendarItem.getStyleName());
    }
    s.setPosition(Position.ABSOLUTE);

    caption = DOM.createDiv();
    caption.addClassName("v-calendar-event-caption");
    getElement().appendChild(caption);

    eventContent = DOM.createDiv();
    eventContent.addClassName("v-calendar-event-content");
    getElement().appendChild(eventContent);

    if (weekGrid.getCalendar().isItemResizeAllowed() && getCalendarItem().isResizeable()) {
        topResizeBar = DOM.createDiv();
        bottomResizeBar = DOM.createDiv();

        topResizeBar.addClassName("v-calendar-event-resizetop");
        bottomResizeBar.addClassName("v-calendar-event-resizebottom");

        getElement().appendChild(topResizeBar);
        getElement().appendChild(bottomResizeBar);
    }

    eventIndex = calendarItem.getIndex();

}
 
Example 13
Project: cuba   File: CubaFileUploadProgressWindow.java   View Source Code Vote up 5 votes
private void fixIE8FocusCaptureIssue() {
    Element e = DOM.createInputText();
    Style elemStyle = e.getStyle();
    elemStyle.setPosition(Style.Position.ABSOLUTE);
    elemStyle.setTop(-10, Style.Unit.PX);
    elemStyle.setWidth(0, Style.Unit.PX);
    elemStyle.setHeight(0, Style.Unit.PX);

    contentPanel.getElement().appendChild(e);
    e.focus();
    contentPanel.getElement().removeChild(e);
}
 
Example 14
Project: Wiab.pro   File: DomUtil.java   View Source Code Vote up 5 votes
/**
 * Puts cover element on the covered element.
 * The cover and covered elements have the same position and size.
 * 
 * @param cover the cover element
 * @param covered the covered element
 */
public static void putCover(Element cover, Element covered) {
    Element parent = covered.getParentElement();
    Rect coveredRect = DomUtil.getElementAbsoluteRect(covered);
    Rect parentRect = DomUtil.getElementAbsoluteRect(parent);
    Style coverStyle = cover.getStyle();
    coverStyle.setPosition(Style.Position.ABSOLUTE);      
    coverStyle.setTop(coveredRect.getTop() - parentRect.getTop(), Style.Unit.PX);
    coverStyle.setLeft(coveredRect.getLeft() - parentRect.getLeft(), Style.Unit.PX);
    coverStyle.setRight(parentRect.getRight() - coveredRect.getRight(), Style.Unit.PX);
    coverStyle.setBottom(parentRect.getBottom() - coveredRect.getBottom(), Style.Unit.PX);      
    parent.appendChild(cover);    
}
 
Example 15
Project: kie-docker-ci   File: NavigationItemView.java   View Source Code Vote up 5 votes
private void show(final String id, final String _title, final String _text, final SafeUri imageUri, final int containersRunningCount) {
    showTitle(_title);
    showRunningContainers(id, containersRunningCount);
    
    // Show the navigation item image.
    final boolean isImage = imageUri != null;
    if (isImage) {
        image.setUrl(imageUri);
        image.setSize(getSizeInPx(), getSizeInPx());
    }
    image.setVisible(isImage);

    // Show the navigation item text.
    final boolean isText = _text != null;
    if (isText) {
        text.setText(new SafeHtmlBuilder().appendEscaped(_text).toSafeHtml().asString());
    }
    
    // Styles for placing the text over the image.
    final Style textStyle = text.getElement().getStyle();
    if (isImage && isText) {
        textStyle.setPosition(Style.Position.ABSOLUTE);
        textStyle.setMarginTop(size / 2, Style.Unit.PX);
        final int tSize = (int) (_text.length() * 5);
        textStyle.setMarginLeft( ( size / 2 ) - tSize, Style.Unit.PX);
    } else if (isText) {
        textStyle.setPosition(Style.Position.RELATIVE);
        textStyle.clearMarginTop();
        textStyle.clearMarginLeft();
    }
    text.setVisible(isText);

    // Add the click handler.
    addItemDetailClickHandler(id);
}
 
Example 16
Project: che   File: SpeedSearch.java   View Source Code Vote up 5 votes
private void initSearchPopUp() {
  this.searchPopUp = new SearchPopUp();
  Style style = this.searchPopUp.getElement().getStyle();

  style.setBackgroundColor("grey");
  style.setBorderStyle(Style.BorderStyle.SOLID);
  style.setBorderColor("#dbdbdb");
  style.setBorderWidth(1, Style.Unit.PX);
  style.setPadding(2, Style.Unit.PX);
  style.setPosition(Style.Position.FIXED);
  style.setTop(100, Style.Unit.PX);
  style.setLeft(20, Style.Unit.PX);
}
 
Example 17
Project: appformer   File: ResizableMovableHeader.java   View Source Code Vote up 5 votes
private static void setLine(final Style style,
                            final int width,
                            final int top,
                            final int height,
                            final String color) {
    style.setPosition(Position.ABSOLUTE);
    style.setTop(top,
                 PX);
    style.setHeight(height,
                    PX);
    style.setWidth(width,
                   PX);
    style.setBackgroundColor(color);
    style.setZIndex(Integer.MAX_VALUE);
}
 
Example 18
Project: appformer   File: TextBoxDOMElement.java   View Source Code Vote up 5 votes
public TextBoxDOMElement(final TextBox widget,
                         final GridLayer gridLayer,
                         final GridWidget gridWidget) {
    super(widget,
          gridLayer,
          gridWidget);
    final Style style = widget.getElement().getStyle();
    style.setWidth(100,
                   Style.Unit.PCT);
    style.setHeight(HEIGHT,
                    Style.Unit.PX);
    style.setPaddingLeft(2,
                         Style.Unit.PX);
    style.setPaddingRight(2,
                          Style.Unit.PX);
    style.setFontSize(10,
                      Style.Unit.PX);

    // --- Workaround for BS2 ---
    style.setPosition(Style.Position.RELATIVE);
    style.setPaddingTop(0,
                        Style.Unit.PX);
    style.setPaddingBottom(0,
                           Style.Unit.PX);
    style.setProperty("WebkitBoxSizing",
                      "border-box");
    style.setProperty("MozBoxSizing",
                      "border-box");
    style.setProperty("boxSizing",
                      "border-box");
    style.setProperty("lineHeight",
                      "normal");
    // --- End workaround ---

    getContainer().getElement().getStyle().setPaddingLeft(5,
                                                          Style.Unit.PX);
    getContainer().getElement().getStyle().setPaddingRight(5,
                                                           Style.Unit.PX);
    getContainer().setWidget(widget);
}
 
Example 19
Project: appformer   File: CheckBoxDOMElement.java   View Source Code Vote up 5 votes
public CheckBoxDOMElement(final CheckBox widget,
                          final GridLayer gridLayer,
                          final GridWidget gridWidget) {
    super(widget,
          gridLayer,
          gridWidget);
    final Style style = widget.getElement().getStyle();
    style.setMarginTop(0,
                       Style.Unit.PX);
    style.setMarginLeft(2,
                        Style.Unit.PX);
    style.setWidth(SIZE,
                   Style.Unit.PX);
    style.setHeight(SIZE,
                    Style.Unit.PX);

    // --- Workaround for BS2 ---
    style.setPosition(Style.Position.RELATIVE);
    style.setPaddingTop(0,
                        Style.Unit.PX);
    style.setPaddingBottom(0,
                           Style.Unit.PX);
    style.setProperty("WebkitBoxSizing",
                      "border-box");
    style.setProperty("MozBoxSizing",
                      "border-box");
    style.setProperty("boxSizing",
                      "border-box");
    style.setProperty("lineHeight",
                      "normal");
    // --- End workaround ---

    getContainer().setWidget(widget);
}
 
Example 20
Project: appformer   File: ListBoxDOMElement.java   View Source Code Vote up 5 votes
public ListBoxDOMElement(final ListBox widget,
                         final GridLayer gridLayer,
                         final GridWidget gridWidget) {
    super(widget,
          gridLayer,
          gridWidget);
    final Style style = widget.getElement().getStyle();
    style.setWidth(100,
                   Style.Unit.PCT);
    style.setHeight(HEIGHT,
                    Style.Unit.PX);
    style.setPaddingLeft(2,
                         Style.Unit.PX);
    style.setPaddingRight(2,
                          Style.Unit.PX);
    style.setFontSize(10,
                      Style.Unit.PX);

    // --- Workaround for BS2 ---
    style.setPosition(Style.Position.RELATIVE);
    style.setPaddingTop(0,
                        Style.Unit.PX);
    style.setPaddingBottom(0,
                           Style.Unit.PX);
    style.setProperty("WebkitBoxSizing",
                      "border-box");
    style.setProperty("MozBoxSizing",
                      "border-box");
    style.setProperty("boxSizing",
                      "border-box");
    style.setProperty("lineHeight",
                      "normal");
    // --- End workaround ---

    getContainer().getElement().getStyle().setPaddingLeft(5,
                                                          Style.Unit.PX);
    getContainer().getElement().getStyle().setPaddingRight(5,
                                                           Style.Unit.PX);
    getContainer().setWidget(widget);
}
 
Example 21
Project: appformer   File: StencilPaletteBuilder.java   View Source Code Vote up 5 votes
private void setDragProxyPosition(final LienzoPanel dragProxyParentPanel,
                                  final LienzoPanel dragProxyPanel,
                                  final double proxyWidth,
                                  final double proxyHeight,
                                  final NodeMouseDownEvent event) {
    Style style = dragProxyPanel.getElement().getStyle();
    style.setPosition(Style.Position.ABSOLUTE);
    style.setLeft(dragProxyParentPanel.getAbsoluteLeft() + event.getX() - (proxyWidth / 2),
                  Style.Unit.PX);
    style.setTop(dragProxyParentPanel.getAbsoluteTop() + event.getY() - (proxyHeight / 2),
                 Style.Unit.PX);
    style.setZIndex(ZINDEX);
}
 
Example 22
Project: appformer   File: WorkbenchSplitLayoutPanel.java   View Source Code Vote up 5 votes
public Splitter(Widget target,
                boolean reverse) {
    this.target = target;
    this.reverse = reverse;

    final ResizeFlowPanel widget = new ResizeFlowPanel();

    sinkEvents(Event.ONMOUSEDOWN | Event.ONMOUSEUP | Event.ONMOUSEMOVE | Event.ONDBLCLICK);

    this.hover = new FlowPanel();
    final Style style = hover.getElement().getStyle();
    style.setOpacity(0);
    style.setZIndex(2);
    style.setPosition(Position.FIXED);
    setUpHoverStyle(style,
                    DEFAULT_SPLITTER_HOVER_SIZE);
    widget.add(hover);
    initWidget(widget);

    mouseTracker = Document.get().createDivElement();
    mouseTracker.getStyle().setCursor(getHoverCursorStyle());
    mouseTracker.getStyle().setZIndex(Integer.MAX_VALUE);
    mouseTracker.getStyle().setPosition(Position.ABSOLUTE);
    mouseTracker.getStyle().setHeight(50,
                                      Unit.PX);
    mouseTracker.getStyle().setWidth(50,
                                     Unit.PX);
}
 
Example 23
Project: appformer   File: Layouts.java   View Source Code Vote up 5 votes
/**
 * Sets the CSS on the given widget so it automatically fills the available space, rather than being sized based on
 * the amount of space required by its contents. This tends to be useful when building a UI that always fills the
 * available space on the screen, as most desktop application windows do.
 * <p>
 * To achieve this, the element is given relative positioning with top and left set to 0px and width and height set
 * to 100%. This makes the widget fill its nearest ancestor which has relative or absolute positioning. This
 * technique is compatible with GWT's LayoutPanel system. Note that, like LayoutPanels, this only works if the host
 * page is in standards mode (has a {@code <!DOCTYPE html>} header).
 * @param w the widget that should always fill its available space, rather than being sized to fit its contents.
 */
public static void setToFillParent(Widget w) {
    Element e = w.getElement();
    Style s = e.getStyle();
    s.setPosition(Position.RELATIVE);
    s.setTop(0.0,
             Unit.PX);
    s.setLeft(0.0,
              Unit.PX);
    s.setWidth(100.0,
               Unit.PCT);
    s.setHeight(100.0,
                Unit.PCT);
}
 
Example 24
Project: empiria.player   File: AndroidVisibilityChanger.java   View Source Code Vote up 4 votes
@Override
public void show(VisibilityClient client) {
    Style style = client.getElementStyle();
    style.setPosition(Position.STATIC);
    style.clearTop();
}
 
Example 25
Project: empiria.player   File: AndroidVisibilityChanger.java   View Source Code Vote up 4 votes
@Override
public void hide(VisibilityClient client) {
    final Style style = client.getElementStyle();
    style.setPosition(Position.FIXED);
    style.setTop(TOP_HIDDEN, Unit.PX);
}