List of usage examples for com.google.gwt.event.dom.client KeyPressEvent getCharCode
public char getCharCode()
From source file:at.ait.dme.yuma.client.colorpicker.ColorPicker.java
License:Artistic License
/** * Fired when a keyboard action generates a character. This occurs after onKeyDown and onKeyUp are fired for the physical key that was pressed. * * It should be noted that many browsers do not generate keypress events for non-printing keyCode values, such as KEY_ENTER or arrow keys. These keyCodes can be reliably captured either with onKeyDown(Widget, char, int) or onKeyUp(Widget, char, int). * * Subclasses that override this method must call <tt>super.onKeyPress(sender, keyCode, modifiers)</tt> to ensure that the Widget recieves its events. * @param sender the widget that was focused when the event occurred. * @see com.google.gwt.user.client.ui.KeyboardListener *///from w w w . ja v a 2s.c o m public void onKeyPress(KeyPressEvent event) { Widget sender = (Widget) event.getSource(); char keyCode = event.getCharCode(); if (sender == tbHexColor) { // Disallow non-hex in hexadecimal boxes if ((!Character.isDigit(keyCode)) && (keyCode != 'A') && (keyCode != 'a') && (keyCode != 'B') && (keyCode != 'b') && (keyCode != 'C') && (keyCode != 'c') && (keyCode != 'D') && (keyCode != 'd') && (keyCode != 'E') && (keyCode != 'e') && (keyCode != 'F') && (keyCode != 'f') && (keyCode != (char) KeyCodes.KEY_TAB) && (keyCode != (char) KeyCodes.KEY_BACKSPACE) && (keyCode != (char) KeyCodes.KEY_DELETE) && (keyCode != (char) KeyCodes.KEY_ENTER) && (keyCode != (char) KeyCodes.KEY_HOME) && (keyCode != (char) KeyCodes.KEY_END) && (keyCode != (char) KeyCodes.KEY_LEFT) && (keyCode != (char) KeyCodes.KEY_UP) && (keyCode != (char) KeyCodes.KEY_RIGHT) && (keyCode != (char) KeyCodes.KEY_DOWN)) { ((TextBox) sender).cancelKey(); } } else { // Disallow non-numerics in numeric boxes if ((!Character.isDigit(keyCode)) && (keyCode != (char) KeyCodes.KEY_TAB) && (keyCode != (char) KeyCodes.KEY_BACKSPACE) && (keyCode != (char) KeyCodes.KEY_DELETE) && (keyCode != (char) KeyCodes.KEY_ENTER) && (keyCode != (char) KeyCodes.KEY_HOME) && (keyCode != (char) KeyCodes.KEY_END) && (keyCode != (char) KeyCodes.KEY_LEFT) && (keyCode != (char) KeyCodes.KEY_UP) && (keyCode != (char) KeyCodes.KEY_RIGHT) && (keyCode != (char) KeyCodes.KEY_DOWN)) { ((TextBox) sender).cancelKey(); } } }
From source file:at.ait.dme.yuma.client.map.annotation.ControlPointForm.java
License:EUPL
public ControlPointForm(ImageAnnotationComposite annotationComposite, ControlPointLayer controlPointLayer, ImageAnnotationTreeNode annotationTreeNode, boolean fragmentAnnotation, boolean update) { // Reference to control point layer this.controlPointLayer = controlPointLayer; // Place name (will be geo-coded) HorizontalPanel placeNamePanel = new HorizontalPanel(); Label placeNameLabel = new Label("Place: "); placeNameLabel.setStyleName("cp-Editor-Label"); placeNamePanel.add(placeNameLabel);/*from w ww . j a va 2 s . co m*/ placeName = new TextBox(); placeName.setStyleName("cp-Editor-Field"); placeName.addKeyPressHandler(new KeyPressHandler() { @Override public void onKeyPress(KeyPressEvent event) { doAsyncGeocoding(placeName.getText() + event.getCharCode()); } }); placeNamePanel.add(placeName); // Lon (determined automatically - field disabled) HorizontalPanel lonPanel = new HorizontalPanel(); Label lonLabel = new Label("Lon: "); lonLabel.setStyleName("cp-Editor-Label"); lonPanel.add(lonLabel); lon = new TextBox(); lon.setEnabled(false); lon.setStyleName("cp-Editor-Field"); lonPanel.add(lon); // Lat (determined automatically - field disabled) HorizontalPanel latPanel = new HorizontalPanel(); Label latLabel = new Label("Lat: "); latLabel.setStyleName("cp-Editor-Label"); latPanel.add(latLabel); lat = new TextBox(); lat.setEnabled(false); lat.setStyleName("cp-Editor-Field"); latPanel.add(lat); // X/Y (determined automatically - field disabled) HorizontalPanel xyPanel = new HorizontalPanel(); Label xyLabel = new Label("X/Y: "); xyLabel.setStyleName("cp-Editor-Label"); xyPanel.add(xyLabel); xy = new TextBox(); xy.setEnabled(false); xy.setStyleName("cp-Editor-Field"); xyPanel.add(xy); if (update) { ImageAnnotation annotation = annotationTreeNode.getAnnotation(); placeName.setText(annotation.getTitle()); GeoPoint p = (GeoPoint) annotation.getFragment().getShape(); lon.setText(Double.toString(p.getLng())); lat.setText(Double.toString(p.getLat())); setXY(p.getX(), p.getY()); } // Assemble the main FlowPanel FlowPanel form = new FlowPanel(); form.setStyleName("cp-Editor"); form.add(placeNamePanel); form.add(lonPanel); form.add(latPanel); form.add(xyPanel); form.add(createButtonsPanel(update, annotationTreeNode, annotationComposite)); form.setStyleName("imageAnnotation-form"); initWidget(form); controlPointLayer.setControlPointForm(this); if (update) { controlPointLayer.showActiveFragmentPanel(annotationTreeNode.getAnnotation(), false); } else { controlPointLayer.showActiveFragmentPanel(null, false); } }
From source file:br.org.olimpiabarbacena.client.formulario.Membro.java
License:Apache License
public Membro(Principal principal, DialogBox dialogo) { this.principal = principal; this.dialogo = dialogo; initWidget(uiBinder.createAndBindUi(this)); dateboxNascimento.setFormat(new DateBox.DefaultFormat(DateTimeFormat.getFormat("dd/MM/yyyy"))); // Let's disallow non-numeric entry in the normal text box. textboxCPF.addKeyPressHandler(new KeyPressHandler() { @Override// w w w . j av a 2 s . c o m public void onKeyPress(KeyPressEvent event) { if (!InputValidator.isInteger(event.getCharCode())) { // TextBox.cancelKey() suppresses the current keyboard ((TextBox) event.getSource()).cancelKey(); } } }); // Let's disallow non-numeric entry in the normal text box. textboxCEP.addKeyPressHandler(new KeyPressHandler() { @Override public void onKeyPress(KeyPressEvent event) { if (!InputValidator.isInteger(event.getCharCode())) { // TextBox.cancelKey() suppresses the current keyboard ((TextBox) event.getSource()).cancelKey(); } } }); // adiciona a lista dos estados brasileiros comboEstado.addItem("AC"); comboEstado.addItem("AL"); comboEstado.addItem("AP"); comboEstado.addItem("AM"); comboEstado.addItem("BA"); comboEstado.addItem("CE"); comboEstado.addItem("DF"); comboEstado.addItem("ES"); comboEstado.addItem("GO"); comboEstado.addItem("MA"); comboEstado.addItem("MT"); comboEstado.addItem("MS"); comboEstado.addItem("MG"); comboEstado.addItem("PA"); comboEstado.addItem("PB"); comboEstado.addItem("PR"); comboEstado.addItem("PE"); comboEstado.addItem("PI"); comboEstado.addItem("RJ"); comboEstado.addItem("RN"); comboEstado.addItem("RS"); comboEstado.addItem("RO"); comboEstado.addItem("RR"); comboEstado.addItem("SC"); comboEstado.addItem("SP"); comboEstado.addItem("SE"); comboEstado.addItem("TO"); }
From source file:ch.heftix.mailxel.client.AddressOverviewGrid.java
License:Open Source License
public AddressOverviewGrid(final MailServiceAsync mailxelService, final MailxelPanel mailxelPanel) { HorizontalPanel toolbar = new HorizontalPanel(); Image save = new Image("img/save.png"); save.setTitle("Save"); save.setStylePrimaryName("mailxel-toolbar-item"); save.addClickHandler(new ClickHandler() { public void onClick(ClickEvent sender) { final StatusItem si = mailxelPanel.statusStart("address update"); List<AddressTO> addressesToSave = new ArrayList<AddressTO>(); int len = grid.getRowCount(); for (int i = FIRST_PAYLOAD_ROW; i < len; i++) { TextBoxWChangeDetection tbS = (TextBoxWChangeDetection) grid.getWidget(i, 0); TextBoxWChangeDetection tbN = (TextBoxWChangeDetection) grid.getWidget(i, 1); TextBoxWChangeDetection tbA = (TextBoxWChangeDetection) grid.getWidget(i, 2); CheckBoxWChangeDetection cbV = (CheckBoxWChangeDetection) grid.getWidget(i, 3); CheckBoxWChangeDetection cbP = (CheckBoxWChangeDetection) grid.getWidget(i, 4); if (null != tbS && null != tbA && null != cbV && null != cbP && (tbS.isDirty() || tbN.isDirty() || tbA.isDirty() || cbV.isDirty() || cbP.isDirty())) { // add to save list AddressTO to = new AddressTO(); to.shortname = tbS.getText(); if (tbS.isDirty()) { to.shortNameDirty = true; }/* ww w .ja v a 2 s. c om*/ to.name = tbN.getText(); if (tbN.isDirty()) { to.nameDirty = true; } to.address = tbA.getText(); to.isValid = cbV.getValue(); if (cbV.isDirty()) { to.validDirty = true; } to.isPreferred = cbP.getValue(); if (cbP.isDirty()) { to.preferredDirty = true; } addressesToSave.add(to); } } mailxelService.saveAddresses(addressesToSave, new AsyncCallback<Void>() { public void onFailure(Throwable caught) { si.error(caught); } public void onSuccess(Void result) { si.done(); } }); } }); toolbar.add(save); // toolbar.add(statusMessage); add(toolbar); final TextBox shortname = new TextBox(); shortname.setWidth("50px"); final TextBox address = new TextBox(); address.setWidth("300px"); // header grid.setText(LABEL_ROW, 0, "Shortname"); grid.setText(LABEL_ROW, 1, "Name"); grid.setText(LABEL_ROW, 2, "Address"); grid.setText(LABEL_ROW, 3, "Valid"); grid.setText(LABEL_ROW, 4, "Pref."); grid.setText(LABEL_ROW, 5, "Last Seen"); grid.setText(LABEL_ROW, 6, "# Seen"); ColumnFormatter fmt = grid.getColumnFormatter(); fmt.setWidth(0, "50px"); fmt.setWidth(1, "100px"); fmt.setWidth(2, "300px"); fmt.setWidth(3, "50px"); fmt.setWidth(4, "50px"); fmt.setWidth(5, "100px"); fmt.setWidth(6, "100px"); final AsyncCallback<List<AddressTO>> callback = new AsyncCallback<List<AddressTO>>() { public void onSuccess(List<AddressTO> result) { addresses = result; // 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 (AddressTO address : result) { TextBoxWChangeDetection snTB = new TextBoxWChangeDetection(); snTB.setText(address.shortname); snTB.setWidth("50px"); grid.setWidget(row, 0, snTB); // grid.setText(row, 1, address.address); TextBoxWChangeDetection nTB = new TextBoxWChangeDetection(); if (null != address.name) { nTB.setText(address.name); } nTB.setWidth("100px"); grid.setWidget(row, 1, nTB); TextBoxWChangeDetection aTB = new TextBoxWChangeDetection(); aTB.setText(address.address); aTB.setWidth("300px"); grid.setWidget(row, 2, aTB); CheckBoxWChangeDetection cbValid = new CheckBoxWChangeDetection(); cbValid.setValue(address.isValid); grid.setWidget(row, 3, cbValid); CheckBoxWChangeDetection cbPref = new CheckBoxWChangeDetection(); cbPref.setValue(address.isPreferred); grid.setWidget(row, 4, cbPref); grid.setText(row, 5, address.lastSeen); grid.setText(row, 6, Integer.toString(address.count)); row++; } if (null != statusItem) { statusItem.done("found " + Integer.toString(row - FIRST_PAYLOAD_ROW) + " addresses.", 0); statusItem = null; } } public void onFailure(Throwable caught) { statusItem.error(caught); } }; final KeyPressHandler kbla = new KeyPressHandler() { public void onKeyPress(KeyPressEvent event) { if (KeyCodes.KEY_ENTER == event.getCharCode()) { String snTxt = UIUtil.trimNull(shortname.getText()); String aTxt = UIUtil.trimNull(address.getText()); statusItem = mailxelPanel.statusStart("address search"); mailxelService.searchAddresses(snTxt, aTxt, callback); } } }; // final KeyboardListenerAdapter kbla = new KeyboardListenerAdapter() { // // public void onKeyPress(Widget sender, char keyCode, int modifiers) { // if (KEY_ENTER == keyCode) { // String snTxt = UIUtil.trimNull(shortname.getText()); // String aTxt = UIUtil.trimNull(address.getText()); // // statusItem = mailxelPanel.statusStart("address search started"); // // mailxelService.searchAddresses(snTxt, aTxt, callback); // } // } // }; shortname.addKeyPressHandler(kbla); address.addKeyPressHandler(kbla); grid.setWidget(HEADER_ROW_1, 0, shortname); grid.setWidget(HEADER_ROW_1, 2, address); add(grid); }
From source file:ch.heftix.mailxel.client.CategoryOverviewGrid.java
License:Open Source License
public CategoryOverviewGrid(final MailServiceAsync mailxelService, final MailxelPanel mailxelPanel) { HorizontalPanel toolbar = new HorizontalPanel(); Image save = new Image("img/save.png"); save.setTitle("Save"); save.setStylePrimaryName("mailxel-toolbar-item"); save.addClickHandler(new ClickHandler() { public void onClick(ClickEvent sender) { final StatusItem si = mailxelPanel.statusStart("category update"); List<Category> categoriesToSave = new ArrayList<Category>(); int len = grid.getRowCount(); for (int i = FIRST_PAYLOAD_ROW; i < len; i++) { TextBoxWChangeDetection tbS = (TextBoxWChangeDetection) grid.getWidget(i, 0); if (null != tbS && tbS.isDirty()) { // add to save list Category existing = categories.get(i - FIRST_PAYLOAD_ROW); existing.name = tbS.getText(); categoriesToSave.add(existing); }/*from www . j av a 2 s. c o m*/ } mailxelService.saveCategories(categoriesToSave, new AsyncCallback<Void>() { public void onFailure(Throwable caught) { si.error(caught); } public void onSuccess(Void result) { si.done(); } }); } }); toolbar.add(save); Image addCategory = new Image("img/plus.png"); addCategory.setTitle("New Category"); addCategory.setStylePrimaryName("mailxel-toolbar-item"); addCategory.addClickHandler(new ClickHandler() { public void onClick(ClickEvent sender) { Category cat = new Category(); cat.id = Constants.UNDEFINED_ID; cat.name = "new category"; categories.add(cat); updateGrid(categories); } }); toolbar.add(addCategory); add(toolbar); final TextBox category = new TextBox(); category.setWidth("400px"); // header grid.setText(LABEL_ROW, 0, "Category"); final MailxelAsyncCallback<List<Category>> callback = new MailxelAsyncCallback<List<Category>>() { private StatusItem si = null; public void setStatusItem(StatusItem statusItem) { this.si = statusItem; } public void onSuccess(List<Category> result) { categories = result; int row = updateGrid(result); si.done("found " + Integer.toString(row - FIRST_PAYLOAD_ROW) + " categories.", 0); } public void onFailure(Throwable caught) { si.error(caught); } }; // final KeyboardListenerAdapter kbla = new KeyboardListenerAdapter() { // // public void onKeyPress(Widget sender, char keyCode, int modifiers) { // if (KEY_ENTER == keyCode) { // String snTxt = UIUtil.trimNull(category.getText()); // // mailxelPanel.setStatus("category search started"); // // mailxelService.searchCategories(snTxt, callback); // } // } // }; final KeyPressHandler kbla = new KeyPressHandler() { public void onKeyPress(KeyPressEvent event) { if (KeyCodes.KEY_ENTER == event.getCharCode()) { String snTxt = UIUtil.trimNull(category.getText()); StatusItem si = mailxelPanel.statusStart("category search"); callback.setStatusItem(si); mailxelService.searchCategories(snTxt, callback); } } }; category.addKeyPressHandler(kbla); grid.setWidget(HEADER_ROW_1, 0, category); add(grid); }
From source file:ch.heftix.mailxel.client.IconOverviewGrid.java
License:Open Source License
public IconOverviewGrid(final MailServiceAsync mailxelService, final MailxelPanel mailxelPanel) { HorizontalPanel toolbar = new HorizontalPanel(); // Image addQuery = new Image("img/plus.png"); // addQuery.setTitle("New Query"); // addQuery.setStylePrimaryName("mailxel-toolbar-item"); // addQuery.addClickHandler(new ClickHandler() { ////w ww . j a v a 2 s. c om // public void onClick(ClickEvent sender) { // MessageQueryTO mqTO = new MessageQueryTO(); // mqTO.id = MessageQueryTO.NEW_ID; // mqTO.name = "new query"; // queries.add(mqTO); // updateGrid(queries); // MessageQueryEditGrid dg = new MessageQueryEditGrid(mailxelService, // mailxelPanel, mqTO); // mailxelPanel.addTab(dg, "new message query"); // } // }); // // toolbar.add(addQuery); add(toolbar); final TextBox query = new TextBox(); query.setWidth("400px"); // header grid.setText(LABEL_ROW, 0, "Id"); grid.setText(LABEL_ROW, 1, "Icon"); grid.setText(LABEL_ROW, 2, "Name"); final MailxelAsyncCallback<List<IconTO>> callback = new MailxelAsyncCallback<List<IconTO>>() { private StatusItem si = null; public void setStatusItem(StatusItem statusItem) { this.si = statusItem; } public void onSuccess(List<IconTO> result) { icons = result; int row = updateGrid(result); si.done("found " + Integer.toString(row - FIRST_PAYLOAD_ROW) + " icons.", 0); } public void onFailure(Throwable caught) { si.error(caught); } }; final KeyPressHandler kbla = new KeyPressHandler() { public void onKeyPress(KeyPressEvent event) { if (KeyCodes.KEY_ENTER == event.getCharCode()) { String snTxt = UIUtil.trimNull(query.getText()); StatusItem si = mailxelPanel.statusStart("icon search"); callback.setStatusItem(si); mailxelService.searchIcons(snTxt, callback); } } }; query.addKeyPressHandler(kbla); grid.setWidget(HEADER_ROW_1, 2, query); grid.addClickHandler(new ClickHandler() { public void onClick(ClickEvent clickEvent) { Cell cell = grid.getCellForEvent(clickEvent); final int row = cell.getRowIndex(); // row >= FIRST_PAYLOAD_ROW: skip header if (row >= FIRST_PAYLOAD_ROW) { IconTO icon = icons.get(row - FIRST_PAYLOAD_ROW); } } }); add(grid); }
From source file:ch.heftix.mailxel.client.LoginPanel.java
License:Open Source License
public LoginPanel(final MailServiceAsync mailxelService, final MailxelPanel mailxelPanel) { super(true);//from ww w. j a v a 2 s . c o m FlexTable grid = new FlexTable(); // header grid.setText(0, 0, "Account"); grid.setText(0, 1, "Password"); // send account grid.setText(1, 0, "Send"); final PasswordTextBox smtb = new PasswordTextBox(); grid.setWidget(1, 1, smtb); LoginButton loginSMTPButton = new LoginButton(mailxelService, MailService.ACCOUNT_SEND, smtb); grid.setWidget(1, 2, loginSMTPButton); // one line per account ConfigTO configTO = mailxelPanel.getConfig(); String[] accounts = configTO.accountNames; for (int i = 0; i < accounts.length; i++) { final String account = accounts[i]; // label grid.setText(i + 2, 0, account); // field final PasswordTextBox tb = new PasswordTextBox(); grid.setWidget(i + 2, 1, tb); // button final LoginButton button = new LoginButton(mailxelService, account, tb); tb.addKeyPressHandler(new KeyPressHandler() { public void onKeyPress(KeyPressEvent event) { if (event.getCharCode() == KeyCodes.KEY_ENTER) { button.doLogin(); } } }); grid.setWidget(i + 2, 2, button); } add(grid); }
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; }/* ww w . ja v a2s .c om*/ }; 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.MailOverviewGrid.java
License:Open Source License
private void init(final boolean withoutSearch, final MailServiceAsync mailxelService, final MailxelPanel mailxelPanel) { this.mailxelService = mailxelService; rf = grid.getRowFormatter();/* w w w . ja v a 2s. 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.MessageQueryOverviewGrid.java
License:Open Source License
public MessageQueryOverviewGrid(final MailServiceAsync mailxelService, final MailxelPanel mailxelPanel) { HorizontalPanel toolbar = new HorizontalPanel(); Image addQuery = new Image("img/plus.png"); addQuery.setTitle("New Query"); addQuery.setStylePrimaryName("mailxel-toolbar-item"); addQuery.addClickHandler(new ClickHandler() { public void onClick(ClickEvent sender) { MessageQueryTO mqTO = new MessageQueryTO(); mqTO.id = Constants.UNDEFINED_ID; mqTO.name = "new query"; queries.add(mqTO);//from www.j a va2 s. c o m updateGrid(queries); MessageQueryEditGrid dg = new MessageQueryEditGrid(mailxelService, mailxelPanel, mqTO); mailxelPanel.addTab(dg, "new message query"); } }); toolbar.add(addQuery); add(toolbar); final TextBox query = new TextBox(); query.setWidth("400px"); // header grid.setText(LABEL_ROW, 0, "Count"); grid.setText(LABEL_ROW, 1, "Short"); grid.setText(LABEL_ROW, 2, "Query Name"); final MailxelAsyncCallback<List<MessageQueryTO>> callback = new MailxelAsyncCallback<List<MessageQueryTO>>() { private StatusItem si = null; public void setStatusItem(StatusItem statusItem) { this.si = statusItem; } public void onSuccess(List<MessageQueryTO> result) { queries = result; int row = updateGrid(result); si.done("found " + Integer.toString(row - FIRST_PAYLOAD_ROW) + " queries.", 0); } public void onFailure(Throwable caught) { si.error(caught); } }; final KeyPressHandler kbla = new KeyPressHandler() { public void onKeyPress(KeyPressEvent event) { if (KeyCodes.KEY_ENTER == event.getCharCode()) { String snTxt = UIUtil.trimNull(query.getText()); StatusItem si = mailxelPanel.statusStart("query search"); callback.setStatusItem(si); mailxelService.searchQueries(null, snTxt, callback); } } }; query.addKeyPressHandler(kbla); grid.setWidget(HEADER_ROW_1, 2, query); grid.addClickHandler(new ClickHandler() { public void onClick(ClickEvent clickEvent) { Cell cell = grid.getCellForEvent(clickEvent); final int row = cell.getRowIndex(); // row >= FIRST_PAYLOAD_ROW: skip header if (row >= FIRST_PAYLOAD_ROW) { MessageQueryTO query = queries.get(row - FIRST_PAYLOAD_ROW); final MessageQueryEditGrid detailGrid = new MessageQueryEditGrid(mailxelService, mailxelPanel, query); mailxelPanel.addTab(detailGrid, "mquery: " + query.shortname); } } }); add(grid); }