List of usage examples for com.google.gwt.user.client.ui PopupPanel show
public void show()
From source file:asquare.gwt.tests.popupflash.client.Demo.java
License:Apache License
public void onModuleLoad() { RootPanel body = RootPanel.get();/*from w w w . j a v a2 s . c om*/ DOM.setStyleAttribute(body.getElement(), "background", "blue"); body.add(new Button("Show popup", new ClickHandler() { public void onClick(ClickEvent event) { Button showPopupButton = (Button) event.getSource(); PopupPanel popup = new PopupPanel(true); popup.add(new HTML("Click outside the popup to dismiss it")); DOM.setStyleAttribute(popup.getElement(), "border", "solid white 5px"); DOM.setStyleAttribute(popup.getElement(), "background", "red"); popup.setSize("20em", "20em"); int x = showPopupButton.getAbsoluteLeft(); int y = showPopupButton.getAbsoluteTop() + showPopupButton.getOffsetHeight(); popup.setPopupPosition(x, y); popup.show(); } })); }
From source file:asquare.gwt.tests.popuphidden.client.Demo.java
License:Apache License
public void onModuleLoad() { RootPanel body = RootPanel.get();//from ww w .j av a 2 s.c om DOM.setStyleAttribute(body.getElement(), "background", "blue"); final Button showPopupButton = new Button("Show popup"); showPopupButton.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { final PopupPanel popup = new PopupPanel(true); VerticalPanel outer = new VerticalPanel(); outer.add(new HTML("Click outside the popup to dismiss it")); outer.add(new Button("DOM.setStyleAttribute(popup.getElement(), \"visibility\", \"hidden\")", new ClickHandler() { public void onClick(ClickEvent event) { DOM.setStyleAttribute(popup.getElement(), "visibility", "hidden"); } })); popup.setWidget(outer); DOM.setStyleAttribute(popup.getElement(), "border", "double black 4px"); DOM.setStyleAttribute(popup.getElement(), "background", "red"); popup.setSize("20em", "20em"); int x = showPopupButton.getAbsoluteLeft(); int y = showPopupButton.getAbsoluteTop() + showPopupButton.getOffsetHeight(); popup.setPopupPosition(x, y); popup.show(); } }); body.add(showPopupButton); }
From source file:asquare.gwt.tk.uitest.popuppanel.client.Demo.java
License:Apache License
private Widget createDefaultTransparencyTest() { RowPanel outer = new RowPanel(); outer.add(new HTML("<h3>Default transparency test</h3>")); final Button button = new Button("Show popup"); button.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { PopupPanel popup = new PopupPanel(true); popup.setPopupPosition(button.getAbsoluteLeft(), button.getAbsoluteTop() + button.getOffsetHeight()); popup.setWidth("10em"); DomUtil.setStyleAttribute(popup, "border", "solid black 1px"); popup.setWidget(new HTML("<p>This popup should be transparent in all browsers.</p>")); popup.show(); }//from ww w .j av a2s . c om }); outer.add(button); return outer; }
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 w w w.ja v a2s. c o 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.MailOverviewCellTable.java
License:Open Source License
private void init(final boolean withoutSearch, final MailServiceAsync mailxelService, final MailxelPanel mailxelPanel) { this.mailxelService = mailxelService; TextColumn<Envelope> toColumn = new TextColumn<Envelope>() { public String getValue(Envelope env) { return env.to; }/*w ww .j a v a 2 s .c o m*/ }; TextColumn<Envelope> dateColumn = new TextColumn<Envelope>() { public String getValue(Envelope env) { return env.date; } }; TextColumn<Envelope> gtdColumn = new TextColumn<Envelope>() { public String getValue(Envelope env) { return env.GTD; } }; TextColumn<Envelope> aColumn = new TextColumn<Envelope>() { public String getValue(Envelope env) { return Integer.toString(env.nattach); } }; rf = grid.getRowFormatter(); // header grid.setText(LABEL_ROW, C_FROM, "From"); grid.setText(LABEL_ROW, C_TO, "To"); grid.setText(LABEL_ROW, C_DATE, "Date"); grid.setText(LABEL_ROW, C_GTD, "GTD"); grid.setText(LABEL_ROW, C_ATTACHMENT, "A"); // subjectPanel.add(new Label("Subject")); // grid.setWidget(LABEL_ROW, C_SUBJECT, subjectPanel); grid.setText(LABEL_ROW, C_SUBJECT, "Subject"); ColumnFormatter fmt = grid.getColumnFormatter(); fmt.setWidth(C_FROM, "75px"); fmt.setWidth(C_TO, "75px"); fmt.setWidth(C_DATE, "75px"); fmt.setWidth(C_GTD, "50px"); fmt.setWidth(C_ATTACHMENT, "10px"); fmt.setWidth(C_SUBJECT, "400px"); final KeyPressHandler kbla = new KeyPressHandler() { public void onKeyPress(KeyPressEvent keyPressEvent) { if (KeyCodes.KEY_ENTER == keyPressEvent.getCharCode()) { currentPage = 0; startMessageSearch(mailxelService, mailxelPanel); } } }; fts = new TextBox(); fts.setTitle("full text search"); fts.setWidth("700px"); fts.addKeyPressHandler(kbla); final Image nextPage = new Image("img/resultset_next.png"); nextPage.setTitle("Next Page"); nextPage.setStylePrimaryName("mailxel-toolbar-item"); nextPage.addClickHandler(new ClickHandler() { public void onClick(ClickEvent sender) { currentPage++; startMessageSearch(mailxelService, mailxelPanel); } }); final Image prevPage = new Image("img/resultset_previous.png"); prevPage.setTitle("Previous Page"); prevPage.setStylePrimaryName("mailxel-toolbar-item"); prevPage.addClickHandler(new ClickHandler() { public void onClick(ClickEvent sender) { if (currentPage > 0) { currentPage--; } startMessageSearch(mailxelService, mailxelPanel); } }); // paginatePanel.add(attachmentName); searchPanel.add(fts); searchPanel.add(prevPage); searchPanel.add(nextPage); grid.addClickHandler(new ClickHandler() { public void onClick(ClickEvent clickEvent) { Cell cell = grid.getCellForEvent(clickEvent); if (null == cell) { return; } final int row = cell.getRowIndex(); final int col = cell.getCellIndex(); // row >= FIRST_PAYLOAD_ROW: skip header // col > 0: skip first col; contains a checkbox with separate // listener if (row >= first_payload_row && col > 0) { Envelope env = envelopes.get(row - first_payload_row); if (col == C_ATTACHMENT && env.nattach > 0) { // show popup with attachment details mailxelService.getAttachments(env.id, new AsyncCallback<List<AttachmentTO>>() { public void onSuccess(List<AttachmentTO> result) { PopupPanel pop = new PopupPanel(true); AttachmentBar ab = new AttachmentBar(mailxelService); for (AttachmentTO aTO : result) { ab.addAttachement(aTO, mailxelPanel, null); } pop.add(ab); Widget tmp = (Image) grid.getWidget(row, col); int x = tmp.getAbsoluteLeft(); int y = tmp.getAbsoluteTop(); pop.setPopupPosition(x, y); pop.show(); } public void onFailure(Throwable caught) { // ignore } }); } else if (991 == env.curcatid) { // edit message rf.setStylePrimaryName(row, "row-selected"); MailTO mt = new MailTO(); final MailSendGrid sg = new MailSendGrid(mailxelService, mailxelPanel, mt, MailSendGrid.TYPE_NEW); sg.setMailDetail(env.id); mailxelPanel.addTab(sg, env.from + ": " + env.subject); } else { // open a detail tab rf.setStylePrimaryName(row, "row-selected"); cl.setCursorPosition(row - first_payload_row); addDetailTab(mailxelService, mailxelPanel, env); } } } }); if (!withoutSearch) { add(searchPanel); } ScrollPanel sp = new ScrollPanel(); sp.add(grid); add(sp); }
From source file:ch.heftix.mailxel.client.MailOverviewCellTable.java
License:Open Source License
public void fillGrid(List<Envelope> result) { envelopes = result;// ww w. ja v a 2 s. c om // checkboxes = new ArrayList<CheckBox>(envelopes.size()); // clean all except header int rows = grid.getRowCount(); for (int i = rows - 1; i >= first_payload_row; i--) { grid.removeRow(i); } int row = first_payload_row; for (final Envelope envelope : result) { grid.setText(row, C_SELECT, Integer.toString(envelope.count)); setTextHelper(grid, row, C_FROM, envelope.from, 12); setTextHelper(grid, row, C_TO, envelope.to, 12); Label dateTime = dateTimeLabel(envelope.date, envelope.time); if (envelope.urgency > 0) { String style = "background-color:#FA5858;"; switch (envelope.urgency) { case 4: style = "background-color:#FA5858;"; break; case 3: style = "background-color:#FAAC58;"; break; case 2: style = "background-color:#F4FA58;"; break; default: style = "background-color:#ACFA58;"; break; } DOM.setElementAttribute(dateTime.getElement(), "style", style); } grid.setWidget(row, C_DATE, dateTime); // GTD label (unless label is 'not categorized') if (990 != envelope.curcatid) { Label gtdLabel = createLabel(envelope.GTD, 16); grid.setWidget(row, C_GTD, gtdLabel); // see if there is an icon for it Image img = setIconForGTD(grid, row, envelope.curcatid, envelope.GTD); img.addMouseOverHandler(new MouseOverHandler() { public void onMouseOver(final MouseOverEvent event) { final PopupPanel pop = new PopupPanel(true); pop.setPopupPosition(event.getClientX(), event.getClientY()); mailxelService.getCategoryHistory(envelope.id, new AsyncCallback<List<AttachedCategoryTO>>() { public void onFailure(Throwable caught) { // } public void onSuccess(List<AttachedCategoryTO> result) { if (null == result || result.size() < 1) { return; } FlexTable ft = new FlexTable(); pop.add(ft); int row = 0; for (AttachedCategoryTO cat : result) { ft.setText(row, 0, cat.date); String url = DirectMailServiceUtil.getIconURL(cat.category.iconid); if (null != url) { Image img = new Image(url); ft.setWidget(row, 1, img); } ft.setText(row, 2, cat.category.name); row++; } pop.show(); } }); } }); } if (envelope.nattach > 0) { Image attach = new Image("img/attach.png"); grid.setWidget(row, C_ATTACHMENT, attach); } Label subject = setTextHelper(grid, row, C_SUBJECT, envelope.subject, 64); // subject.addMouseOverHandler(new MouseOverHandler() { // // public void onMouseOver(MouseOverEvent event) { // // System.out.println("on mouse over:" + event + "/" + // // envelope); // mailxelService.snippet(envelope.id, // new AsyncCallback<String>() { // // public void onFailure(Throwable caught) { // System.out.println("E snippet: " + caught); // } // // public void onSuccess(String result) { // System.out.println("I snippet: " + result); // // } // }); // } // }); if (row % 2 == 0) { rf.setStylePrimaryName(row, "row-bg"); } row++; } cl = new CursoredList<Envelope>(envelopes); cl.setCursorPosition(0); }
From source file:ch.heftix.mailxel.client.MailOverviewGrid.java
License:Open Source License
private void init(final boolean withoutSearch, final MailServiceAsync mailxelService, final MailxelPanel mailxelPanel) { this.mailxelService = mailxelService; rf = grid.getRowFormatter();/*from ww w . j av a2s. c o m*/ // header grid.setText(LABEL_ROW, C_FROM, "From"); grid.setText(LABEL_ROW, C_TO, "To"); grid.setText(LABEL_ROW, C_DATE, "Date"); grid.setText(LABEL_ROW, C_GTD, "GTD"); grid.setText(LABEL_ROW, C_ATTACHMENT, "A"); // subjectPanel.add(new Label("Subject")); // grid.setWidget(LABEL_ROW, C_SUBJECT, subjectPanel); grid.setText(LABEL_ROW, C_SUBJECT, "Subject"); ColumnFormatter fmt = grid.getColumnFormatter(); fmt.setWidth(C_FROM, "75px"); fmt.setWidth(C_TO, "75px"); fmt.setWidth(C_DATE, "75px"); fmt.setWidth(C_GTD, "50px"); fmt.setWidth(C_ATTACHMENT, "10px"); fmt.setWidth(C_SUBJECT, "400px"); final KeyPressHandler kbla = new KeyPressHandler() { public void onKeyPress(KeyPressEvent keyPressEvent) { if (KeyCodes.KEY_ENTER == keyPressEvent.getCharCode()) { currentPage = 0; startMessageSearch(mailxelService, mailxelPanel); } } }; fts = new TextBox(); fts.setTitle("full text search"); fts.setWidth("700px"); fts.addKeyPressHandler(kbla); final Image nextPage = new Image("img/resultset_next.png"); nextPage.setTitle("Next Page"); nextPage.setStylePrimaryName("mailxel-toolbar-item"); nextPage.addClickHandler(new ClickHandler() { public void onClick(ClickEvent sender) { currentPage++; startMessageSearch(mailxelService, mailxelPanel); } }); final Image prevPage = new Image("img/resultset_previous.png"); prevPage.setTitle("Previous Page"); prevPage.setStylePrimaryName("mailxel-toolbar-item"); prevPage.addClickHandler(new ClickHandler() { public void onClick(ClickEvent sender) { if (currentPage > 0) { currentPage--; } startMessageSearch(mailxelService, mailxelPanel); } }); // paginatePanel.add(attachmentName); searchPanel.add(fts); searchPanel.add(prevPage); searchPanel.add(nextPage); grid.addClickHandler(new ClickHandler() { public void onClick(ClickEvent clickEvent) { Cell cell = grid.getCellForEvent(clickEvent); if (null == cell) { return; } final int row = cell.getRowIndex(); final int col = cell.getCellIndex(); // row >= FIRST_PAYLOAD_ROW: skip header // col > 0: skip first col; contains a checkbox with separate // listener if (row >= first_payload_row && col > 0) { Envelope env = envelopes.get(row - first_payload_row); if (col == C_ATTACHMENT && env.nattach > 0) { // show popup with attachment details mailxelService.getAttachments(env.id, new AsyncCallback<List<AttachmentTO>>() { public void onSuccess(List<AttachmentTO> result) { PopupPanel pop = new PopupPanel(true); AttachmentBar ab = new AttachmentBar(mailxelService); for (AttachmentTO aTO : result) { ab.addAttachement(aTO, mailxelPanel, null); } pop.add(ab); Widget tmp = (Image) grid.getWidget(row, col); int x = tmp.getAbsoluteLeft(); int y = tmp.getAbsoluteTop(); pop.setPopupPosition(x, y); pop.show(); } public void onFailure(Throwable caught) { // ignore } }); } else if (991 == env.curcatid) { // edit message rf.setStylePrimaryName(row, "row-selected"); MailTO mt = new MailTO(); final MailSendGrid sg = new MailSendGrid(mailxelService, mailxelPanel, mt, MailSendGrid.TYPE_NEW); sg.setMailDetail(env.id); mailxelPanel.addTab(sg, env.from + ": " + env.subject); } else { // open a detail tab rf.setStylePrimaryName(row, "row-selected"); cl.setCursorPosition(row - first_payload_row); addDetailTab(mailxelService, mailxelPanel, env); } } } }); if (!withoutSearch) { add(searchPanel); } ScrollPanel sp = new ScrollPanel(); sp.add(grid); add(sp); }
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 . ja v a2 s . c o m 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 w w . java 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:ch.heftix.mailxel.client.StatusItem.java
License:Open Source License
public void error(final Throwable caught) { working.setUrl("img/exclamation-white.png"); lDone.setText(caught.getMessage());/*from w ww. j av a 2 s .c o m*/ working.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { HTML html = new HTML(UIUtil.stackTrace(caught)); PopupPanel pop = new PopupPanel(true); pop.add(html); int x = working.getAbsoluteLeft(); int y = working.getAbsoluteTop(); pop.setPopupPosition(x, y); pop.show(); } }); isDone = true; }