public CreateGroupWidget(UserGroup parent) { initComponents(); this.parent = parent; int row = 0; createTable.setWidget(row, 0, closeLink); createTable.getFlexCellFormatter().setColSpan(row, 0, 2); row += 1; createTable.setHTML(row, 0, "<b>Name</b>"); createTable.setWidget(row, 1, groupName); row += 1; createTable.setHTML(row, 0, "<b>Description</b>"); createTable.setWidget(row, 1, groupDescription); row += 1; createTable.setWidget(row, 0, table); createTable.getFlexCellFormatter().setColSpan(row, 0, 2); row += 1; createTable.setWidget(row, 0, createButton); createTable.getFlexCellFormatter().setHorizontalAlignment(row, 0, HasAlignment.ALIGN_RIGHT); createTable.setWidget(row, 1, cancelButton); popup.setWidget(createTable); popup.setGlassEnabled(true); popup.setGlassStyleName("dialog_box_glass"); closeLink.addClickHandler(new CloseWidgetHandler()); cancelButton.addClickHandler(new CloseWidgetHandler()); }
/** * Creates an empty dialog box specifying its "auto-hide" property. It should not be shown until * its child widget has been added using {@link #add(Widget)}. * * @param autoHide <code>true</code> if the dialog should be automatically hidden when the user * clicks outside of it * @param modal <code>true</code> if keyboard and mouse events for widgets not contained by the * dialog should be ignored */ public MyDialogBox(boolean autoHide, boolean modal) { super(autoHide, modal); dock = new HorizontalPanel(); dock.add(caption); HorizontalPanel hp = new HorizontalPanel(); hp.setSpacing(0); dock.setHorizontalAlignment(HorizontalPanel.ALIGN_RIGHT); listener = new DialogListener(this); minimiseBtn.addClickListener(listener); maximiseBtn.addClickListener(listener); closeBtn.addClickListener(listener); hp.add(minimiseBtn); hp.add(maximiseBtn); hp.add(closeBtn); dock.add(hp); panel.add(dock); panel.setHeight("100%"); panel.setSpacing(0); sp = new ScrollPanel(); panel.add(sp); super.setWidget(panel); setStyleName("gwt-DialogBox"); dock.setStyleName("Caption"); caption.addMouseListener(this); }
private void showMessagePopup() { Label validationMessageLabel = new Label(); validationMessageLabel.setStyleName("validation-textbox-message-label"); // $NON-NLS-1$ validationMessageLabel.setText(getValidationMessage()); VerticalPanel messagePanel = new VerticalPanel(); messagePanel.add(validationMessageLabel); HorizontalPanel bottomPanel = new HorizontalPanel(); SimplePanel hSpacer = new SimplePanel(); hSpacer.setStylePrimaryName("validation-textbox-left-image-buffer"); // $NON-NLS-1$ bottomPanel.add(hSpacer); SimplePanel tailImagePanel = new SimplePanel(); image = new Image(GWT.getModuleBaseURL() + "images/spacer.gif"); // $NON-NLS-1$ image.setStylePrimaryName("validation-textbox-tail-image"); // $NON-NLS-1$ tailImagePanel.add(image); bottomPanel.add(tailImagePanel); messagePanel.add(bottomPanel); popupPanel = new PopupPanel(true, false); popupPanel.setWidget(messagePanel); popupPanel.setPopupPositionAndShow( new PositionCallback() { public void setPosition(int offsetWidth, int offsetHeight) { int absLeft = -1; int absTop = -1; absLeft = textBox.getAbsoluteLeft(); absTop = textBox.getAbsoluteTop(); Rectangle popupSize = ElementUtils.getSize(popupPanel.getElement()); popupPanel.setPopupPosition( absLeft, absTop - popupSize.height >= 0 ? absTop - popupSize.height : absTop); } }); popupPanel.show(); }
/** Creates the conditions group operator popup. */ private void setupPopup() { popup = new PopupPanel(true, true); MenuBar menuBar = new MenuBar(true); menuBar.addItem( CONDITIONS_OPERATOR_TEXT_ALL, true, new Command() { public void execute() { popup.hide(); setText(CONDITIONS_OPERATOR_TEXT_ALL); } }); menuBar.addSeparator(); menuBar.addItem( CONDITIONS_OPERATOR_TEXT_ANY, true, new Command() { public void execute() { popup.hide(); setText(CONDITIONS_OPERATOR_TEXT_ANY); } }); // menuBar.addSeparator(); // menuBar.addItem(CONDITIONS_OPERATOR_TEXT_NONE,true,new Command(){ // public void execute() {popup.hide(); setText(CONDITIONS_OPERATOR_TEXT_NONE);}}); // // menuBar.addSeparator(); // menuBar.addItem(CONDITIONS_OPERATOR_TEXT_NOT_ALL,true, new Command(){ // public void execute() {popup.hide(); setText(CONDITIONS_OPERATOR_TEXT_NOT_ALL);}}); popup.setWidget(menuBar); }
/** Show lightbox */ public void show() { int w = getWidth(); int h = getHeight(); background.setWidth(Integer.toString(w)); background.setHeight(Integer.toString(h)); if (GWT.isScript()) { background.setWidget(png = new PNGImage("images/lightbox.png", w, h)); } background.setPopupPosition(0, 0); hideSelects(); background.show(); backgroundFixup(background.getElement()); /** * Using setPopupPositionAndShow so child popup will not jump when centering * * @author Luis Faria */ child.setPopupPositionAndShow( new PositionCallback() { public void setPosition(int offsetWidth, int offsetHeight) { center(offsetWidth, offsetHeight); } }); }
private PopupPanel createPopup() { PopupPanel p = new PopupPanel(true, false); p.setWidget(suggestionMenu); p.setStyleName(STYLE_NAME_POPUP_PANEL); p.setPreviewingAllNativeEvents(true); p.addAutoHidePartner(getTextBox().getElement()); return p; }
public static void tip(String message, UIObject target) { HTML messageLabel = new HTML(message); messageLabel.addStyleName("content"); PopupPanel tip = new DecoratedPopupPanel(true); tip.addStyleName("tip-box"); tip.setWidget(messageLabel); tip.showRelativeTo(target); }
// @UiHandler({"edit_field"}) public void editFieldCmd(ClickEvent ev) { PopupPanel p = new PopupPanel(); // p.setTitle("Редактирование поля..."); p.setModal(true); // p.setPopupPosition(200, 200); p.setSize("100%", "100%"); p.setWidget(new FieldEditor(new MultiValuedField(this.dto, null, this.filling, base_name), p)); p.show(); p.center(); }
// @UiHandler({"edit_items"}) public void editItemsCmd(ClickEvent ev) { PopupPanel p = new PopupPanel(true); // p.setTitle("Редактирование элементов..."); p.setModal(false); // p.setPopupPosition(200, 200); p.setSize("100%", "100%"); p.setWidget(new MultiValuedEntity(this.dto, null, this.filling, "", this)); p.show(); p.center(); }
/** Creates a new instance of PopupDatePicker */ public PopupDatePicker() { Binding b = new Binding(label, "value", null, base, "value", converter); b.setLeft(); b.bind(); pp.setWidget(base); this.hp.add(this.label); this.hp.add(this.icon); fp.setWidget(hp); this.initWidget(fp); this.setStyleName("gwittir-PopupDatePicker"); icon.addClickListener( new ClickListener() { public void onClick(Widget sender) { fp.setFocus(true); if (pp.isAttached()) { pp.hide(); } else { int width = Window.getClientWidth() + Window.getScrollLeft(); pp.setPopupPosition(getAbsoluteLeft(), getAbsoluteTop() + getOffsetHeight()); base.addCalendarListener( new CalendarListener() { public boolean onDateClicked(Calendar calendar, Date date) { if (date.getMonth() != base.getRenderDate().getMonth() || date.getYear() != base.getRenderDate().getYear()) { return true; } pp.hide(); calendar.removeCalendarListener(this); return true; } }); pp.show(); if (pp.getPopupLeft() + base.getOffsetWidth() > width) { pp.setPopupPosition( pp.getPopupLeft() + (width - pp.getPopupLeft() - base.getOffsetWidth()), pp.getPopupTop()); } } } }); this.base.addPropertyChangeListener( "value", new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { if (!hasFirstSet) { hasFirstSet = true; } else { changes.firePropertyChange("value", evt.getOldValue(), evt.getNewValue()); } } }); }
@SuppressWarnings("unchecked") @Override protected void showSuggestions( final SuggestBox suggestBox, Collection<? extends Suggestion> suggestions, boolean isDisplayStringHTML, boolean isAutoSelectEnabled, final SuggestionCallback callback) { // Hide popup if not needed boolean anySuggestions = suggestions != null && suggestions.size() > 0; if (!anySuggestions) { hideSuggestions(); return; } // Create suggestion popup and suggestions table widget if (suggestionPopup == null) { suggestionPopup = createPopup(); } // Hide the popup before we manipulate the menu within it. if (suggestionPopup.isAttached()) { suggestionPopup.hide(); } // Link the popup autoHide to the TextBox. // If the suggest box has changed, free the old one first. if (suggestBox != null) { suggestionPopup.removeAutoHidePartner(suggestBox.getElement()); suggestionPopup.addAutoHidePartner(suggestBox.getElement()); } // Create suggestions table widget suggestionsTable = getSuggestionCellList( (Collection<SearchSuggestion>) suggestions, suggestBox, suggestionPopup); // Add table to popup suggestionPopup.setWidget(suggestionsTable); // Show the popup under the TextBox. suggestionPopup.showRelativeTo(searchBoxPanel); int searchBoxWidth = searchBoxPanel.getElement().getClientWidth(); Element table = (Element) suggestionPopup.getElement().getElementsByTagName("table").getItem(0); // $NON-NLS-1$ suggestionPopup.getElement().getStyle().setWidth(searchBoxWidth, Unit.PX); table.getStyle().setWidth(searchBoxWidth, Unit.PX); }
private void showWaitPanelIfRequired(RequestContext context) { if (getServicePropertyBoolean(context.getMethodName(), "showWaitPanel", false)) { GwtUtils.log(getClass(), "showWaitPanelIfRequired", "showWaitPanel = true"); if (waitPanel == null) { waitPanel = new PopupPanel(); GwtUtils.setStyleAttribute(waitPanel, "border", "none"); GwtUtils.setStyleAttribute(waitPanel, "background", "transparent"); waitPanel.setGlassEnabled(false); waitPanel.setAnimationEnabled(true); Image waitingImg = new Image(UriUtils.fromTrustedString("/images/commons/transp-loading.gif")); waitPanel.setWidget(waitingImg); } GwtUtils.showWait(waitPanel); } }
private void showSelectRefreshIntervalPopup( final int left, final int top, final Button refreshIntervalSelector) { VerticalPanel popupContent = new VerticalPanel(); // int configuredSeconds = presenter.getAutoRefreshSeconds(); int configuredSeconds = view.getRefreshValue(); if (configuredSeconds > 0) { updateRefreshInterval(true, configuredSeconds); } else { updateRefreshInterval(false, 0); } RadioButton oneMinuteRadioButton = createTimeSelectorRadioButton( 60, "1 Minute", configuredSeconds, refreshIntervalSelector, popupContent); RadioButton fiveMinuteRadioButton = createTimeSelectorRadioButton( 300, "5 Minutes", configuredSeconds, refreshIntervalSelector, popupContent); RadioButton tenMinuteRadioButton = createTimeSelectorRadioButton( 600, "10 Minutes", configuredSeconds, refreshIntervalSelector, popupContent); popupContent.add(oneMinuteRadioButton); popupContent.add(fiveMinuteRadioButton); popupContent.add(tenMinuteRadioButton); Button resetButton = new Button("Disable Autorefresh"); resetButton.setSize(ButtonSize.MINI); resetButton.addClickHandler( new ClickHandler() { @Override public void onClick(ClickEvent event) { updateRefreshInterval(false, 0); view.saveRefreshValue(0); refreshIntervalSelector.setActive(false); popup.hide(); } }); popupContent.add(resetButton); popup.setWidget(popupContent); popup.show(); int finalLeft = left - popup.getOffsetWidth(); popup.setPopupPosition(finalLeft, top); }
// @UiHandler({"edit_selection"}) public void editSelectionCmd(ClickEvent ev) { // DialogBox dialogBox = createDialogBox("Редактирование выбора..."); // dialogBox.setGlassEnabled(true); // dialogBox.setAnimationEnabled(true); PopupPanel p = new PopupPanel(true); p.setModal(false); // p.setPopupPosition(200, 200); p.setAnimationEnabled(true); // p.setTitle("Редактирование выбора..."); // dialogBox.setModal(true); // dialogBox.center(); p.setSize("100%", "100%"); p.setWidget(new MultiselectionEditor(this, p)); p.setVisible(true); p.show(); p.center(); }
/** * Create the list of Contacts. * * @param images the {@link Images} used in the Contacts * @return the list of contacts */ @ShowcaseSource private VerticalPanel createContactsItem(Images images) { // Create a popup to show the contact info when a contact is clicked HorizontalPanel contactPopupContainer = new HorizontalPanel(); contactPopupContainer.setSpacing(5); contactPopupContainer.add(new Image(images.defaultContact())); final HTML contactInfo = new HTML(); contactPopupContainer.add(contactInfo); final PopupPanel contactPopup = new PopupPanel(true, false); contactPopup.setWidget(contactPopupContainer); // Create the list of contacts VerticalPanel contactsPanel = new VerticalPanel(); contactsPanel.setSpacing(4); String[] contactNames = constants.cwStackPanelContacts(); String[] contactEmails = constants.cwStackPanelContactsEmails(); for (int i = 0; i < contactNames.length; i++) { final String contactName = contactNames[i]; final String contactEmail = contactEmails[i]; final HTML contactLink = new HTML("<a href=\"javascript:undefined;\">" + contactName + "</a>"); contactsPanel.add(contactLink); // Open the contact info popup when the user clicks a contact contactLink.addClickHandler( new ClickHandler() { public void onClick(ClickEvent event) { // Set the info about the contact contactInfo.setHTML(contactName + "<br><i>" + contactEmail + "</i>"); // Show the popup of contact info int left = contactLink.getAbsoluteLeft() + 14; int top = contactLink.getAbsoluteTop() + 14; contactPopup.setPopupPosition(left, top); contactPopup.show(); } }); } return contactsPanel; }
/** * Opens an HTML popup info window at the given screen coordinates (within the plot bounds) * * <p>It sets the same font family, size, color and bgcolor defined for markers, if you wanted * override them use the css selector div.chrono-infoWindow-content. * * <p>FIXME: (MCM) this should be a unique instance of popup: ask Shawn */ public InfoWindow createInfoWindow(String html, double x, double y) { final PopupPanel pp = new DecoratedPopupPanel(true); pp.addStyleName("chrono-infoWindow"); Widget content = new HTML(html); content.setStyleName("chrono-infoWindow-content"); pp.setWidget(content); pp.setPopupPosition( getElement().getAbsoluteLeft() + (int) x, getElement().getAbsoluteTop() + (int) y); GssProperties markerProperties = gssContext.getPropertiesBySelector("marker"); if (markerProperties != null) { pp.getElement().getStyle().setBackgroundColor(markerProperties.bgColor.toString()); pp.getElement().getStyle().setColor(markerProperties.color.toString()); pp.getElement().getStyle().setProperty("fontFamily", markerProperties.fontFamily.toString()); pp.getElement().getStyle().setProperty("fontSize", markerProperties.fontSize.toString()); pp.getElement().getStyle().setPadding(5, Unit.PX); } pp.getElement().getStyle().setZIndex(9999); pp.show(); return new BrowserInfoWindow(this, pp); }
// Method response to user click of "Search" menu in top menubar. // Causes popup panel to appear protected void doPostSearch() { VerticalPanel content = new VerticalPanel(); content.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER); HorizontalPanel inputRow = new HorizontalPanel(); Label searchTermLabel = new Label("Search Title Term: "); final TextBox searchTermTextBox = new TextBox(); inputRow.add(searchTermLabel); inputRow.add(searchTermTextBox); HorizontalPanel btnRow = new HorizontalPanel(); btnRow.setStyleName("search-button-row"); Button cancelBtn = new Button("Cancel"); cancelBtn.addClickHandler( new ClickHandler() { @Override public void onClick(ClickEvent event) { searchPopup.hide(); } }); Button searchBtn = new Button("Search"); searchBtn.addClickHandler( new ClickHandler() { @Override public void onClick(ClickEvent event) { control.handleTitleSearchRequest(searchTermTextBox.getText()); searchPopup.hide(); } }); btnRow.add(cancelBtn); btnRow.add(new Label("")); btnRow.add(searchBtn); content.add(inputRow); content.add(btnRow); searchPopup.setWidget(content); searchPopup.center(); }
private void loadNewImage(final PhotoModel photoModel, final int nextIdx) { imagePopup.clear(); imagePopup.setHeight(photoModel.getHeight() + "px"); imagePopup.setWidth(photoModel.getWidth() + "px"); Image fullImage = new Image(photoModel.getURL()); imagePopup.setWidget(fullImage); if (currIdx > 0) { ImageMouseDownHandler mouseDownHandler = new ImageMouseDownHandler(); mouseDownHandler.setPhotoModelList(photoModelList); mouseDownHandler.setImagePopup(imagePopup); mouseDownHandler.setCurrIdx(nextIdx); mouseDownHandler.setFullImage(fullImage); fullImage.addMouseDownHandler(mouseDownHandler); ImageMouseMoveHandler mouseMoveHandler = new ImageMouseMoveHandler(); mouseMoveHandler.setFullImage(fullImage); fullImage.addMouseMoveHandler(mouseMoveHandler); } getImagePopup().center(); }
/** * Create a new date box. * * @param date the default date. * @param picker the picker to drop down from the date box * @param format to use to parse and format dates */ public DateBox(DatePicker picker, Date date, Format format) { this.picker = picker; this.popup = new PopupPanel(true); assert format != null : "You may not construct a date box with a null format"; this.format = format; popup.addAutoHidePartner(box.getElement()); popup.setWidget(picker); popup.setStyleName("dateBoxPopup"); initWidget(box); setStyleName(DEFAULT_STYLENAME); handler = new DateBoxHandler(); picker.addValueChangeHandler(handler); box.addFocusHandler(handler); box.addBlurHandler(handler); box.addClickHandler(handler); box.addKeyDownHandler(handler); box.setDirectionEstimator(false); popup.addCloseHandler(handler); setValue(date); }
// Method response to user click of "Address" button in a post row // Causes popup panel to appear protected void doMapPopup(PostData post) { VerticalPanel content = new VerticalPanel(); content.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER); final String address = post.getAddress(); // Create a Panel to hold the map HorizontalPanel mapPanel = new HorizontalPanel(); mapPanel.setSize("400px", "400px"); // Create the Google Map object, with set options MapOptions myOptions = MapOptions.create(); myOptions.setZoom(8.0); myOptions.setCenter(LatLng.create(-34.397, 150.644)); myOptions.setMapTypeId(MapTypeId.ROADMAP); final GoogleMap map = GoogleMap.create(mapPanel.getElement(), myOptions); // GeoCoder is Google Maps API for taking an address and finding // latitude-longitude. Geocoder geocoder = Geocoder.create(); GeocoderRequest request = GeocoderRequest.create(); request.setAddress(address); geocoder.geocode( request, new Callback() { public void handle(JsArray<GeocoderResult> results, GeocoderStatus status) { if (status == GeocoderStatus.OK) { GeocoderResult location = results.get(0); // Bug Fix - Needed to make sure that map is re-sized to parent panel map.triggerResize(); map.setCenter(location.getGeometry().getLocation()); // Create Marker (red) to show location MarkerOptions markerOpts = MarkerOptions.create(); markerOpts.setMap(map); // Title of Marker will be address markerOpts.setTitle(address); // Place Marker at address location markerOpts.setPosition(location.getGeometry().getLocation()); Marker.create(markerOpts); } else { Window.alert("Geocode was not successful for the following reason: " + status); } } }); HorizontalPanel btnRow = new HorizontalPanel(); btnRow.setStyleName("search-button-row"); Button cancelBtn = new Button("Cancel"); cancelBtn.addClickHandler( new ClickHandler() { @Override public void onClick(ClickEvent event) { searchPopup.hide(); } }); btnRow.add(cancelBtn); content.add(mapPanel); content.add(btnRow); searchPopup.setWidget(content); searchPopup.center(); }
public ComboBox(String cssSuffix) { cellList = new CellList<String>( new TextCell() { @Override public void render(Context context, String data, SafeHtmlBuilder sb) { String cssName = (context.getIndex() % 2 > 0) ? "combobox-item combobox-item-odd" : "combobox-item"; if (data.equals(currentValue.getText())) cssName += " combobox-item-selected"; sb.append(TEMPLATE.item(cssName, data)); } }); final SingleSelectionModel<String> selectionModel = new SingleSelectionModel<String>(); cellList.setSelectionModel(selectionModel); selectionModel.addSelectionChangeHandler( new SelectionChangeEvent.Handler() { public void onSelectionChange(SelectionChangeEvent event) { String selectedValue = selectionModel.getSelectedObject(); currentValue.setHTML(selectedValue); popup.hide(); onSelection(selectedValue); } }); final String panelId = "popup_" + HTMLPanel.createUniqueId(); popup = new PopupPanel(true, true) { @Override protected void onPreviewNativeEvent(Event.NativePreviewEvent event) { if (Event.ONKEYUP == event.getTypeInt()) { if (event.getNativeEvent().getKeyCode() == ESCAPE) { // Dismiss when escape is pressed popup.hide(); } } } public void onBrowserEvent(Event event) { super.onBrowserEvent(event); } }; popup.getElement().setId(panelId); popup.setStyleName("default-popup"); popup.setWidget(cellList); currentValue = new HTML(" "); currentValue.setStyleName("combobox-value" + cssSuffix); header = new HorizontalPanel(); header.setStyleName("combobox" + cssSuffix); header.add(currentValue); Image img = new Image(Icons.INSTANCE.comboPicker()); header.add(img); currentValue.getElement().getParentElement().setAttribute("width", "100%"); img.getParent().getElement().setAttribute("width", "18"); header.getElement().setAttribute("width", "100%"); header.getElement().setAttribute("cellspacing", "0"); header.getElement().setAttribute("cellpadding", "0"); header.getElement().setAttribute("border", "0"); ClickHandler clickHandler = new ClickHandler() { @Override public void onClick(ClickEvent clickEvent) { openPanel(); } }; currentValue.addClickHandler(clickHandler); img.addClickHandler(clickHandler); }
public void onBrowserEvent(Event event) { // the id's which are set on these menu items must be set AFTER the items are added to their // menu // when an element is added to a menu an auto-generated id will be assigned, so we must override // this if (perspective != null) { if ((DOM.eventGetType(event) & Event.ONDBLCLICK) == Event.ONDBLCLICK) { openTabInNewWindow(); } else if (DOM.eventGetButton(event) == Event.BUTTON_RIGHT) { int left = Window.getScrollLeft() + DOM.eventGetClientX(event); int top = Window.getScrollTop() + DOM.eventGetClientY(event); popupMenu.setPopupPosition(left, top); MenuBar menuBar = new MenuBar(true); menuBar.setAutoOpen(true); if (tabContent instanceof IFrameTabPanel) { MenuItem backMenuItem = new MenuItem( Messages.getString("back"), new TabCommand(TABCOMMANDTYPE.BACK, popupMenu)); // $NON-NLS-1$ menuBar.addItem(backMenuItem); backMenuItem.getElement().setId("back"); // $NON-NLS-1$ menuBar.addSeparator(); MenuItem reloadTabMenuItem = new MenuItem( Messages.getString("reloadTab"), new TabCommand(TABCOMMANDTYPE.RELOAD, popupMenu)); // $NON-NLS-1$ menuBar.addItem(reloadTabMenuItem); reloadTabMenuItem.getElement().setId("reloadTab"); // $NON-NLS-1$ } if (tabPanel.getTabBar().getTabCount() > 1) { MenuItem reloadAllTabsMenuItem = new MenuItem( Messages.getString("reloadAllTabs"), new TabCommand(TABCOMMANDTYPE.RELOAD_ALL, popupMenu)); // $NON-NLS-1$ menuBar.addItem(reloadAllTabsMenuItem); reloadAllTabsMenuItem.getElement().setId("reloadAllTabs"); // $NON-NLS-1$ } else { MenuItem reloadAllTabsMenuItem = new MenuItem(Messages.getString("reloadAllTabs"), (Command) null); // $NON-NLS-1$ menuBar.addItem(reloadAllTabsMenuItem); reloadAllTabsMenuItem.getElement().setId("reloadAllTabs"); // $NON-NLS-1$ reloadAllTabsMenuItem.setStyleName("disabledMenuItem"); // $NON-NLS-1$ } menuBar.addSeparator(); if (tabContent instanceof IFrameTabPanel) { MenuItem openTabInNewWindowMenuItem = new MenuItem( Messages.getString("openTabInNewWindow"), new TabCommand(TABCOMMANDTYPE.NEW_WINDOW, popupMenu)); // $NON-NLS-1$ menuBar.addItem(openTabInNewWindowMenuItem); openTabInNewWindowMenuItem.getElement().setId("openTabInNewWindow"); // $NON-NLS-1$ MenuItem createDeepLinkMenuItem = new MenuItem( Messages.getString("createDeepLink"), new TabCommand(TABCOMMANDTYPE.CREATE_DEEP_LINK, popupMenu)); // $NON-NLS-1$ menuBar.addItem(createDeepLinkMenuItem); createDeepLinkMenuItem.getElement().setId("deepLink"); // $NON-NLS-1$ menuBar.addSeparator(); } menuBar.addItem( new MenuItem( Messages.getString("closeTab"), new TabCommand(TABCOMMANDTYPE.CLOSE, popupMenu))); // $NON-NLS-1$ if (tabPanel.getTabBar().getTabCount() > 1) { MenuItem closeOtherTabsMenuItem = new MenuItem( Messages.getString("closeOtherTabs"), new TabCommand(TABCOMMANDTYPE.CLOSE_OTHERS, popupMenu)); // $NON-NLS-1$ menuBar.addItem(closeOtherTabsMenuItem); closeOtherTabsMenuItem.getElement().setId("closeOtherTabs"); // $NON-NLS-1$ MenuItem closeAllTabsMenuItem = new MenuItem( Messages.getString("closeAllTabs"), new TabCommand(TABCOMMANDTYPE.CLOSE_ALL, popupMenu)); // $NON-NLS-1$ menuBar.addItem(closeAllTabsMenuItem); closeAllTabsMenuItem.getElement().setId("closeAllTabs"); // $NON-NLS-1$ } else { MenuItem closeOtherTabsMenuItem = new MenuItem(Messages.getString("closeOtherTabs"), (Command) null); // $NON-NLS-1$ closeOtherTabsMenuItem.setStyleName("disabledMenuItem"); // $NON-NLS-1$ MenuItem closeAllTabsMenuItem = new MenuItem(Messages.getString("closeAllTabs"), (Command) null); // $NON-NLS-1$ closeAllTabsMenuItem.setStyleName("disabledMenuItem"); // $NON-NLS-1$ menuBar.addItem(closeOtherTabsMenuItem); menuBar.addItem(closeAllTabsMenuItem); closeOtherTabsMenuItem.getElement().setId("closeOtherTabs"); // $NON-NLS-1$ closeAllTabsMenuItem.getElement().setId("closeAllTabs"); // $NON-NLS-1$ } popupMenu.setWidget(menuBar); popupMenu.hide(); popupMenu.show(); } } super.onBrowserEvent(event); }
public Widget asWidget() { if (null == cellTable.getSelectionModel()) cellTable.setSelectionModel(new SingleSelectionModel<T>()); cellTable .getSelectionModel() .addSelectionChangeHandler( new SelectionChangeEvent.Handler() { @Override public void onSelectionChange(SelectionChangeEvent selectionChangeEvent) { T selection = ((SingleSelectionModel<T>) cellTable.getSelectionModel()).getSelectedObject(); String displayValue = renderer.render(selection); currentDisplayedValue.setText(displayValue); } }); final String panelId = "popup_" + HTMLPanel.createUniqueId(); popup = new PopupPanel(true, true) { @Override protected void onPreviewNativeEvent(Event.NativePreviewEvent event) { if (Event.ONKEYUP == event.getTypeInt()) { if (event.getNativeEvent().getKeyCode() == ESCAPE) { // Dismiss when escape is pressed popup.hide(); } } } public void onBrowserEvent(Event event) { super.onBrowserEvent(event); } }; popup.getElement().setId(panelId); popup.setStyleName("default-popup"); /*popup.addCloseHandler(new CloseHandler<PopupPanel>() { public void onClose(CloseEvent<PopupPanel> event) { } });*/ VerticalPanel layout = new VerticalPanel(); layout.setStyleName("fill-layout-width"); layout.addStyleName("tablepicker-popup"); if (description != null) layout.add(new Label(description)); layout.add(cellTable); DefaultPager pager = new DefaultPager(); pager.setDisplay(cellTable); layout.add(pager); popup.setWidget(layout); currentDisplayedValue = new HTML(" "); currentDisplayedValue.setStyleName("table-picker-value"); header = new HorizontalPanel(); header.setStyleName("table-picker"); header.add(currentDisplayedValue); Image img = new Image(ConsoleIcons.INSTANCE.tablePicker()); header.add(img); currentDisplayedValue.getElement().getParentElement().setAttribute("width", "100%"); img.getParent().getElement().setAttribute("width", "18"); header.getElement().setAttribute("width", "100%"); header.getElement().setAttribute("cellspacing", "0"); header.getElement().setAttribute("cellpadding", "0"); header.getElement().setAttribute("border", "0"); ClickHandler clickHandler = new ClickHandler() { @Override public void onClick(ClickEvent clickEvent) { openPanel(); } }; currentDisplayedValue.addClickHandler(clickHandler); img.addClickHandler(clickHandler); return header; }