Java Code Examples for com.google.gwt.dom.client.Style#setWidth()
The following examples show how to use
com.google.gwt.dom.client.Style#setWidth() .
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: CubaFileDownloaderConnector.java From cuba with Apache License 2.0 | 6 votes |
public void downloadFileById(String resourceId) { final String url = getResourceUrl(resourceId); if (url != null && !url.isEmpty()) { final IFrameElement iframe = Document.get().createIFrameElement(); Style style = iframe.getStyle(); style.setVisibility(Style.Visibility.HIDDEN); style.setHeight(0, Style.Unit.PX); style.setWidth(0, Style.Unit.PX); iframe.setFrameBorder(0); iframe.setTabIndex(-1); iframe.setSrc(url); RootPanel.getBodyElement().appendChild(iframe); Timer removeTimer = new Timer() { @Override public void run() { iframe.removeFromParent(); } }; removeTimer.schedule(60 * 1000); } }
Example 2
Source File: CellContainerToDomMapper.java From jetpad-projectional-open-source with Apache License 2.0 | 6 votes |
private void refreshLineHighlight() { if (myLineHighlightUpToDate || !isAttached()) return; Cell current = getSource().focusedCell.get(); for (Element e : Arrays.asList(myLineHighlight1, myLineHighlight2)) { Style style = e.getStyle(); if (current == null || !Cells.isLeaf(current)) { style.setVisibility(Style.Visibility.HIDDEN); } else { int deltaTop = myContent.getAbsoluteTop() - getTarget().getAbsoluteTop(); style.setVisibility(Style.Visibility.VISIBLE); int rootTop = myContent.getAbsoluteTop(); final Element currentElement = getElement(current); int currentTop = currentElement.getAbsoluteTop(); style.setTop(currentTop - rootTop + deltaTop, Style.Unit.PX); style.setHeight(currentElement.getClientHeight(), Style.Unit.PX); if (e == myLineHighlight2) { style.setWidth(0, Style.Unit.PX); style.setWidth(getTarget().getScrollWidth(), Style.Unit.PX); } } } myLineHighlightUpToDate = true; }
Example 3
Source File: DomTextEditor.java From jetpad-projectional-open-source with Apache License 2.0 | 6 votes |
private void updateCaretAndSelection() { Style caretStyle = myCaretDiv.getStyle(); updateCaretPosition(); caretStyle.setTop(0, Style.Unit.PX); caretStyle.setWidth(1, Style.Unit.PX); caretStyle.setHeight(getLineHeight(), Style.Unit.PX); caretStyle.setBackgroundColor("black"); Style selectionStyle = mySelectionDiv.getStyle(); selectionStyle.setTop(0, Style.Unit.PX); selectionStyle.setHeight(getLineHeight(), Style.Unit.PX); selectionStyle.setBackgroundColor("Highlight"); selectionStyle.setColor("HighlightText"); updateSelectionBoundsAndText(); }
Example 4
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 5
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 6
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 7
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 8
Source File: ImageThumbnailWidget.java From swellrt with Apache License 2.0 | 5 votes |
private void setImageSize() { int width = isFullSize?attachmentWidth:thumbnailWidth; int height = isFullSize?attachmentHeight:thumbnailHeight; image.setPixelSize(width, height); //TODO(user,danilatos): Whinge about how declarative UI doesn't let us avoid this hack: Style pstyle = image.getElement().getParentElement().getParentElement().getStyle(); if (width == 0) { image.setWidth(""); pstyle.clearWidth(); } else { pstyle.setWidth(width, Unit.PX); } if (height == 0) { image.setHeight(""); pstyle.clearHeight(); } else { pstyle.setHeight(height, Unit.PX); } String url = isFullSize?attachmentUrl:thumbnailUrl; if (url != null) { if (doubleBufferLoader == null) { doubleBufferLoader = new DoubleBufferImage(spin, errorLabel, image); } doubleBufferLoader.loadImage(url); DOM.setStyleAttribute(image.getElement(), "visibility", ""); } // NOTE(user): IE requires that the imageCaptionContainer element has a width // in order to correctly center the caption. if (DO_FRAME_WIDTH_UPDATE) { captionPanel.getElement().getStyle().setWidth(width, Unit.PX); } }
Example 9
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 10
Source File: ImageThumbnailWidget.java From incubator-retired-wave with Apache License 2.0 | 5 votes |
private void setImageSize() { int width = isFullSize?attachmentWidth:thumbnailWidth; int height = isFullSize?attachmentHeight:thumbnailHeight; image.setPixelSize(width, height); //TODO(user,danilatos): Whinge about how declarative UI doesn't let us avoid this hack: Style pstyle = image.getElement().getParentElement().getParentElement().getStyle(); if (width == 0) { image.setWidth(""); pstyle.clearWidth(); } else { pstyle.setWidth(width, Unit.PX); } if (height == 0) { image.setHeight(""); pstyle.clearHeight(); } else { pstyle.setHeight(height, Unit.PX); } String url = isFullSize?attachmentUrl:thumbnailUrl; if (url != null) { if (doubleBufferLoader == null) { doubleBufferLoader = new DoubleBufferImage(spin, errorLabel, image); } doubleBufferLoader.loadImage(url); DOM.setStyleAttribute(image.getElement(), "visibility", ""); } // NOTE(user): IE requires that the imageCaptionContainer element has a width // in order to correctly center the caption. if (DO_FRAME_WIDTH_UPDATE) { captionPanel.getElement().getStyle().setWidth(width, Unit.PX); } }
Example 11
Source File: DomTextEditor.java From jetpad-projectional-open-source with Apache License 2.0 | 5 votes |
private void updateSelectionBoundsAndText() { int left = Math.min(myCaretPosition, mySelectionStart); int right = Math.max(myCaretPosition, mySelectionStart); String text = myText == null ? "" : myText; text = text.substring(left, right); Style selectionStyle = mySelectionDiv.getStyle(); selectionStyle.setLeft(getCaretOffset(left), Style.Unit.PX); selectionStyle.setWidth(getCaretOffset(right) - getCaretOffset(left), Style.Unit.PX); mySelectionDiv.setInnerText(TextMetricsCalculator.normalize(text)); }
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; }