List of usage examples for com.google.gwt.user.client.ui PopupPanel setPopupPositionAndShow
public void setPopupPositionAndShow(PositionCallback callback)
From source file:accelerator.client.view.desktop.DesktopMainMenuView.java
License:Open Source License
@UiHandler("createButton") void onCreateButtonClick(ClickEvent e) { final PopupPanel popup = new PopupPanel(true, false); MenuBar menu = new MenuBar(true); menu.addItem("?", new Command() { public void execute() { popup.hide();//from www. ja v a2s . c om ProjectDialogBox dlg = new ProjectDialogBox(); dlg.setHandler(new ProjectDialogBox.Handler() { public void onOk(Project input) { handler.createProject(input); } }); dlg.center(); } }); menu.addItem("?", new Command() { public void execute() { popup.hide(); TagDialogBox dlg = new TagDialogBox(); dlg.setHandler(new TagDialogBox.Handler() { public void onOk(Tag input) { handler.createTag(input); } }); dlg.center(); } }); popup.setWidget(menu); popup.setPopupPositionAndShow(new PositionCallback() { public void setPosition(int offsetWidth, int offsetHeight) { int left = createButton.getAbsoluteLeft(); int top = createButton.getAbsoluteTop() - offsetHeight; popup.setPopupPosition(left, top); } }); }
From source file:accelerator.client.view.desktop.DesktopMainMenuView.java
License:Open Source License
@UiHandler("editButton") void onEditButtonClick(ClickEvent e) { final PopupPanel popup = new PopupPanel(true, false); MenuBar menu = new MenuBar(true); {/*from w w w .j a va 2s.c o m*/ final Project p = getSelectedProject(); final boolean isProjectSelected = p != null; // MenuItem edit = new MenuItem("", new Command() { public void execute() { assert (p != null); popup.hide(); ProjectDialogBox dlg = new ProjectDialogBox(p); dlg.setHandler(new ProjectDialogBox.Handler() { public void onOk(Project input) { handler.updateProject(input); } }); dlg.center(); } }); edit.setEnabled(isProjectSelected); menu.addItem(edit); // MenuItem delete = new MenuItem("", new Command() { public void execute() { assert (p != null); popup.hide(); handler.deleteProject(p); } }); delete.setEnabled(isProjectSelected); menu.addItem(delete); } menu.addSeparator(); { final Tag t = getSelectedTag(); final boolean isTagSelected = t != null; // MenuItem edit = new MenuItem("", new Command() { public void execute() { assert (t != null); popup.hide(); TagDialogBox dlg = new TagDialogBox(t); dlg.setHandler(new TagDialogBox.Handler() { public void onOk(Tag input) { handler.updateTag(input); } }); dlg.center(); } }); edit.setEnabled(isTagSelected); menu.addItem(edit); // MenuItem delete = new MenuItem("", new Command() { public void execute() { assert (t != null); popup.hide(); handler.deleteTag(t); } }); delete.setEnabled(isTagSelected); menu.addItem(delete); } popup.setWidget(menu); popup.setPopupPositionAndShow(new PositionCallback() { public void setPosition(int offsetWidth, int offsetHeight) { int left = editButton.getAbsoluteLeft(); int top = editButton.getAbsoluteTop() - offsetHeight; popup.setPopupPosition(left, top); } }); }
From source file:com.google.api.explorer.client.history.JsonPrettifier.java
License:Apache License
/** * Create a drop down menu that allows the user to navigate to compatible methods for the * specified resource./* www . j a va 2s.c om*/ * * @param methods Methods for which to build the menu. * @param service Service to which the methods correspond. * @param objectToPackage Object which should be passed to the destination menus. * @param linkFactory Factory that will be used to create links. * @return A button that will show the menu that was generated or {@code null} if there are no * compatible methods. */ private static PushButton createRequestMenu(final Collection<ApiMethod> methods, final ApiService service, DynamicJso objectToPackage, PrettifierLinkFactory linkFactory) { // Determine if a menu even needs to be generated. if (methods.isEmpty()) { return null; } // Create the parameters that will be passed to the destination menu. String resourceContents = new JSONObject(objectToPackage).toString(); final Multimap<String, String> resourceParams = ImmutableMultimap.of(UrlBuilder.BODY_QUERY_PARAM_KEY, resourceContents); // Create the menu itself. FlowPanel menuContents = new FlowPanel(); // Add a description of what the menu does. Label header = new Label("Use this resource in one of the following methods:"); header.addStyleName(style.dropDownMenuItem()); menuContents.add(header); // Add a menu item for each method. for (ApiMethod method : methods) { PushButton methodItem = new PushButton(); methodItem.addStyleName(style.dropDownMenuItem()); methodItem.addStyleName(style.selectableDropDownMenuItem()); methodItem.setText(method.getId()); menuContents.add(methodItem); // When clicked, Navigate to the menu item. UrlBuilder builder = new UrlBuilder(); String newUrl = builder.addRootNavigationItem(RootNavigationItem.ALL_VERSIONS) .addService(service.getName(), service.getVersion()).addMethodName(method.getId()) .addQueryParams(resourceParams).toString(); methodItem.addClickHandler(linkFactory.generateMenuHandler(newUrl)); } // Create the panel which will be disclosed. final PopupPanel popupMenu = new PopupPanel(/* auto hide */ true); popupMenu.setStyleName(style.dropDownMenuPopup()); FocusPanel focusContents = new FocusPanel(); focusContents.addMouseOutHandler(new MouseOutHandler() { @Override public void onMouseOut(MouseOutEvent event) { popupMenu.hide(); } }); focusContents.setWidget(menuContents); popupMenu.setWidget(focusContents); // Create the button which will disclose the menu. final PushButton menuButton = new PushButton(new Image(resources.downArrow())); menuButton.addStyleName(style.reusableResourceButton()); menuButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { popupMenu.setPopupPositionAndShow(new PositionCallback() { @Override public void setPosition(int offsetWidth, int offsetHeight) { popupMenu.setPopupPosition( menuButton.getAbsoluteLeft() + menuButton.getOffsetWidth() - offsetWidth, menuButton.getAbsoluteTop() + menuButton.getOffsetHeight()); } }); } }); // Return only the button to the caller. return menuButton; }
From source file:com.google.gwt.sample.stockwatcher.client.SitePage.java
private static void renderActuatorPopups() { stop();/*from w w w.ja v a2 s .com*/ for (String controller : Data.controllerActuatorList.keySet()) { ArrayList<PopupPanel> popups = new ArrayList<>(); for (String actuators : Data.controllerActuatorList.get(controller)) { ArrayList<String> attributes = Data.actuatorAttributeList.get(actuators); String name = attributes.get(0); String status = attributes.get(2); final double x = Double.parseDouble(attributes.get(3)); final double y = Double.parseDouble(attributes.get(4)); String controlType = attributes.get(5); String icon = Images.getImage(Images.ACTUATOR_CURRENT_ICON, 25); Actuator temp = new Actuator(icon, name, status, controlType); final PopupPanel container = new PopupPanel(); actuatorIcons.add(container); container.add(temp); container.getElement().getStyle().setBackgroundColor("rgba(255,0,0,0.0)"); container.getElement().getStyle().setBorderWidth(0, Unit.PX); container.setPopupPositionAndShow(new PopupPanel.PositionCallback() { public void setPosition(int offsetWidth, int offsetHeight) { int left = sitePic.getAbsoluteLeft() + (int) (x * (double) sitePic.getWidth()); int top = sitePic.getAbsoluteTop() + (int) (y * (double) sitePic.getHeight()); container.setPopupPosition(left, top); } }); container.setVisible(false); popups.add(container); } controllerActuatorPopupList.put(controller, popups); } }
From source file:com.google.gwt.sample.stockwatcher.client.SitePage.java
private static void renderControllerPopups() { for (String site : Data.siteControllerList.keySet()) { ArrayList<PopupPanel> popups = new ArrayList<>(); for (String controller : Data.siteControllerList.get(site)) { ArrayList<String> attributes = Data.controllerAttributeList.get(controller); final String name = attributes.get(0); final double x = Double.parseDouble(attributes.get(2)); final double y = Double.parseDouble(attributes.get(3)); Controller cToggle = new Controller(controller); final PopupPanel container = new PopupPanel(); controllerIcons.add(container); container.add(cToggle);/*from w w w.ja va 2 s .c o m*/ container.getElement().getStyle().setBackgroundColor("rgba(255,0,0,0.0)"); container.getElement().getStyle().setBorderWidth(0, Unit.PX); container.setTitle(name); container.setPopupPositionAndShow(new PopupPanel.PositionCallback() { public void setPosition(int offsetWidth, int offsetHeight) { int left = sitePic.getAbsoluteLeft() + (int) (x * (double) sitePic.getWidth()); int top = sitePic.getAbsoluteTop() + (int) (y * (double) sitePic.getHeight()); container.setPopupPosition(left, top); } }); container.setVisible(false); popups.add(container); } siteControllerPopupList.put(site, popups); } }
From source file:com.google.gwt.sample.stockwatcher.client.SitePage.java
private static void renderSensorPopups() { for (String controller : Data.controllerSensorList.keySet()) { ArrayList<PopupPanel> popups = new ArrayList<>(); for (String sensors : Data.controllerSensorList.get(controller)) { ArrayList<String> attributes = Data.sensorAttributeList.get(sensors); String name = attributes.get(0); String type = attributes.get(1); final double x = Double.parseDouble(attributes.get(9)); final double y = Double.parseDouble(attributes.get(10)); String icon = setSensorIcon(type); Sensor temp = new Sensor(icon, name); final PopupPanel container = new PopupPanel(); sensorIcons.add(container);// w ww . ja va2 s. c om container.add(temp); container.getElement().getStyle().setBackgroundColor("rgba(255,0,0,0.0)"); container.getElement().getStyle().setBorderWidth(0, Unit.PX); container.setPopupPositionAndShow(new PopupPanel.PositionCallback() { public void setPosition(int offsetWidth, int offsetHeight) { int left = sitePic.getAbsoluteLeft() + (int) (x * (double) sitePic.getWidth()); int top = sitePic.getAbsoluteTop() + (int) (y * (double) sitePic.getHeight()); container.setPopupPosition(left, top); } }); container.setVisible(false); popups.add(container); } controllerSensorPopupList.put(controller, popups); } }
From source file:com.xclinical.mdr.client.ui.AbstractPerspective.java
License:Apache License
public void showPopup(final PopupPanel panel) { panel.setPopupPositionAndShow(new PositionCallback() { public void setPosition(int offsetWidth, int offsetHeight) { panel.setPopupPosition((Window.getClientWidth() - offsetWidth) / 2, 0); }//from w ww .j a v a 2 s . c o m }); }
From source file:nl.mpi.tg.eg.experiment.client.view.ComplexView.java
License:Open Source License
public void showHtmlPopup(String popupText, final PresenterEventListner... buttonListeners) { final PopupPanel popupPanel = new PopupPanel(false); // the close action to this panel causes background buttons to be clicked popupPanel.setGlassEnabled(true);//from w w w . j a v a2 s. co m popupPanel.setStylePrimaryName("svgPopupPanel"); final VerticalPanel popupverticalPanel = new VerticalPanel(); final HTML htmlText = new HTML(new SafeHtmlBuilder().appendHtmlConstant(popupText).toSafeHtml()); htmlText.setStylePrimaryName("popupTextBox"); popupverticalPanel.add(htmlText); popupverticalPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_RIGHT); final HorizontalPanel buttonPanel = new HorizontalPanel(); for (final PresenterEventListner buttonListener : buttonListeners) { final SingleShotEventListner okSingleShotEventListner = new SingleShotEventListner() { @Override protected void singleShotFired() { popupPanel.hide(); buttonListener.eventFired(null, null); } }; final Button okButton = new Button(buttonListener.getLabel()); if (buttonListener.getStyleName() != null && !buttonListener.getStyleName().isEmpty()) { okButton.addStyleName(buttonListener.getStyleName()); } okButton.addClickHandler(okSingleShotEventListner); okButton.addTouchStartHandler(okSingleShotEventListner); okButton.addTouchMoveHandler(okSingleShotEventListner); okButton.addTouchEndHandler(okSingleShotEventListner); buttonPanel.add(okButton); } popupverticalPanel.add(buttonPanel); popupPanel.setWidget(popupverticalPanel); popupPanel.setPopupPositionAndShow(new PopupPanel.PositionCallback() { @Override public void setPosition(int offsetWidth, int offsetHeight) { final int topPosition = Window.getClientHeight() / 2 - offsetHeight; // topPosition is used to make sure the dialogue is above the half way point on the screen to avoid the software keyboard covering the box // topPosition is also checked to make sure it does not show above the top of the page popupPanel.setPopupPosition(Window.getClientWidth() / 2 - offsetWidth / 2, (topPosition < 0) ? 0 : topPosition); } }); }
From source file:nl.ru.languageininteraction.language.client.view.AbstractSvgView.java
License:Open Source License
public void showWidgetPopup(final PresenterEventListner saveEventListner, IsWidget popupContentWidget) { final PopupPanel popupPanel = new PopupPanel(false); // the close action to this panel causes background buttons to be clicked popupPanel.setGlassEnabled(true);// w w w.jav a 2 s .co m popupPanel.setStylePrimaryName("svgPopupPanel"); final VerticalPanel popupverticalPanel = new VerticalPanel(); popupverticalPanel.add(popupContentWidget); popupverticalPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_RIGHT); final SingleShotEventListner cancelSingleShotEventListner = new SingleShotEventListner() { @Override protected void singleShotFired() { popupPanel.hide(); } }; final HorizontalPanel buttonPanel = new HorizontalPanel(); String popupCancelButtonLabel = ""; // messages.popupCancelButtonLabel(); final Button cancelButton = new Button(popupCancelButtonLabel); cancelButton.addClickHandler(cancelSingleShotEventListner); cancelButton.addTouchStartHandler(cancelSingleShotEventListner); cancelButton.addTouchMoveHandler(cancelSingleShotEventListner); cancelButton.addTouchEndHandler(cancelSingleShotEventListner); buttonPanel.add(cancelButton); if (saveEventListner != null) { final SingleShotEventListner okSingleShotEventListner = new SingleShotEventListner() { @Override protected void singleShotFired() { popupPanel.hide(); saveEventListner.eventFired(null, this); } }; String popupOkButtonLabel = ""; // messages.popupOkButtonLabel(); final Button okButton = new Button(popupOkButtonLabel); okButton.addClickHandler(okSingleShotEventListner); okButton.addTouchStartHandler(okSingleShotEventListner); okButton.addTouchMoveHandler(okSingleShotEventListner); okButton.addTouchEndHandler(okSingleShotEventListner); buttonPanel.add(okButton); } popupverticalPanel.add(buttonPanel); popupPanel.setWidget(popupverticalPanel); popupPanel.setPopupPositionAndShow(new PopupPanel.PositionCallback() { @Override public void setPosition(int offsetWidth, int offsetHeight) { final int topPosition = Window.getClientHeight() / 2 - offsetHeight; // topPosition is used to make sure the dialogue is above the half way point on the screen to avoid the software keyboard covering the box // topPosition is also checked to make sure it does not show above the top of the page popupPanel.setPopupPosition(Window.getClientWidth() / 2 - offsetWidth / 2, (topPosition < 0) ? 0 : topPosition); } }); }
From source file:org.freemedsoftware.gwt.client.widget.MultiPageForm.java
License:Open Source License
public void addWidget(String name, WidgetType type, String options, String value, String help, Integer page, Integer x, Integer y, String textName) { HashSetter w;//from ww w . j a va2s. c om if (type == WidgetType.TEXT) { w = new CustomTextBox(); try { Integer len = new Integer(options); if (len > 0) { JsonUtil.debug("addWidget " + name + " has length of " + len); ((CustomTextBox) w).setVisibleLength(len.intValue() + 1); ((CustomTextBox) w).setMaxLength(len.intValue()); } } catch (Exception ex) { } } else if (type == WidgetType.MODULE) { w = new SupportModuleWidget(options); } else if (type == WidgetType.SELECT) { w = new CustomListBox(); // Push in all "options" values String[] o = options.split(","); for (int iter = 0; iter < o.length; iter++) { // Check for "description" pairs if (o[iter].contains("|")) { String[] i = o[iter].split("\\|"); ((CustomListBox) w).addItem(i[0], i[1]); } else { if (o[iter].length() > 0) { ((CustomListBox) w).addItem(o[iter]); } } } } else if (type == WidgetType.PATIENT) { w = new PatientWidget(); } else if (type == WidgetType.DATE) { w = new CustomDatePicker(); } else { // Unimplemented, use text box as fallback w = new CustomTextBox(); JsonUtil.debug("MultiPageForm" + ": Unimplemented type '" + type + "' found. Fallback to TextBox."); } // Add to indices and display widgets.put(name, w); if (help != null) { final Image image = new Image(); image.setUrl("resources/images/q_help.16x16.png"); final PopupPanel popup = new PopupPanel(); final HTML html = new HTML(); html.setHTML(help); popup.add(html); popup.setStyleName("freemed-HelpPopup"); image.addMouseOutHandler(new MouseOutHandler() { @Override public void onMouseOut(MouseOutEvent event) { // Hide help PopUp popup.hide(); } }); image.addMouseMoveHandler(new MouseMoveHandler() { @Override public void onMouseMove(MouseMoveEvent event) { // Do nothing popup.setPopupPositionAndShow(new PositionCallback() { public void setPosition(int offsetWidth, int offsetHeight) { // Show it relative to the mouse-pointer. popup.setPopupPosition(offsetWidth + 20, offsetHeight + 20); } }); } }); } // Set widget value after it is added. this.setWidgetValue(name, value); // Place on page GeneratedFormWidget thisPage = pages.get(page); if (thisPage != null) { thisPage.addWidget((Widget) w, x, y, textName); } else { JsonUtil.debug("Could not add widget to page " + page + " at " + x + "," + y); } }