List of usage examples for com.google.gwt.user.client.ui Widget getOffsetHeight
@Override
public int getOffsetHeight()
From source file:ca.upei.ic.timetable.client.CalendarPanel.java
License:Apache License
protected void reorganizePanel(AbsolutePanel panel) { Set<Widget> remaining = new HashSet<Widget>(); Set<Widget> processing = new HashSet<Widget>(); // add all widgets to remaining for (Widget w : panel) { remaining.add(w);/* ww w . ja v a 2 s . com*/ } // loop until no remaining widgets while (remaining.size() > 0) { // get the first widget Widget first = remaining.iterator().next(); int top = panel.getWidgetTop(first); int bottom = panel.getWidgetTop(first) + first.getOffsetHeight(); remaining.remove(first); processing.add(first); // find out the overlapping widgets from the first one boolean continueProcessing = true; while (continueProcessing) { // default to terminate the processing // this is a hack because no goto statement is supported in // Java. boolean terminateProcessing = true; // iterate all widgets until one overlapping widget is found. for (Widget widget : remaining) { int widgetTop = panel.getWidgetTop(widget); int widgetBottom = panel.getWidgetTop(widget) + widget.getOffsetHeight(); // found if (top < widgetBottom && widgetTop < bottom) { // add to processing set, remove from remaining set processing.add(widget); remaining.remove(widget); // reset top and bottom if necessary if (top > widgetTop) top = widgetTop; if (bottom < widgetBottom) bottom = widgetBottom; // don't terminate processing terminateProcessing = false; break; } } // really want to terminate the process? if (terminateProcessing) continueProcessing = false; } // all processing widgets found, try to reposition/resize the // widgets int count = processing.size(); int index = 0; for (Widget widget : processing) { int widgetWidth = (panel.getOffsetWidth() - 2) / count; int widgetTop = panel.getWidgetTop(widget); int widgetLeft = index * widgetWidth; widget.setWidth(Integer.toString(widgetWidth) + "px"); panel.setWidgetPosition(widget, widgetLeft, widgetTop); index++; } // clear the processing set processing.clear(); } }
From source file:cc.alcina.framework.gwt.client.stdlayout.MainTabPanel.java
License:Apache License
public int getTabBarHeight() { VerticalPanel vp = (VerticalPanel) getWidget(); Widget w = vp.getWidget(0); return w.getOffsetHeight(); }
From source file:cc.alcina.framework.gwt.client.util.WidgetUtils.java
License:Apache License
public static void copySize(Widget from, Widget to) { to.setSize(from.getOffsetWidth() + "px", from.getOffsetHeight() + "px"); }
From source file:cc.alcina.framework.gwt.client.util.WidgetUtils.java
License:Apache License
public static void scrollIntoViewWhileKeepingRect(Rect bounds, Widget widget, int pad) { // assume widget is below bounds int scrollTop = Window.getScrollTop(); int clientHeight = Window.getClientHeight(); int widgetTop = widget.getAbsoluteTop(); int widgetHeight = widget.getOffsetHeight(); if (widgetTop + widgetHeight + pad > scrollTop + clientHeight) { int bestDeltaDown = widgetTop + widgetHeight + pad - (scrollTop + clientHeight); int delta = Math.min(bounds.y1 - scrollTop, bestDeltaDown); delta = Math.max(0, delta); smoothScrollTo(scrollTop + delta, widget); }//from ww w . j av a 2s . c om }
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);/* w w w .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:cc.kune.common.client.tooltip.Tooltip.java
License:GNU Affero Public License
/** * Calculate position./*from w w w . j a v a 2 s. c o m*/ * * @return the tooltip position */ private TooltipPosition calculatePosition(final Widget forWidget) { return TooltipPositionCalculator.calculate(Window.getClientWidth(), Window.getClientHeight(), forWidget.getAbsoluteLeft(), forWidget.getAbsoluteTop(), forWidget.getOffsetWidth(), forWidget.getOffsetHeight(), getTip().getWidth(), getTip().getHeight()); }
From source file:cc.kune.common.client.ui.MaskWidget.java
License:GNU Affero Public License
@Override public void mask(final IsWidget widget, final String message) { label.setText(message);/*from w w w . j a v a 2s .c o m*/ setPopupPositionAndShow(new PositionCallback() { @Override public void setPosition(final int offsetWidth, final int offsetHeight) { final Widget asWidget = widget.asWidget(); final int w = asWidget.getOffsetWidth(); final int h = asWidget.getOffsetHeight(); MaskWidget.this.setPopupPosition(asWidget.getAbsoluteLeft(), asWidget.getAbsoluteTop()); getElement().getStyle().setWidth(w, Unit.PX); getElement().getStyle().setHeight(h, Unit.PX); flow.getElement().getStyle().setTop((h - flow.getOffsetHeight()) / 2d, Unit.PX); flow.getElement().getStyle().setLeft((w - flow.getOffsetWidth()) / 2d, Unit.PX); } }); }
From source file:ch.eaternity.client.FlexTableRowDropController.java
License:Apache License
@Override public void onMove(DragContext context) { super.onMove(context); targetRow = DOMUtil.findIntersect(flexTableRowsAsIndexPanel, new CoordinateLocation(context.mouseX, context.mouseY), LocationWidgetComparator.BOTTOM_HALF_COMPARATOR) - 1; if (flexTable.getRowCount() > 0) { Widget w = flexTable.getWidget(targetRow == -1 ? 0 : targetRow, 0); Location widgetLocation = new WidgetLocation(w, context.boundaryPanel); Location tableLocation = new WidgetLocation(flexTable, context.boundaryPanel); context.boundaryPanel.add(positioner, tableLocation.getLeft(), widgetLocation.getTop() + (targetRow == -1 ? 0 : w.getOffsetHeight())); }/* w ww .j a va 2s . co m*/ }
From source file:ch.unifr.pai.twice.dragndrop.client.MPDragNDrop.java
License:Apache License
@Override public void initialize(Widget w, int offsetX, int offsetY, DragConfiguration conf) { this.w = w;//w w w .java2 s . c o m this.percOffsetX = (int) (100.0 / w.getOffsetWidth() * offsetX); this.percOffsetY = (int) (100.0 / w.getOffsetHeight() * offsetY); this.originDisplay = w.getElement().getStyle().getDisplay(); this.conf = conf; }
From source file:ch.unifr.pai.twice.dragndrop.client.MPDragNDrop.java
License:Apache License
/** * This method looks up all the drop targets which are intersecting with the given element. If the drop targets differ in their priorities ({@link Priority} * ), only widgets of the highest priority are returned. * //from w w w . j a v a 2s . c om * @param e * - a HTML element (typically the HTML element of the dragged widget) * @return the drop target widgets which are intersecting with the given element and do have the highest priority */ protected Set<Widget> getAffectedDropTargets(Element e) { int w1X = e.getAbsoluteLeft(); int w1Y = e.getAbsoluteTop(); int w1Width = e.getOffsetWidth(); int w1Height = e.getOffsetHeight(); Map<Integer, HashSet<Widget>> targets = new HashMap<Integer, HashSet<Widget>>(); for (Widget w2 : dropTargetRegistry.keySet()) { int w2X = w2.getAbsoluteLeft(); int w2Y = w2.getAbsoluteTop(); boolean xCollision = w1X < w2X ? w2X - w1X < w1Width : w1X - w2X < w2.getOffsetWidth(); boolean yCollision = w1Y < w2Y ? w2Y - w1Y < w1Height : w1Y - w2Y < w2.getOffsetHeight(); String idStyle = w2.getElement().getId() != null && !w2.getElement().getId().equals("") ? "hover-" + w2.getElement().getId() : null; if (xCollision && yCollision) { if (idStyle != null) { e.addClassName(idStyle); } DropTargetHandler h = dropTargetRegistry.get(w2); if (h != null) { int prio = h.getPriority().getValue(); HashSet<Widget> widgetsForPrio = targets.get(prio); if (widgetsForPrio == null) { widgetsForPrio = new HashSet<Widget>(); targets.put(prio, widgetsForPrio); } widgetsForPrio.add(w2); } } else if (idStyle != null) { e.removeClassName(idStyle); } } if (targets.isEmpty()) return null; int maxprio = 0; for (Integer i : targets.keySet()) { if (i > maxprio) { maxprio = i; } } return targets.get(maxprio); }