List of usage examples for com.google.gwt.user.client.ui PopupPanel getOffsetWidth
@Override public int getOffsetWidth()
From source file:com.ponysdk.ui.terminal.ui.PTPopupPanel.java
License:Apache License
@Override public void addHandler(final PTInstruction addHandler, final UIService uiService) { final String handler = addHandler.getString(HANDLER.KEY); if (HANDLER.KEY_.POPUP_POSITION_CALLBACK.equals(handler)) { final PopupPanel popupPanel = cast(); popupPanel.setVisible(false);/* w w w . j a v a 2 s . c o m*/ popupPanel.show(); final PTInstruction eventInstruction = new PTInstruction(); eventInstruction.setObjectID(addHandler.getObjectID()); eventInstruction.put(TYPE.KEY, TYPE.KEY_.EVENT); eventInstruction.put(HANDLER.KEY, HANDLER.KEY_.POPUP_POSITION_CALLBACK); eventInstruction.put(PROPERTY.OFFSETWIDTH, popupPanel.getOffsetWidth()); eventInstruction.put(PROPERTY.OFFSETHEIGHT, popupPanel.getOffsetHeight()); eventInstruction.put(PROPERTY.CLIENT_WIDTH, Window.getClientWidth()); eventInstruction.put(PROPERTY.CLIENT_HEIGHT, Window.getClientHeight()); uiService.triggerEvent(eventInstruction); return; } super.addHandler(addHandler, uiService); }
From source file:com.totsp.gwittir.client.validator.PopupValidationFeedback.java
License:Open Source License
public void handleException(Object source, ValidationException exception) { final Widget w = (Widget) source; final PopupPanel p = new PopupPanel(false); popups.put(source, p);// w w w. j a v a 2s .co m p.setStyleName("gwittir-ValidationPopup"); p.setWidget(new Label(this.getMessage(exception))); p.setPopupPosition(-5000, -5000); p.show(); if (this.position == BOTTOM) { p.setPopupPosition(w.getAbsoluteLeft(), w.getAbsoluteTop() + w.getOffsetHeight()); } else if (this.position == RIGHT) { p.setPopupPosition(w.getAbsoluteLeft() + w.getOffsetWidth(), w.getAbsoluteTop()); } else if (this.position == LEFT) { p.setPopupPosition(w.getAbsoluteLeft() - p.getOffsetWidth(), w.getAbsoluteTop()); } else if (this.position == TOP) { p.setPopupPosition(w.getAbsoluteLeft(), w.getAbsoluteTop() - p.getOffsetHeight()); } if (w instanceof SourcesPropertyChangeEvents) { GWT.log("is PCE", null); PropertyChangeListener attachListener = new PropertyChangeListener() { 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:next.common.ui.ui.Logger.java
License:Apache License
public static void debug(PopupPanel popup) { Element el = DOM.getElementById(ElementIds.DEBUG); if (el != null) { Logger.debug("offsetWidth:" + popup.getOffsetWidth() + ", offsetHeight:" + popup.getOffsetHeight() + "<br>" + ", ClientWidth" + Window.getClientWidth() + ", ClientHeight" + Window.getClientHeight() + "<br>ScrollLeft" + Window.getScrollLeft() + ", ScrollTop" + Window.getScrollTop()); }/* w ww. j a v a2 s .c o m*/ }
From source file:org.freemedsoftware.gwt.client.Util.java
License:Open Source License
/** * Attaches the mouseover help popup/*ww w . j a va2 s .c om*/ * * @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.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;/*w w w .java 2 s.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;/* www . j a va2 s.co 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); }
From source file:stroom.widget.popup.client.view.PopupSupportImpl.java
License:Apache License
@Override public void show(final PopupType popupType, final PopupPosition popupPosition, final PopupSize popupSize, final PopupUiHandlers popupUiHandlers) { this.popupUiHandlers = popupUiHandlers; if (popup == null) { popup = createPopup(popupType, popupSize, popupUiHandlers); }//from w ww .j a v a2s . com final PopupPanel popupPanel = (PopupPanel) popup; // Hide the popup because we are going to position it before making it // visible. popupPanel.setVisible(false); // Way to set popups to be non modal for now. if (modal != null) { popupPanel.setModal(modal); } // Set the popup size. if (popupSize != null) { popupPanel.setWidth(popupSize.getWidth() + "px"); popupPanel.setHeight(popupSize.getHeight() + "px"); } // Add auto hide partners. if (autoHidePartners != null && autoHidePartners.size() > 0) { for (final Element element : autoHidePartners) { popupPanel.addAutoHidePartner(element); } } // Attach the popup to the DOM. popupPanel.show(); // Defer the command to position and make visible because we need the // popup to size first. Scheduler.get().scheduleDeferred(new ScheduledCommand() { @Override public void execute() { if (popup != null) { // Now get the popup size. final int w = popupPanel.getOffsetWidth(); final int h = popupPanel.getOffsetHeight(); if (popupPosition == null) { // Center the popup in the client window. centerPopup(popup, w, h); } else { // Position the popup so it is as close as possible to // the required location but is all on screen. positionPopup(popup, popupType, popupPosition, w, h); } // Make the popup visible. popupPanel.setVisible(true); popupPanel.getElement().getStyle().setOpacity(1); // Tell the view that the popup is visible if necessary. onShow(); } } }); }