List of usage examples for com.google.gwt.user.client.ui PopupPanel getPopupTop
public int getPopupTop()
From source file:com.nitrous.gwt.earth.client.demo.ShimDemo.java
License:Apache License
/** * This is how to display a GWT PopupPanel over the top of the Google Earth * Plug-in using the 'shim' technique. The shim technique places an IFrame * in-front of the earth plug-in but behind the PopupPanel by configuring * the absolute position, size and z-index of the IFrame. *///from w w w.j a v a 2s .c om private void showPopupWindow() { // the HTML content to be rendered inside the PopupPanel HTML content = new HTML("<b>Window test</b><br>" + "This PopupPanel is visible since we have an IFrame (shim) between the PopupPanel and the Google Earth Plugin. " + "View source code <a href=\"" + "http://code.google.com/p/gwt-earth-3/source/browse/trunk/src/com/nitrous/gwt/earth/client/demo/ShimDemo.java\"" + " target=\"new\">here</a>"); // configure the PopupPanel size and position final PopupPanel window = new PopupPanel(false, false); window.setTitle("Shim test"); window.add(content); final int width = 300; final int height = 80; window.setSize(width + "px", height + "px"); window.center(); final int left = window.getPopupLeft(); final int top = window.getPopupTop(); // Configure the z-index of the PopupPanel HTML content so that it is rendered in-front of everything (highest z-index) content.getElement().setAttribute("style", "z-index: " + (Integer.MAX_VALUE) + ";" + " width: " + width + "px;" + " height: " + height + "px;"); // PopupPanel is to be displayed immediately behind content (slightly lower z-index) window.getElement().setAttribute("style", "z-index: " + (Integer.MAX_VALUE - 1) + ";" + " position: absolute;" + " left: " + left + "px;" + " top: " + top + "px;"); window.show(); // Allow some time for the browser to render the window and then configure the IFrame shim Scheduler.get().scheduleDeferred(new ScheduledCommand() { @Override public void execute() { final IFrameElement iframe = Document.get().createIFrameElement(); // Initialize the IFrame to be the same size and position as the // window but with a smaller z-index value. // The size of the IFrame is tweaked by +9px to allow the border of the PopupPanel to be rendered correctly. iframe.setAttribute("style", "z-index: " + (Integer.MAX_VALUE - 2) + ";" + " width: " + (width + 9) + "px;" + " height: " + (height + 9) + "px;" + " position: absolute;" + " left: " + left + "px;" + " top: " + top + "px;"); // add the IFrame to the document body Document.get().getBody().appendChild(iframe); // remove the IFrame when the PopupPanel is closed window.addCloseHandler(new CloseHandler<PopupPanel>() { @Override public void onClose(CloseEvent<PopupPanel> event) { iframe.removeFromParent(); } }); } }); }
From source file:org.openremote.manager.client.toast.PopupToastDisplay.java
License:Open Source License
protected void setRelativePosition(Collection<ToastPopupPanel> panels, ToastPopupPanel panel, int desiredLeft, int desiredTop, int originTop, int offsetHeight, int offsetWidth) { for (PopupPanel existingPanel : panels) { Rectangle existingRec = new Rectangle( new Point(existingPanel.getPopupLeft(), existingPanel.getPopupTop()), existingPanel.getOffsetWidth(), existingPanel.getOffsetHeight()); Rectangle newRec = new Rectangle(new Point(desiredLeft, desiredTop), offsetWidth, offsetHeight); // Detect collision with existing panel in grid if (existingRec.isOverlapping(newRec)) { // Calculate new grid position int newTop = desiredTop - offsetHeight - MARGIN_BOTTOM_PIXEL; if (newTop < 0) { desiredTop = originTop;//from w w w . j a v a 2s . c o m desiredLeft = desiredLeft - offsetWidth - MARGIN_RIGHT_PIXEL; } else { desiredTop = newTop; } // Recursive processing until a free slot in the grid is found setRelativePosition(panels, panel, desiredLeft, desiredTop, originTop, offsetHeight, offsetWidth); return; } } panel.setPopupPosition(desiredLeft, desiredTop); }
From source file:org.seamless.gwt.notify.client.PopupNotificationDisplay.java
License:Open Source License
protected void setRelativePosition(Collection<PopupMessagePanel> messagePanels, PopupMessagePanel messagePanel, int desiredLeft, int desiredTop, int originTop, int offsetHeight, int offsetWidth) { for (PopupPanel existingPanel : messagePanels) { Rectangle existingRec = new Rectangle( new Point(existingPanel.getPopupLeft(), existingPanel.getPopupTop()), existingPanel.getOffsetWidth(), existingPanel.getOffsetHeight()); Rectangle newRec = new Rectangle(new Point(desiredLeft, desiredTop), offsetWidth, offsetHeight); // Detect collision with existing panel in grid if (existingRec.isOverlapping(newRec)) { // Calculate new grid position int newTop = desiredTop - offsetHeight - MARGIN_BOTTOM_PIXEL; if (newTop < 0) { desiredTop = originTop;//from w w w. j a va2s. c o m desiredLeft = desiredLeft - offsetWidth - MARGIN_RIGHT_PIXEL; } else { desiredTop = newTop; } // Recursive processing until a free slot in the grid is found setRelativePosition(messagePanels, messagePanel, desiredLeft, desiredTop, originTop, offsetHeight, offsetWidth); return; } } messagePanel.setPopupPosition(desiredLeft, desiredTop); }