List of usage examples for com.google.gwt.view.client SingleSelectionModel SingleSelectionModel
public SingleSelectionModel(ProvidesKey<T> keyProvider)
From source file:cc.alcina.framework.gwt.client.widget.SelectWithSearch.java
License:Apache License
private void updateItemsCellList(String filterText, HasWidgets itemHolder) { emptyItems = true;//from ww w . jav a2 s . c o m Cell<T> cell = new AbstractCell<T>() { @Override public void render(com.google.gwt.cell.client.Cell.Context context, T value, SafeHtmlBuilder sb) { sb.appendEscaped((String) renderer.apply(value)); } }; CellList<T> cellList = new CellList<T>(cell); cellList.setPageSize(9999); cellList.setKeyboardPagingPolicy(KeyboardPagingPolicy.INCREASE_RANGE); cellList.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.DISABLED); // Add a selection model so we can select cells. final SingleSelectionModel<T> selectionModel = new SingleSelectionModel<T>(new SimpleKeyProvider<T>()); cellList.setSelectionModel(selectionModel); selectionModel.addSelectionChangeHandler(new SelectionChangeEvent.Handler() { @Override public void onSelectionChange(SelectionChangeEvent event) { itemSelected(selectionModel.getSelectedObject()); } }); List<T> items = new ArrayList<>(); for (G c : keys) { if (!itemMap.containsKey(c)) { continue; } for (T item : itemMap.get(c)) { String filterable = CommonUtils.nullToEmpty(((String) renderer.apply(item))).toLowerCase(); if (itemFilter.allow(item, filterable, filterText) && !selectedItems.contains(item)) { items.add(item); } } } ListDataProvider<T> dataProvider = new ListDataProvider<T>(); dataProvider.getList().addAll(items); dataProvider.addDataDisplay(cellList); emptyItems = items.isEmpty(); itemHolder.clear(); itemHolder.add(cellList); afterUpdateItems(emptyItems); }
From source file:cc.kune.gspace.client.i18n.I18nCellList.java
License:Apache License
/** * Instantiates a new i18n cell list./*from www . ja v a2 s .c om*/ * * @param data * the data * @param i18n * the i18n * @param saver * the saver */ @Inject public I18nCellList(final I18nTranslationDataProvider data, final I18nUITranslationService i18n, final I18nTranslatorSaver saver) { this.data = data; final TranslationCell cell = new TranslationCell(); // Set a key provider that provides a unique key for each contact. If key is // used to identify translations when fields change. cellList = new CellList<I18nTranslationDTO>(cell, I18nTranslationDTO.KEY_PROVIDER); cellList.setPageSize(30); cellList.setEmptyListMessage(SafeHtmlUtils .fromTrustedString("<span style='padding: 10px; font-style: italic;'>Empty list</span>")); cellList.setKeyboardPagingPolicy(KeyboardPagingPolicy.INCREASE_RANGE); cellList.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.BOUND_TO_SELECTION); final SingleSelectionModel<I18nTranslationDTO> selectionModel = new SingleSelectionModel<I18nTranslationDTO>( I18nTranslationDTO.KEY_PROVIDER); // Add a selection model so we can select cells. cellList.setSelectionModel(selectionModel); // Create the UiBinder. final Binder uiBinder = GWT.create(Binder.class); initWidget(uiBinder.createAndBindUi(this)); translatorForm.init(data, i18n, saver); cellList.setValueUpdater(new ValueUpdater<I18nTranslationDTO>() { @Override public void update(final I18nTranslationDTO value) { // save(value); } }); selectionModel.addSelectionChangeHandler(new SelectionChangeEvent.Handler() { @Override public void onSelectionChange(final SelectionChangeEvent event) { translatorForm.setInfo(selectionModel.getSelectedObject()); Scheduler.get().scheduleEntry(new ScheduledCommand() { @Override public void execute() { translatorForm.focusToTranslate(); } }); } }); // cellList.sinkEvents(com.google.gwt.user.client.Event.KEYEVENTS); data.addDataDisplay(cellList); data.setSelectionMode(selectionModel); data.setLoadCallback(new SimpleCallback() { @Override public void onCallback() { translatorForm.focusToTranslate(); NotifyUser.hideProgress(); } }); // Set the cellList as the display of the pagers. // pagerPanel is a scrollable pager that extends the range when the // user scrolls to the bottom. rangeLabelPager is a pager that displays the // current range, but does not have any controls to change the range. pagerPanel.setDisplay(cellList); // pagerPanel.setStyleName("k-i18n-trans-list"); rangeLabelPager.setDisplay(cellList); }
From source file:cimav.client.view.catalogos.tabulador.NivelesUi.java
private void buildGrid() { // super.onLoad(); //To change body of generated methods, choose Tools | Templates. /*//w ww. j a v a 2s . co m * Set a key provider that provides a unique key for each contact. If key is * used to identify contacts when fields (such as the name and address) * change. */ dataGrid = new CellTable<>(NivelesProvider.get().getDataProvider()); //cellTable.setWidth("100%"); //cellTable.setHeight("100%"); /* * Do not refresh the headers every time the data is updated. The footer * depends on the current data, so we do not disable auto refresh on the * footer. */ dataGrid.setAutoHeaderRefreshDisabled(true); // Set the message to display when the table is empty. dataGrid.setEmptyTableWidget(new Label("No hay Niveles")); // Attach a column sort handler to the ListDataProvider to sort the list. ColumnSortEvent.ListHandler<Tabulador> sortHandler = new ColumnSortEvent.ListHandler<>( NivelesProvider.get().getDataProvider().getList()); dataGrid.addColumnSortHandler(sortHandler); // Create a Pager to control the table. SimplePager.Resources pagerResources = GWT.create(SimplePager.Resources.class); pager = new SimplePager(SimplePager.TextLocation.CENTER, pagerResources, false, 0, true); pager.setDisplay(dataGrid); dataGrid.setPageSize(50); // Add a selection model so we can select cells. final SelectionModel<Tabulador> selectionModel = new SingleSelectionModel<>( NivelesProvider.get().getDataProvider()); selectionModel.addSelectionChangeHandler(new SelectionChangeEvent.Handler() { @Override public void onSelectionChange(SelectionChangeEvent event) { //System.out.println("123> " + event.getSource() + " - " + event.getAssociatedType()); if (event.getSource() instanceof SingleSelectionModel) { SingleSelectionModel selecter = (SingleSelectionModel) event.getSource(); Tabulador sel = (Tabulador) selecter.getSelectedObject(); GWT.log("Sel>> " + sel); } } }); dataGrid.setSelectionModel(selectionModel); dataGrid.addDomHandler(new DoubleClickHandler() { @SuppressWarnings("unchecked") @Override public void onDoubleClick(DoubleClickEvent event) { // DataGrid<Departamento> grid = (DataGrid<Departamento>) event.getSource(); // int row = grid.getKeyboardSelectedRow(); // Departamento item = grid.getVisibleItem(row); } }, DoubleClickEvent.getType()); initTableColumns(sortHandler); // Add the CellList to the adapter in the database. NivelesProvider.get().getDataProvider().addDataDisplay(dataGrid); }
From source file:com.appspot.socialinquirer.client.view.ActivityViewImpl.java
License:Apache License
/** * Instantiates a new activity view impl. * * @param constants the constants/*from w w w. jav a 2 s .co m*/ * @param master the master */ public ActivityViewImpl(final EverScribeConstants constants, final boolean master) { this.constants = constants; activitiesTable = new CellTable<NamedBean>(); SimplePager.Resources linkedHubPagerResources = GWT.create(SimplePager.Resources.class); activitiesPaginator = new SimplePager(TextLocation.CENTER, linkedHubPagerResources, false, 0, true); activitiesPaginator.setDisplay(activitiesTable); activitiesPaginator.setPageSize(5); activitiesTable.setPageSize(5); final SelectionModel<NamedBean> activitiesSelectionModel = new SingleSelectionModel<NamedBean>( new KeyProvider<NamedBean>()); activitiesTable.setSelectionModel(activitiesSelectionModel, DefaultSelectionEventManager.<NamedBean>createCheckboxManager()); initTableColumns(activitiesTable, activitiesSelectionModel); initWidget(uiBinder.createAndBindUi(ActivityViewImpl.this)); }
From source file:com.appspot.socialinquirer.client.view.HomeViewImpl.java
License:Apache License
/** * Instantiates a new home view impl./*w w w . j ava 2 s.c o m*/ * * @param constants the constants * @param oracle the oracle */ public HomeViewImpl(final EverScribeConstants constants, SingleWordSuggestOracle oracle) { this.constants = constants; questionsTable = new CellTable<Question>(); SimplePager.Resources ideasPagerResources = GWT.create(SimplePager.Resources.class); questionsPaginator = new SimplePager(TextLocation.CENTER, ideasPagerResources, false, 0, true); questionsPaginator.setDisplay(questionsTable); final SelectionModel<Question> questionsSelectionModel = new SingleSelectionModel<Question>( new KeyProvider<Question>()); questionsTable.setSelectionModel(questionsSelectionModel, DefaultSelectionEventManager.<Question>createCheckboxManager()); initTableColumns(questionsTable, questionsSelectionModel); questionsSearchBox = new SuggestBox(oracle); templatesTable = new CellTable<Message>(); SimplePager.Resources linkedHubPagerResources = GWT.create(SimplePager.Resources.class); templatesPaginator = new SimplePager(TextLocation.CENTER, linkedHubPagerResources, false, 0, true); templatesPaginator.setPageSize(5); templatesTable.setPageSize(5); templatesPaginator.setDisplay(templatesTable); // final SelectionModel<Message> linkedHubConnectionsSelectionModel = new MultiSelectionModel<Message>( // new KeyProvider<Message>()); // templatesTable.setSelectionModel(linkedHubConnectionsSelectionModel, // DefaultSelectionEventManager.<Message>createCheckboxManager()); initTableColumns(templatesTable); initWidget(uiBinder.createAndBindUi(this)); searchResults.setVisible(false); introduction.setVisible(true); feeds.setVisible(false); viewMenu.setCommand(new Command() { @Override public void execute() { presenter.onViewClicked(getSelectedQuestion()); } }); // followMenu.setCommand(new Command() { // @Override // public void execute() { // presenter.onFollowClicked(getSelectedQuestion()); // } // }); analyzeMenu.setCommand(new Command() { @Override public void execute() { presenter.onAnalyzeClicked(getSelectedQuestion()); } }); summarizeMenu.setCommand(new Command() { @Override public void execute() { presenter.onSummarizeClicked(getSelectedQuestion()); } }); suggestAnswerMenu.setCommand(new Command() { @Override public void execute() { presenter.onSuggestAnswerClicked(getSelectedQuestion()); } }); spellCheckMenu.setCommand(new Command() { @Override public void execute() { presenter.onSpellCheckClicked(getSelectedQuestion()); } }); speakMenu.setCommand(new Command() { @Override public void execute() { presenter.onSpeakClicked(getSelectedQuestion()); } }); runCodeMenu.setCommand(new Command() { @Override public void execute() { presenter.onRunCodeClicked(getSelectedQuestion()); } }); for (final TextLanguage language : TextLanguage.values()) { MenuItem menuItem = new MenuItem(language.name(), new Command() { @Override public void execute() { presenter.onTranslateClicked(getSelectedQuestion(), language); } }); menuItem.setEnabled(true); languageBar.addItem(menuItem); } }
From source file:com.appspot.socialinquirer.client.view.NetworkViewImpl.java
License:Apache License
/** * Instantiates a new network view impl. * * @param constants the constants/*from ww w .j a v a2 s. co m*/ */ public NetworkViewImpl(EverScribeConstants constants) { this.constants = constants; GWT.runAsync(new RunAsyncCallback() { public void onFailure(Throwable caught) { Window.alert("Code download failed"); } public void onSuccess() { connectionsTable = new CellTable<User>(); SimplePager.Resources linkedHubPagerResources = GWT.create(SimplePager.Resources.class); connectionsPaginator = new SimplePager(TextLocation.CENTER, linkedHubPagerResources, false, 0, true); connectionsPaginator.setDisplay(connectionsTable); final SelectionModel<User> linkedHubConnectionsSelectionModel = new SingleSelectionModel<User>( new KeyProvider<User>()); connectionsTable.setSelectionModel(linkedHubConnectionsSelectionModel, DefaultSelectionEventManager.<User>createCheckboxManager()); initTableColumns(connectionsTable, linkedHubConnectionsSelectionModel); initWidget(uiBinder.createAndBindUi(NetworkViewImpl.this)); } }); }
From source file:com.appspot.socialinquirer.client.view.QuestionsViewImpl.java
License:Apache License
/** * Instantiates a new questions view impl. * * @param constants the constants//from www . j a va2s . c om */ public QuestionsViewImpl(final EverScribeConstants constants) { this.constants = constants; questionsTable = new CellTable<Question>(); SimplePager.Resources ideasPagerResources = GWT.create(SimplePager.Resources.class); questionsPaginator = new SimplePager(TextLocation.CENTER, ideasPagerResources, false, 0, true); questionsPaginator.setDisplay(questionsTable); final SelectionModel<Question> questionsSelectionModel = new SingleSelectionModel<Question>( new KeyProvider<Question>()); questionsTable.setSelectionModel(questionsSelectionModel, DefaultSelectionEventManager.<Question>createCheckboxManager()); initTableColumns(questionsTable, questionsSelectionModel); initWidget(uiBinder.createAndBindUi(this)); // menu commands viewMenu.setCommand(new Command() { @Override public void execute() { presenter.onViewClicked(getSelectedQuestion()); } }); // followMenu.setCommand(new Command() { // @Override // public void execute() { // presenter.onFollowClicked(getSelectedQuestion()); // } // }); analyzeMenu.setCommand(new Command() { @Override public void execute() { presenter.onAnalyzeClicked(getSelectedQuestion()); } }); summarizeMenu.setCommand(new Command() { @Override public void execute() { presenter.onSummarizeClicked(getSelectedQuestion()); } }); suggestAnswerMenu.setCommand(new Command() { @Override public void execute() { presenter.onSuggestAnswerClicked(getSelectedQuestion()); } }); spellCheckMenu.setCommand(new Command() { @Override public void execute() { presenter.onSpellCheckClicked(getSelectedQuestion()); } }); speakMenu.setCommand(new Command() { @Override public void execute() { presenter.onSpeakClicked(getSelectedQuestion()); } }); runCodeMenu.setCommand(new Command() { @Override public void execute() { presenter.onRunCodeClicked(getSelectedQuestion()); } }); for (final TextLanguage language : TextLanguage.values()) { MenuItem menuItem = new MenuItem(language.name(), new Command() { @Override public void execute() { presenter.onTranslateClicked(getSelectedQuestion(), language); } }); menuItem.setEnabled(true); languageBar.addItem(menuItem); } }
From source file:com.appspot.socialinquirer.client.view.QuestionViewImpl.java
License:Apache License
/** * Instantiates a new question view impl. * * @param constants the constants/*from w ww . ja v a 2s . c o m*/ */ public QuestionViewImpl(final EverScribeConstants constants) { this.constants = constants; answersTable = new CellTable<Answer>(); SimplePager.Resources ideasPagerResources = GWT.create(SimplePager.Resources.class); answersPaginator = new SimplePager(TextLocation.CENTER, ideasPagerResources, false, 0, true); answersPaginator.setDisplay(answersTable); final SelectionModel<Answer> answerSelectionModel = new SingleSelectionModel<Answer>( new KeyProvider<Answer>()); answersTable.setSelectionModel(answerSelectionModel, DefaultSelectionEventManager.<Answer>createCheckboxManager()); initTableColumns(answersTable, answerSelectionModel); initWidget(uiBinder.createAndBindUi(this)); // followMenu.setCommand(new Command() { // @Override // public void execute() { // presenter.onFollowClicked(question); // } // }); analyzeMenu.setCommand(new Command() { @Override public void execute() { presenter.onAnalyzeClicked(question); } }); summarizeMenu.setCommand(new Command() { @Override public void execute() { presenter.onSummarizeClicked(question); } }); suggestAnswerMenu.setCommand(new Command() { @Override public void execute() { presenter.onSuggestAnswerClicked(question); } }); spellCheckMenu.setCommand(new Command() { @Override public void execute() { presenter.onSpellCheckClicked(question); } }); speakMenu.setCommand(new Command() { @Override public void execute() { presenter.onSpeakClicked(question); } }); runCodeMenu.setCommand(new Command() { @Override public void execute() { presenter.onRunCodeClicked(question); } }); followQuestionAuthorMenu.setCommand(new Command() { @Override public void execute() { presenter.onFollowUserClicked(questionAuthor.getText()); } }); // followAnswerAuthorMenu.setCommand(new Command() { // @Override // public void execute() { // presenter.onFollowUserClicked(answerAuthor.getText()); // } // }); for (final TextLanguage language : TextLanguage.values()) { MenuItem menuItem = new MenuItem(language.name(), new Command() { @Override public void execute() { presenter.onTranslateClicked(question, language); } }); menuItem.setEnabled(true); languageBar.addItem(menuItem); } answers.setAnimationEnabled(true); }
From source file:com.appspot.socialinquirer.client.view.QuizViewImpl.java
License:Apache License
/** * Instantiates a new quiz view impl.//from w ww. ja v a 2 s. c o m * * @param constants the constants */ public QuizViewImpl(final EverScribeConstants constants) { this.constants = constants; answersTable = new CellTable<Answer>(); SimplePager.Resources ideasPagerResources = GWT.create(SimplePager.Resources.class); answersPaginator = new SimplePager(TextLocation.CENTER, ideasPagerResources, false, 0, true); answersPaginator.setDisplay(answersTable); final SelectionModel<Answer> answerSelectionModel = new SingleSelectionModel<Answer>( new KeyProvider<Answer>()); answersTable.setSelectionModel(answerSelectionModel, DefaultSelectionEventManager.<Answer>createCheckboxManager()); initTableColumns(answersTable, answerSelectionModel); initWidget(uiBinder.createAndBindUi(this)); }
From source file:com.appspot.socialinquirer.client.view.TopicsViewImpl.java
License:Apache License
/** * Instantiates a new topics view impl./*from ww w . j a v a 2 s . com*/ */ public TopicsViewImpl() { activeTagsList = new CellList<Tag>(new TagCell()); followingTagsList = new CellList<Tag>(new TagCell()); suggestedTagsList = new CellList<Tag>(new TagCell()); SelectionModel<Tag> tagSelectionModel = new SingleSelectionModel<Tag>(new ProvidesKey<Tag>() { @Override public Object getKey(Tag item) { return item.getTag(); } }); tagSelectionModel.addSelectionChangeHandler(new SelectionChangeEvent.Handler() { public void onSelectionChange(SelectionChangeEvent event) { setSelectedTag(getSelectedTag(activeTagsList)); } }); activeTagsList.setSelectionModel(tagSelectionModel); tagSelectionModel = new SingleSelectionModel<Tag>(new ProvidesKey<Tag>() { @Override public Object getKey(Tag item) { return item.getTag(); } }); tagSelectionModel.addSelectionChangeHandler(new SelectionChangeEvent.Handler() { public void onSelectionChange(SelectionChangeEvent event) { setSelectedTag(getSelectedTag(followingTagsList)); } }); followingTagsList.setSelectionModel(tagSelectionModel); tagSelectionModel = new SingleSelectionModel<Tag>(new ProvidesKey<Tag>() { @Override public Object getKey(Tag item) { return item.getTag(); } }); tagSelectionModel.addSelectionChangeHandler(new SelectionChangeEvent.Handler() { public void onSelectionChange(SelectionChangeEvent event) { setSelectedTag(getSelectedTag(suggestedTagsList)); } }); suggestedTagsList.setSelectionModel(tagSelectionModel); initWidget(uiBinder.createAndBindUi(TopicsViewImpl.this)); }