List of usage examples for com.google.gwt.user.client.ui Widget getOffsetWidth
@Override public int getOffsetWidth()
From source file:fi.jasoft.dragdroplayouts.client.ui.VDDAbsoluteLayout.java
License:Apache License
/** * Updates the drag details while a component is dragged * //from w w w . j av a2 s. co m * @param drag * The drag event to update the details from */ protected void updateDragDetails(VDragEvent drag) { // Get absolute coordinates int absoluteLeft = getAbsoluteLeft(); int absoluteTop = getAbsoluteTop(); drag.getDropDetails().put(Constants.DROP_DETAIL_ABSOLUTE_LEFT, absoluteLeft); drag.getDropDetails().put(Constants.DROP_DETAIL_ABSOLUTE_TOP, absoluteTop); // Get relative coordinates String offsetLeftStr = drag.getDragImage().getStyle().getMarginLeft(); int offsetLeft = Integer.parseInt(offsetLeftStr.substring(0, offsetLeftStr.length() - 2)); int relativeLeft = Util.getTouchOrMouseClientX(drag.getCurrentGwtEvent()) - canvas.getAbsoluteLeft() + offsetLeft; String offsetTopStr = drag.getDragImage().getStyle().getMarginTop(); int offsetTop = Integer.parseInt(offsetTopStr.substring(0, offsetTopStr.length() - 2)); int relativeTop = Util.getTouchOrMouseClientY(drag.getCurrentGwtEvent()) - canvas.getAbsoluteTop() + offsetTop; drag.getDropDetails().put(Constants.DROP_DETAIL_RELATIVE_LEFT, relativeLeft); drag.getDropDetails().put(Constants.DROP_DETAIL_RELATIVE_TOP, relativeTop); // Get component size Widget w = (Widget) drag.getTransferable().getData(Constants.TRANSFERABLE_DETAIL_COMPONENT); if (w != null) { drag.getDropDetails().put(Constants.DROP_DETAIL_COMPONENT_WIDTH, w.getOffsetWidth()); drag.getDropDetails().put(Constants.DROP_DETAIL_COMPONENT_HEIGHT, w.getOffsetHeight()); } else { drag.getDropDetails().put(Constants.DROP_DETAIL_COMPONENT_WIDTH, -1); drag.getDropDetails().put(Constants.DROP_DETAIL_COMPONENT_HEIGHT, -1); } // Add mouse event details MouseEventDetails details = new MouseEventDetails(drag.getCurrentGwtEvent(), getElement()); drag.getDropDetails().put(Constants.DROP_DETAIL_MOUSE_EVENT, details.serialize()); }
From source file:fr.fg.client.openjwt.ui.JSRowLayout.java
License:Open Source License
public void update() { int maxWidth = 0; int totalHeight = 0; int[] dimensions = new int[rowsCount]; // Calcule les dimensions des lignes for (int i = 0; i < rowsCount; i++) { ArrayList<Widget> components = layoutComponents.get(i); int width = 0; int rowHeight = rowsHeight.get(i); for (int j = 1; j < components.size() - 1; j++) { Widget widget = components.get(j); if (!widget.isVisible()) continue; if (widget instanceof JSComponent) { width += ((JSComponent) widget).getPixelWidth(); rowHeight = Math.max(rowHeight, ((JSComponent) widget).getPixelHeight()); } else { width += widget.getOffsetWidth(); rowHeight = Math.max(rowHeight, widget.getOffsetHeight()); }//from ww w . j a v a2s . co m } dimensions[i] = width; components.get(0).setHeight(rowHeight + "px"); components.get(components.size() - 1).setHeight(rowHeight + "px"); if (width > maxWidth) maxWidth = width; totalHeight += rowHeight; } // Calcule la marge de la ligne pour l'alignement for (int i = 0; i < rowsCount; i++) { ArrayList<Widget> components = layoutComponents.get(i); switch (rowsAlignment.get(i)) { case ALIGN_LEFT: components.get(0).setWidth("0px"); components.get(0).setHeight("0px"); int width = maxWidth - dimensions[i]; components.get(components.size() - 1).setWidth(width + "px"); if (width == 0) components.get(components.size() - 1).setHeight("0px"); break; case ALIGN_CENTER: width = (int) Math.floor((maxWidth - dimensions[i]) / 2.); components.get(0).setWidth(width + "px"); if (width == 0) components.get(0).setHeight("0px"); width = (int) Math.ceil((maxWidth - dimensions[i]) / 2.); components.get(components.size() - 1).setWidth(width + "px"); if (width == 0) components.get(components.size() - 1).setHeight("0px"); break; case ALIGN_RIGHT: width = maxWidth - dimensions[i]; components.get(0).setWidth(width + "px"); if (width == 0) components.get(0).setHeight("0px"); components.get(components.size() - 1).setWidth("0px"); components.get(components.size() - 1).setHeight("0px"); break; } } setPixelSize(maxWidth, totalHeight); }
From source file:fr.putnami.pwt.core.widget.incubating.TableFilter.java
License:Open Source License
public void redraw() { this.button.setIconType(IconFont.ICON_FILTER); this.button.setActive(this.activate); Container row = (Container) ((Widget) this.headerCell).getParent(); this.headerCell.clear(); if (this.valueChangeRegistration != null) { this.valueChangeRegistration.removeHandler(); this.valueChangeRegistration = null; }/*from w w w . j av a2 s . co m*/ boolean showFilterRow = false; if (this.activate) { this.headerCell.append(this.inputText); this.valueChangeRegistration = this.inputText.addBlurHandler(new BlurHandler() { @Override public void onBlur(BlurEvent event) { String newValue = TableFilter.this.inputText.flush(); if (!Objects.equal(TableFilter.this.filterValue, newValue)) { TableFilter.this.filterValue = newValue; TableFilter.this.getDriver().resetDisplay(); } } }); Widget hCell = this.button.getParent().getParent(); hCell.getElement().getStyle().setWidth(hCell.getOffsetWidth(), Unit.PX); showFilterRow = true; } if (!showFilterRow) { for (Widget cell : row) { if (cell instanceof TableTH) { showFilterRow |= Iterators.size(((TableTH<?>) cell).iterator()) > 0; if (showFilterRow) { break; } } } } row.setVisible(showFilterRow); }
From source file:gov.noaa.pmel.tmap.las.client.laswidget.WindowBox.java
License:Apache License
/** * Called when the minimize icon is clicked. The default implementation hides the container of the dialog box. * /*from ww w . j ava2 s . c om*/ * @param event The {@link ClickEvent} to handle */ protected void onMinimizeClick(ClickEvent event) { Widget widget = getWidget(); if (widget == null) return; boolean visible = widget.isVisible(); int offsetWidth = widget.getOffsetWidth(); widget.setVisible(!visible); this.minimized = visible; if (visible) { this.container.setWidth(offsetWidth + "px"); this.minimize.setStyleName("gwt-extras-dialog-maximize"); } else { //this.container.setWidth(0+"px"); this.minimize.setStyleName("gwt-extras-dialog-minimize"); } }
From source file:info.magnolia.ui.vaadin.gwt.client.magnoliashell.shell.ShellAppLauncher.java
License:Open Source License
private void doUpdateDivetPosition(final ShellAppType type, boolean animated) { Widget w = controlsMap.get(type); divetWrapper.getStyle().setDisplay(Display.BLOCK); switch (type) { case APPLAUNCHER: divetWrapper.setClassName("divet-green"); break;//from www.j a v a2 s. c o m case PULSE: divetWrapper.setClassName("divet-gray"); break; case FAVORITE: divetWrapper.setClassName("divet-white"); break; default: divetWrapper.setClassName("divet-white"); } int divetPos = w.getAbsoluteLeft() + (w.getOffsetWidth() / 2) - divetWrapper.getOffsetWidth() / 2; if (animated && divetWrapper.getAbsoluteLeft() != divetPos) { Logger.getLogger(getClass().getName()).log(Level.INFO, "DIVET POS: " + divetPos); divetAnimation.setProperty("left", divetPos); divetAnimation.run(DIVET_ANIMATION_SPEED, divetWrapper); } else { divetWrapper.getStyle().setLeft(divetPos, Unit.PX); } }
From source file:net.opentsdb.tsd.client.QueryUi.java
License:Open Source License
/** * Ensures all the widgets in the given panel have the same size. * Otherwise by default the panel will automatically resize itself to the * contents of the currently active panel's widget, which is annoying * because it makes a number of things move around in the UI. * @param panel The panel containing the widgets to resize. *///ww w. java2 s. c o m private static void ensureSameWidgetSize(final DecoratedTabPanel panel) { if (!panel.isAttached()) { throw new IllegalArgumentException("panel not attached: " + panel); } int maxw = 0; int maxh = 0; for (final Widget widget : panel) { final int w = widget.getOffsetWidth(); final int h = widget.getOffsetHeight(); if (w > maxw) { maxw = w; } if (h > maxh) { maxh = h; } } if (maxw == 0 || maxh == 0) { throw new IllegalArgumentException("maxw=" + maxw + " maxh=" + maxh); } for (final Widget widget : panel) { setOffsetWidth(widget, maxw); setOffsetHeight(widget, maxh); } }
From source file:net.opentsdb.tsd.client.QueryUi.java
License:Open Source License
/** * Properly sets the total width of a widget. * This takes into account decorations such as border, margin, and padding. *//*ww w . ja v a2s.c o m*/ private static void setOffsetWidth(final Widget widget, int width) { widget.setWidth(width + "px"); final int offset = widget.getOffsetWidth(); if (offset > 0) { width -= offset - width; if (width > 0) { widget.setWidth(width + "px"); } } }
From source file:org.adamtacy.client.ui.effects.impl.browsers.EffectImplementationIE6.java
License:Apache License
/** * Reflects an image//w ww. j av a 2 s. co m */ @Override public void reflectImage(final NEffectPanel thePanel, final int height, final double opacity, final int gap, boolean setUp) { final DockPanel container = new DockPanel(); final Image v = new Image(); SimplePanel gapPanel; Widget w = thePanel.getPanelWidget(); if (!(w instanceof Image)) { w = ((VerticalPanel) w).getWidget(0); } // For some reason when reloading a page in IE a complete refresh is not // made // and so this effect is not fired; by adding this load listener overcomes // this problem // go figure...... if (!loaded) { ((Image) w).addLoadHandler(theIEFix); loaded = true; } else { // ((Image) w).removeLoadHandler(theIEFix); } gapPanel = new SimplePanel(); gapPanel.setWidth("100%"); gapPanel.add(new HTML(" ")); gapPanel.setHeight(gap + "px"); int imgWidth = w.getOffsetWidth(); int imgHeight = w.getOffsetHeight(); int canvasHeight = new Double(imgHeight * height / 100).intValue(); v.setUrl(((Image) w).getUrl()); v.getElement().getStyle().setProperty("filter", "flipv progid:DXImageTransform.Microsoft.Alpha(opacity=" + (opacity * 100) + ", style=1, finishOpacity=0, startx=0, starty=0, finishx=0, finishy=" + (height * 100) + ")"); v.setHeight(canvasHeight + "px"); v.setWidth(imgWidth + "px"); thePanel.remove(w); container.add(w, DockPanel.NORTH); container.add(v, DockPanel.SOUTH); container.add(gapPanel, DockPanel.CENTER); thePanel.add(container); }
From source file:org.adamtacy.client.ui.effects.impl.browsers.EffectImplementationStandard.java
License:Apache License
/** * Reflects an image by creating a DockPanel where the original image is place * in the top and a canvas object containing a refection of the original image * is placed below. At the moment I can't seem to reuse the original canvas so * if any action is performed requiring the reflection to be re-drawn a new * canvas object is required (compare that to the Opera version where reuse is * possible)//from w ww. j a va2 s. c om * * @param gap */ public void reflectImage(NEffectPanel thePanel, int height, double opacity, int gap, boolean setUp) { DockPanel container; Widget w; SimplePanel gapPanel; Canvas v; w = getReflectedImage(thePanel, setUp); if (setUp) { v = new Canvas(); container = (DockPanel) thePanel.getPanelWidget(); // Remove from panel now as this may make any animations look much // smoother // If not, there is a danger on slow(er) systems that the reflection hangs // out from image until re-drawn. container.remove(WHERE_IS_REFLECTION); } else { container = new DockPanel(); v = new Canvas(); } gapPanel = new SimplePanel(); gapPanel.setWidth("100%"); gapPanel.add(new HTML(" ")); gapPanel.setHeight(gap + "px"); int imgWidth = w.getOffsetWidth(); int imgHeight = w.getOffsetHeight(); int canvasHeight = (int) ((imgHeight * height) / 100); v.setSize(imgWidth, canvasHeight); reflect(v.getElement(), w.getElement(), canvasHeight, opacity); if (setUp) { container.add(v, DockPanel.SOUTH); } else { container.add(w, DockPanel.NORTH); container.add(v, DockPanel.SOUTH); thePanel.add(container); } container.add(gapPanel, DockPanel.CENTER); }
From source file:org.apache.solr.explorer.client.core.manager.ui.WidgetProgressIndicator.java
License:Apache License
/** * Constructs a new MessageProgressIndicator with a given initial message to be displayed. * * @param widget The widget this indicator is for. * @param message The initial message to be displayed. *///ww w . jav a 2 s .c om public WidgetProgressIndicator(final Widget widget, String message) { super(false, true); messageLabel = new Label(message); messageLabel.setStyleName("Label"); setPopupPositionAndShow(new PositionCallback() { public void setPosition(int offsetWidth, int offsetHeight) { int left = widget.getAbsoluteLeft(); int top = widget.getAbsoluteTop(); setPopupPosition(left, top); } }); CenterPanel centerPanel = new CenterPanel(messageLabel); centerPanel.setSize(widget.getOffsetWidth() + "px", widget.getOffsetHeight() + "px"); setWidget(centerPanel); setStyleName("WidgetProgressIndicator"); addStyleName("transparent-50"); }