List of usage examples for com.google.gwt.user.client.ui ValueListBox ValueListBox
public ValueListBox(Renderer<T> renderer)
From source file:org.mklab.taskit.client.ui.StudentListViewImpl.java
License:Apache License
private void initSortTypeList() { this.sortTypeList = new ValueListBox<StudentListViewImpl.SortType>(new Renderer<SortType>() { @Override// w w w .ja va 2 s . c om public String render(SortType object) { if (object == null) return ""; //$NON-NLS-1$ final Messages messages = getClientFactory().getMessages(); switch (object) { case ID_ASCENDING: return messages.sortTypeIdAscending(); case ID_DESCENDING: return messages.sortTypeIdDescending(); case SCORE_ASCENDING: return messages.sortTypeScoreAscending(); case SCORE_DESCENDING: return messages.sortTypeScoreDescending(); default: throw new IllegalStateException("Unknown sort type : " + object); //$NON-NLS-1$ } } @Override public void render(SortType object, Appendable appendable) throws IOException { appendable.append(render(object)); } }); this.sortTypeList.setAcceptableValues(Arrays.asList(SortType.values())); this.sortTypeList.setValue(lastSortType, false); this.sortTypeList.addValueChangeHandler(new ValueChangeHandler<SortType>() { @SuppressWarnings({ "synthetic-access", "unqualified-field-access" }) @Override public void onValueChange(@SuppressWarnings("unused") ValueChangeEvent<SortType> event) { lastSortType = sortTypeList.getValue(); resetListData(); } }); }
From source file:org.mklab.taskit.client.ui.StudentListViewImpl.java
License:Apache License
private void initUserList(final Messages messages) { this.userList = new ValueListBox<UserProxy>(new Renderer<UserProxy>() { @Override//from w ww . ja va 2s . c o m public String render(UserProxy object) { if (object == null) return messages.selectIdLabel(); StringBuilder sb = new StringBuilder(object.getAccount().getId()); if (object.getName() != null) { sb.append(" " + object.getName()); //$NON-NLS-1$ } return sb.toString(); } @Override public void render(UserProxy object, Appendable appendable) throws IOException { appendable.append(render(object)); } }); this.userList.addValueChangeHandler(new ValueChangeHandler<UserProxy>() { @SuppressWarnings("synthetic-access") @Override public void onValueChange(ValueChangeEvent<UserProxy> event) { StudentListViewImpl.this.presenter.listSelectionChanged(event.getValue()); } }); }