Java Code Examples for com.google.gwt.dom.client.Style#setPosition()
The following examples show how to use
com.google.gwt.dom.client.Style#setPosition() .
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: DateCellDayItem.java From calendar-component with Apache License 2.0 | 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 2
Source File: CubaFileUploadProgressWindow.java From cuba with Apache License 2.0 | 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 3
Source File: VDDGridLayout.java From cuba with Apache License 2.0 | 5 votes |
/** * Emphasizes a component container when user is hovering a dragged * component over the container. * * @param cell * The container * @param event */ protected void emphasis(CellDetails cell, VDragEvent event) { Style shadowStyle = dragShadow.getElement().getStyle(); shadowStyle.setPosition(Position.ABSOLUTE); shadowStyle.setWidth(cell.width, Unit.PX); shadowStyle.setHeight(cell.height, Unit.PX); shadowStyle.setLeft(cell.x, Unit.PX); shadowStyle.setTop(cell.y, Unit.PX); // Remove any existing empasis deEmphasis(); // Ensure we are not dragging ourself into ourself ComponentConnector draggedConnector = (ComponentConnector) event .getTransferable() .getData(Constants.TRANSFERABLE_DETAIL_COMPONENT); if (draggedConnector != null && draggedConnector.getWidget() == VDDGridLayout.this) { return; } HorizontalDropLocation hl = getHorizontalDropLocation(cell, event); VerticalDropLocation vl = getVerticalDropLocation(cell, event); // Apply over style setStyleName(dragShadow.getElement(), OVER, true); // Add vertical location dependent style setStyleName(dragShadow.getElement(), OVER + "-" + vl.toString().toLowerCase(), true); // Add horizontal location dependent style setStyleName(dragShadow.getElement(), OVER + "-" + hl.toString().toLowerCase(), true); }
Example 4
Source File: MaterialCutOut.java From gwt-material-addins with Apache License 2.0 | 5 votes |
protected void setCutOutStyle() { Style style = getElement().getStyle(); style.setWidth(100, Unit.PCT); style.setHeight(100, Unit.PCT); style.setPosition(Position.FIXED); style.setTop(0, Unit.PX); style.setLeft(0, Unit.PX); style.setZIndex(10000); focusElement.setClassName(AddinsCssName.MATERIAL_CUTOUT_FOCUS); style = focusElement.getStyle(); style.setProperty("content", "\'\'"); style.setPosition(Position.ABSOLUTE); style.setZIndex(-1); }
Example 5
Source File: MaterialCutOut.java From gwt-material-addins with Apache License 2.0 | 5 votes |
/** * Gets the computed background color, based on the backgroundColor CSS * class. */ protected void setupComputedBackgroundColor() { // temp is just a widget created to evaluate the computed background // color MaterialWidget temp = new MaterialWidget(Document.get().createDivElement()); temp.setBackgroundColor(backgroundColor); // setting a style to make it invisible for the user Style style = temp.getElement().getStyle(); style.setPosition(Position.FIXED); style.setWidth(1, Unit.PX); style.setHeight(1, Unit.PX); style.setLeft(-10, Unit.PX); style.setTop(-10, Unit.PX); style.setZIndex(-10000); // adding it to the body (on Chrome the component must be added to the // DOM before getting computed values). String computed = ColorHelper.setupComputedBackgroundColor(backgroundColor); // convert rgb to rgba, considering the opacity field if (opacity < 1 && computed.startsWith("rgb(")) { computed = computed.replace("rgb(", "rgba(").replace(")", ", " + opacity + ")"); } computedBackgroundColor = computed; }
Example 6
Source File: InputDatePicker.java From putnami-web-toolkit with GNU Lesser General Public License v3.0 | 5 votes |
public void popup(Widget container, Widget relativeTo) { this.setVisible(true); StyleUtils.addStyle(this, InputDatePicker.STYLE_POPUP); RootPanel.get().add(this); Element positioningElement = this.getElement(); Element relativeElement = relativeTo.getElement(); int targetHeight = relativeElement.getOffsetHeight(); int targetTop = relativeElement.getAbsoluteTop(); int positioningWidth = positioningElement.getOffsetWidth(); int targetRight = relativeElement.getAbsoluteRight(); Style elementStyle = positioningElement.getStyle(); elementStyle.setPosition(Position.ABSOLUTE); elementStyle.setLeft(targetRight - positioningWidth, Unit.PX); elementStyle.setTop(targetTop + targetHeight, Unit.PX); StyleUtils.addStyle(this, InputDatePicker.STYLE_FADE); StyleUtils.addStyle(this, InputDatePicker.STYLE_SHOW); this.setFocus(true); if (this.popupBlurHandler == null) { this.popupBlurHandler = this.addBlurHandler(new BlurHandler() { @Override public void onBlur(BlurEvent event) { InputDatePicker.this.hide(); } }); } }
Example 7
Source File: Affix.java From putnami-web-toolkit with GNU Lesser General Public License v3.0 | 5 votes |
protected void toggleAffix(Affixed affix) { Element e = this.getElement(); Style style = e.getStyle(); if (this.affixed != affix) { this.clearElementStyle(); this.affixed = affix; StyleUtils.addStyle(e, this.affixed); } switch (affix) { case AFFIX: style.setTop(this.offsetTop, Unit.PX); style.setWidth(this.offsetWidth, Unit.PX); style.setHeight(this.offsetHeight, Unit.PX); style.setZIndex(this.layerIndex); e.getParentElement().getStyle().setPaddingTop(this.offsetHeight, Unit.PX); break; case BOTTOM: int docHeigth = Document.get().getScrollHeight(); int scrollTop = Window.getScrollTop(); int bottom = this.offsetBottom - (docHeigth - scrollTop - this.clientHeigth); if (this.fixBottom != Integer.MIN_VALUE) { bottom = Math.max(bottom, this.fixBottom); } style.setPosition(Position.FIXED); style.setBottom(bottom, Unit.PX); style.setWidth(this.offsetWidth, Unit.PX); style.setHeight(this.offsetHeight, Unit.PX); style.setZIndex(this.layerIndex); break; default: break; } }
Example 8
Source File: ViewContainerToElementMapper.java From jetpad-projectional-open-source with Apache License 2.0 | 5 votes |
public ViewContainerToElementMapper(ViewContainer source, Element target, final boolean eventsDisabled) { super(source, target); myCtx = new ViewToDomContext() { @Override public ReadableProperty<Rectangle> visibleArea() { return myVisibleArea; } @Override public MapperFactory<View, Element> getFactory() { return ViewMapperFactory.factory(this); } @Override public Boolean areEventsDisabled() { return eventsDisabled; } }; disablePopup(myRootDiv); target.appendChild(myRootDiv); myRootDiv.setTabIndex(0); final Style rootDivStyle = myRootDiv.getStyle(); rootDivStyle.setPosition(Style.Position.RELATIVE); rootDivStyle.setPadding(0, Style.Unit.PX); rootDivStyle.setOverflow(Style.Overflow.VISIBLE); rootDivStyle.setOutlineStyle(Style.OutlineStyle.NONE); }
Example 9
Source File: BaseViewMapper.java From jetpad-projectional-open-source with Apache License 2.0 | 5 votes |
protected Element createSVG() { Element result = SvgUtil.createSvgElement("svg"); //without setting absolute position svg element might move down for unknown reason Style style = result.getStyle(); style.setPosition(Style.Position.ABSOLUTE); style.setLeft(0, Style.Unit.PX); style.setTop(0, Style.Unit.PX); return result; }
Example 10
Source File: ClipboardSupport.java From jetpad-projectional-open-source with Apache License 2.0 | 5 votes |
private TextArea createClipboardTextArea() { final TextArea pasteArea = new TextArea(); pasteArea.setPixelSize(0, 0); Style style = pasteArea.getElement().getStyle(); style.setPosition(Style.Position.FIXED); RootPanel.get().add(pasteArea); pasteArea.setFocus(true); return pasteArea; }
Example 11
Source File: DomTextEditor.java From jetpad-projectional-open-source with Apache License 2.0 | 5 votes |
public DomTextEditor(Element root) { myRoot = root; Style rootStyle = myRoot.getStyle(); rootStyle.setPosition(Style.Position.RELATIVE); myTextContainer = DOM.createSpan(); Style textStyle = myTextContainer.getStyle(); textStyle.setZIndex(10); textStyle.setWhiteSpace(Style.WhiteSpace.NOWRAP); myRoot.appendChild(myTextContainer); Element caretDiv = DOM.createDiv(); Style caretStyle = caretDiv.getStyle(); caretStyle.setPosition(Style.Position.ABSOLUTE); caretStyle.setZIndex(10); myRoot.appendChild(caretDiv); myCaretDiv = caretDiv; Element selectionDiv = DOM.createDiv(); Style selectionStyle = selectionDiv.getStyle(); selectionStyle.setPosition(Style.Position.ABSOLUTE); selectionStyle.setZIndex(1); myRoot.appendChild(selectionDiv); mySelectionDiv = selectionDiv; update(); updateCaretVisibility(); updateSelectionVisibility(); updateCaretAndSelection(); }
Example 12
Source File: IframeCoverUtility.java From cuba with Apache License 2.0 | 4 votes |
/** * Adds an iframe cover over an Embedded component * * @param iframe * The iframe element * @return The element which covers the iframe */ private static Element addIframeCover(Element iframe) { if (iframeCoverMap.containsKey(iframe)) { return iframeCoverMap.get(iframe); } // Get dimensions String iframeWidth = iframe.getAttribute("width"); String iframeHeight = iframe.getAttribute("height"); Style iframeStyle = iframe.getStyle(); if (!iframeWidth.equals("") && !iframeHeight.equals("")) { iframeStyle.setPosition(Position.ABSOLUTE); iframeStyle.setTop(0, Unit.PX); iframeStyle.setLeft(0, Unit.PX); } // Create the cover element Element coverContainer = DOM.createDiv(); DOM.setStyleAttribute(coverContainer, "width", iframeWidth); DOM.setStyleAttribute(coverContainer, "height", iframeHeight); coverContainer.setClassName("v-dragdrop-iframe-container"); coverContainer.getStyle().setPosition(Position.RELATIVE); iframe.getParentElement().appendChild(coverContainer); // Move iframe to cover container iframe.getParentElement().replaceChild(coverContainer, iframe); coverContainer.appendChild(iframe); // Style the cover Element cover = DOM.createDiv(); cover.setClassName(SHIM_STYLENAME); Style coverStyle = cover.getStyle(); coverStyle.setPosition(Position.ABSOLUTE); coverStyle.setWidth(100, Unit.PCT); coverStyle.setHeight(100, Unit.PCT); coverStyle.setTop(0, Unit.PX); coverStyle.setLeft(0, Unit.PX); coverContainer.appendChild(cover); iframeCoverMap.put(iframe, coverContainer); return coverContainer; }