List of usage examples for com.google.gwt.user.client.ui Label addClickHandler
public HandlerRegistration addClickHandler(ClickHandler handler)
From source file:eml.studio.client.mvp.presenter.DatasetLoader.java
License:Open Source License
/** * Loading data to the page//ww w .j a v a2 s.co m */ private void load() { resultStart = (currentPage - 1) * 13; if (currentPage == lastPage) { everyPageSize = resultSize - resultStart; } else { everyPageSize = 13; } adminView.getDataGrid().resize(everyPageSize + 1, 7); adminView.getDataGrid().setText(0, 0, "Name"); adminView.getDataGrid().setText(0, 1, "Category"); adminView.getDataGrid().setText(0, 2, "Description"); adminView.getDataGrid().setText(0, 3, "Version"); adminView.getDataGrid().setText(0, 4, "CreateDate"); adminView.getDataGrid().setText(0, 5, "Owner"); adminView.getDataGrid().setText(0, 6, "Operation"); datasetService.loadPart(resultStart, everyPageSize, new AsyncCallback<List<Dataset>>() { @Override public void onFailure(Throwable caught) { // TODO Auto-generated method stub alertPanel.setContent(caught.getMessage()); alertPanel.show(); } @Override public void onSuccess(List<Dataset> result) { // TODO Auto-generated method stub for (int i = 0; i < everyPageSize; i++) { adminView.getDataGrid().setText(i + 1, 0, result.get(i).getName()); final String categoryId = result.get(i).getCategory(); final int a = i; if (categoryId.length() == 0) { adminView.getDataGrid().setText(a + 1, 1, ""); } else if (("?").equals(categoryId) || ("my data").equals(categoryId.toLowerCase()) || ("?").equals(categoryId) || ("shared data").equals(categoryId.toLowerCase()) || ("?").equals(categoryId) || ("system data").equals(categoryId.toLowerCase())) { adminView.getDataGrid().setText(a + 1, 1, categoryId); } else { categoryService.getCategory(categoryId, new AsyncCallback<Category>() { @Override public void onFailure(Throwable caught) { // TODO Auto-generated method stub adminView.getDataGrid().setText(a + 1, 1, categoryId); } @Override public void onSuccess(Category result) { // TODO Auto-generated method stub if (result != null) { adminView.getDataGrid().setText(a + 1, 1, result.getPath()); } else adminView.getDataGrid().setText(a + 1, 1, ""); } }); } if (result.get(i).getDescription().length() > 50) { adminView.getDataGrid().setText(i + 1, 2, result.get(i).getDescription().substring(0, 49) + "..."); } else { adminView.getDataGrid().setText(i + 1, 2, result.get(i).getDescription()); } adminView.getDataGrid().setText(i + 1, 3, result.get(i).getVersion()); adminView.getDataGrid().setText(i + 1, 4, result.get(i).getCreatedate()); adminView.getDataGrid().setText(i + 1, 5, result.get(i).getOwner()); final String dataId = result.get(i).getId(); final String dataName = result.get(i).getName(); Label deleteData = new Label(); deleteData.setTitle(Constants.adminUIMsg.deleteData()); deleteData.addStyleName("admin-user-delete"); deleteData.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { // TODO Auto-generated method stub deletePanel.setContent(Constants.adminUIMsg.dataDelete1() + dataName + Constants.adminUIMsg.dataDelete2()); deletePanel.show(); deletePanel.getConfirmBtn().addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { // TODO Auto-generated method stub Dataset dataset = new Dataset(); dataset.setId(dataId); datasetService.delete(dataId, new AsyncCallback<Void>() { @Override public void onFailure(Throwable caught) { // TODO Auto-generated method stub deletePanel.hide(); alertPanel.setContent(caught.getMessage()); alertPanel.show(); } @Override public void onSuccess(Void result) { // TODO Auto-generated method stub deletePanel.hide(); alertPanel.setContent(Constants.adminUIMsg.dataSuccess()); alertPanel.show(); } }); } }); } }); HorizontalPanel operate = new HorizontalPanel(); operate.addStyleName("admin-user"); operate.add(deleteData); adminView.getDataGrid().setWidget(i + 1, 6, operate); } } }); }
From source file:eml.studio.client.mvp.presenter.DatasetLoader.java
License:Open Source License
/** * Reload search result to the page//ww w .ja v a 2 s .c o m */ private void reload() { resultStart = (currentPage - 1) * 13; if (currentPage == lastPage) { //Every page show 13 records, if the last page has less than 13 records, it show real records everyPageSize = resultSize - resultStart; } else { everyPageSize = 13; } adminView.getDataGrid().resize(everyPageSize + 1, 7); adminView.getDataGrid().setText(0, 0, "Name"); adminView.getDataGrid().setText(0, 1, "Category"); adminView.getDataGrid().setText(0, 2, "Description"); adminView.getDataGrid().setText(0, 3, "Version"); adminView.getDataGrid().setText(0, 4, "CreateDate"); adminView.getDataGrid().setText(0, 5, "Owner"); adminView.getDataGrid().setText(0, 6, "Operation"); datasetService.search(searchDataset, searchStart, searchEnd, resultStart, everyPageSize, new AsyncCallback<List<Dataset>>() { @Override public void onFailure(Throwable caught) { // TODO Auto-generated method stub alertPanel.setContent(caught.getMessage()); alertPanel.show(); } @Override public void onSuccess(List<Dataset> result) { // TODO Auto-generated method stub for (int i = 0; i < everyPageSize; i++) { adminView.getDataGrid().setText(i + 1, 0, result.get(i).getName()); final String categoryId = result.get(i).getCategory(); final int a = i; if (categoryId.length() == 0) { adminView.getDataGrid().setText(a + 1, 1, ""); } else if (("?").equals(categoryId) || ("my data").equals(categoryId.toLowerCase()) || ("?").equals(categoryId) || ("shared data").equals(categoryId.toLowerCase()) || ("?").equals(categoryId) || ("system data").equals(categoryId.toLowerCase())) { adminView.getDataGrid().setText(a + 1, 1, categoryId); } else { categoryService.getCategory(categoryId, new AsyncCallback<Category>() { @Override public void onFailure(Throwable caught) { // TODO Auto-generated method stub adminView.getDataGrid().setText(a + 1, 1, categoryId); } @Override public void onSuccess(Category result) { // TODO Auto-generated method stub if (result != null) { adminView.getDataGrid().setText(a + 1, 1, result.getPath()); } else adminView.getDataGrid().setText(a + 1, 1, ""); } }); } if (result.get(i).getDescription().length() > 50) { adminView.getDataGrid().setText(i + 1, 2, result.get(i).getDescription().substring(0, 49) + "..."); } else { adminView.getDataGrid().setText(i + 1, 2, result.get(i).getDescription()); } adminView.getDataGrid().setText(i + 1, 3, result.get(i).getVersion()); adminView.getDataGrid().setText(i + 1, 4, result.get(i).getCreatedate()); adminView.getDataGrid().setText(i + 1, 5, result.get(i).getOwner()); final String dataId = result.get(i).getId(); final String dataName = result.get(i).getName(); Label deleteData = new Label(); deleteData.setTitle(Constants.adminUIMsg.deleteData()); deleteData.addStyleName("admin-user-delete"); deleteData.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { // TODO Auto-generated method stub deletePanel.setContent(Constants.adminUIMsg.dataDelete1() + dataName + Constants.adminUIMsg.dataDelete2()); deletePanel.show(); deletePanel.getConfirmBtn().addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { // TODO Auto-generated method stub Dataset dataset = new Dataset(); dataset.setId(dataId); datasetService.delete(dataId, new AsyncCallback<Void>() { @Override public void onFailure(Throwable caught) { // TODO Auto-generated method stub deletePanel.hide(); alertPanel.setContent(caught.getMessage()); alertPanel.show(); } @Override public void onSuccess(Void result) { // TODO Auto-generated method stub deletePanel.hide(); alertPanel.setContent(Constants.adminUIMsg.dataSuccess()); alertPanel.show(); } }); } }); } }); HorizontalPanel operate = new HorizontalPanel(); operate.addStyleName("admin-user"); operate.add(deleteData); adminView.getDataGrid().setWidget(i + 1, 6, operate); } } }); }
From source file:eml.studio.client.ui.panel.HistoryPopupPanel.java
License:Open Source License
/** * Paging data loading//w w w. j ava 2 s .c o m * * @param currentPage current page number */ public void pageLoader(final int currentPage) { logger.info("current page=" + currentPage); final int startIndex = (currentPage - 1) * everyPageSize; int endIndex = startIndex; if (currentPage == totalPage) endIndex = totalRecords; else endIndex = startIndex + everyPageSize; final int size = endIndex - startIndex; pageChkBox = new HashMap<String, CheckBox>(); jobSrv.getRefOozieJobPage(bdaJobId, startIndex, size, startTime, endTime, new AsyncCallback<List<OozieJob>>() { @Override public void onFailure(Throwable caught) { // TODO Auto-generated method stub logger.warning( "The paging data of run history records loading failed! Page=" + currentPage); } @Override public void onSuccess(final List<OozieJob> result) { // TODO Auto-generated method stub if (result != null) { curPageRealSize = result.size(); logger.info("start=" + startIndex + ";end=" + (startIndex + size) + ";curSize = " + result.size()); pageGrid.addStyleName("run-history-page"); clearHistoryGridData(); for (int i = 0; i < result.size(); i++) { final OozieJob oozieJob = result.get(i); runHistoryGrid.setText(i + 1, 0, oozieJob.getAppName()); runHistoryGrid.setText(i + 1, 1, oozieJob.getStatus()); runHistoryGrid.setText(i + 1, 2, oozieJob.getAccount()); runHistoryGrid.setText(i + 1, 3, oozieJob.getDescription()); if (oozieJob.getCreatedTime() == null) runHistoryGrid.setText(i + 1, 4, ""); else runHistoryGrid.setText(i + 1, 4, formatter.format(oozieJob.getCreatedTime())); if (oozieJob.getEndTime() == null) runHistoryGrid.setText(i + 1, 5, ""); else runHistoryGrid.setText(i + 1, 5, formatter.format(oozieJob.getEndTime())); final HorizontalPanel optPanel = new HorizontalPanel(); Label historyViewLabel = new Label(); historyViewLabel.setTitle(Constants.studioUIMsg.historyView()); historyViewLabel.addStyleName("run-history-view"); historyViewLabel.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { // TODO Auto-generated method stub HistoryPopupPanel.this.hide(); String message = bdaJobId + "&instance=" + oozieJob.getId(); goToOozInstance(oozieJob.getId(), message); } }); Label deleteLabel = new Label(); deleteLabel.setTitle(Constants.studioUIMsg.historyDelete()); deleteLabel.setStyleName("run-history-delete"); deleteLabel.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { // TODO Auto-generated method stub if (result.size() == 1 && totalPage == 1) //Only one page and only include one record Window.alert("There has only one record, can't be deleted!"); else { final DeletePanel deletePanel = new DeletePanel(); deletePanel.setContent("Sure to delete this history record?"); deletePanel.show(); deletePanel.getConfirmBtn().addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { // TODO Auto-generated method stub deleteOozJob(oozieJob.getId()); deletePanel.hide(); } }); } } }); CheckBox delChkBox = null; if (totalViewChkBox.containsKey(oozieJob.getId())) delChkBox = totalViewChkBox.get(oozieJob.getId()); else { delChkBox = new CheckBox(); delChkBox.setStyleName("run-history-record-chk-box"); delChkBox.addValueChangeHandler(new ValueChangeHandler<Boolean>() { @Override public void onValueChange(ValueChangeEvent<Boolean> event) { // TODO Auto-generated method stub if (event.getValue()) { delOozieJobs.add(oozieJob.getId()); } else { if (delOozieJobs.contains(oozieJob.getId())) delOozieJobs.remove(oozieJob.getId()); } } }); totalViewChkBox.put(oozieJob.getId(), delChkBox); } pageChkBox.put(oozieJob.getId(), delChkBox); if (selectAllChkBox.isVisible()) delChkBox.setVisible(true); else delChkBox.setVisible(false); optPanel.add(historyViewLabel); if (isExample && !AppController.power.equals("111")) { } else optPanel.add(deleteLabel); optPanel.add(delChkBox); runHistoryGrid.setWidget(i + 1, 6, optPanel); } } } }); }
From source file:eml.studio.client.ui.widget.panel.SqlScriptFileConfigTable.java
License:Open Source License
public SqlScriptFileConfigTable(SqlProgramWidget widget, String name) { this.widget = widget; this.name = name; this.insertRow(0); Label add = new Label(); add.addStyleName("admin-user-edit"); this.setWidget(0, 0, new Label(name)); this.setWidget(0, 1, new Label()); this.setWidget(0, 2, add); this.setWidget(0, 3, new Label()); add.addClickHandler(new ClickHandler() { @Override/*from w w w .j a v a2s . c om*/ public void onClick(ClickEvent event) { int i = 0; while (i < SqlScriptFileConfigTable.this.getRowCount() && SqlScriptFileConfigTable.this.getWidget(i, 2) != event.getSource()) i++; if (i < SqlScriptFileConfigTable.this.getRowCount()) { addRow(i, ""); } } }); }
From source file:eml.studio.client.ui.widget.panel.SqlScriptFileConfigTable.java
License:Open Source License
protected void addRow(int row, TextBox box) { this.insertRow(row); this.setWidget(row, 0, new Label(name + " " + row)); this.setWidget(row, 1, box); Label add = new Label(); add.addStyleName("admin-user-edit"); Label del = new Label(); del.addStyleName("admin-user-delete"); this.setWidget(row, 2, add); this.setWidget(row, 3, del); for (int i = row + 1; i < this.getRowCount() - 1; ++i) { Label label = (Label) this.getWidget(i, 0); label.setText(name + " " + i); }/*from w w w . ja v a 2 s . co m*/ add.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { int i = 0; while (i < SqlScriptFileConfigTable.this.getRowCount() && SqlScriptFileConfigTable.this.getWidget(i, 2) != event.getSource()) i++; if (i < SqlScriptFileConfigTable.this.getRowCount()) { addRow(i, ""); } } }); del.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { int i = 0; while (i < SqlScriptFileConfigTable.this.getRowCount() && SqlScriptFileConfigTable.this.getWidget(i, 3) != event.getSource()) i++; if (i < SqlScriptFileConfigTable.this.getRowCount()) { deleteRow(i); } } }); active(); }
From source file:fr.aliasource.webmail.client.addressbook.ContactGroups.java
License:GNU General Public License
public void updateGrid(final ContactGroup[] groups) { clear();//from www.j a v a 2 s.c o m resizeRows(groups.length + 2); // Header setWidget(0, 0, new Label(I18N.strings.contactGroup())); getRowFormatter().setStyleName(0, "addressBookHeader"); // Group List for (int i = 0; i < groups.length; i++) { final ContactGroup cg = groups[i]; final int row = i + 1; String label = cg.getDisplayName(); if (i18nStrings.containsKey(cg.getId())) { label = i18nStrings.get(cg.getId()); } Label groupLabel = new Label(label, true); Label groupCount = new Label(Integer.toString(cg.getSize()), false); ClickHandler handler = createClickListener(row, groups, cg); groupLabel.addClickHandler(handler); groupCount.addClickHandler(handler); setWidget(row, 0, groupLabel); setWidget(row, 1, groupCount); getRowFormatter().setStyleName(row, "addressBookItem"); if (AllGroup == null) { AllGroup = cg; } } // Search Results setWidget(groups.length + 1, 0, new Label(I18N.strings.searchContactResults(), true)); getRowFormatter().setVisible(groups.length + 1, false); }
From source file:fr.aliasource.webmail.client.addressbook.ContactList.java
License:GNU General Public License
public void updateGrid(final UiContact[] contacts) { Arrays.sort(contacts, new ContactComp()); clear();//from w w w . ja v a2s . c o m int limit = getNbDisplayItems(); if (limit > contacts.length || isDisplayAllContact()) { limit = contacts.length; setDisplayAllContact(true); } resizeRows(limit + 1); // Header setWidget(0, 0, new Label(I18N.strings.contactName())); getRowFormatter().setStyleName(0, "addressBookHeader"); for (int i = 0; i < limit; i++) { final CheckBox cb = new CheckBox(); final UiContact co = contacts[i]; final int row = i + 1; Label l = new Label(contacts[i].getDisplayName(), true); l.addClickHandler(createLabelClickListener(cb, co, row)); cb.addClickHandler(createCbClickListener(cb, row, co)); setWidget(row, 0, cb); setWidget(row, 1, l); getRowFormatter().setStyleName(row, "addressBookItem"); } if (!isDisplayAllContact()) { int pos = limit + 1; resizeRows(pos + 1); Anchor hl = new Anchor(I18N.strings.displayAllXContacts(Integer.toString(contacts.length))); hl.addClickHandler(new ClickHandler() { public void onClick(ClickEvent sender) { // TODO Auto-generated method stub setDisplayAllContact(!isDisplayAllContact()); clear(); updateGrid(contacts); getRowFormatter().removeStyleName(getNbDisplayItems(), "contentInfo"); webmail.getAddressBook().getContactDisplay().reset(); } }); setWidget(pos, 1, hl); getRowFormatter().setStyleName(pos, "contentInfo"); setHeight("100%"); // "Display all" link on grid bottom } else { setHeight(""); } }
From source file:fr.aliasource.webmail.client.reader.AbstractMessageWidget.java
License:GNU General Public License
protected VerticalPanel showQuotedText(String body) { VerticalPanel newBody = new VerticalPanel(); newBody.addStyleName("messageText"); if (body == null) { return newBody; }/*from w w w. j av a 2s . co m*/ if (body.contains("<table") || body.contains("<div") || body.contains("<blockquote") || body.contains("<ul")) { newBody.add(new HTML(body)); return newBody; } body = body.replace("<br>\n", "\n"); body = body.replace("<BR>\n", "\n"); body = body.replace("<br/>\n", "\n"); body = body.replace("<BR/>\n", "\n"); body = body.replace("<br>", "\n"); body = body.replace("<BR>", "\n"); body = body.replace("<br/>", "\n"); body = body.replace("<BR/>", "\n"); String[] lines = body.split("\n"); StringBuilder quoted = new StringBuilder(); StringBuilder text = new StringBuilder(); for (int i = 0; i < lines.length; i++) { if (lines[i].startsWith(">")) { quoted.append(lines[i]).append("<br/>"); final DisclosurePanel quotedText = new DisclosurePanel(); final Label quotedHeader = new Label("- " + I18N.strings.showQuotedText() + " -"); if (i + 1 < lines.length && !lines[i + 1].startsWith(">")) { quotedHeader.addClickHandler(new ClickHandler() { public void onClick(ClickEvent ev) { if (!quotedText.isOpen()) { quotedHeader.setText("- " + I18N.strings.hideQuotedText() + " -"); } else { quotedHeader.setText("- " + I18N.strings.showQuotedText() + " -"); } } }); quotedText.setHeader(quotedHeader); quotedText.setStyleName("quotedText"); quotedText.add(new HTML(quoted.toString())); newBody.add(quotedText); quoted.delete(0, quoted.length()); } else if (i + 1 == lines.length) { quotedText.setHeader(quotedHeader); quotedText.setStyleName("quotedText"); quotedText.add(new HTML(quoted.toString())); newBody.add(quotedText); quoted.delete(0, quoted.length()); } } else { text.append(lines[i]).append("<br/>"); if (i + 1 < lines.length && lines[i + 1].startsWith(">")) { newBody.add(new HTML(text.toString())); text.delete(0, text.length()); } else { if (text.length() > 0) { newBody.add(new HTML(text.toString())); text.delete(0, text.length()); } } } } return newBody; }
From source file:fr.aliasource.webmail.client.reader.ForwardedMessageWidget.java
License:GNU General Public License
/** * MessageWidget constructor : without reply widget (for forwarded messages) *//* w ww . j ava 2s . co m*/ public ForwardedMessageWidget(View ui, ConversationDisplay convDisp, DateFormatter df, ClientMessage cm, RecipientsStyleHandler rsh, boolean clickableHeader) { this.ui = ui; this.rsh = rsh; this.cm = cm; dp = new VerticalPanel(); dp.setWidth("100%"); Label title = new Label(I18N.strings.forwardedMessage() + " - " + cm.getSubject()); title.setStyleName("header"); title.addClickHandler(new ClickHandler() { private boolean open; public void onClick(ClickEvent ev) { if (this.open) { dp.remove(header); dp.remove(content); } else { dp.add(header); dp.add(content); } this.open = !this.open; } }); createHeader(df, rsh, cm, clickableHeader, false); createContent(cm, df); dp.add(title); dp.addStyleName("content"); setWidth("100%"); add(dp); }
From source file:fr.gael.dhus.gwt.client.module.LoginModule.java
License:Open Source License
private static void loginRefresh() { final SecurityServiceAsync securityService = SecurityServiceAsync.Util.getInstance(); AccessDeniedRedirectionCallback<UserData> callback = new AccessDeniedRedirectionCallback<UserData>() { public void onSuccess(UserData result) { if (result == null) { showLogin();//from w ww . ja va2s . c o m usernameInput.setValue(""); passwordInput.setValue(""); Label login_forgot = Label.wrap(RootPanel.get("login_forgot").getElement()); login_forgot.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { Page.FORGOT.load(); } }); GWTClient.loggedOut(); } else { showLogout(result.getUsername()); GWTClient.loggedIn(result); } } public void _onFailure(Throwable ex) { Window.alert("Error while requesting user information.\n" + ex.getMessage()); showLogin(); GWTClient.loggedOut(); } }; securityService.getCurrentUser(callback); }