List of usage examples for com.google.gwt.dom.client Style setTop
public void setTop(double value, Unit unit)
From source file:cc.alcina.framework.gwt.client.util.ClientUtils.java
License:Apache License
public static String trimToWidth(String s, String style, int pxWidth, String ellipsis) { if (pxWidth <= 20) { return s; }//from ww w . j ava 2s. c om ellipsis = ellipsis == null ? "\u2026" : ellipsis; int r0 = 0; int r1 = s.length(); Label l = new Label(); setElementStyle(l.getElement(), style); Style cStyle = l.getElement().getStyle(); cStyle.setPosition(Position.ABSOLUTE); cStyle.setLeft(0, Unit.PX); cStyle.setTop(0, Unit.PX); cStyle.setDisplay(Display.INLINE_BLOCK); cStyle.setProperty("whitespace", "nowrap"); cStyle.setProperty("visibility", "hidden"); RootPanel.get().add(l); boolean tried = false; while (true) { int mid = (r1 - r0) / 2 + r0; String t = tried ? s.substring(0, mid) + ellipsis : s; l.setText(t); if (l.getOffsetWidth() <= pxWidth) { if (!tried || (r1 - r0) <= 1) { RootPanel.get().remove(l); return t; } r0 = mid; } else { if (!tried) { tried = true; } else { r1 = mid; } } } }
From source file:cc.alcina.framework.gwt.client.widget.RelativePopupValidationFeedback.java
License:Apache License
@Override public void handleException(Object source, ValidationException exception) { final Widget w = (Widget) source; resolve(source);// www . ja v a 2 s .c o m if (!DomUtils.isVisibleAncestorChain(w.getElement())) { return; } Widget suppressValidationFeedbackFor = RenderContext.get().getSuppressValidationFeedbackFor(); if (suppressValidationFeedbackFor != null && suppressValidationFeedbackFor.getElement().isOrHasChild(w.getElement())) { return; } final RelativePopup p = new RelativePopup(); p.setVisible(false); popups.put(source, p); WidgetByElementTracker.get().register(p); p.setStyleName("gwittir-ValidationPopup"); if (getCss() != null) { p.addStyleName(getCss()); } if (exception instanceof ProcessingServerValidationException) { ProcessingServerValidationException psve = (ProcessingServerValidationException) exception; FlowPanel fp = new FlowPanel(); fp.setStyleName("gwittir-ServerValidation"); fp.add(new InlineLabel(this.getMessage(exception))); p.add(fp); psve.setSourceWidget(source); psve.setFeedback(this); } else { p.add(renderExceptionWidget(exception)); } int x = w.getAbsoluteLeft(); int y = w.getAbsoluteTop(); Widget pw = WidgetUtils.getPositioningParent(w); ComplexPanel cp = WidgetUtils.complexChildOrSelf(pw); if (!(pw instanceof RootPanel)) { x -= pw.getAbsoluteLeft(); y -= pw.getAbsoluteTop(); } cp.add(p); if (this.position == BOTTOM) { y += w.getOffsetHeight(); } else if (this.position == RIGHT) { x += w.getOffsetWidth(); } else if (this.position == LEFT) { x -= p.getOffsetWidth(); } else if (this.position == TOP) { y -= p.getOffsetHeight(); } Element h = p.getElement(); Style style = h.getStyle(); style.setPosition(Position.ABSOLUTE); style.setLeft(x, Unit.PX); style.setTop(y, Unit.PX); if (this.position == BOTTOM) { style.setWidth(w.getOffsetWidth(), Unit.PX); } p.setVisible(true); if (w instanceof SourcesPropertyChangeEvents) { // GWT.log("is PCE", null); PropertyChangeListener attachListener = new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent propertyChangeEvent) { if (((Boolean) propertyChangeEvent.getNewValue()).booleanValue()) { p.setVisible(true); } else { p.setVisible(false); } } }; listeners.put(w, attachListener); ((SourcesPropertyChangeEvents) w).addPropertyChangeListener("attached", attachListener); ((SourcesPropertyChangeEvents) w).addPropertyChangeListener("visible", attachListener); } }
From source file:client.ui.components.MaterialButton.java
License:Open Source License
@Override public void onClick(ClickEvent event) { if (animationEnabled) { ink.removeClassName(Class.ANIMATE.getName()); Style style = ink.getStyle(); int size = anchor.getOffsetWidth(); style.setWidth(size, Style.Unit.PX); style.setHeight(size, Style.Unit.PX); style.setMarginLeft(-size / 2, Style.Unit.PX); style.setMarginTop(-size / 2, Style.Unit.PX); style.setLeft(event.getX(), Style.Unit.PX); style.setTop(event.getY(), Style.Unit.PX); ink.addClassName(Class.ANIMATE.getName()); }//from w w w .jav a2 s. c o m }
From source file:client.ui.components.MaterialItem.java
License:Open Source License
@Override public void onClick(ClickEvent event) { if (animationEnabled) { Element inkElement = ink.getElement(); inkElement.removeClassName(Class.ANIMATE.getName()); Style style = inkElement.getStyle(); int size = panel.getOffsetWidth(); style.setWidth(size, Style.Unit.PX); style.setHeight(size, Style.Unit.PX); style.setMarginLeft(-size / 2, Style.Unit.PX); style.setMarginTop(-size / 2, Style.Unit.PX); style.setLeft(event.getX(), Style.Unit.PX); style.setTop(event.getY(), Style.Unit.PX); inkElement.addClassName(Class.ANIMATE.getName()); }/*from w w w. ja v a2s . com*/ }
From source file:com.ait.lienzo.client.widget.panel.mediators.PanelPreviewMediator.java
License:Apache License
@Override protected void onEnable() { final LienzoBoundsPanel panel = getPanel(); final int panelWidthPx = panel.getWidthPx(); final int panelHeightPx = panel.getHeightPx(); final Style style = previewPanel.getElement().getStyle(); style.setPosition(Style.Position.ABSOLUTE); style.setTop(0, Style.Unit.PX); style.setLeft(0, Style.Unit.PX); style.setBorderStyle(Style.BorderStyle.NONE); style.setBackgroundColor(PREVIEW_BG_COLOR); previewPanel.setPixelSize(panelWidthPx, panelHeightPx); previewPanel.setVisible(true);/*ww w . ja v a2s . c o m*/ final BoundingBox areaBox = area.get(); final double fitLevel = PanelTransformUtils.computeZoomLevelFitToWidth(areaBox.getWidth(), areaBox.getHeight(), panel); final Viewport viewport = previewLayer.getViewport(); final Transform transform = new Transform(); transform.translate(areaBox.getX(), areaBox.getY()); transform.scale(fitLevel, fitLevel); viewport.setTransform(transform); getLayer().drawWithTransforms(previewLayer.getContext(), 1, new BoundingBox(0, 0, panelWidthPx, panelHeightPx), new Supplier<Transform>() { @Override public Transform get() { return transform; } }); mediator.setMaxScale(maxScale); mediator.setEnabled(true); getLayer().setVisible(false); }
From source file:com.alkacon.acacia.client.ui.AttributeValueView.java
License:Open Source License
/** * @see com.alkacon.geranium.client.dnd.I_Draggable#getDragHelper(com.alkacon.geranium.client.dnd.I_DropTarget) *//*from w w w. j a v a 2s . com*/ public Element getDragHelper(I_DropTarget target) { closeHelpBubble(null); // using the widget element as the drag helper also to avoid cloning issues on input fields m_dragHelper = getElement(); Element parentElement = getElement().getParentElement(); if (parentElement == null) { parentElement = target.getElement(); } int elementTop = getElement().getAbsoluteTop(); int parentTop = parentElement.getAbsoluteTop(); Style style = m_dragHelper.getStyle(); style.setWidth(m_dragHelper.getOffsetWidth(), Unit.PX); // the dragging class will set position absolute style.setTop(elementTop - parentTop, Unit.PX); m_dragHelper.addClassName(formCss().dragHelper()); return m_dragHelper; }
From source file:com.alkacon.acacia.client.ui.ChoiceSubmenu.java
License:Open Source License
/** * Helper method to position a submenu on the left side of a menu entry.<p> * /* w ww . j av a 2s . c om*/ * @param widgetEntry the widget entry relative to which the submenu should be positioned */ protected void positionNextToMenuEntry(final ChoiceMenuEntryWidget widgetEntry) { Element elem = getElement(); elem.getStyle().setPosition(Style.Position.ABSOLUTE); Element referenceElement = null; int startX = -2000; int startY = -2000; int deltaX = 0; int deltaY = 0; referenceElement = widgetEntry.getElement(); Style style = elem.getStyle(); style.setLeft(startX, Unit.PX); style.setTop(startY, Unit.PX); int myRight = elem.getAbsoluteRight(); int myTop = elem.getAbsoluteTop(); int refLeft = referenceElement.getAbsoluteLeft(); int refTop = referenceElement.getAbsoluteTop(); int newLeft = startX + (refLeft - myRight) + deltaX; int newTop; if (openAbove(referenceElement)) { int myHeight = elem.getOffsetHeight(); int refHeight = referenceElement.getOffsetHeight(); newTop = startY + ((refTop + refHeight) - (myTop + myHeight)) + deltaY; } else { newTop = startY + (refTop - myTop) + deltaY; } style.setLeft(newLeft, Unit.PX); style.setTop(newTop, Unit.PX); }
From source file:com.alkacon.geranium.client.ui.HighlightingBorder.java
License:Open Source License
/** * Sets the border position.<p>/*from w w w .ja v a 2 s.c o m*/ * * @param height the height * @param width the width * @param positionLeft the absolute left position * @param positionTop the absolute top position */ public void setPosition(int height, int width, int positionLeft, int positionTop) { positionLeft -= BORDER_OFFSET; // make sure highlighting does not introduce additional horizontal scroll-bars if ((m_positioningParent == null) && (positionLeft < 0)) { // position left should not be negative width += positionLeft; positionLeft = 0; } width += (2 * BORDER_OFFSET) - BORDER_WIDTH; if ((m_positioningParent == null) && (Window.getClientWidth() < (width + positionLeft)) && (Window.getScrollLeft() == 0)) { // highlighting should not extend over the right hand width = Window.getClientWidth() - (positionLeft + BORDER_WIDTH); } Style style = getElement().getStyle(); style.setLeft(positionLeft, Unit.PX); style.setTop(positionTop - BORDER_OFFSET, Unit.PX); setHeight((height + (2 * BORDER_OFFSET)) - BORDER_WIDTH); setWidth(width); }
From source file:com.alkacon.geranium.client.util.DebugLog.java
License:Open Source License
/** * Constructor.<p>//from www . ja va2 s . c om */ @SuppressWarnings("unused") private DebugLog() { if (!DEBUG) { return; } m_html = new HTML(); initWidget(m_html); Style style = getElement().getStyle(); style.setWidth(200, Unit.PX); style.setHeight(500, Unit.PX); style.setPadding(10, Unit.PX); style.setOverflow(Overflow.AUTO); style.setBorderStyle(BorderStyle.SOLID); style.setBorderColor(I_LayoutBundle.INSTANCE.constants().css().borderColor()); style.setBorderWidth(1, Unit.PX); style.setPosition(Position.FIXED); style.setTop(50, Unit.PX); style.setRight(50, Unit.PX); style.setBackgroundColor(I_LayoutBundle.INSTANCE.constants().css().backgroundColorDialog()); style.setZIndex(10); }
From source file:com.alkacon.geranium.client.util.DomUtil.java
License:Open Source License
/** * Positions an element in the DOM relative to another element.<p> * /*from w ww . j av a 2 s . c o m*/ * @param elem the element to position * @param referenceElement the element relative to which the first element should be positioned * @param dx the x offset relative to the reference element * @param dy the y offset relative to the reference element */ public static void positionElement(Element elem, Element referenceElement, int dx, int dy) { com.google.gwt.dom.client.Style style = elem.getStyle(); style.setLeft(0, Unit.PX); style.setTop(0, Unit.PX); int myX = elem.getAbsoluteLeft(); int myY = elem.getAbsoluteTop(); int refX = referenceElement.getAbsoluteLeft(); int refY = referenceElement.getAbsoluteTop(); int newX = (refX - myX) + dx; int newY = (refY - myY) + dy; style.setLeft(newX, Unit.PX); style.setTop(newY, Unit.PX); }