List of usage examples for com.google.gwt.view.client SelectionModel addSelectionChangeHandler
HandlerRegistration addSelectionChangeHandler(SelectionChangeEvent.Handler handler);
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 w w . j a v a2 s .c o 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.TopicsViewImpl.java
License:Apache License
/** * Instantiates a new topics view impl.//from w ww . ja v a2s. 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)); }
From source file:com.bradrydzewski.gwtgantt.gantt.TaskDisplayPresenter.java
License:Open Source License
@Override public void setSelectionModel(SelectionModel<? super T> selectionModel) { clearSelectionModel();//from w ww. jav a2 s. c o m // Set the new selection model. this.selectionModel = selectionModel; if (selectionModel != null) { selectionHandler = selectionModel.addSelectionChangeHandler(new SelectionChangeEvent.Handler() { @Override public void onSelectionChange(SelectionChangeEvent event) { updateSelection(); } }); } // Update the current selection state based on the new model. updateSelection(); }
From source file:org.activityinfo.ui.client.widget.CellTable.java
License:Open Source License
public CellTable(int pageSize, Resources resources) { super(pageSize, resources); addAttachHandler(new AttachEvent.Handler() { @Override// w w w .ja v a 2 s. c o m public void onAttachOrDetach(AttachEvent event) { if (event.isAttached()) { Scheduler.get().scheduleDeferred(new Scheduler.ScheduledCommand() { @Override public void execute() { affixer = new CellTableAffixer(CellTable.this); final SelectionModel<? super T> selectionModel = CellTable.this.getSelectionModel(); if (selectionModel != null) { selectionModel.addSelectionChangeHandler(new SelectionChangeEvent.Handler() { @Override public void onSelectionChange(SelectionChangeEvent event) { // AI-535 : Affixed table headers don't work in IE10 affixer.forceAffix(); } }); } } }); addScrollHandlers(); } } }); }
From source file:org.cimav.client.ui.departamentos.DepartamentosUI.java
private void buildGrid() { // super.onLoad(); //To change body of generated methods, choose Tools | Templates. /*//from ww w. java 2s . c o 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 DataGrid<>(Departamento.KEY_PROVIDER); dataGrid.setWidth("100%"); dataGrid.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 departamentos")); // Attach a column sort handler to the ListDataProvider to sort the list. ListHandler<Departamento> sortHandler = new ListHandler<>(DeptoDatabase.get().getDataProvider().getList()); dataGrid.addColumnSortHandler(sortHandler); // Create a Pager to control the table. SimplePager.Resources pagerResources = GWT.create(SimplePager.Resources.class); pager = new SimplePager(TextLocation.CENTER, pagerResources, false, 0, true); pager.setDisplay(dataGrid); dataGrid.setPageSize(30); // Add a selection model so we can select cells. final SelectionModel<Departamento> selectionModel = new SingleSelectionModel<>(Departamento.KEY_PROVIDER); 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(); Departamento sel = (Departamento) selecter.getSelectedObject(); // Seleccion actual DeptoDatabase.currentDepto = sel; System.out.println("Depto.Id --> " + DeptoDatabase.currentDepto); departamentoEditorUI.setDepartamento(DeptoDatabase.currentDepto); // Actualizar botones updateWidgets(); } } }); 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); // simple selecciona el tab del Editor tabLayout.selectTab(1); } }, DoubleClickEvent.getType()); initTableColumns(sortHandler); // Add the CellList to the adapter in the database. DeptoDatabase.get().addDataDisplay(dataGrid); }
From source file:org.cimav.rh.client.departamentos.DepartamentosUI.java
private void buildGrid() { // super.onLoad(); //To change body of generated methods, choose Tools | Templates. /*// w w w. ja v a 2s. c o 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 DataGrid<>(Departamento.KEY_PROVIDER); dataGrid.setWidth("100%"); dataGrid.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 departamentos")); // Attach a column sort handler to the ListDataProvider to sort the list. ListHandler<Departamento> sortHandler = new ListHandler<>(DeptoDatabase.get().getDataProvider().getList()); dataGrid.addColumnSortHandler(sortHandler); // Add a selection model so we can select cells. final SelectionModel<Departamento> selectionModel = new SingleSelectionModel<>(Departamento.KEY_PROVIDER); 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(); Departamento sel = (Departamento) selecter.getSelectedObject(); // Seleccion actual DeptoDatabase.currentDepto = sel; System.out.println("Depto.Id --> " + DeptoDatabase.currentDepto); departamentoEditorUI.setDepartamento(DeptoDatabase.currentDepto); // Actualizar botones updateWidgets(); } } }); dataGrid.setSelectionModel(selectionModel); initTableColumns(sortHandler); // Add the CellList to the adapter in the database. DeptoDatabase.get().addDataDisplay(dataGrid); }
From source file:org.eclipse.che.ide.ext.java.client.refactoring.preview.PreviewViewImpl.java
License:Open Source License
/** {@inheritDoc} */ @Override/*from w w w .j a v a2 s . c o m*/ public void setTreeOfChanges(final RefactoringPreview changes) { showDiffPanel(false); final SelectionModel<RefactoringPreview> selectionModel = new SingleSelectionModel<>(); selectionModel.addSelectionChangeHandler(new SelectionChangeEvent.Handler() { @Override public void onSelectionChange(SelectionChangeEvent event) { RefactoringPreview selectedNode = (RefactoringPreview) ((SingleSelectionModel) selectionModel) .getSelectedObject(); delegate.onSelectionChanged(selectedNode); } }); CellTree tree = new CellTree(new PreviewChangesModel(changes, selectionModel, delegate), null, cellTreeResources); treePanel.clear(); treePanel.add(tree); }