List of usage examples for com.google.gwt.cell.client ButtonCell ButtonCell
public ButtonCell()
From source file:br.org.olimpiabarbacena.client.Pesquisar.java
License:Apache License
public void listarAcervo() { // remove todas as colunas for (int i = cellTable.getColumnCount() - 1; i >= 0; i--) { cellTable.removeColumn(i);//from w ww. j av a 2s . c o m } // Adiciona coluna imagem para exibir o tipo. Column<Object, ImageResource> colunaTipo = new Column<Object, ImageResource>(new ImageResourceCell()) { @Override public ImageResource getValue(Object object) { if (object.getClass().getName().equals("br.org.olimpiabarbacena.shared.dados.Midia")) { if (((Midia) object).getTipo() == Tipo.LIVRO) { return Icons.INSTANCE.livro(); } else if (((Midia) object).getTipo() == Tipo.CD) { return Icons.INSTANCE.cd(); } else if (((Midia) object).getTipo() == Tipo.DVD) { return Icons.INSTANCE.dvd(); } else if (((Midia) object).getTipo() == Tipo.REVISTA) { return Icons.INSTANCE.revista(); } else if (((Midia) object).getTipo() == Tipo.JORNAL) { return Icons.INSTANCE.jornal(); } else { return Icons.INSTANCE.desconhecido(); } } return Icons.INSTANCE.desconhecido(); } }; cellTable.addColumn(colunaTipo, "Tipo"); cellTable.setColumnWidth(colunaTipo, "16px"); // Adiciona coluna texto para exibir o ttulo. TextColumn<Object> colunaNome = new TextColumn<Object>() { @Override public String getValue(Object object) { if (object.getClass().getName().equals("br.org.olimpiabarbacena.shared.dados.Midia")) { return ((Midia) object).getTitulo(); } return new String(); } }; colunaNome.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT); cellTable.addColumn(colunaNome, "Ttulo"); // Adiciona coluna com o boto editar. ButtonCell buttonCellEditar = new ButtonCell() { @Override public void render(Context context, SafeHtml data, SafeHtmlBuilder sb) { if (data != null) { ImageResource icon = Icons.INSTANCE.editar(); String iconDisplay = AbstractImagePrototype.create(icon).getHTML(); iconDisplay = iconDisplay.replaceFirst(">", " title=\"Editar\">"); SafeHtml html = SafeHtmlUtils.fromTrustedString(iconDisplay); sb.append(html); } } }; Column<Object, String> colunaEditar = new Column<Object, String>(buttonCellEditar) { @Override public String getValue(Object object) { return "Editar"; } }; colunaEditar.setFieldUpdater(new FieldUpdater<Object, String>() { @Override public void update(int index, Object object, String value) { if (object.getClass().getName().equals("br.org.olimpiabarbacena.shared.dados.Midia")) { if (((Midia) object).getTipo() == Tipo.LIVRO) { principal.getControle().setDialogo(new DialogBox(false)); principal.getControle().getDialogo().setWidth("464px"); principal.getControle().getDialogo().setHeight("417px"); principal.getControle().setLivro(new br.org.olimpiabarbacena.client.formulario.midia.Livro( principal, principal.getControle().getDialogo())); principal.getControle().getLivro().get(((Midia) object).getId()); principal.getControle().getDialogo().setWidget(principal.getControle().getLivro()); principal.getControle().getDialogo().center(); } else if (((Midia) object).getTipo() == Tipo.CD) { principal.getControle().setDialogo(new DialogBox(false)); principal.getControle().getDialogo().setWidth("462px"); principal.getControle().getDialogo().setHeight("261px"); principal.getControle().setCD(new br.org.olimpiabarbacena.client.formulario.midia.CD( principal, principal.getControle().getDialogo(), Tipo.CD)); principal.getControle().getCD().get(((Midia) object).getId()); principal.getControle().getDialogo().setWidget(principal.getControle().getCD()); principal.getControle().getDialogo().center(); } else if (((Midia) object).getTipo() == Tipo.DVD) { principal.getControle().setDialogo(new DialogBox(false)); principal.getControle().getDialogo().setWidth("462px"); principal.getControle().getDialogo().setHeight("261px"); principal.getControle().setCD(new br.org.olimpiabarbacena.client.formulario.midia.CD( principal, principal.getControle().getDialogo(), Tipo.DVD)); principal.getControle().getCD().get(((Midia) object).getId()); principal.getControle().getDialogo().setWidget(principal.getControle().getCD()); principal.getControle().getDialogo().center(); } else if (((Midia) object).getTipo() == Tipo.JORNAL) { principal.getControle().setDialogo(new DialogBox(false)); principal.getControle().getDialogo().setWidth("460px"); principal.getControle().getDialogo().setHeight("359px"); principal.getControle() .setJornal(new br.org.olimpiabarbacena.client.formulario.midia.Jornal(principal, principal.getControle().getDialogo(), Tipo.JORNAL)); principal.getControle().getJornal().get(((Midia) object).getId()); principal.getControle().getDialogo().setWidget(principal.getControle().getJornal()); principal.getControle().getDialogo().center(); } else if (((Midia) object).getTipo() == Tipo.REVISTA) { principal.getControle().setDialogo(new DialogBox(false)); principal.getControle().getDialogo().setWidth("460px"); principal.getControle().getDialogo().setHeight("359px"); principal.getControle() .setJornal(new br.org.olimpiabarbacena.client.formulario.midia.Jornal(principal, principal.getControle().getDialogo(), Tipo.REVISTA)); principal.getControle().getJornal().get(((Midia) object).getId()); principal.getControle().getDialogo().setWidget(principal.getControle().getJornal()); principal.getControle().getDialogo().center(); } } } }); colunaEditar.setCellStyleNames("gwt-cell-pointer"); cellTable.addColumn(colunaEditar, new String()); cellTable.setColumnWidth(colunaEditar, "16px"); // Adiciona coluna com o boto remover. ButtonCell buttonCellRemover = new ButtonCell() { @Override public void render(Context context, SafeHtml data, SafeHtmlBuilder sb) { if (data != null) { ImageResource icon = Icons.INSTANCE.remover(); String iconDisplay = AbstractImagePrototype.create(icon).getHTML(); iconDisplay = iconDisplay.replaceFirst(">", " title=\"Remover\">"); SafeHtml html = SafeHtmlUtils.fromTrustedString(iconDisplay); sb.append(html); } } }; Column<Object, String> colunaRemover = new Column<Object, String>(buttonCellRemover) { @Override public String getValue(Object object) { return "Remover"; } }; colunaRemover.setFieldUpdater(new FieldUpdater<Object, String>() { @Override public void update(int index, Object object, String value) { if (object.getClass().getName().equals("br.org.olimpiabarbacena.shared.dados.Midia")) { if (Window.confirm( "Deseja remover \"" + ((Midia) object).getTitulo() + "\" e suas dependncias?")) { midiaService.remover(((Midia) object).getId(), new AsyncCallback<Void>() { @Override public void onFailure(Throwable caught) { }; @Override public void onSuccess(Void result) { limpar(); listarAcervo(); }; }); } } } }); colunaRemover.setCellStyleNames("gwt-cell-pointer"); cellTable.addColumn(colunaRemover, new String()); cellTable.setColumnWidth(colunaRemover, "16px"); dataProvider = new AsyncDataProvider<Object>() { @Override protected void onRangeChanged(HasData<Object> display) { final Range range = display.getVisibleRange(); final int start = range.getStart(); final int end = start + range.getLength(); midiaService.listar(textboxPesquisar.getText(), new AsyncCallback<List<Midia>>() { @Override public void onFailure(Throwable caught) { Window.alert(caught.getMessage()); } @Override public void onSuccess(List<Midia> result) { // convert old list type to new list type List<Object> list = new ArrayList<Object>(result.size()); for (Midia midia : result) { list.add(midia); } updateRowData(start, list.subList(start, (result.size() < end) ? result.size() : end)); updateRowCount(result.size(), true); } }); } }; dataProvider.addDataDisplay(cellTable); }
From source file:br.org.olimpiabarbacena.client.Pesquisar.java
License:Apache License
public void listarMembro() { // remove todas as colunas for (int i = cellTable.getColumnCount() - 1; i >= 0; i--) { cellTable.removeColumn(i);/* w w w. j a v a2s . c om*/ } // Adiciona coluna texto para exibir o nome. TextColumn<Object> colunaNome = new TextColumn<Object>() { @Override public String getValue(Object object) { if (object.getClass().getName().equals("br.org.olimpiabarbacena.shared.dados.Membro")) { return ((Membro) object).getNome(); } return new String(); } }; colunaNome.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT); cellTable.addColumn(colunaNome, "Nome"); // Adiciona coluna com o boto editar. ButtonCell buttonCellEditar = new ButtonCell() { @Override public void render(Context context, SafeHtml data, SafeHtmlBuilder sb) { if (data != null) { ImageResource icon = Icons.INSTANCE.editar(); String iconDisplay = AbstractImagePrototype.create(icon).getHTML(); iconDisplay = iconDisplay.replaceFirst(">", " title=\"Editar\">"); SafeHtml html = SafeHtmlUtils.fromTrustedString(iconDisplay); sb.append(html); } } }; Column<Object, String> colunaEditar = new Column<Object, String>(buttonCellEditar) { @Override public String getValue(Object object) { return "Editar"; } }; colunaEditar.setFieldUpdater(new FieldUpdater<Object, String>() { @Override public void update(int index, Object object, String value) { if (object.getClass().getName().equals("br.org.olimpiabarbacena.shared.dados.Membro")) { principal.getControle().setDialogo(new DialogBox(false)); principal.getControle().getDialogo().setWidth("466px"); principal.getControle().getDialogo().setHeight("319px"); br.org.olimpiabarbacena.client.formulario.Membro membro = new br.org.olimpiabarbacena.client.formulario.Membro( principal, principal.getControle().getDialogo()); membro.buttonHistorico.setVisible(false); membro.buttonFechar.setText("Cancelar"); membro.get(((Membro) object).getId()); principal.getControle().getDialogo().setWidget(membro); principal.getControle().getDialogo().center(); } } }); colunaEditar.setCellStyleNames("gwt-cell-pointer"); cellTable.addColumn(colunaEditar, new String()); cellTable.setColumnWidth(colunaEditar, "16px"); // Adiciona coluna com o boto remover. ButtonCell buttonCellRemover = new ButtonCell() { @Override public void render(Context context, SafeHtml data, SafeHtmlBuilder sb) { if (data != null) { ImageResource icon = Icons.INSTANCE.remover(); String iconDisplay = AbstractImagePrototype.create(icon).getHTML(); iconDisplay = iconDisplay.replaceFirst(">", " title=\"Remover\">"); SafeHtml html = SafeHtmlUtils.fromTrustedString(iconDisplay); sb.append(html); } } }; Column<Object, String> colunaRemover = new Column<Object, String>(buttonCellRemover) { @Override public String getValue(Object object) { return "Remover"; } }; colunaRemover.setFieldUpdater(new FieldUpdater<Object, String>() { @Override public void update(int index, Object object, String value) { if (object.getClass().getName().equals("br.org.olimpiabarbacena.shared.dados.Membro")) { if (Window.confirm( "Deseja remover \"" + ((Membro) object).getNome() + "\" e suas dependncias?")) { membroService.remover(((Membro) object).getId(), new AsyncCallback<Void>() { @Override public void onFailure(Throwable caught) { }; @Override public void onSuccess(Void result) { limpar(); listarMembro(); }; }); } } } }); colunaRemover.setCellStyleNames("gwt-cell-pointer"); cellTable.addColumn(colunaRemover, new String()); cellTable.setColumnWidth(colunaRemover, "16px"); dataProvider = new AsyncDataProvider<Object>() { @Override protected void onRangeChanged(HasData<Object> display) { final Range range = display.getVisibleRange(); final int start = range.getStart(); final int end = start + range.getLength(); membroService.listar(textboxPesquisar.getText(), new AsyncCallback<List<Membro>>() { @Override public void onFailure(Throwable caught) { Window.alert(caught.getMessage()); } @Override public void onSuccess(List<Membro> result) { // convert old list type to new list type List<Object> list = new ArrayList<Object>(result.size()); for (Membro membro : result) { list.add(membro); } updateRowData(start, list.subList(start, (result.size() < end) ? result.size() : end)); updateRowCount(result.size(), true); } }); } }; dataProvider.addDataDisplay(cellTable); }
From source file:br.org.olimpiabarbacena.client.Pesquisar.java
License:Apache License
public void listarEmprestimo() { // remove todas as colunas for (int i = cellTable.getColumnCount() - 1; i >= 0; i--) { cellTable.removeColumn(i);//from w w w.j a v a 2 s .co m } // Adiciona coluna imagem para exibir a situao. Column<Object, ImageResource> colunaSituacao = new Column<Object, ImageResource>(new ImageResourceCell()) { @Override public ImageResource getValue(Object object) { if (object.getClass().getName().equals("br.org.olimpiabarbacena.shared.dados.Emprestimo")) { if (((Emprestimo) object).getEntrega() == null) { return Icons.INSTANCE.emprestado(); } else { return Icons.INSTANCE.baixado(); } } else { return Icons.INSTANCE.desconhecido(); } } }; cellTable.addColumn(colunaSituacao, new String()); cellTable.setColumnWidth(colunaSituacao, "16px"); // Adiciona coluna texto para exibir o ttulo. TextColumn<Object> colunaNome = new TextColumn<Object>() { @Override public String getValue(Object object) { if (object.getClass().getName().equals("br.org.olimpiabarbacena.shared.dados.Emprestimo")) { return ((Emprestimo) object).getMidiaObject().getTitulo(); } return new String(); } }; colunaNome.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT); cellTable.addColumn(colunaNome, "Ttulo"); // Adiciona coluna com o boto reservar. ButtonCell buttonCellReservar = new ButtonCell() { @Override public void render(Context context, SafeHtml data, SafeHtmlBuilder sb) { if (data != null) { ImageResource icon = Icons.INSTANCE.reservar(); String iconDisplay = AbstractImagePrototype.create(icon).getHTML(); iconDisplay = iconDisplay.replaceFirst(">", " title=\"Reservar\">"); SafeHtml html = SafeHtmlUtils.fromTrustedString(iconDisplay); sb.append(html); } } }; Column<Object, String> colunaReservar = new Column<Object, String>(buttonCellReservar) { @Override public String getValue(Object object) { return "Reservar"; } }; colunaReservar.setFieldUpdater(new FieldUpdater<Object, String>() { @Override public void update(int index, Object object, String value) { if (object.getClass().getName().equals("br.org.olimpiabarbacena.shared.dados.Emprestimo")) { principal.getControle().setDialogo(new DialogBox(false)); principal.getControle().getDialogo().setWidth("450px"); principal.getControle().getDialogo().setHeight("91px"); Reserva reserva = new Reserva(((Emprestimo) object), principal.getControle().getDialogo()); principal.getControle().getDialogo().setWidget(reserva); principal.getControle().getDialogo().center(); } } }); colunaReservar.setCellStyleNames("gwt-cell-pointer"); cellTable.addColumn(colunaReservar, new String()); cellTable.setColumnWidth(colunaReservar, "16px"); // Adiciona coluna com o boto reservar. ButtonCell buttonCellBaixar = new ButtonCell() { @Override public void render(Context context, SafeHtml data, SafeHtmlBuilder sb) { if (data != null) { ImageResource icon = Icons.INSTANCE.baixar(); String iconDisplay = AbstractImagePrototype.create(icon).getHTML(); iconDisplay = iconDisplay.replaceFirst(">", " title=\"Baixar\">"); SafeHtml html = SafeHtmlUtils.fromTrustedString(iconDisplay); sb.append(html); } } }; Column<Object, String> colunaBaixar = new Column<Object, String>(buttonCellBaixar) { @Override public String getValue(Object object) { return "Baixar"; } }; colunaBaixar.setFieldUpdater(new FieldUpdater<Object, String>() { @Override public void update(int index, Object object, String value) { if (object.getClass().getName().equals("br.org.olimpiabarbacena.shared.dados.Emprestimo")) { if (((Emprestimo) object).getEntrega() == null) { if (Window.confirm("Deseja baixar \"" + ((Emprestimo) object).getMidiaObject().getTitulo() + "\" emprestado para \"" + ((Emprestimo) object).getMembroObject().getNome() + "\"?")) { emprestimoService.baixar(((Emprestimo) object).getId(), new AsyncCallback<Void>() { @Override public void onFailure(Throwable caught) { }; @Override public void onSuccess(Void result) { limpar(); listarEmprestimo(); }; }); } } else { Window.alert("Esta mdia j foi devolvida."); } } } }); colunaBaixar.setCellStyleNames("gwt-cell-pointer"); cellTable.addColumn(colunaBaixar, new String()); cellTable.setColumnWidth(colunaBaixar, "16px"); // Adiciona coluna com o boto visualizar. ButtonCell buttonCellVisualizar = new ButtonCell() { @Override public void render(Context context, SafeHtml data, SafeHtmlBuilder sb) { if (data != null) { ImageResource icon = Icons.INSTANCE.visualizar(); String iconDisplay = AbstractImagePrototype.create(icon).getHTML(); iconDisplay = iconDisplay.replaceFirst(">", " title=\"Visualizar\">"); SafeHtml html = SafeHtmlUtils.fromTrustedString(iconDisplay); sb.append(html); } } }; Column<Object, String> colunaVisualizar = new Column<Object, String>(buttonCellVisualizar) { @Override public String getValue(Object object) { return "Visualizar"; } }; colunaVisualizar.setFieldUpdater(new FieldUpdater<Object, String>() { @Override public void update(int index, Object object, String value) { if (object.getClass().getName().equals("br.org.olimpiabarbacena.shared.dados.Emprestimo")) { principal.getControle().setDialogo(new DialogBox(false)); principal.getControle().getDialogo().setWidth("451px"); principal.getControle().getDialogo().setHeight("124px"); principal.getControle().getDialogo().setWidget( new br.org.olimpiabarbacena.client.formulario.midia.Emprestimo(((Emprestimo) object), principal.getControle().getDialogo())); principal.getControle().getDialogo().center(); } } }); colunaVisualizar.setCellStyleNames("gwt-cell-pointer"); cellTable.addColumn(colunaVisualizar, new String()); cellTable.setColumnWidth(colunaVisualizar, "16px"); // Adiciona coluna com o boto remover. ButtonCell buttonCellRemover = new ButtonCell() { @Override public void render(Context context, SafeHtml data, SafeHtmlBuilder sb) { if (data != null) { ImageResource icon = Icons.INSTANCE.remover(); String iconDisplay = AbstractImagePrototype.create(icon).getHTML(); iconDisplay = iconDisplay.replaceFirst(">", " title=\"Remover\">"); SafeHtml html = SafeHtmlUtils.fromTrustedString(iconDisplay); sb.append(html); } } }; Column<Object, String> colunaRemover = new Column<Object, String>(buttonCellRemover) { @Override public String getValue(Object object) { return "Remover"; } }; colunaRemover.setFieldUpdater(new FieldUpdater<Object, String>() { @Override public void update(int index, Object object, String value) { if (object.getClass().getName().equals("br.org.olimpiabarbacena.shared.dados.Emprestimo")) { if (Window.confirm("Deseja remover \"" + ((Emprestimo) object).getMidiaObject().getTitulo() + "\" emprestado para \"" + ((Emprestimo) object).getMembroObject().getNome() + "\"?")) { emprestimoService.remover(((Emprestimo) object).getId(), new AsyncCallback<Void>() { @Override public void onFailure(Throwable caught) { }; @Override public void onSuccess(Void result) { limpar(); listarEmprestimo(); }; }); } } } }); colunaRemover.setCellStyleNames("gwt-cell-pointer"); cellTable.addColumn(colunaRemover, new String()); cellTable.setColumnWidth(colunaRemover, "16px"); dataProvider = new AsyncDataProvider<Object>() { @Override protected void onRangeChanged(HasData<Object> display) { final Range range = display.getVisibleRange(); final int start = range.getStart(); final int end = start + range.getLength(); emprestimoService.listar(textboxPesquisar.getText(), new AsyncCallback<List<Emprestimo>>() { @Override public void onFailure(Throwable caught) { Window.alert(caught.getMessage()); } @Override public void onSuccess(List<Emprestimo> result) { // convert old list type to new list type List<Object> list = new ArrayList<Object>(result.size()); for (Emprestimo emprestimo : result) { list.add(emprestimo); } updateRowData(start, list.subList(start, (result.size() < end) ? result.size() : end)); updateRowCount(result.size(), true); } }); } }; dataProvider.addDataDisplay(cellTable); }
From source file:com.Administration.client.Administration.java
License:Apache License
/** * ? ? /* www .java 2 s . c om*/ */ private void initTable() { // ? Column<LinkData, String> codeColumn = new Column<LinkData, String>(new TextCell()) { // C ? - ? ? @Override public String getValue(LinkData object) { // ? ? ? ? return object.getCode(); } }; codeColumn.setSortable(true); // ? sortHandler.setComparator(codeColumn, new Comparator<LinkData>() { // ? // , ? @Override public int compare(LinkData o1, LinkData o2) { // ? ?? if (o1 == o2) { return 0; } if (o1 != null) { return (o2 != null) ? o1.getCode().compareTo(o2.getCode()) : 1; } return -1; } }); cellTable.addColumn(codeColumn, "Short Link"); // ? // ? ?? Column<LinkData, String> originalLinkColumn = new Column<LinkData, String>(new EditTextCell()) { @Override public String getValue(LinkData object) { return object.getLink(); } }; originalLinkColumn.setSortable(true); sortHandler.setComparator(originalLinkColumn, new Comparator<LinkData>() { @Override public int compare(LinkData o1, LinkData o2) { if (o1 == o2) { return 0; } if (o1 != null) { return (o2 != null) ? o1.getLink().compareTo(o2.getLink()) : 1; } return -1; } }); cellTable.addColumn(originalLinkColumn, "Original Link"); originalLinkColumn.setFieldUpdater(new FieldUpdater<LinkData, String>() { // ? ? @Override public void update(int index, final LinkData object, final String value) { // ?? ? // ? ? AdministrationServiceInterface.App.getInstance().setOriginalLink(object.getId(), value, new AsyncCallback<Boolean>() { @Override public void onFailure(Throwable caught) { // ? ? ??? label.setHTML("<h4>Connection error!<br>Can't update data!<h4>"); // ? } @Override public void onSuccess(Boolean result) { // ? ? if (!result) { // ? ? ? ? label.setHTML("<h4>Server error!<h4>"); // } else { // ? ? object.setLink(value); dataProvider.refresh(); } } }); } }); DateTimeFormat dateFormat = DateTimeFormat.getFormat("dd MMM yyyy"); // // ? ?? Column<LinkData, Date> createDateColumn = new Column<LinkData, Date>(new DateCell(dateFormat)) { @Override public Date getValue(LinkData object) { return object.getCreateDate(); } }; createDateColumn.setSortable(true); sortHandler.setComparator(createDateColumn, new Comparator<LinkData>() { @Override public int compare(LinkData o1, LinkData o2) { if (o1 == o2) { return 0; } if (o1 != null) { return (o2 != null) ? o1.getCreateDate().compareTo(o2.getCreateDate()) : 1; } return -1; } }); cellTable.addColumn(createDateColumn, "Create date"); DatePickerCell cell = new DatePickerCell(dateFormat); // ?? ? // ? Column<LinkData, Date> expiredDateColumn = new Column<LinkData, Date>(cell) { @Override public Date getValue(LinkData object) { return object.getExpiredDate(); } }; expiredDateColumn.setSortable(true); sortHandler.setComparator(expiredDateColumn, new Comparator<LinkData>() { @Override public int compare(LinkData o1, LinkData o2) { if (o1 == o2) { return 0; } if (o1 != null) { return (o2 != null) ? o1.getExpiredDate().compareTo(o2.getExpiredDate()) : 1; } return -1; } }); cellTable.addColumn(expiredDateColumn, "Expired Date"); expiredDateColumn.setFieldUpdater(new FieldUpdater<LinkData, Date>() { @Override public void update(int index, final LinkData object, final Date value) { AdministrationServiceInterface.App.getInstance().setExpiredDate(object.getId(), value, new AsyncCallback<Boolean>() { @Override public void onFailure(Throwable caught) { label.setHTML("<h4>Connection error!<br>Can't update data!<h4>"); } @Override public void onSuccess(Boolean result) { if (!result) { label.setHTML("<h4>Server error!<h4>"); } else { object.setExpiredDate(value); dataProvider.refresh(); } } }); } }); // - Column<LinkData, Number> currentCountColumn = new Column<LinkData, Number>(new NumberCell()) { @Override public Number getValue(LinkData object) { return object.getCurrentCount(); } }; currentCountColumn.setSortable(true); sortHandler.setComparator(currentCountColumn, new Comparator<LinkData>() { @Override public int compare(LinkData o1, LinkData o2) { if (o1 == o2) { return 0; } if (o1 != null) { return (o2 != null) ? o1.getCurrentCount().compareTo(o2.getCurrentCount()) : 1; } return -1; } }); currentCountColumn.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_RIGHT); cellTable.addColumn(currentCountColumn, "Current visits"); // ?, GWT EditNumberCell. . // ? ? ?. ? ?? ?. // ? - Column<LinkData, String> maxCountColumn = new Column<LinkData, String>(new EditTextCell()) { @Override public String getValue(LinkData object) { Integer t = object.getMaxCount(); if (t == 0) { return "Infinity"; } else { return t.toString(); // GWT!!! } } }; maxCountColumn.setSortable(true); sortHandler.setComparator(maxCountColumn, new Comparator<LinkData>() { @Override public int compare(LinkData o1, LinkData o2) { if (o1 == o2) { return 0; } if (o1 != null) { return (o2 != null) ? o1.getMaxCount().compareTo(o2.getMaxCount()) : 1; } return -1; } }); maxCountColumn.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_RIGHT); cellTable.addColumn(maxCountColumn, "Max Visits"); maxCountColumn.setFieldUpdater(new FieldUpdater<LinkData, String>() { @Override public void update(int index, final LinkData object, final String value) { final Integer t; if (value.equals("Infinity")) { t = 0; } else { t = Integer.parseInt(value); } if (t < 0) { label.setHTML("Wrong maximum count!"); } AdministrationServiceInterface.App.getInstance().setMaxCount(object.getId(), t, new AsyncCallback<Boolean>() { @Override public void onFailure(Throwable caught) { label.setHTML("<h4>Connection error!<br>Can't update data!<h4>"); } @Override public void onSuccess(Boolean result) { if (!result) { label.setHTML("Server error!"); } else { object.setMaxCount(t); dataProvider.refresh(); } } }); } }); // Column<LinkData, String> passwordColumn = new Column<LinkData, String>(new EditTextCell()) { @Override public String getValue(LinkData object) { if (object.getPassword().equals("")) { return ""; } else { // ? , ? return "*********"; } } }; cellTable.addColumn(passwordColumn, "Password"); passwordColumn.setFieldUpdater(new FieldUpdater<LinkData, String>() { @Override public void update(int index, final LinkData object, final String value) { final String pass; if (value.isEmpty() || value.contains(" ")) { // ? ? ? ?? ? ? pass = null; } else { pass = value; } AdministrationServiceInterface.App.getInstance().setPassword(object.getId(), getMD5(pass), new AsyncCallback<Boolean>() { @Override public void onFailure(Throwable caught) { label.setHTML("<h4>Connection error!<br>Can't update data!<h4>"); } @Override public void onSuccess(Boolean result) { if (!result) { label.setHTML("<h4>Server error!<h4>"); } else { object.setPassword(getMD5(pass)); dataProvider.refresh(); } } }); } }); // ?? Column<LinkData, String> deleteColumn = new Column<LinkData, String>(new ButtonCell()) { @Override public String getValue(LinkData object) { return "Delete link"; // + object.getCode(); // + "' link"; } }; cellTable.addColumn(deleteColumn, ""); deleteColumn.setFieldUpdater(new FieldUpdater<LinkData, String>() { @Override public void update(int index, final LinkData object, String value) { if (Window.confirm("Shortlink " + object.getCode() + " will be delete!")) { AdministrationServiceInterface.App.getInstance().deleteLink(object.getId(), new AsyncCallback<Boolean>() { @Override public void onFailure(Throwable caught) { label.setHTML("<h4>Connection error!<br>Can't delete data!<h4>"); } @Override public void onSuccess(Boolean result) { if (!result) { label.setHTML("<h4>Server error!<h4>"); } else { // ? ?? dataProvider.getList().remove(object); dataProvider.refresh(); } } }); } } }); }
From source file:com.agnie.useradmin.contextmgr.client.presenter.shared.ui.CTXUsersCellTable.java
License:Open Source License
public CTXUsersCellTable() { initWidget(uiBinder.createAndBindUi(this)); multiSelectionModel = new MultiSelectionModel<UserApplicationCtxRegistrationPx>(keyProvider); table.setPageSize(ApplicationConfig.getInstance().getPageSize()); Column<UserApplicationCtxRegistrationPx, Boolean> select = new Column<UserApplicationCtxRegistrationPx, Boolean>( new CheckboxCell(true, false)) { @Override/* w ww. ja v a2s . c o m*/ public Boolean getValue(UserApplicationCtxRegistrationPx object) { return multiSelectionModel.isSelected(object); } }; table.addColumn(select, messages.select()); Column<UserApplicationCtxRegistrationPx, String> fname = new TextColumn<UserApplicationCtxRegistrationPx>() { @Override public String getValue(UserApplicationCtxRegistrationPx object) { return object.getUser().getFirstName(); } }; fname.setSortable(true); fname.setDataStoreName("user.firstName"); table.addColumn(fname, messages.fName()); Column<UserApplicationCtxRegistrationPx, String> lName = new TextColumn<UserApplicationCtxRegistrationPx>() { @Override public String getValue(UserApplicationCtxRegistrationPx object) { return object.getUser().getLastName(); } }; lName.setSortable(true); lName.setDataStoreName("user.lastName"); table.addColumn(lName, messages.lName()); Column<UserApplicationCtxRegistrationPx, String> userName = new TextColumn<UserApplicationCtxRegistrationPx>() { @Override public String getValue(UserApplicationCtxRegistrationPx object) { return object.getUser().getUserName(); } }; userName.setSortable(true); userName.setDataStoreName("user.userName"); table.addColumn(userName, messages.uName()); Column<UserApplicationCtxRegistrationPx, String> status = new TextColumn<UserApplicationCtxRegistrationPx>() { @Override public String getValue(UserApplicationCtxRegistrationPx object) { return (object.getStatus() != null ? object.getStatus().getLocalized() : RequestStatus.DISABLED.getLocalized()); } }; status.setSortable(true); status.setDataStoreName("status"); table.addColumn(status, messages.status()); Column<UserApplicationCtxRegistrationPx, String> roles = new Column<UserApplicationCtxRegistrationPx, String>( new ButtonCell()) { @Override public String getValue(UserApplicationCtxRegistrationPx object) { return messages.view_edit(); } }; roles.setFieldUpdater(new FieldUpdater<UserApplicationCtxRegistrationPx, String>() { @Override public void update(int index, UserApplicationCtxRegistrationPx object, String value) { if (presenter.checkPermission(Permissions.CONTEXT_USER_ROLE_MANAGER)) { getViewFactory().getCTXUsersView().getUserCTXRoles(object); } } }); table.addColumn(roles, messages.roles()); Column<UserApplicationCtxRegistrationPx, String> adminRoles = new Column<UserApplicationCtxRegistrationPx, String>( new ButtonCell()) { @Override public String getValue(UserApplicationCtxRegistrationPx object) { return messages.view_edit(); } }; adminRoles.setFieldUpdater(new FieldUpdater<UserApplicationCtxRegistrationPx, String>() { @Override public void update(int index, UserApplicationCtxRegistrationPx object, String value) { if (presenter.checkPermission(Permissions.CONTEXT_USER_ADMIN_ROLE_MANAGER)) { getViewFactory().getCTXUsersView().getUserCTXAdminRoles(object); } } }); table.addColumn(adminRoles, messages.adminRoles()); VerticalPanel panel = new VerticalPanel(); Label label = new Label(messages.no_data()); panel.add(label); panel.setCellHorizontalAlignment(label, HasHorizontalAlignment.ALIGN_CENTER); table.setEmptyTableWidget(label); table.setSelectionModel(multiSelectionModel, DefaultSelectionEventManager.<UserApplicationCtxRegistrationPx>createCustomManager( new MultiSelectEventTranslator<UserApplicationCtxRegistrationPx>())); pager.setRangeLimited(true); pager.setDisplay(table); AsyncHandler columnSortHandler = new AsyncHandler(table); table.addColumnSortHandler(columnSortHandler); }
From source file:com.agnie.useradmin.main.client.presenter.sahered.ui.AppUsersCellTable.java
License:Open Source License
public AppUsersCellTable() { initWidget(uiBinder.createAndBindUi(this)); multiSelectionModel = new MultiSelectionModel<UserApplicationRegistrationPx>(keyProvider); table.setPageSize(ApplicationConfig.getInstance().getPageSize()); Column<UserApplicationRegistrationPx, Boolean> select = new Column<UserApplicationRegistrationPx, Boolean>( new CheckboxCell(true, false)) { @Override/*w ww .jav a2s. com*/ public Boolean getValue(UserApplicationRegistrationPx object) { return multiSelectionModel.isSelected(object); } }; table.addColumn(select, messages.select()); Column<UserApplicationRegistrationPx, String> fName = new TextColumn<UserApplicationRegistrationPx>() { @Override public String getValue(UserApplicationRegistrationPx object) { return object.getUser().getFirstName(); } }; fName.setSortable(true); fName.setDataStoreName("user.firstName"); table.addColumn(fName, messages.fName()); Column<UserApplicationRegistrationPx, String> lName = new TextColumn<UserApplicationRegistrationPx>() { @Override public String getValue(UserApplicationRegistrationPx object) { return object.getUser().getLastName(); } }; lName.setSortable(true); lName.setDataStoreName("user.lastName"); table.addColumn(lName, messages.lName()); Column<UserApplicationRegistrationPx, String> userName = new TextColumn<UserApplicationRegistrationPx>() { @Override public String getValue(UserApplicationRegistrationPx object) { return object.getUser().getUserName(); } }; userName.setSortable(true); userName.setDataStoreName("user.userName"); table.addColumn(userName, messages.uName()); Column<UserApplicationRegistrationPx, String> status = new TextColumn<UserApplicationRegistrationPx>() { @Override public String getValue(UserApplicationRegistrationPx object) { return (object.getStatus() != null ? object.getStatus().getLocalized() : RequestStatus.DISABLED.getLocalized()); } }; status.setSortable(true); status.setDataStoreName("status"); table.addColumn(status, messages.status()); Column<UserApplicationRegistrationPx, String> roles = new Column<UserApplicationRegistrationPx, String>( new ButtonCell()) { @Override public String getValue(UserApplicationRegistrationPx object) { return messages.view_edit(); } }; roles.setFieldUpdater(new FieldUpdater<UserApplicationRegistrationPx, String>() { @Override public void update(int index, UserApplicationRegistrationPx object, String value) { if (presenter.checkPermission(Permissions.APPLICATION_USER_ROLE_MANAGER)) { getViewFactory().getAppUsersView().getUserAppRoles(object); } } }); table.addColumn(roles, messages.roles()); Column<UserApplicationRegistrationPx, String> adminRoles = new Column<UserApplicationRegistrationPx, String>( new ButtonCell()) { @Override public String getValue(UserApplicationRegistrationPx object) { return messages.view_edit(); } }; adminRoles.setFieldUpdater(new FieldUpdater<UserApplicationRegistrationPx, String>() { @Override public void update(int index, UserApplicationRegistrationPx object, String value) { if (presenter.checkPermission(Permissions.APPLICATION_USER_ADMIN_ROLE_MANAGER)) { getViewFactory().getAppUsersView().getUserAppAdminRoles(object); } } }); table.addColumn(adminRoles, messages.adminRoles()); VerticalPanel panel = new VerticalPanel(); Label label = new Label(messages.no_data()); panel.add(label); panel.setCellHorizontalAlignment(label, HasHorizontalAlignment.ALIGN_CENTER); table.setEmptyTableWidget(label); table.setSelectionModel(multiSelectionModel, DefaultSelectionEventManager.<UserApplicationRegistrationPx>createCustomManager( new MultiSelectEventTranslator<UserApplicationRegistrationPx>())); pager.setRangeLimited(true); pager.setDisplay(table); AsyncHandler columnSortHandler = new AsyncHandler(table); table.addColumnSortHandler(columnSortHandler); }
From source file:com.google.gwt.sample.showcase.client.content.cell.CwCellSampler.java
License:Apache License
/** * Initialize this example./*from www. ja v a 2s . c o m*/ */ @ShowcaseSource @Override public Widget onInitialize() { Images images = GWT.create(Images.class); // Create the table. editableCells = new ArrayList<AbstractEditableCell<?, ?>>(); contactList = new DataGrid<ContactInfo>(25, ContactInfo.KEY_PROVIDER); contactList.setMinimumTableWidth(140, Unit.EM); ContactDatabase.get().addDataDisplay(contactList); // CheckboxCell. final Category[] categories = ContactDatabase.get().queryCategories(); addColumn(new CheckboxCell(), "Checkbox", new GetValue<Boolean>() { @Override public Boolean getValue(ContactInfo contact) { // Checkbox indicates that the contact is a relative. // Index 0 = Family. return contact.getCategory() == categories[0]; } }, new FieldUpdater<ContactInfo, Boolean>() { @Override public void update(int index, ContactInfo object, Boolean value) { if (value) { // If a relative, use the Family Category. pendingChanges.add(new CategoryChange(object, categories[0])); } else { // If not a relative, use the Contacts Category. pendingChanges.add(new CategoryChange(object, categories[categories.length - 1])); } } }); // TextCell. addColumn(new TextCell(), "Text", new GetValue<String>() { @Override public String getValue(ContactInfo contact) { return contact.getFullName(); } }, null); // EditTextCell. Column<ContactInfo, String> editTextColumn = addColumn(new EditTextCell(), "EditText", new GetValue<String>() { @Override public String getValue(ContactInfo contact) { return contact.getFirstName(); } }, new FieldUpdater<ContactInfo, String>() { @Override public void update(int index, ContactInfo object, String value) { pendingChanges.add(new FirstNameChange(object, value)); } }); contactList.setColumnWidth(editTextColumn, 16.0, Unit.EM); // TextInputCell. Column<ContactInfo, String> textInputColumn = addColumn(new TextInputCell(), "TextInput", new GetValue<String>() { @Override public String getValue(ContactInfo contact) { return contact.getLastName(); } }, new FieldUpdater<ContactInfo, String>() { @Override public void update(int index, ContactInfo object, String value) { pendingChanges.add(new LastNameChange(object, value)); } }); contactList.setColumnWidth(textInputColumn, 16.0, Unit.EM); // ClickableTextCell. addColumn(new ClickableTextCell(), "ClickableText", new GetValue<String>() { @Override public String getValue(ContactInfo contact) { return "Click " + contact.getFirstName(); } }, new FieldUpdater<ContactInfo, String>() { @Override public void update(int index, ContactInfo object, String value) { Window.alert("You clicked " + object.getFullName()); } }); // ActionCell. addColumn(new ActionCell<ContactInfo>("Click Me", new ActionCell.Delegate<ContactInfo>() { @Override public void execute(ContactInfo contact) { Window.alert("You clicked " + contact.getFullName()); } }), "Action", new GetValue<ContactInfo>() { @Override public ContactInfo getValue(ContactInfo contact) { return contact; } }, null); // ButtonCell. addColumn(new ButtonCell(), "Button", new GetValue<String>() { @Override public String getValue(ContactInfo contact) { return "Click " + contact.getFirstName(); } }, new FieldUpdater<ContactInfo, String>() { @Override public void update(int index, ContactInfo object, String value) { Window.alert("You clicked " + object.getFullName()); } }); // DateCell. DateTimeFormat dateFormat = DateTimeFormat.getFormat(PredefinedFormat.DATE_MEDIUM); addColumn(new DateCell(dateFormat), "Date", new GetValue<Date>() { @Override public Date getValue(ContactInfo contact) { return contact.getBirthday(); } }, null); // DatePickerCell. addColumn(new DatePickerCell(dateFormat), "DatePicker", new GetValue<Date>() { @Override public Date getValue(ContactInfo contact) { return contact.getBirthday(); } }, new FieldUpdater<ContactInfo, Date>() { @Override public void update(int index, ContactInfo object, Date value) { pendingChanges.add(new BirthdayChange(object, value)); } }); // NumberCell. Column<ContactInfo, Number> numberColumn = addColumn(new NumberCell(), "Number", new GetValue<Number>() { @Override public Number getValue(ContactInfo contact) { return contact.getAge(); } }, null); numberColumn.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LOCALE_END); // IconCellDecorator. addColumn(new IconCellDecorator<String>(images.contactsGroup(), new TextCell()), "Icon", new GetValue<String>() { @Override public String getValue(ContactInfo contact) { return contact.getCategory().getDisplayName(); } }, null); // ImageCell. addColumn(new ImageCell(), "Image", new GetValue<String>() { @Override public String getValue(ContactInfo contact) { return "contact.jpg"; } }, null); // SelectionCell. List<String> options = new ArrayList<String>(); for (Category category : categories) { options.add(category.getDisplayName()); } addColumn(new SelectionCell(options), "Selection", new GetValue<String>() { @Override public String getValue(ContactInfo contact) { return contact.getCategory().getDisplayName(); } }, new FieldUpdater<ContactInfo, String>() { @Override public void update(int index, ContactInfo object, String value) { for (Category category : categories) { if (category.getDisplayName().equals(value)) { pendingChanges.add(new CategoryChange(object, category)); break; } } } }); // Create the UiBinder. Binder uiBinder = GWT.create(Binder.class); Widget widget = uiBinder.createAndBindUi(this); // Add handlers to redraw or refresh the table. redrawButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { contactList.redraw(); } }); commitButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { // Commit the changes. for (PendingChange<?> pendingChange : pendingChanges) { pendingChange.commit(); } pendingChanges.clear(); // Push the changes to the views. ContactDatabase.get().refreshDisplays(); } }); return widget; }
From source file:com.mquick.client.application.home.HomePageView.java
License:Apache License
private void initCellTable() { TextColumn<ClientEntity> id_Column = new TextColumn<ClientEntity>() { @Override//www . j ava2 s. c om public String getValue(ClientEntity object) { if (object == null) return " "; return object.getMaigcCode() + ""; } }; expressportals.addColumn(id_Column, "ID"); TextColumn<ClientEntity> name_Column = new TextColumn<ClientEntity>() { @Override public String getValue(ClientEntity object) { if (object == null) return " "; return object.getName(); } }; expressportals.addColumn(name_Column, "NAME"); ButtonCell buttonCell = new ButtonCell(); Column<ClientEntity, String> action_Column = new Column<ClientEntity, String>(buttonCell) { @Override public String getValue(ClientEntity object) { // The value to display in the button. return "unimpl"; //object.getName(); } }; action_Column.setFieldUpdater(new FieldUpdater<ClientEntity, String>() { @Override public void update(int index, ClientEntity object, String value) { getUiHandlers().pushTerminal(index, object, value); } }); expressportals.addColumn(action_Column, "ACTION"); }
From source file:com.phideltcmu.recruiter.client.ui.table.RecruitTable.java
License:Creative Commons License
private void defineColumns() { ButtonCell buttonCell = new ButtonCell() { @Override/* w w w. j a v a 2s . c o m*/ public boolean handlesSelection() { return false; } }; Column<Person, String> detailsButton = new Column<Person, String>(buttonCell) { @Override public String getValue(Person person) { return "View"; } }; detailsButton.setFieldUpdater(new FieldUpdater<Person, String>() { @Override public void update(int i, Person person, String s) { new PersonDetails(person).display(); } }); extraColumns.add(new ExtraColumn("Details", detailsButton)); if (DynamicRecruiter.authUser.isAdmin()) { Column<Person, String> deletePersonButton = new Column<Person, String>(buttonCell) { @Override public String getValue(Person person) { return "Delete"; } }; deletePersonButton.setFieldUpdater(new FieldUpdater<Person, String>() { @Override public void update(int i, Person person, String s) { DynamicRecruiter.RECRUIT_SERVICE.removeUser(person.getAndrewID(), DynamicRecruiter.authUser.getAuthToken(), new RemoveUserHandler()); } }); extraColumns.add(new ExtraColumn("Options", deletePersonButton)); } }
From source file:com.phideltcmu.recruiter.client.ui.table.SearchMatchTable.java
License:Creative Commons License
public SearchMatchTable(final Label statusLabel) { ButtonCell buttonCell = new ButtonCell() { @Override/*from w w w .j ava 2 s .c om*/ public boolean handlesSelection() { return false; } }; Column<Person, String> addButtonColumn = new Column<Person, String>(buttonCell) { @Override public String getValue(Person person) { return person.getInTable() == true ? "Add Referral" : "Add to list"; } }; addButtonColumn.setFieldUpdater(new FieldUpdater<Person, String>() { @Override public void update(int i, Person person, String s) { statusLabel.setText("Adding " + person.getFullName() + "..."); DynamicRecruiter.RECRUIT_SERVICE.addPerson(person, DynamicRecruiter.authUser, new AddUserHandler(statusLabel)); } }); List<ExtraColumn> extraCols = new ArrayList<ExtraColumn>(); extraCols.add(new ExtraColumn("", addButtonColumn)); this.initColumns(extraCols); }