List of usage examples for com.google.gwt.user.client.ui Widget getAbsoluteTop
public int getAbsoluteTop()
From source file:org.drools.guvnor.client.ruleeditor.VersionBrowser.java
License:Apache License
private void restore(Widget w, final String versionUUID, final Command refresh) { final CheckinPopup pop = new CheckinPopup(w.getAbsoluteLeft() + 10, w.getAbsoluteTop() + 10, "Restore this version?"); pop.setCommand(new Command() { public void execute() { RepositoryServiceFactory.getService().restoreVersion(versionUUID, uuid, pop.getCheckinComment(), new GenericCallback() { public void onSuccess(Object data) { refresh.execute(); }/* w w w. java 2s. c om*/ }); } }); pop.show(); }
From source file:org.drools.guvnor.client.ruleeditor.VersionBrowser.java
License:Apache License
private void restore(Widget w, final Command refresh, final String versionUUID, final String headUUID) { final CheckinPopup pop = new CheckinPopup(w.getAbsoluteLeft() + 10, w.getAbsoluteTop() + 10, "Restore this version?"); pop.setCommand(new Command() { public void execute() { RepositoryServiceFactory.getService().restoreVersion(versionUUID, headUUID, pop.getCheckinComment(), new GenericCallback() { public void onSuccess(Object data) { refresh.execute(); }//from www.j a va 2 s. c o m }); } }); pop.show(); }
From source file:org.ednovo.gooru.client.mvp.dnd.PickupDragController.java
License:Open Source License
@Override public void dragStart() { super.dragStart(); lastResetCacheTimeMillis = System.currentTimeMillis(); WidgetLocation currentDraggableLocation = new WidgetLocation(context.draggable, context.boundaryPanel); if (getBehaviorDragProxy()) { movablePanel = newDragProxy(context); context.boundaryPanel.add(movablePanel, currentDraggableLocation.getLeft(), currentDraggableLocation.getTop()); checkGWTIssue1813(movablePanel, context.boundaryPanel); } else {/*from ww w . j a v a 2 s .c o m*/ saveSelectedWidgetsLocationAndStyle(); AbsolutePanel container = new AbsolutePanel(); container.getElement().getStyle().setProperty("overflow", "visible"); container.setPixelSize(context.draggable.getOffsetWidth(), context.draggable.getOffsetHeight()); context.boundaryPanel.add(container, currentDraggableLocation.getLeft(), currentDraggableLocation.getTop()); checkGWTIssue1813(container, context.boundaryPanel); int draggableAbsoluteLeft = context.draggable.getAbsoluteLeft(); int draggableAbsoluteTop = context.draggable.getAbsoluteTop(); HashMap<Widget, CoordinateLocation> widgetLocation = new HashMap<Widget, CoordinateLocation>(); draggedElementStartLeft = draggableAbsoluteLeft; draggedElementStartTop = draggableAbsoluteTop; for (Widget widget : context.selectedWidgets) { widgetLocation.put(widget, new CoordinateLocation(widget.getAbsoluteLeft(), widget.getAbsoluteTop())); } context.dropController = getIntersectDropController(context.mouseX, context.mouseY); if (context.dropController != null) { context.dropController.onEnter(context); } for (Widget widget : context.selectedWidgets) { Location location = widgetLocation.get(widget); int relativeX = location.getLeft() - draggableAbsoluteLeft; int relativeY = location.getTop() - draggableAbsoluteTop; container.add(widget, relativeX, relativeY); } movablePanel = container; } movablePanel.addStyleName(DragClientBundle.INSTANCE.css().movablePanel()); calcBoundaryOffset(); dropTargetClientWidth = DOMUtil.getClientWidth(context.boundaryPanel.getElement()); dropTargetClientHeight = DOMUtil.getClientHeight(context.boundaryPanel.getElement()); }
From source file:org.freemedsoftware.gwt.client.Util.java
License:Open Source License
/** * Attaches the mouseover help popup/*w w w . j a va 2 s . co m*/ * * @param widget * - Widget for which mouseover help popup is required * * @param title * - title of the help dialog * * @param help * - detailed text explaining the topic * */ public static void attachHelp(final Widget widget, String title, String help, final boolean showOnLeft) { final PopupPanel popup = new PopupPanel(); final HTML html = new HTML(); html.setHTML("<b>" + title + "</b><br/><br/>" + help); popup.add(html); popup.setStyleName("freemed-HelpPopup"); if (widget instanceof FocusWidget) { ((FocusWidget) widget).addMouseOutHandler(new MouseOutHandler() { @Override public void onMouseOut(MouseOutEvent event) { // Hide help PopUp popup.hide(); } }); ((FocusWidget) widget).addMouseDownHandler(new MouseDownHandler() { @Override public void onMouseDown(MouseDownEvent event) { // Hide help PopUp popup.hide(); } }); ((FocusWidget) widget).addMouseMoveHandler(new MouseMoveHandler() { @Override public void onMouseMove(MouseMoveEvent event) { // Do nothing popup.show(); popup.setPopupPosition( widget.getAbsoluteLeft() + (showOnLeft ? -1 * popup.getOffsetWidth() : 20), widget.getAbsoluteTop() + 20); } }); } else if (widget instanceof Image) { ((Image) widget).addMouseOutHandler(new MouseOutHandler() { @Override public void onMouseOut(MouseOutEvent event) { // Hide help PopUp popup.hide(); } }); ((Image) widget).addMouseDownHandler(new MouseDownHandler() { @Override public void onMouseDown(MouseDownEvent event) { // Hide help PopUp popup.hide(); } }); ((Image) widget).addMouseMoveHandler(new MouseMoveHandler() { @Override public void onMouseMove(MouseMoveEvent event) { // Do nothing popup.show(); popup.setPopupPosition( widget.getAbsoluteLeft() + (showOnLeft ? -1 * popup.getOffsetWidth() : 20), widget.getAbsoluteTop() + 20); } }); } }
From source file:org.gems.ajax.client.util.Util.java
License:Open Source License
public static int getDiagramY(Widget w) { return w.getAbsoluteTop() - getContainerY(findParentDiagram(w)); }
From source file:org.gwm.splice.client.desktop.DesktopManager.java
License:Apache License
public boolean canDrop(Widget widget) { RootPanel rp = RootPanel.get();//from w w w .j av a 2s . c o m int x = widget.getAbsoluteLeft(); int y = widget.getAbsoluteTop(); int h = widget.getOffsetHeight(); int w = widget.getAbsoluteLeft(); boolean overlapX = false; boolean overlapY = false; for (Iterator iter = rp.iterator(); iter.hasNext();) { Widget child = (Widget) iter.next(); if (child == widget) { continue; } int cx = child.getAbsoluteLeft(); int cy = child.getAbsoluteTop(); int ch = child.getOffsetHeight(); int cw = child.getOffsetWidth(); if (x == cx || y == cy) { return false; } if (x > cx) { if (x <= (cx + cw)) { overlapX = true; } } else if (x < cx) { if ((x + w) >= cx) { overlapX = true; } } if (y > cy) { if (y <= (cy + ch)) { overlapY = true; } } else if (y < cy) { if ((y + h) >= cy) { overlapY = true; } } if (overlapX && overlapY) { return false; } } return true; }
From source file:org.gwt.mosaic.ui.client.layout.CustomGridLayout.java
License:Apache License
/** * Lays out the specified {@link LayoutPanel} using this layout. * <p>//from w w w . j a v a2 s. c o m * The grid layout manager determines the size of individual widgets by * dividing the free space in the panel into equal-sized portions according to * the number of rows and columns in the layout. The container's free space * equals the container's size minus any margins and any specified horizontal * or vertical gap. * * @param layoutPanel the panel in which to do the layout * * @see org.gwt.mosaic.ui.client.layout.LayoutManager#layoutPanel(org.gwt.mosaic.ui.client.layout.LayoutPanel) */ public void layoutPanel(LayoutPanel layoutPanel) { try { if (layoutPanel == null || !init(layoutPanel)) { return; } final Dimension box = DOM.getClientSize(layoutPanel.getElement()); final int left = paddingLeftMeasure.sizeOf(layoutPanel); final int top = paddingTopMeasure.sizeOf(layoutPanel); int width = box.width - (left + paddingRightMeasure.sizeOf(layoutPanel)); int height = box.height - (top + paddingBottomMeasure.sizeOf(layoutPanel)); final int spacing = layoutPanel.getWidgetSpacing(); // adjust for spacing width -= ((cols - 1) * spacing); height -= ((rows - 1) * spacing); final int colWidth = width / cols; final int rowHeight = height / rows; for (int r = 0; r < rows; r++) { for (int c = 0; c < cols; c++) { Widget widget = widgetMatrix[c][r]; if (widget == null || widget == SPAN) { continue; } if (widget instanceof InternalDecoratorPanel) { widget = ((InternalDecoratorPanel) widget).getWidget(); } int cellWidth; int cellHeight; final GridLayoutData layoutData = (GridLayoutData) widget.getLayoutData(); final Widget parent = widget.getParent(); if (parent instanceof InternalDecoratorPanel) { final InternalDecoratorPanel decPanel = (InternalDecoratorPanel) parent; final int borderSizes[] = decPanel.getBorderSizes(); final Dimension decPanelFrameSize = new Dimension(borderSizes[1] + borderSizes[3], borderSizes[0] + borderSizes[0]); cellWidth = colWidth * layoutData.colspan - decPanelFrameSize.width + spacing * (layoutData.colspan - 1); cellHeight = rowHeight * layoutData.rowspan - decPanelFrameSize.height + spacing * (layoutData.rowspan - 1); } else { cellWidth = colWidth * layoutData.colspan + spacing * (layoutData.colspan - 1); cellHeight = rowHeight * layoutData.rowspan + spacing * (layoutData.rowspan - 1); } HorizontalAlignmentConstant hAlignment = layoutData.getHorizontalAlignment(); if (hAlignment == null) { hAlignment = getHorizontalAlignment(); } Dimension prefSize = null; if (hAlignment == null) { layoutData.targetLeft = left + (spacing + colWidth) * c; layoutData.targetWidth = cellWidth; } else { // (ggeorg) this call to WidgetHelper.getPreferredSize() is // required even for ALIGN_LEFT prefSize = new Dimension(preferredWidthMeasure.sizeOf(widget), preferredHeightMeasure.sizeOf(widget)); if (HasHorizontalAlignment.ALIGN_LEFT == hAlignment) { layoutData.targetLeft = left + (spacing + colWidth) * c; } else if (HasHorizontalAlignment.ALIGN_CENTER == hAlignment) { layoutData.targetLeft = left + (spacing + colWidth) * c + (cellWidth / 2) - prefSize.width / 2; } else { layoutData.targetLeft = left + (spacing + colWidth) * c + cellWidth - prefSize.width; } layoutData.targetWidth = prefSize.width; } VerticalAlignmentConstant vAlignment = layoutData.getVerticalAlignment(); if (vAlignment == null) { vAlignment = getVerticalAlignment(); } if (vAlignment == null) { layoutData.targetTop = top + (spacing + rowHeight) * r; layoutData.targetHeight = cellHeight; } else { if (prefSize == null) { // (ggeorg) this call to WidgetHelper.getPreferredSize() is // required even for ALIGN_TOP prefSize = new Dimension(preferredWidthMeasure.sizeOf(widget), preferredHeightMeasure.sizeOf(widget)); } if (HasVerticalAlignment.ALIGN_TOP == vAlignment) { layoutData.targetTop = top + (spacing + rowHeight) * r; } else if (HasVerticalAlignment.ALIGN_MIDDLE == vAlignment) { layoutData.targetTop = top + (spacing + rowHeight) * r + (cellHeight / 2) - prefSize.height / 2; } else { layoutData.targetTop = top + (spacing + rowHeight) * r + cellHeight - prefSize.height; } layoutData.targetHeight = prefSize.height; } if (layoutPanel.isAnimationEnabled()) { layoutData.setSourceLeft(widget.getAbsoluteLeft() - layoutPanel.getAbsoluteLeft()); layoutData.setSourceTop(widget.getAbsoluteTop() - layoutPanel.getAbsoluteTop()); layoutData.setSourceWidth(widget.getOffsetWidth()); layoutData.setSourceHeight(widget.getOffsetHeight()); } } } super.layoutPanel(layoutPanel); } catch (Exception e) { GWT.log(e.getMessage(), e); Window.alert(this.getClass().getName() + ".layoutPanel(): " + e.getLocalizedMessage()); } }
From source file:org.gwtportlets.portlet.client.edit.PageEditorMenuBar.java
License:Open Source License
protected void onLoad() { super.onLoad(); final Widget p = getParent(); if (!(p instanceof PopupPanel)) { return;//from w w w.jav a2 s. co m } // reposition the popup so it does not go off screen etc p.setVisible(false); final int left = p.getAbsoluteLeft(); final int top = p.getAbsoluteTop(); LDOM.setPosition(p.getElement(), 0, 0); // put here so size is not constrained DeferredCommand.addCommand(new Command() { public void execute() { Rectangle nextTo = new Rectangle(); nextTo.x = left; nextTo.y = top; nextTo.width = 1; nextTo.height = 1; Rectangle r = LDOM.getNextToPosition(p.getOffsetWidth(), p.getOffsetHeight(), nextTo, true, 0); LDOM.setPosition(p.getElement(), r.x, r.y); p.setVisible(true); } }); }
From source file:org.gwtportlets.portlet.client.edit.row.RowLayoutEditor.java
License:Open Source License
/** * Figure out the best index for widget in our container assuming it is * dropped at clientX and clientY.// w w w . j ava2 s . c om */ private int getDropIndex(int clientX, int clientY) { int wc = container.getWidgetCount(); if (getTargetLayout().isColumn()) { for (int i = wc - 1; i >= 0; i--) { Widget w = container.getWidget(i); int top = w.getAbsoluteTop(); if (clientY >= top) { return clientY >= top + w.getOffsetHeight() * 2 / 3 ? i + 1 : i; } } } else { for (int i = wc - 1; i >= 0; i--) { Widget w = container.getWidget(i); int left = w.getAbsoluteLeft(); if (clientX >= left) { return clientX >= left + w.getOffsetWidth() * 2 / 3 ? i + 1 : i; } } } return 0; }
From source file:org.jboss.ballroom.client.util.LoadingOverlay.java
License:Open Source License
public static void on(Widget parent, boolean loading) { if (parent != null && loading) { int left = parent.getAbsoluteLeft(); int top = parent.getAbsoluteTop(); int width = parent.getOffsetWidth(); int height = parent.getOffsetHeight(); p = new PopupPanel(); //p.setStylePrimaryName("bpm-loading-overlay"); p.setWidget(new Image("images/loading_lite.gif")); p.setPopupPosition(left + (width / 2) - 15, top + (height / 2) - 15); p.show();/*from w w w .j ava2 s. c o m*/ } else { if (p != null) { p.hide(); p = null; } } }