List of usage examples for com.google.gwt.user.client.ui PopupPanel hide
public void hide()
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(); ProjectDialogBox dlg = new ProjectDialogBox(); dlg.setHandler(new ProjectDialogBox.Handler() { public void onOk(Project input) { handler.createProject(input); }/*from ww w . j av a 2 s .c o m*/ }); 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 ww w . ja 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:cc.alcina.framework.gwt.client.util.WidgetUtils.java
License:Apache License
public static void copyTextToClipboard(String text) { FlowPanel fp = new FlowPanel(); TextArea ta = new TextArea(); ta.setSize("600px", "300px"); ta.setText(text);//from ww w .j a v a 2 s. co m fp.add(ta); PopupPanel pp = new PopupPanel(); pp.add(fp); pp.setAnimationEnabled(false); pp.show(); ta.setSelectionRange(0, text.length()); try { execCopy(); } catch (JavaScriptException e) { pp.hide(); if (e.getMessage().contains("NS_ERROR_XPC_NOT_ENOUGH_ARGS")) { Registry.impl(ClientNotifications.class) .showMessage(new HTML("<div class='info'>Sorry, clipboard operations" + " are disabled by Mozilla/Firefox" + " security settings. <br><br> Please see " + "<a href='http://www.mozilla.org/editor/midasdemo/securityprefs.html'>" + "http://www.mozilla.org/editor/midasdemo/securityprefs.html</a></div> ")); } else { throw e; } } pp.hide(); }
From source file:ch.heftix.mailxel.client.MailSendGrid.java
License:Open Source License
public MailSendGrid(final MailServiceAsync mailxelService, final MailxelPanel mailxelPanel, final MailTO mailTO, final char type) { this.mailxelService = mailxelService; this.mailxelPanel = mailxelPanel; cTO = mailxelPanel.getConfig();//from www .j a v a 2 s.c om HorizontalPanel toolbar = new HorizontalPanel(); final Image addAttachement = new Image("img/add-attachment.png"); addAttachement.setTitle("Add Attachement"); addAttachement.setStylePrimaryName("mailxel-toolbar-item"); addAttachement.addClickHandler(new ClickHandler() { public void onClick(ClickEvent sender) { final PopupPanel pup = new PopupPanel(true); HorizontalPanel hp = new HorizontalPanel(); final TextBox tb = new TextBox(); tb.setWidth("300px"); hp.add(tb); // final FileUpload upload = new FileUpload(); // hp.add(upload); Button b = new Button(); b.setText("Add"); b.addClickHandler(new ClickHandler() { public void onClick(ClickEvent sender) { // String name = upload.getFilename(); // // upload.g String name = tb.getText(); if (null != name) { name = name.trim(); if (name.length() > 0) { AttachmentTO aTO = new AttachmentTO(); aTO.name = name; attachmentBar.addCheckableAttachement(aTO); pup.hide(); } } } }); hp.add(b); pup.add(hp); int x = addAttachement.getAbsoluteLeft(); int y = addAttachement.getAbsoluteTop(); pup.setPopupPosition(x, y); pup.show(); } }); final Image setFrom = new Image("img/set-from.png"); setFrom.setTitle("Set From address"); setFrom.setStylePrimaryName("mailxel-toolbar-item"); setFrom.addClickHandler(new ClickHandler() { public void onClick(ClickEvent sender) { grid.insertRow(0); grid.setText(0, 0, "From"); MailSendGrid.this.fromBar = new AddressEditBar(mailxelService, mailxelPanel); grid.setWidget(0, 1, fromBar); } }); Image postpone = new Image("img/save.png"); postpone.setTitle("Postpone Message"); postpone.setStylePrimaryName("mailxel-toolbar-item"); postpone.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { final StatusItem si = mailxelPanel.statusStart("postpone"); MailTO mt = createMail(); mailxelService.postpone(mt, new AsyncCallback<String>() { public void onFailure(Throwable caught) { si.error(caught); } public void onSuccess(String result) { if (null != result && result.startsWith("200 OK")) { si.done(); mailxelPanel.closeTab(MailSendGrid.this); } else { si.error("Postpone failed: " + result); } } }); } }); Image send = new Image("img/paper-plane.png"); if (TYPE_SELF == type) { send.setTitle("Store Note"); } else { send.setTitle("Send Mail"); } send.setStylePrimaryName("mailxel-toolbar-item"); send.addClickHandler(new ClickHandler() { public void onClick(ClickEvent sender) { final StatusItem si = mailxelPanel.statusStart("send/store"); if (sending) { si.error("mail send is already in process"); return; } else { sending = true; } MailTO mt = createMail(); if (TYPE_SELF == type) { mailxelService.storeNote(mt, new AsyncCallback<String>() { public void onFailure(Throwable caught) { si.error(caught); sending = false; } public void onSuccess(String result) { if (null != result && result.startsWith("200 OK")) { si.done(); sending = false; mailxelPanel.closeTab(MailSendGrid.this); } else { si.error("Storing note failed: " + result); sending = false; } } }); } else { mailxelService.send(mt, new AsyncCallback<String>() { public void onFailure(Throwable caught) { si.error(caught); sending = false; } public void onSuccess(String status) { if (status.startsWith("200")) { si.done(); sending = false; if (TYPE_NEW != type) { // add a category entry: answered or forwarded String cat = "ANS"; if (TYPE_FORWARD == type) { cat = "FWD"; } List<Integer> origMailId = new ArrayList<Integer>(); origMailId.add(mailTO.id); final StatusItem sic = mailxelPanel.statusStart("update send/answer flags"); mailxelService.updateCategories(origMailId, cat, new AsyncCallback<Void>() { public void onFailure(Throwable caught) { sic.error(caught); } public void onSuccess(Void result) { sic.done("sent and flags updated", 0); } }); } // close tab mailxelPanel.closeTab(MailSendGrid.this); } else { si.error(status); sending = false; } } }); } } }); if (TYPE_SELF != type) { toolbar.add(setFrom); toolbar.add(postpone); } toolbar.add(addAttachement); toolbar.add(send); add(toolbar); add(statusMessage); initWidgets(mailTO, type); }
From source file:ch.heftix.mailxel.client.MailxelMainToolBar.java
License:Open Source License
public MailxelMainToolBar(final MailServiceAsync mailxelService, final MailxelPanel mailxelPanel) { this.mailxelService = mailxelService; this.mailxelPanel = mailxelPanel; logo = new Image("img/mailxel.png"); logo.setTitle("MailXel " + Version.getVersion()); logo.addClickHandler(new ClickHandler() { public void onClick(ClickEvent sender) { PopupPanel pp = new PopupPanel(true); DisclosurePanel dp = new DisclosurePanel("MailXel " + Version.getVersion()); dp.setWidth("400px"); dp.setOpen(true);/*from w ww . j ava 2 s.c o m*/ HTML html = new HTML(); StringBuffer sb = new StringBuffer(); sb.append("(c) 2008-2010 by Simon Hefti. All rights reserved.<br/>"); sb.append( "<p>mailxel is licensed under the <a href=\"http://www.eclipse.org/legal/epl-v10.html\">EPL 1.0</a>. mailxel is distributed on an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either express or implied."); sb.append("<p>mailxel relies on the following components:"); sb.append("<ul>"); sb.append( "<li>GWT, <a href=\"http://code.google.com/webtoolkit\">http://code.google.com/webtoolkit</a></li>"); sb.append( "<li>sqlite-jdbc, <a href=\"http://www.xerial.org/trac/Xerial/wiki/SQLiteJDBC\">http://www.xerial.org/trac/Xerial/wiki/SQLiteJDBC</a></li>"); sb.append( "<li>(and thus on sqlite itself, <a href=\"http://www.sqlite.org\">http://www.sqlite.org</a>)</li>"); sb.append( "<li>Java Mail API, <a href=\"http://java.sun.com/products/javamail\">http://java.sun.com/products/javamail</a></li>"); sb.append( "<li>jetty servlet container, <a href=\"http://www.eclipse.org/jetty/\">http://www.eclipse.org/jetty/</a></li>"); sb.append( "<li>fugue-icons, <a href=\"http://code.google.com/p/fugue-icons-src/\">http://code.google.com/p/fugue-icons-src/</a></li>"); sb.append("<li>jsoup, <a href=\"http://jsoup.org\">http://jsoup.org</a></li>"); sb.append("</ul>"); html.setHTML(sb.toString()); dp.add(html); dp.setOpen(true); pp.add(dp); pp.show(); } }); Image home = new Image("img/find.png"); home.setTitle("Search"); home.setStylePrimaryName("mailxel-toolbar-item"); home.addClickHandler(new ClickHandler() { public void onClick(ClickEvent sender) { Panel panel = new MailOverviewGrid(mailxelService, mailxelPanel); mailxelPanel.addTab(panel, "Search"); } }); final Image query = new Image("img/document-task.png"); query.setTitle("Search (predefined query)"); query.setStylePrimaryName("mailxel-toolbar-item"); query.addClickHandler(new ClickHandler() { public void onClick(ClickEvent sender) { final StatusItem si = mailxelPanel.statusStart("retrieve stored message queries"); mailxelService.searchQueries(MessageQueryTO.T_MESSAGE_QUERY, null, new AsyncCallback<List<MessageQueryTO>>() { public void onFailure(Throwable caught) { si.error(caught); } public void onSuccess(List<MessageQueryTO> result) { si.done(); if (null != result && result.size() > 0) { PopupMenu popupMenu = new PopupMenu(query); for (MessageQueryTO mqTO : result) { String name = mqTO.shortname + " (" + UIUtil.shorten(mqTO.name) + ")"; MenuItem menuItem = new MenuItem(name, new MessageQueryCommand( mailxelService, mailxelPanel, popupMenu, mqTO)); String url = DirectMailServiceUtil.getIconURL(mqTO.iconId); if (null != url) { String html = "<img src=\"" + url + "\"/> " + name; menuItem.setHTML(html); } popupMenu.addItem(menuItem); } popupMenu.show(); } } }); } }); Image mailnew = new Image("img/mail-new.png"); mailnew.setTitle("New Mail"); mailnew.setStylePrimaryName("mailxel-toolbar-item"); mailnew.addClickHandler(new ClickHandler() { public void onClick(ClickEvent sender) { final MailSendGrid mailSendGrid = new MailSendGrid(mailxelService, mailxelPanel, null, MailSendGrid.TYPE_NEW); mailxelPanel.addTab(mailSendGrid, "New Mail"); } }); Image noteToSelf = new Image("img/note.png"); noteToSelf.setTitle("Note to myself"); noteToSelf.setStylePrimaryName("mailxel-toolbar-item"); noteToSelf.addClickHandler(new ClickHandler() { public void onClick(ClickEvent sender) { final MailSendGrid mailSendGrid = new MailSendGrid(mailxelService, mailxelPanel, null, MailSendGrid.TYPE_SELF); mailxelPanel.addTab(mailSendGrid, "New Note"); } }); Image contacts = new Image("img/address-book.png"); contacts.setTitle("Address Book"); contacts.setStylePrimaryName("mailxel-toolbar-item"); contacts.addClickHandler(new ClickHandler() { public void onClick(ClickEvent sender) { AddressOverviewGrid ag = new AddressOverviewGrid(mailxelService, mailxelPanel); mailxelPanel.addTab(ag, "Contacts"); } }); /** * mail download menu on click, a menu with the available accounts is * displayed, allowing the user is asked to choose the data source. */ final Image download = new Image("img/download-mail.png"); download.setTitle("Mail download"); download.setStylePrimaryName("mailxel-toolbar-item"); download.addClickHandler(new ClickHandler() { public void onClick(ClickEvent sender) { ConfigTO configTO = mailxelPanel.getConfig(); String[] accounts = configTO.accountNames; if (null != accounts && accounts.length > 0) { PopupMenu popupMenu = new PopupMenu(download); // first item: allow download from all known accounts MenuItem menuItem = new MenuItem("Scan all accounts", new ScanMailFolderCommand(mailxelService, mailxelPanel, popupMenu, accounts)); popupMenu.addItem(menuItem); // add one menu item per account for (int i = 0; i < accounts.length; i++) { String[] selectedAccount = new String[1]; selectedAccount[0] = accounts[i]; menuItem = new MenuItem(accounts[i], new ScanMailFolderCommand(mailxelService, mailxelPanel, popupMenu, selectedAccount)); popupMenu.addItem(menuItem); } popupMenu.show(); } } }); final Image reorgMailFolder = new Image("img/wand.png"); reorgMailFolder.setTitle("reorganize mail folder"); reorgMailFolder.setStylePrimaryName("mailxel-toolbar-item"); reorgMailFolder.addClickHandler(new ClickHandler() { public void onClick(ClickEvent sender) { ConfigTO configTO = mailxelPanel.getConfig(); String[] accounts = configTO.accountNames; if (null != accounts && accounts.length > 0) { PopupMenu popupMenu = new PopupMenu(reorgMailFolder); // first item: allow reorg from all known accounts MenuItem menuItem = new MenuItem("All accounts", new ReorgMailFolderCommand(mailxelService, mailxelPanel, popupMenu, reorgMailFolder, accounts)); popupMenu.addItem(menuItem); // add one menu item per account for (int i = 0; i < accounts.length; i++) { String[] selectedAccount = new String[1]; selectedAccount[0] = accounts[i]; menuItem = new MenuItem(accounts[i], new ReorgMailFolderCommand(mailxelService, mailxelPanel, popupMenu, reorgMailFolder, selectedAccount)); popupMenu.addItem(menuItem); } popupMenu.show(); } } }); final Image categories = new Image("img/tags.png"); categories.setTitle("Manage Categories"); categories.setStylePrimaryName("mailxel-toolbar-item"); categories.addClickHandler(new ClickHandler() { public void onClick(ClickEvent sender) { CategoryOverviewGrid cog = new CategoryOverviewGrid(mailxelService, mailxelPanel); mailxelPanel.addTab(cog, "Categories"); } }); final Image setup = new Image("img/preferences-system.png"); setup.setTitle("System Setup"); setup.setStylePrimaryName("mailxel-toolbar-item"); setup.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { // ConfigTabPanel cg = new ConfigTabPanel(); ConfigGrid cg = new ConfigGrid(mailxelService, mailxelPanel); mailxelPanel.addTab(cg, "Setup"); } }); final Image login = new Image("img/lock.png"); login.setTitle("Login"); login.setStylePrimaryName("mailxel-toolbar-item"); login.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { // create login box LoginPanel loginPanel = new LoginPanel(mailxelService, mailxelPanel); int x = login.getAbsoluteLeft(); int y = login.getAbsoluteTop(); loginPanel.setPopupPosition(x, y); loginPanel.show(); } }); final Image additional = new Image("img/context-menu.png"); additional.setTitle("Additional functions"); additional.setStylePrimaryName("mailxel-toolbar-item"); final PopupCommand importMboxCommand = new PopupCommand() { public void execute() { final PopupPanel pup = new PopupPanel(true); HorizontalPanel hp = new HorizontalPanel(); final TextBox tb = new TextBox(); tb.setWidth("300px"); hp.add(tb); Button b = new Button(); b.setText("import"); b.addClickHandler(new ClickHandler() { public void onClick(ClickEvent sender) { String name = tb.getText(); if (null != name) { name = name.trim(); if (name.length() > 0) { final StatusItem si = mailxelPanel.statusStart("Import from mbox: " + name); mailxelService.importMboxFile(name, new AsyncCallback<Void>() { public void onFailure(Throwable caught) { si.error(caught); } public void onSuccess(Void result) { si.done(); } }); pup.hide(); } } } }); hp.add(b); pup.add(hp); int x = additional.getAbsoluteLeft(); int y = additional.getAbsoluteTop(); pup.setPopupPosition(x, y); /** show input box for path to mbox file */ pup.show(); /** hide the list of available additional commands */ hide(); } }; final PopupCommand addressUploadCommand = new PopupCommand() { public void execute() { AddressUploadGrid ug = new AddressUploadGrid(mailxelService, mailxelPanel); mailxelPanel.addTab(ug, "Address Upload"); /** hide the list of available additional commands */ hide(); } }; final Command showWelcomePanelCommand = new Command() { public void execute() { WelcomeToMailxelPanel wp = new WelcomeToMailxelPanel(mailxelService, mailxelPanel); mailxelPanel.addTab(wp, "Welcome"); } }; final PopupCommand deleteConfigCommand = new PopupCommand() { public void execute() { PopupPanel pop = new PopupPanel(true, true); HorizontalPanel hp = new HorizontalPanel(); Label label = new Label("Really delete all configuration?"); hp.add(label); Button b = new Button(); b.setText("Ok"); b.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { final StatusItem si = mailxelPanel.statusStart("deleting configuration"); mailxelService.deleteConfig(new AsyncCallback<Void>() { public void onFailure(Throwable caught) { si.error(caught); } public void onSuccess(Void result) { si.done(); } }); } }); hp.add(b); pop.add(hp); int x = additional.getAbsoluteLeft(); int y = additional.getAbsoluteTop(); pop.setPopupPosition(x, y); pop.show(); /** hide the list of available additional commands */ hide(); } }; final Command updateToMeFlagCommand = new Command() { public void execute() { final StatusItem si = mailxelPanel.statusStart("Update 'to me' flag"); mailxelService.updateToMeFlag(new AsyncCallback<Void>() { public void onFailure(Throwable caught) { si.error(caught); } public void onSuccess(Void result) { si.done(); } }); } }; final Command updateFromMeFlagCommand = new Command() { public void execute() { final StatusItem si = mailxelPanel.statusStart("Update 'from me' flag"); mailxelService.updateFromMeFlag(new AsyncCallback<Void>() { public void onFailure(Throwable caught) { si.error(caught); } public void onSuccess(Void result) { si.done(); } }); } }; final Command showStatisticsCommand = new Command() { public void execute() { StatisticsGrid sg = new StatisticsGrid(mailxelService, mailxelPanel); mailxelPanel.addTab(sg, "Statistics"); } }; final Command showIconsCommand = new Command() { public void execute() { IconOverviewGrid og = new IconOverviewGrid(mailxelService, mailxelPanel); mailxelPanel.addTab(og, "Icons"); } }; final Command showMessageQueriesCommand = new Command() { public void execute() { MessageQueryOverviewGrid mqog = new MessageQueryOverviewGrid(mailxelService, mailxelPanel); mailxelPanel.addTab(mqog, "Message Queries"); } }; final Command showAttachmentGridCommand = new Command() { public void execute() { AttachmentOverviewGrid aog = new AttachmentOverviewGrid(mailxelService, mailxelPanel); mailxelPanel.addTab(aog, "Attachment Overview"); } }; final Command closeAllTabsCommand = new Command() { public void execute() { mailxelPanel.closeAllNonEditTabs(); } }; final Command dbHousekeeping = new Command() { public void execute() { final StatusItem si = mailxelPanel.statusStart("DB housekeeping"); mailxelService.housekeeping(new AsyncCallback<String>() { public void onFailure(Throwable caught) { si.error(caught); } public void onSuccess(String result) { if (result.startsWith("200 OK")) { si.done(); } else { si.error(result); } } }); } }; final Command messageCount = new Command() { public void execute() { updateCounts(); } }; additional.addClickHandler(new ClickHandler() { public void onClick(ClickEvent sender) { MenuBar popupMenuBar = new MenuBar(true); PopupPanel popupPanel = new PopupPanel(true); MenuItem menuItem = new MenuItem("Attachment Overview", showAttachmentGridCommand); popupMenuBar.addItem(menuItem); menuItem = new MenuItem("Close all Tabs", closeAllTabsCommand); popupMenuBar.addItem(menuItem); menuItem = new MenuItem("Message Queries", showMessageQueriesCommand); popupMenuBar.addItem(menuItem); menuItem = new MenuItem("DB Housekeeping", dbHousekeeping); popupMenuBar.addItem(menuItem); menuItem = new MenuItem("update pending messages count", messageCount); popupMenuBar.addItem(menuItem); menuItem = new MenuItem("Statistics", showStatisticsCommand); popupMenuBar.addItem(menuItem); menuItem = new MenuItem("Icons", showIconsCommand); popupMenuBar.addItem(menuItem); menuItem = new MenuItem("Import mbox file", importMboxCommand); importMboxCommand.setPopupPanel(popupPanel); popupMenuBar.addItem(menuItem); menuItem = new MenuItem("Address upload", addressUploadCommand); addressUploadCommand.setPopupPanel(popupPanel); popupMenuBar.addItem(menuItem); menuItem = new MenuItem("Welcome", showWelcomePanelCommand); popupMenuBar.addItem(menuItem); menuItem = new MenuItem("Delete existing configuration", deleteConfigCommand); popupMenuBar.addItem(menuItem); menuItem = new MenuItem("Update 'from me' flag", updateFromMeFlagCommand); popupMenuBar.addItem(menuItem); menuItem = new MenuItem("Update 'to me' flag", updateToMeFlagCommand); popupMenuBar.addItem(menuItem); popupMenuBar.setVisible(true); popupPanel.add(popupMenuBar); int x = additional.getAbsoluteLeft(); int y = additional.getAbsoluteTop(); popupPanel.setPopupPosition(x, y); popupPanel.show(); } }); updateCounts(); add(home); add(query); add(mailnew); add(noteToSelf); add(contacts); add(categories); add(download); add(reorgMailFolder); add(setup); add(login); add(additional); add(logo); add(msgCountAct); }
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./*from w w w.j a v a 2s. c o m*/ * * @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.appinventor.client.explorer.youngandroid.ReportList.java
License:Open Source License
/** * Helper method of creating a sending email popup * @param report//from w w w. jav a 2 s . c om */ private void sendEmailPopup(final GalleryAppReport report) { // Create a PopUpPanel with a button to close it final PopupPanel popup = new PopupPanel(true); popup.setStyleName("ode-InboxContainer"); final FlowPanel content = new FlowPanel(); content.addStyleName("ode-Inbox"); Label title = new Label(MESSAGES.emailSendTitle()); title.addStyleName("InboxTitle"); content.add(title); Button closeButton = new Button(MESSAGES.symbolX()); closeButton.addStyleName("CloseButton"); closeButton.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { popup.hide(); } }); content.add(closeButton); final FlowPanel emailPanel = new FlowPanel(); emailPanel.addStyleName("app-actions"); final Label sentFrom = new Label(MESSAGES.emailSentFrom()); final Label sentTo = new Label(MESSAGES.emailSentTo() + report.getOffender().getUserName()); final TextArea emailBodyText = new TextArea(); emailBodyText.addStyleName("action-textarea"); final Button sendEmail = new Button(MESSAGES.buttonSendEmail()); sendEmail.addStyleName("action-button"); // Account Drop Down Button List<DropDownItem> templateItems = Lists.newArrayList(); // Email Template 1 templateItems.add( new DropDownItem("template1", MESSAGES.inappropriateAppContentRemoveTitle(), new TemplateAction( emailBodyText, EMAIL_INAPPROPRIATE_APP_CONTENT_REMOVE, report.getApp().getTitle()))); templateItems.add(new DropDownItem("template2", MESSAGES.inappropriateAppContentTitle(), new TemplateAction(emailBodyText, EMAIL_INAPPROPRIATE_APP_CONTENT, report.getApp().getTitle()))); templateItems.add(new DropDownItem("template3", MESSAGES.inappropriateUserProfileContentTitle(), new TemplateAction(emailBodyText, EMAIL_INAPPROPRIATE_USER_PROFILE_CONTENT, null))); templateButton = new DropDownButton("template", MESSAGES.labelChooseTemplate(), templateItems, true); templateButton.setStyleName("ode-TopPanelButton"); new TemplateAction(emailBodyText, EMAIL_INAPPROPRIATE_APP_CONTENT, report.getApp().getTitle()).execute(); emailPanel.add(templateButton); emailPanel.add(sentFrom); emailPanel.add(sentTo); emailPanel.add(emailBodyText); emailPanel.add(sendEmail); content.add(emailPanel); popup.setWidget(content); // Center and show the popup popup.center(); final User currentUser = Ode.getInstance().getUser(); sentFrom.setText(MESSAGES.emailSentFrom() + currentUser.getUserName()); sendEmail.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { final OdeAsyncCallback<Long> emailCallBack = new OdeAsyncCallback<Long>(MESSAGES.galleryError()) { @Override public void onSuccess(final Long emailId) { if (emailId == Email.NOTRECORDED) { Window.alert(MESSAGES.moderationErrorFailToSendEmail()); popup.hide(); } else { popup.hide(); storeModerationAction(report.getReportId(), report.getApp().getGalleryAppId(), emailId, GalleryModerationAction.SENDEMAIL, getEmailPreview(emailBodyText.getText())); } } }; String emailBody = emailBodyText.getText() + MESSAGES.galleryVisitGalleryAppLinkLabel( Window.Location.getHost(), report.getApp().getGalleryAppId()); Ode.getInstance().getGalleryService().sendEmail(currentUser.getUserId(), report.getOffender().getUserId(), report.getOffender().getUserEmail(), MESSAGES.moderationSendEmailTitle(), emailBody, emailCallBack); } }); }
From source file:com.google.appinventor.client.explorer.youngandroid.ReportList.java
License:Open Source License
/** * Helper method for deactivating App Popup * @param report GalleryAppReport Gallery App Report * @param rw ReportWidgets Report Widgets *//*from w ww . j a va 2 s. c o m*/ private void deactivateAppPopup(final GalleryAppReport report, final ReportWidgets rw) { // Create a PopUpPanel with a button to close it final PopupPanel popup = new PopupPanel(true); popup.setStyleName("ode-InboxContainer"); final FlowPanel content = new FlowPanel(); content.addStyleName("ode-Inbox"); Label title = new Label(MESSAGES.emailSendTitle()); title.addStyleName("InboxTitle"); content.add(title); Button closeButton = new Button(MESSAGES.symbolX()); closeButton.addStyleName("CloseButton"); closeButton.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { popup.hide(); } }); content.add(closeButton); final FlowPanel emailPanel = new FlowPanel(); emailPanel.addStyleName("app-actions"); final Label sentFrom = new Label(MESSAGES.emailSentFrom()); final Label sentTo = new Label(MESSAGES.emailSentTo() + report.getOffender().getUserName()); final TextArea emailBodyText = new TextArea(); emailBodyText.addStyleName("action-textarea"); final Button sendEmailAndDeactivateApp = new Button(MESSAGES.labelDeactivateAppAndSendEmail()); sendEmailAndDeactivateApp.addStyleName("action-button"); final Button cancel = new Button(MESSAGES.labelCancel()); cancel.addStyleName("action-button"); // Account Drop Down Button List<DropDownItem> templateItems = Lists.newArrayList(); // Email Template 1 templateItems.add( new DropDownItem("template1", MESSAGES.inappropriateAppContentRemoveTitle(), new TemplateAction( emailBodyText, EMAIL_INAPPROPRIATE_APP_CONTENT_REMOVE, report.getApp().getTitle()))); templateItems.add(new DropDownItem("template2", MESSAGES.inappropriateAppContentTitle(), new TemplateAction(emailBodyText, EMAIL_INAPPROPRIATE_APP_CONTENT, report.getApp().getTitle()))); templateItems.add(new DropDownItem("template3", MESSAGES.inappropriateUserProfileContentTitle(), new TemplateAction(emailBodyText, EMAIL_INAPPROPRIATE_USER_PROFILE_CONTENT, null))); templateButton = new DropDownButton("template", MESSAGES.labelChooseTemplate(), templateItems, true); templateButton.setStyleName("ode-TopPanelButton"); // automatically choose first template new TemplateAction(emailBodyText, EMAIL_INAPPROPRIATE_APP_CONTENT_REMOVE, report.getApp().getTitle()) .execute(); emailPanel.add(templateButton); emailPanel.add(sentFrom); emailPanel.add(sentTo); emailPanel.add(emailBodyText); emailPanel.add(sendEmailAndDeactivateApp); emailPanel.add(cancel); content.add(emailPanel); popup.setWidget(content); // Center and show the popup popup.center(); cancel.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { popup.hide(); } }); final User currentUser = Ode.getInstance().getUser(); sentFrom.setText(MESSAGES.emailSentFrom() + currentUser.getUserName()); sendEmailAndDeactivateApp.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { final OdeAsyncCallback<Long> emailCallback = new OdeAsyncCallback<Long>(MESSAGES.galleryError()) { @Override public void onSuccess(final Long emailId) { if (emailId == Email.NOTRECORDED) { Window.alert(MESSAGES.moderationErrorFailToSendEmail()); popup.hide(); } else { popup.hide(); final OdeAsyncCallback<Boolean> callback = new OdeAsyncCallback<Boolean>( // failure message MESSAGES.galleryError()) { @Override public void onSuccess(Boolean success) { if (!success) return; if (rw.appActive == true) { //app was active, now is deactive rw.deactiveAppButton.setText(MESSAGES.labelReactivateApp());//revert button rw.appActive = false; storeModerationAction(report.getReportId(), report.getApp().getGalleryAppId(), emailId, GalleryModerationAction.DEACTIVATEAPP, getEmailPreview(emailBodyText.getText())); } else { //app was deactive, now is active /*This should not be reached, just in case*/ rw.deactiveAppButton.setText(MESSAGES.labelDeactivateApp());//revert button rw.appActive = true; storeModerationAction(report.getReportId(), report.getApp().getGalleryAppId(), emailId, GalleryModerationAction.REACTIVATEAPP, getEmailPreview(emailBodyText.getText())); } //update gallery list galleryClient.appWasChanged(); } }; Ode.getInstance().getGalleryService() .deactivateGalleryApp(report.getApp().getGalleryAppId(), callback); } } }; String emailBody = emailBodyText.getText() + MESSAGES.galleryVisitGalleryAppLinkLabel( Window.Location.getHost(), report.getApp().getGalleryAppId()); Ode.getInstance().getGalleryService().sendEmail(currentUser.getUserId(), report.getOffender().getUserId(), report.getOffender().getUserEmail(), MESSAGES.moderationAppDeactivatedTitle(), emailBody, emailCallback); } }); }
From source file:com.google.appinventor.client.explorer.youngandroid.ReportList.java
License:Open Source License
/** * Helper method of creating popup window to show all associated moderation actions. * @param report GalleryAppReport gallery app report *//*from w ww . j a va2 s .com*/ private void seeAllActionsPopup(GalleryAppReport report) { // Create a PopUpPanel with a button to close it final PopupPanel popup = new PopupPanel(true); popup.setStyleName("ode-InboxContainer"); final FlowPanel content = new FlowPanel(); content.addStyleName("ode-Inbox"); Label title = new Label(MESSAGES.titleSeeAllActionsPopup()); title.addStyleName("InboxTitle"); content.add(title); Button closeButton = new Button(MESSAGES.symbolX()); closeButton.addStyleName("CloseButton"); closeButton.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { popup.hide(); } }); content.add(closeButton); final FlowPanel actionPanel = new FlowPanel(); actionPanel.addStyleName("app-actions"); final OdeAsyncCallback<List<GalleryModerationAction>> callback = new OdeAsyncCallback<List<GalleryModerationAction>>( // failure message MESSAGES.galleryError()) { @Override public void onSuccess(List<GalleryModerationAction> moderationActions) { for (final GalleryModerationAction moderationAction : moderationActions) { FlowPanel record = new FlowPanel(); Label time = new Label(); Date createdDate = new Date(moderationAction.getDate()); DateTimeFormat dateFormat = DateTimeFormat.getFormat("yyyy/MM/dd HH:mm:ss"); time.setText(dateFormat.format(createdDate)); time.addStyleName("time-label"); record.add(time); Label moderatorLabel = new Label(); moderatorLabel.setText(moderationAction.getModeratorName()); moderatorLabel.addStyleName("moderator-link"); moderatorLabel.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { Ode.getInstance().switchToUserProfileView(moderationAction.getModeratorId(), 1 /* 1 for public view*/ ); popup.hide(); } }); record.add(moderatorLabel); final Label actionLabel = new Label(); actionLabel.addStyleName("inline-label"); record.add(actionLabel); int actionType = moderationAction.getActonType(); switch (actionType) { case GalleryModerationAction.SENDEMAIL: actionLabel.setText(MESSAGES.moderationActionSendAnEmail()); createEmailCollapse(record, moderationAction.getMesaageId(), moderationAction.getEmailPreview()); break; case GalleryModerationAction.DEACTIVATEAPP: actionLabel.setText(MESSAGES.moderationActionDeactivateThisAppWithEmail()); createEmailCollapse(record, moderationAction.getMesaageId(), moderationAction.getEmailPreview()); break; case GalleryModerationAction.REACTIVATEAPP: actionLabel.setText(MESSAGES.moderationActionReactivateThisApp()); break; case GalleryModerationAction.MARKASRESOLVED: actionLabel.setText(MESSAGES.moderationActionMarkThisReportAsResolved()); break; case GalleryModerationAction.MARKASUNRESOLVED: actionLabel.setText(MESSAGES.moderationActionMarkThisReportAsUnresolved()); break; default: break; } actionPanel.add(record); } } }; Ode.getInstance().getGalleryService().getModerationActions(report.getReportId(), callback); content.add(actionPanel); popup.setWidget(content); // Center and show the popup popup.center(); }
From source file:com.google.appinventor.client.GalleryClient.java
License:Open Source License
/** * loadSourceFile opens the app as a new app inventor project * @param gApp the app to open//from www . ja v a 2s. co m * @return True if success, otherwise false */ public boolean loadSourceFile(GalleryApp gApp, String newProjectName, final PopupPanel popup) { final String projectName = newProjectName; final String sourceKey = getGallerySettings().getSourceKey(gApp.getGalleryAppId()); final long galleryId = gApp.getGalleryAppId(); // first check name to see if valid and unique... if (!TextValidators.checkNewProjectName(projectName)) return false; // the above function takes care of error messages // Callback for updating the project explorer after the project is created on the back-end final Ode ode = Ode.getInstance(); final OdeAsyncCallback<UserProject> callback = new OdeAsyncCallback<UserProject>( // failure message MESSAGES.createProjectError()) { @Override public void onSuccess(UserProject projectInfo) { Project project = ode.getProjectManager().addProject(projectInfo); Ode.getInstance().openYoungAndroidProjectInDesigner(project); popup.hide(); } @Override public void onFailure(Throwable caught) { popup.hide(); super.onFailure(caught); } }; // this is really what's happening here, we call server to load project ode.getProjectService().newProjectFromGallery(projectName, sourceKey, galleryId, callback); return true; }