List of usage examples for com.google.gwt.user.client.ui PopupPanel hide
public void hide(boolean autoClosed)
From source file:com.threerings.gwt.util.PopupStack.java
License:Open Source License
/** * Pushes any currently showing popup onto the stack and displays the supplied popup. The popup * will centered horizontally in the page and centered vertically around the supplied widget. *//*from ww w .ja v a 2 s.c o m*/ public void show(PopupPanel popup, Widget onCenter) { // determine the ypos of our onCenter target in case it's in the currently popped up popup, // because after we hide that popup we won't be able to compute it int ypos = (onCenter == null) ? 0 : (onCenter.getAbsoluteTop() + onCenter.getOffsetHeight() / 2); PopupPanel showing = _showingPopup.get(); if (showing != null) { // null _showingPopup before hiding to avoid triggering the close handler logic _popups.add(showing); _showingPopup.update(null); showing.hide(true); } if (onCenter == null) { popup.center(); // this will show the popup } else { Popups.centerOn(popup, ypos).show(); } // now that we've centered and shown our popup (which may have involved showing, hiding and // showing it again), we can add a close handler and listen for it to actually close popup.addCloseHandler(new CloseHandler<PopupPanel>() { public void onClose(CloseEvent<PopupPanel> event) { if (_showingPopup.get() == event.getTarget()) { if (_popups.size() > 0) { _showingPopup.update(_popups.remove(_popups.size() - 1)); _showingPopup.get().show(); } else { _showingPopup.update(null); } } } }); _showingPopup.update(popup); }
From source file:org.drools.guvnor.client.widgets.tables.ColumnPicker.java
License:Apache License
public ToggleButton createToggleButton() { final ToggleButton button = new ToggleButton(COLUMN_PICKER_IMAGE); final PopupPanel popup = new PopupPanel(true); popup.addAutoHidePartner(button.getElement()); popup.addCloseHandler(new CloseHandler<PopupPanel>() { public void onClose(CloseEvent<PopupPanel> popupPanelCloseEvent) { button.setDown(false);//from w ww .j ava 2s .c om } }); VerticalPanel popupContent = new VerticalPanel(); for (final ColumnMeta<T> columnMeta : columnMetaList) { final CheckBox checkBox = new CheckBox(columnMeta.getHeader().getValue()); checkBox.setValue(columnMeta.isVisible()); checkBox.addValueChangeHandler(new ValueChangeHandler<Boolean>() { public void onValueChange(ValueChangeEvent<Boolean> booleanValueChangeEvent) { boolean visible = booleanValueChangeEvent.getValue(); if (visible) { // WORKAROUND because CellTable does not support insertColumn at this time for (ColumnMeta<T> resettingColumnMeta : columnMetaList) { if (resettingColumnMeta.isVisible()) { cellTable.removeColumn(resettingColumnMeta.getColumn()); } } columnMeta.setVisible(visible); for (ColumnMeta<T> resettingColumnMeta : columnMetaList) { if (resettingColumnMeta.isVisible()) { cellTable.addColumn(resettingColumnMeta.getColumn(), resettingColumnMeta.getHeader()); } } } else { columnMeta.setVisible(visible); cellTable.removeColumn(columnMeta.getColumn()); } } }); popupContent.add(checkBox); } popup.add(popupContent); button.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { if (button.isDown()) { popup.setPopupPosition(button.getAbsoluteLeft(), button.getAbsoluteTop() + button.getOffsetHeight()); popup.show(); } else { popup.hide(false); } } }); return button; }