List of usage examples for com.google.gwt.user.cellview.client Column setFieldUpdater
public void setFieldUpdater(FieldUpdater<T, C> fieldUpdater)
From source file:com.stoyanr.todo.client.view.ItemsViewImpl.java
License:Open Source License
private Column<T, String> createPriorityColumn(List<String> priorityNames) { Column<T, String> col = new Column<T, String>(new SelectionCell(priorityNames)) { @Override//w w w .j av a 2s . co m public String getValue(T t) { return presenter.getPriority(t); } }; col.setFieldUpdater(new FieldUpdater<T, String>() { @Override public void update(int index, T t, String value) { presenter.updatePriority(t, value); dataProvider.refresh(); } }); col.setSortable(true); return col; }
From source file:com.stoyanr.todo.client.view.ItemsViewImpl.java
License:Open Source License
private Column<T, String> createStatusColumn(List<String> statusNames) { Column<T, String> col = new Column<T, String>(new SelectionCell(statusNames)) { @Override/* w w w.jav a 2 s . c o m*/ public String getValue(T t) { return presenter.getStatus(t); } }; col.setFieldUpdater(new FieldUpdater<T, String>() { @Override public void update(int index, T t, String value) { presenter.updateStatus(t, value); dataProvider.refresh(); } }); col.setSortable(true); return col; }
From source file:com.stoyanr.todo.client.view.ItemsViewImpl.java
License:Open Source License
private Column<T, String> createXColumn() { Column<T, String> col = new Column<T, String>(new ClickableTextCell()) { @Override// w w w . jav a 2 s . c o m public String getValue(T t) { return "x"; } }; col.setFieldUpdater(new FieldUpdater<T, String>() { @Override public void update(int index, T t, String value) { presenter.delete(index, t); } }); col.setCellStyleNames(X_BUTTON_STYLE); col.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_RIGHT); return col; }
From source file:com.tasktop.c2c.server.tasks.client.widgets.admin.customfields.CustomFieldValuesEditor.java
License:Open Source License
private void initTableColumns() { DelegateCell<String> moveUpCell = new DelegateCell<String>(new DelegateCell.RenderDelegate<String>() { @Override/*from ww w. j ava 2s .c o m*/ public SafeHtml render(Cell.Context context, String value, SafeHtmlBuilder sb) { return SafeHtmlUtils.fromSafeConstant("<span class=\"order-control\"><a class=\"up\"/></span>"); } }, new DelegateCell.ActionDelegate<String>() { @Override public void execute(Cell.Context object) { int index = object.getIndex(); if (index > 0) { dataProvider.getList().get(index).setSortkey((short) (index - 1)); dataProvider.getList().get(index - 1).setSortkey((short) index); Collections.sort(dataProvider.getList()); refreshDisplays(); } } }); Column<CustomFieldValue, String> moveUpColumn = new Column<CustomFieldValue, String>(moveUpCell) { @Override public String getValue(CustomFieldValue object) { return null; } @Override public void render(Cell.Context context, CustomFieldValue object, SafeHtmlBuilder sb) { if (context.getIndex() != 0) { super.render(context, object, sb); } } }; cellTable.addColumn(moveUpColumn); cellTable.setColumnWidth(moveUpColumn, 22, Unit.PX); DelegateCell<String> moveDownCell = new DelegateCell<String>(new DelegateCell.RenderDelegate<String>() { @Override public SafeHtml render(Cell.Context context, String value, SafeHtmlBuilder sb) { return SafeHtmlUtils.fromSafeConstant("<span class=\"order-control\"><a class=\"down\"/></span>"); } }, new DelegateCell.ActionDelegate<String>() { @Override public void execute(Cell.Context object) { Short index = (short) object.getIndex(); if (index < dataProvider.getList().size() - 1) { dataProvider.getList().get(index).setSortkey((short) (index + 1)); dataProvider.getList().get(index + 1).setSortkey((short) index); Collections.sort(dataProvider.getList()); refreshDisplays(); } } }); Column<CustomFieldValue, String> moveDownColumn = new Column<CustomFieldValue, String>(moveDownCell) { @Override public String getValue(CustomFieldValue object) { return null; } @Override public void render(Cell.Context context, CustomFieldValue object, SafeHtmlBuilder sb) { if (context.getIndex() != dataProvider.getList().size() - 1) { super.render(context, object, sb); } } }; cellTable.addColumn(moveDownColumn); cellTable.setColumnWidth(moveDownColumn, 22, Unit.PX); Column<CustomFieldValue, String> nameColumn = new Column<CustomFieldValue, String>(new TextInputCell()) { @Override public String getValue(CustomFieldValue value) { return value.getValue(); } }; nameColumn.setFieldUpdater(new FieldUpdater<CustomFieldValue, String>() { @Override public void update(int index, CustomFieldValue customFieldValue, String value) { customFieldValue.setValue(value); } }); cellTable.addColumn(nameColumn); DelegateCell<String> removeCell = new DelegateCell<String>(new DelegateCell.RenderDelegate<String>() { @Override public SafeHtml render(Cell.Context context, String value, SafeHtmlBuilder sb) { final CustomFieldValue referenced = dataProvider.getList().get(context.getIndex()); if (referenced != null && "---".equals(referenced.getValue())) { return SafeHtmlUtils.fromSafeConstant("<a class=\"delete-disabled\"><span/></a>"); } return SafeHtmlUtils.fromSafeConstant("<a class=\"misc-icon cancel\"><span/></a>"); } }, new DelegateCell.ActionDelegate<String>() { @Override public void execute(final Cell.Context object) { final CustomFieldValue toRemove = dataProvider.getList().get(object.getIndex()); if (toRemove == null) { return; } if ("---".equals(toRemove.getValue())) { return; } dataProvider.getList().remove(toRemove); } }); Column<CustomFieldValue, String> removeColumn = new Column<CustomFieldValue, String>(removeCell) { @Override public String getValue(CustomFieldValue object) { return null; } @Override public void render(Cell.Context context, CustomFieldValue object, SafeHtmlBuilder sb) { if (dataProvider.getList().size() == 1) { sb.appendHtmlConstant("<a><span/></a>"); } else { super.render(context, object, sb); } } }; cellTable.addColumn(removeColumn); cellTable.setColumnWidth(removeColumn, 30, Unit.PX); DelegateCell<String> addCell = new DelegateCell<String>(new DelegateCell.RenderDelegate<String>() { @Override public SafeHtml render(Cell.Context context, String value, SafeHtmlBuilder sb) { return SafeHtmlUtils.fromSafeConstant("<a class=\"misc-icon add right\"><span/></a>"); } }, new DelegateCell.ActionDelegate<String>() { @Override public void execute(Cell.Context object) { addNewValue(); } }); Column<CustomFieldValue, String> addColumn = new Column<CustomFieldValue, String>(addCell) { @Override public String getValue(CustomFieldValue object) { return null; } @Override public void render(Cell.Context context, CustomFieldValue object, SafeHtmlBuilder sb) { if (context.getIndex() == dataProvider.getList().size() - 1) { super.render(context, object, sb); } else { sb.appendHtmlConstant("<a><span/></a>"); } } }; cellTable.addColumn(addColumn); cellTable.setColumnWidth(addColumn, 30, Unit.PX); }
From source file:com.tasktop.c2c.server.tasks.client.widgets.admin.iterations.IterationsAdminView.java
License:Open Source License
private void initTableColumns() { Column<Iteration, String> nameColumn = new Column<Iteration, String>(new EditTextCell()) { @Override/* w w w . j a v a 2 s .c o m*/ public String getValue(Iteration iteration) { return iteration.getValue(); } }; nameColumn.setFieldUpdater(new FieldUpdater<Iteration, String>() { @Override public void update(int index, Iteration iteration, String value) { if (iteration.getValue().equals(value)) { return; } iteration.setValue(value); presenter.saveIteration(iteration); } }); cellTable.addColumn(nameColumn, commonProfileMessages.name()); Column<Iteration, Boolean> activeColumn = new Column<Iteration, Boolean>(new CheckboxCell()) { @Override public Boolean getValue(Iteration iteration) { return iteration.getIsActive(); } }; activeColumn.setFieldUpdater(new FieldUpdater<Iteration, Boolean>() { @Override public void update(int index, Iteration iteration, Boolean value) { if (iteration.getIsActive().equals(value)) { return; } iteration.setIsActive(value); presenter.saveIteration(iteration); } }); cellTable.addColumn(activeColumn, tasksMessages.active()); }
From source file:com.tasktop.c2c.server.tasks.client.widgets.admin.products.ProjectAdminTasksEditView.java
License:Open Source License
private void createReleasesTable() { milestoneTable = new CellTable<Milestone>(10, resources); milestoneTable.setWidth("320px", true); DelegateCell<String> moveReleaseUpCell = new DelegateCell<String>( new DelegateCell.RenderDelegate<String>() { @Override/*from w ww .j av a2 s .c o m*/ public SafeHtml render(Cell.Context context, String value, SafeHtmlBuilder sb) { return SafeHtmlUtils .fromSafeConstant("<span class=\"order-control\"><a class=\"up\"/></span>"); } }, new DelegateCell.ActionDelegate<String>() { @Override public void execute(Cell.Context object) { int index = object.getIndex(); if (index > 0) { milestonesEditor.getList().get(index).setSortkey((short) (index - 1)); milestonesEditor.getList().get(index - 1).setSortkey((short) index); Collections.sort(milestonesEditor.getList()); milestoneTable.setRowData(milestonesEditor.getList()); } } }); Column<Milestone, String> moveReleaseUpColumn = new Column<Milestone, String>(moveReleaseUpCell) { @Override public String getValue(Milestone object) { return null; } @Override public void render(Cell.Context context, Milestone object, SafeHtmlBuilder sb) { if (context.getIndex() != 0) { super.render(context, object, sb); } } }; milestoneTable.addColumn(moveReleaseUpColumn); milestoneTable.setColumnWidth(moveReleaseUpColumn, 22, Unit.PX); DelegateCell<String> moveReleaseDownCell = new DelegateCell<String>( new DelegateCell.RenderDelegate<String>() { @Override public SafeHtml render(Cell.Context context, String value, SafeHtmlBuilder sb) { return SafeHtmlUtils .fromSafeConstant("<span class=\"order-control\"><a class=\"down\"/></span>"); } }, new DelegateCell.ActionDelegate<String>() { @Override public void execute(Cell.Context object) { Short index = (short) object.getIndex(); if (index < milestonesEditor.getList().size() - 1) { milestonesEditor.getList().get(index).setSortkey((short) (index + 1)); milestonesEditor.getList().get(index + 1).setSortkey(index); Collections.sort(milestonesEditor.getList()); milestoneTable.setRowData(milestonesEditor.getList()); } } }); Column<Milestone, String> moveReleaseDownColumn = new Column<Milestone, String>(moveReleaseDownCell) { @Override public String getValue(Milestone object) { return null; } @Override public void render(Cell.Context context, Milestone object, SafeHtmlBuilder sb) { if (context.getIndex() != milestonesEditor.getList().size() - 1) { super.render(context, object, sb); } } }; milestoneTable.addColumn(moveReleaseDownColumn); milestoneTable.setColumnWidth(moveReleaseDownColumn, 22, Unit.PX); DelegateCell<String> moveReleaseToTopCell = new DelegateCell<String>( new DelegateCell.RenderDelegate<String>() { @Override public SafeHtml render(Cell.Context context, String value, SafeHtmlBuilder sb) { return SafeHtmlUtils .fromSafeConstant("<span class=\"order-control\"><a class=\"top\"/></span>"); } }, new DelegateCell.ActionDelegate<String>() { @Override public void execute(Cell.Context object) { int index = object.getIndex(); Milestone topRelease = milestonesEditor.getList().get(index); milestonesEditor.getList().remove(topRelease); milestonesEditor.getList().add(0, topRelease); int i = 0; for (Milestone milestone : milestonesEditor.getList()) { milestone.setSortkey((short) i); i++; } Collections.sort(milestonesEditor.getList()); milestoneTable.setRowData(milestonesEditor.getList()); } }); Column<Milestone, String> moveReleaseToTopColumn = new Column<Milestone, String>(moveReleaseToTopCell) { @Override public String getValue(Milestone object) { return null; } @Override public void render(Cell.Context context, Milestone object, SafeHtmlBuilder sb) { if (context.getIndex() != 0) { super.render(context, object, sb); } } }; milestoneTable.addColumn(moveReleaseToTopColumn); milestoneTable.setColumnWidth(moveReleaseToTopColumn, 22, Unit.PX); Column<Milestone, String> releaseVersionColumn = addColumn( new TextBoxCell(new TextBoxCell.TemplateDelegate() { @Override public SafeHtml getHtml(Context context, String string) { SafeHtml releaseVerHtml = template.releaseVersion(tasksMessages.releaseVersion(), string); String fieldName = "value"; if (ValidationUtils.hasError(context.getKey(), fieldName, errorTable)) { String errorMsg = ValidationUtils.getErrorMessage(context.getKey(), fieldName, errorTable); return template.errorWrapper(releaseVerHtml, SafeHtmlUtils.fromString(errorMsg)); } else { return releaseVerHtml; } } }), new GetValue<Milestone, String>() { @Override public String getValue(Milestone object) { return milestonesEditor.getEditors() .get(milestonesEditor.getList().indexOf(object)).valueEditor.getValue(); } }); releaseVersionColumn.setFieldUpdater(new FieldUpdater<Milestone, String>() { @Override public void update(int index, Milestone object, String value) { Milestone currentDefaultMilestone = productDefaultRelease.getValue(); for (Milestone milestone : presenter.getProduct().getMilestones()) { if (milestone.getId().equals(object.getId())) { milestone.setValue(value); break; } } for (Milestone milestone : presenter.getProduct().getMilestones()) { if (milestone.getId().equals(currentDefaultMilestone.getId())) { productDefaultRelease.asEditor().getValue().setValue(value); break; } } milestonesEditor.getEditors().get(index).valueEditor.setValue(value); productDefaultRelease.setAcceptableValues(presenter.getProduct().getMilestones()); } }); milestoneTable.addColumn(releaseVersionColumn); milestoneTable.setColumnWidth(releaseVersionColumn, 250, Unit.PX); DelegateCell<String> removeReleaseCell = new DelegateCell<String>( new DelegateCell.RenderDelegate<String>() { @Override public SafeHtml render(Cell.Context context, String value, SafeHtmlBuilder sb) { final Milestone referenced = milestonesEditor.getList().get(context.getIndex()); if (referenced != null && "---".equals(referenced.getValue())) { return SafeHtmlUtils.fromSafeConstant("<a class=\"delete-disabled\"><span/></a>"); } return SafeHtmlUtils.fromSafeConstant("<a class=\"misc-icon cancel\"><span/></a>"); } }, new DelegateCell.ActionDelegate<String>() { @Override public void execute(final Cell.Context object) { final Milestone toRemove = milestonesEditor.getList().get(object.getIndex()); if (toRemove == null) { return; } if ("---".equals(toRemove.getValue())) { return; } presenter.deleteMilestone(toRemove.getId(), new ClientCallback<Void>() { @Override public void onReturn(Void aVoid) { for (Milestone milestone : presenter.getProduct().getMilestones()) { if (milestone.getId().equals(toRemove.getId())) { presenter.getProduct().getMilestones().remove(milestone); break; } } productDefaultRelease.setAcceptableValues(presenter.getProduct().getMilestones()); milestonesEditor.getList().remove(toRemove); milestoneTable.setRowData(milestonesEditor.getList()); } }); } }); Column<Milestone, String> removeReleaseColumn = new Column<Milestone, String>(removeReleaseCell) { @Override public String getValue(Milestone object) { return null; } @Override public void render(Cell.Context context, Milestone object, SafeHtmlBuilder sb) { if (milestoneTable.getRowCount() == 1) { sb.appendHtmlConstant("<a><span/></a>"); } else { super.render(context, object, sb); } } }; milestoneTable.addColumn(removeReleaseColumn); milestoneTable.setColumnWidth(removeReleaseColumn, 30, Unit.PX); DelegateCell<String> addReleaseCell = new DelegateCell<String>(new DelegateCell.RenderDelegate<String>() { @Override public SafeHtml render(Cell.Context context, String value, SafeHtmlBuilder sb) { return SafeHtmlUtils.fromSafeConstant("<a class=\"misc-icon add right\"><span/></a>"); } }, new DelegateCell.ActionDelegate<String>() { @Override public void execute(Cell.Context object) { Milestone newMilestone = presenter.createNewTransientMilestone(milestonesEditor.getList()); milestonesEditor.getList().add(newMilestone); milestoneTable.setRowData(milestonesEditor.getList()); presenter.getProduct().getMilestones().add(ProjectAdminTasksUtil.duplicateMilestone(newMilestone)); productDefaultRelease.setAcceptableValues(presenter.getProduct().getMilestones()); } }); Column<Milestone, String> addReleaseColumn = new Column<Milestone, String>(addReleaseCell) { @Override public String getValue(Milestone object) { return null; } @Override public void render(Cell.Context context, Milestone object, SafeHtmlBuilder sb) { if (context.getIndex() == milestoneTable.getRowCount() - 1) { super.render(context, object, sb); } else { sb.appendHtmlConstant("<a><span/></a>"); } } }; milestoneTable.addColumn(addReleaseColumn); milestoneTable.setColumnWidth(addReleaseColumn, 30, Unit.PX); }
From source file:com.tasktop.c2c.server.tasks.client.widgets.admin.products.ProjectAdminTasksEditView.java
License:Open Source License
private void createComponentsTable() { componentsTable = new CellTable<Component>(10, resources); componentListDataProvider.addDataDisplay(componentsTable); componentsTable.setWidth("540px", true); Column<Component, String> nameColumn = addColumn(new TextBoxCell(new TextBoxCell.TemplateDelegate() { @Override/*from w ww . j a va 2 s. co m*/ public SafeHtml getHtml(Context context, String string) { SafeHtml componentNameHtml = template.componentName(commonProfileMessages.name(), string); String fieldName = "name"; if (ValidationUtils.hasError(context.getKey(), fieldName, errorTable)) { String errorMsg = ValidationUtils.getErrorMessage(context.getKey(), fieldName, errorTable); return template.errorWrapper(componentNameHtml, SafeHtmlUtils.fromString(errorMsg)); } else { return componentNameHtml; } } }), new GetValue<Component, String>() { @Override public String getValue(Component object) { return componentsEditor.getEditors().get(componentsEditor.getList().indexOf(object)).nameEditor .getValue(); } }); nameColumn.setFieldUpdater(new FieldUpdater<Component, String>() { @Override public void update(int index, Component object, String value) { componentsEditor.getEditors().get(index).nameEditor.setValue(value); } }); componentsTable.addColumn(nameColumn, SafeHtmlUtils.fromSafeConstant("<h4>Name</h4>")); componentsTable.setColumnWidth(nameColumn, 250, Unit.PX); Column<Component, String> descriptionColumn = addColumn(new TextBoxCell(new TextBoxCell.TemplateDelegate() { @Override public SafeHtml getHtml(Context context, String string) { SafeHtml componentDescHtml = template.componentDescription(tasksMessages.description(), string); String fieldName = "description"; if (ValidationUtils.hasError(context.getKey(), fieldName, errorTable)) { String errorMsg = ValidationUtils.getErrorMessage(context.getKey(), fieldName, errorTable); return template.errorWrapper(componentDescHtml, SafeHtmlUtils.fromString(errorMsg)); } else { return componentDescHtml; } } }), new GetValue<Component, String>() { @Override public String getValue(Component object) { return componentsEditor.getEditors() .get(componentsEditor.getList().indexOf(object)).descriptionEditor.getValue(); } }); descriptionColumn.setFieldUpdater(new FieldUpdater<Component, String>() { @Override public void update(int index, Component object, String value) { componentsEditor.getEditors().get(index).descriptionEditor.setValue(value); } }); componentsTable.addColumn(descriptionColumn, SafeHtmlUtils.fromSafeConstant("<h4>" + tasksMessages.description() + "</h4>")); componentsTable.setColumnWidth(descriptionColumn, 250, Unit.PX); DelegateCell<String> removeComponentCell = new DelegateCell<String>( new DelegateCell.RenderDelegate<String>() { @Override public SafeHtml render(Cell.Context context, String value, SafeHtmlBuilder sb) { return SafeHtmlUtils.fromSafeConstant("<a class=\"misc-icon cancel\"><span/></a>"); } }, new DelegateCell.ActionDelegate<String>() { @Override public void execute(final Cell.Context object) { presenter.deleteComponent(componentsEditor.getList().get(object.getIndex()).getId(), new ClientCallback<Void>() { @Override public void onReturn(Void aVoid) { componentsEditor.getList().remove(object.getIndex()); componentsTable.setRowData(componentsEditor.getList()); } }); } }); Column<Component, String> removeComponentColumn = new Column<Component, String>(removeComponentCell) { @Override public String getValue(Component object) { return null; } @Override public void render(Cell.Context context, Component object, SafeHtmlBuilder sb) { if (componentsTable.getRowCount() == 1) { sb.appendHtmlConstant("<a><span/></a>"); } else { super.render(context, object, sb); } } }; componentsTable.addColumn(removeComponentColumn); componentsTable.setColumnWidth(removeComponentColumn, 30, Unit.PX); DelegateCell<String> addComponentCell = new DelegateCell<String>(new DelegateCell.RenderDelegate<String>() { @Override public SafeHtml render(Cell.Context context, String value, SafeHtmlBuilder sb) { return SafeHtmlUtils.fromSafeConstant("<a class=\"misc-icon add right\"><span/></a>"); } }, new DelegateCell.ActionDelegate<String>() { @Override public void execute(Cell.Context object) { componentsEditor.getList().add(presenter.createNewTransientComponent(componentsEditor.getList())); componentsTable.setRowData(componentsEditor.getList()); } }); Column<Component, String> addComponentColumn = new Column<Component, String>(addComponentCell) { @Override public String getValue(Component object) { return null; } @Override public void render(Cell.Context context, Component object, SafeHtmlBuilder sb) { if (context.getIndex() == componentsTable.getRowCount() - 1) { super.render(context, object, sb); } else { sb.appendHtmlConstant("<a><span/></a>"); } } }; componentsTable.addColumn(addComponentColumn); componentsTable.setColumnWidth(addComponentColumn, 25, Unit.PX); }
From source file:cz.filmtit.client.dialogs.AddSubtitleItemDialog.java
License:Open Source License
/** * create the table//from w w w . j a va 2s . co m */ private void initTable() { // create columns Column<SrtTime, String> hColumn = new Column<SrtTime, String>(new TextInputCell()) { @Override public String getValue(SrtTime time) { return time.getStringH(); } }; Column<SrtTime, String> mColumn = new Column<SrtTime, String>(new TextInputCell()) { @Override public String getValue(SrtTime time) { return time.getStringM(); } }; Column<SrtTime, String> sColumn = new Column<SrtTime, String>(new TextInputCell()) { @Override public String getValue(SrtTime time) { return time.getStringS(); } }; Column<SrtTime, String> tColumn = new Column<SrtTime, String>(new TextInputCell()) { @Override public String getValue(SrtTime time) { return time.getStringT(); } }; // add column styles hColumn.setCellStyleNames("numerical2digits"); mColumn.setCellStyleNames("numerical2digits"); sColumn.setCellStyleNames("numerical2digits"); tColumn.setCellStyleNames("numerical3digits"); // add column update handlers hColumn.setFieldUpdater(new FieldUpdater<SrtTime, String>() { @Override public void update(int index, SrtTime time, String value) { try { time.setH(value); } catch (InvalidValueException e) { Window.alert(e.getLocalizedMessage()); } } }); mColumn.setFieldUpdater(new FieldUpdater<SrtTime, String>() { @Override public void update(int index, SrtTime time, String value) { try { time.setM(value); } catch (InvalidValueException e) { Window.alert(e.getLocalizedMessage()); } } }); sColumn.setFieldUpdater(new FieldUpdater<SrtTime, String>() { @Override public void update(int index, SrtTime time, String value) { try { time.setS(value); } catch (InvalidValueException e) { Window.alert(e.getLocalizedMessage()); } } }); tColumn.setFieldUpdater(new FieldUpdater<SrtTime, String>() { @Override public void update(int index, SrtTime time, String value) { try { time.setT(value); } catch (InvalidValueException e) { Window.alert(e.getLocalizedMessage()); } } }); // add columns to table //timesTable = new CellTable<SrtTime>(); timesTable.addColumn(hColumn, "hour"); timesTable.addColumn(mColumn, "minute"); timesTable.addColumn(sColumn, "second"); timesTable.addColumn(tColumn, "milisecond"); // add the data ArrayList<SrtTime> rowData = new ArrayList<SrtTime>(2); rowData.add(startTimeWorking); rowData.add(endTimeWorking); // timesTable.setRowData(rowData); // timesTable.setRowCount(2, true); //timesTable.setVisibleRange(new Range(0, 2)); timesTable.setRowData(0, rowData); // show the table timesTable.redraw(); }
From source file:cz.filmtit.client.dialogs.TimeEditDialog.java
License:Open Source License
/** * create the table/*from ww w. j av a2 s . c o m*/ */ private void initTable() { // create columns Column<SrtTime, String> hColumn = new Column<SrtTime, String>(new TextInputCell()) { @Override public String getValue(SrtTime time) { return time.getStringH(); } }; Column<SrtTime, String> mColumn = new Column<SrtTime, String>(new TextInputCell()) { @Override public String getValue(SrtTime time) { return time.getStringM(); } }; Column<SrtTime, String> sColumn = new Column<SrtTime, String>(new TextInputCell()) { @Override public String getValue(SrtTime time) { return time.getStringS(); } }; Column<SrtTime, String> tColumn = new Column<SrtTime, String>(new TextInputCell()) { @Override public String getValue(SrtTime time) { return time.getStringT(); } }; // add column styles hColumn.setCellStyleNames("numerical2digits"); mColumn.setCellStyleNames("numerical2digits"); sColumn.setCellStyleNames("numerical2digits"); tColumn.setCellStyleNames("numerical3digits"); // add column update handlers hColumn.setFieldUpdater(new FieldUpdater<SrtTime, String>() { @Override public void update(int index, SrtTime time, String value) { try { time.setH(value); } catch (InvalidValueException e) { Window.alert(e.getLocalizedMessage()); } } }); mColumn.setFieldUpdater(new FieldUpdater<SrtTime, String>() { @Override public void update(int index, SrtTime time, String value) { try { time.setM(value); } catch (InvalidValueException e) { Window.alert(e.getLocalizedMessage()); } } }); sColumn.setFieldUpdater(new FieldUpdater<SrtTime, String>() { @Override public void update(int index, SrtTime time, String value) { try { time.setS(value); } catch (InvalidValueException e) { Window.alert(e.getLocalizedMessage()); } } }); tColumn.setFieldUpdater(new FieldUpdater<SrtTime, String>() { @Override public void update(int index, SrtTime time, String value) { try { time.setT(value); } catch (InvalidValueException e) { Window.alert(e.getLocalizedMessage()); } } }); // add columns to table //timesTable = new CellTable<SrtTime>(); timesTable.addColumn(hColumn, "hour"); timesTable.addColumn(mColumn, "minute"); timesTable.addColumn(sColumn, "second"); timesTable.addColumn(tColumn, "milisecond"); // add the data ArrayList<SrtTime> rowData = new ArrayList<SrtTime>(2); rowData.add(startTimeWorking); rowData.add(endTimeWorking); // timesTable.setRowData(rowData); // timesTable.setRowCount(2, true); //timesTable.setVisibleRange(new Range(0, 2)); timesTable.setRowData(0, rowData); // show the table timesTable.redraw(); }
From source file:cz.filmtit.client.pages.UserPage.java
License:Open Source License
/** * Shows the page and loads the list of user's documents. *///from ww w. j a v a 2s . c o m public UserPage() { initWidget(uiBinder.createAndBindUi(this)); /** * A column consisting of EdiTextCells with a title (aka a tool-tip) * * @author rur * */ abstract class EditableTitledColumn extends Column<Document, String> { private String title; public String getTitle() { return title; } public void setTitle(String title) { this.title = title; } public EditableTitledColumn(String title) { super(new EditTextCell()); this.title = title; } @Override public void render(Context context, Document object, SafeHtmlBuilder sb) { sb.appendHtmlConstant("<div title=\"" + title + "\">"); super.render(context, object, sb); sb.appendHtmlConstant("</div>"); } } // column with Document title Column<Document, String> nameClm = new EditableTitledColumn("click to change document title") { @Override public String getValue(Document doc) { return doc.getTitle(); } }; // use ChangeDocumentTitle() to change the title nameClm.setFieldUpdater(new FieldUpdater<Document, String>() { @Override public void update(int index, Document doc, String newTitle) { if (newTitle == null || newTitle.isEmpty()) { // we don't accept the new title // refresh to show the original one Gui.getPageHandler().refresh(); } else if (newTitle.equals(doc.getTitle())) { // not changed, ignore } else { new ChangeDocumentTitle(doc.getId(), newTitle); doc.setTitle(newTitle); } } }); // column with Movie title Column<Document, String> mSourceClm = new EditableTitledColumn("click to change movie title") { @Override public String getValue(Document doc) { if (doc.getMovie() == null) { return "(none)"; } else { return doc.getMovie().toString(); } } }; // use ChangeMovieTitle() to change the title mSourceClm.setFieldUpdater(new FieldUpdater<Document, String>() { @Override public void update(int index, Document doc, String newTitle) { if (newTitle == null || newTitle.isEmpty()) { // we don't accept the new title // refresh to show the original one Gui.getPageHandler().refresh(); } else if (doc.getMovie() != null && doc.getMovie().toString().equals(newTitle)) { // not changed, ignore } else { // TODO: should lock the page while waiting for media sources new ChangeMovieTitle(doc.getId(), newTitle); } } }); // column with translation direction TextColumn<Document> languageClm = new TextColumn<Document>() { @Override public String getValue(Document doc) { // TODO: do you prefer names or codes? return doc.getLanguage().getTranslationDirectionNames(); } }; // percentage of translated chunks TextColumn<Document> doneClm = new TextColumn<Document>() { @Override public String getValue(Document doc) { return Double.toString( Math.round(10000 * doc.getTranslatedChunksCount() / doc.getTotalChunksCount()) / 100) + "%"; } }; // date and time of last edit of the document (table is sorted by this column) TextColumn<Document> lastEditedClm = new TextColumn<Document>() { @Override public String getValue(Document doc) { Date lastChange = new Date(doc.getLastChange()); return DateTimeFormat.getFormat("dd/MM/yyy HH:mm").format(lastChange); } }; com.github.gwtbootstrap.client.ui.ButtonCell buttonCell = new com.github.gwtbootstrap.client.ui.ButtonCell(); // edit button com.google.gwt.user.cellview.client.Column<Document, String> buttonClm = new com.google.gwt.user.cellview.client.Column<Document, String>( buttonCell) { @Override public String getValue(Document doc) { return "Edit"; } }; buttonClm.setFieldUpdater(new FieldUpdater<Document, String>() { public void update(int index, Document doc, String value) { editDocument(doc); } }); // export button com.google.gwt.user.cellview.client.Column<Document, String> exportSubtitlesButton = new com.google.gwt.user.cellview.client.Column<Document, String>( buttonCell) { @Override public String getValue(Document doc) { return "Export"; } }; exportSubtitlesButton.setFieldUpdater(new FieldUpdater<Document, String>() { public void update(int index, Document doc, String value) { new DownloadDialog(doc); } }); // share button com.google.gwt.user.cellview.client.Column<Document, String> settingsButton = new com.google.gwt.user.cellview.client.Column<Document, String>( buttonCell) { @Override public String getValue(Document doc) { return "Settings"; } }; settingsButton.setFieldUpdater(new FieldUpdater<Document, String>() { public void update(int index, Document doc, String value) { new SettingsDialog(Gui.getUser(), doc); } }); // delete button com.google.gwt.user.cellview.client.Column<Document, String> deleteButton = new com.google.gwt.user.cellview.client.Column<Document, String>( buttonCell) { @Override public String getValue(Document doc) { return "Remove"; } }; deleteButton.setFieldUpdater(new FieldUpdater<Document, String>() { public void update(int index, Document doc, String value) { if (Window.confirm("Do you really want to remove the document " + doc.getTitle() + " from your list of documents?" + "\nNote: Document will still be available to users who have access to this document.")) { new DeleteDocument(doc.getId()); } } }); docTable.addColumn(nameClm, "Document"); docTable.addColumn(mSourceClm, "Movie/TV Show"); docTable.addColumn(languageClm, "Language"); docTable.addColumn(doneClm, "Translated"); docTable.addColumn(lastEditedClm, "Last edited"); docTable.addColumn(buttonClm, "Edit"); docTable.addColumn(settingsButton, "Settings"); docTable.addColumn(exportSubtitlesButton, "Export"); docTable.addColumn(deleteButton, "Remove"); // load documents new GetListOfDocuments(this); Gui.getGuiStructure().contentPanel.setStyleName("users_page"); Gui.getGuiStructure().contentPanel.setWidget(this); }