List of usage examples for com.google.gwt.gen2.table.event.client RowSelectionEvent getSelectedRows
public Set<Row> getSelectedRows()
From source file:com.qualogy.qafe.gwt.client.component.QPagingScrollTable.java
License:Apache License
public void onRowSelection(final RowSelectionEvent event) { if (hasOverflow()) { final Set<Row> selected = event.getSelectedRows(); for (final Row row : selected) { final DataContainerGVO dm = getRowValue(row.getRowIndex()); final SetValueGVO setValue = new SetValueGVO(); setValue.setDataContainer(dm); if (overflow instanceof HasWidgets) { SetValueExecute.processWidgets((HasWidgets) overflow, setValue); }/*from www . j a va 2 s.c o m*/ } } handleRowSelection(event); }
From source file:com.qualogy.qafe.gwt.client.component.QPagingScrollTable.java
License:Apache License
private int getLastSelectedIndex(final RowSelectionEvent event) { int rowIndex = -1; final Object[] selected = event.getSelectedRows().toArray(); if (selected.length == 0) { return rowIndex; }/*from w w w . j a v a2 s . com*/ if (selected[selected.length - 1] instanceof Row) { final Row lastRowSelected = (Row) selected[selected.length - 1]; rowIndex = lastRowSelected.getRowIndex(); } return rowIndex; }
From source file:edu.caltech.ipac.firefly.ui.previews.TableFilteringPreview.java
protected void loadTable(final DataSet data) { Widget w = container.getWidget();/*from w w w . j av a2 s .co m*/ if (w != null) { container.remove(w); } raIdx = data.getModel().getColumnNames().indexOf("ra"); decIdx = data.getModel().getColumnNames().indexOf("dec"); idIdx = data.getModel().getColumnNames().indexOf(CatalogRequest.UPDLOAD_ROW_ID); objNameIdx = data.getModel().getColumnNames().indexOf("objname"); data.getColumn(idIdx).setHidden(true); //data.getColumn(idIdx).setVisible(false); //data.getColumn(idIdx).setWidth(0); data.getColumn(objNameIdx).setWidth(60); data.getColumn(raIdx).setWidth(60); data.getColumn(decIdx).setWidth(60); final BasicTable table = new BasicTable(data); table.setSize("100%", "100%"); table.getDataTable().setSelectionEnabled(true); table.getDataTable().addRowSelectionHandler(new RowSelectionHandler() { public void onRowSelection(RowSelectionEvent event) { String filterStr; String colName, v; Set<TableEvent.Row> srows = event.getSelectedRows(); ArrayList<String> fList = new ArrayList<String>(); for (TableEvent.Row r : srows) { int idx = r.getRowIndex(); TableData.Row row = /*data.getModel().getRow(idx);*/ table.getRows().get(idx); //since RA Dec are unique keys in the table, we can simply use ra, dec columns for filtering. /*v = getColumnValue(row,objNameIdx); if (v!=null && v.length()>0) { colName = getColumnName(data, objNameIdx); filterStr = colName + " = " + v; fList.add(filterStr); } else*/ { /*colName = getColumnName(data, raIdx); v = getColumnValue(row,raIdx); filterStr = colName + " = " + v; fList.add(filterStr); colName = getColumnName(data, decIdx); v = getColumnValue(row,decIdx); filterStr = colName + " = " + v; fList.add(filterStr);*/ colName = getColumnName(data, idIdx); v = getColumnValue(row, idIdx); filterStr = colName + " = " + v; fList.add(filterStr); } TableFilteringPreview.this.mainTable.getDataModel().setFilters(fList); TableFilteringPreview.this.mainTable.getDataModel().fireDataStaleEvent(); setActiveTarget(row); } } }); table.getDataTable().selectRow(0, true); container.setWidget(table); }
From source file:edu.ycp.cs.netcoder.client.CourseAndProblemView.java
License:Open Source License
/** * Constructor.//from ww w . j a va 2 s . co m * * @param session the Session */ public CourseAndProblemView(Session session) { super(session); // Subscribe to session ADDED_OBJECT events (to find out when course list is loaded) getSession().subscribe(Session.Event.ADDED_OBJECT, this, getSubscriptionRegistrar()); LayoutPanel layoutPanel = getLayoutPanel(); // Add grid to display problems headerTable = new FixedWidthFlexTable(); FlexCellFormatter formatter = headerTable.getFlexCellFormatter(); headerTable.setHTML(0, 0, "Problem name"); headerTable.setHTML(0, 1, "Description"); formatter.setColSpan(0, 0, 1); formatter.setColSpan(0, 1, 1); grid = new FixedWidthGrid(); grid.setSelectionPolicy(SelectionPolicy.ONE_ROW); grid.setSelectionEnabled(true); grid.addRowSelectionHandler(new RowSelectionHandler() { @Override public void onRowSelection(RowSelectionEvent event) { //Window.alert("Row selection event!"); CourseSelection courseSelection = getSession().get(CourseSelection.class); Problem[] problemList = courseSelection.getProblemList(); Set<Row> selectedRows = event.getSelectedRows(); //Window.alert(selectedRows.size() + " rows selected"); if (selectedRows.size() == 1) { // A problem has been selected Row row = selectedRows.iterator().next(); int index = row.getRowIndex(); Problem problem = problemList[index]; //Window.alert("Setting problem " + problem.getBriefDescription() + " in session"); getSession().add(problem); } } }); setColumnWidth(0, 100); setColumnWidth(1, 300); table = new ScrollTable(grid, headerTable); layoutPanel.add(table); // Status and button bar widget this.statusAndButtonBar = new StatusAndButtonBarWidget(getSession(), getSubscriptionRegistrar()); statusAndButtonBar.addToLeftPanel(new StatusMessageWidget(getSession(), getSubscriptionRegistrar())); Button selectProblemButton = new Button("Select problem"); selectProblemButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { Problem problem = getSession().get(Problem.class); if (problem != null) { // Woot!!! //Window.alert("firing PROBLEM_CHOSEN for " + problem.getBriefDescription()); getSession().notifySubscribers(Session.Event.PROBLEM_CHOSEN, problem); } } }); statusAndButtonBar.addToRightPanel(selectProblemButton); layoutPanel.add(statusAndButtonBar); // Problem description this.problemDescriptionWidget = new ProblemDescriptionWidget(getSession(), getSubscriptionRegistrar()); layoutPanel.add(problemDescriptionWidget); initWidget(layoutPanel); // Subscribe to window resize events getSession().get(WindowResizeNotifier.class).subscribe(WindowResizeNotifier.WINDOW_RESIZED, this, getSubscriptionRegistrar()); // Subscribe to changes in selected course CourseSelection courseSelection = new CourseSelection(); addSessionObject(courseSelection); courseSelection.subscribe(CourseSelection.Event.COURSE_SELECTED, this, getSubscriptionRegistrar()); courseSelection.subscribe(CourseSelection.Event.COURSE_LOADED, this, getSubscriptionRegistrar()); }
From source file:org.apache.hupa.widgets.ui.RefetchPagingScrollTable.java
License:Apache License
public RefetchPagingScrollTable(MutableTableModel<RowType> tableModel, FixedWidthGrid dataTable, FixedWidthFlexTable headerTable, TableDefinition<RowType> tableDefinition) { super(tableModel, dataTable, headerTable, tableDefinition); getDataTable().addRowSelectionHandler(new RowSelectionHandler() { public void onRowSelection(RowSelectionEvent event) { Iterator<Row> rowIndexIt = event.getSelectedRows().iterator(); while (rowIndexIt.hasNext()) { RowType row = getRowValue(rowIndexIt.next().getRowIndex()); if (selectedRows.contains(row) == false) { selectedRows.add(row); }/*w w w. j a va 2 s . c o m*/ } Iterator<Row> rowDeselectIndexIt = event.getDeselectedRows().iterator(); while (rowDeselectIndexIt.hasNext()) { RowType row = getRowValue(rowDeselectIndexIt.next().getRowIndex()); selectedRows.remove(row); } } }); }
From source file:org.gss_project.gss.admin.client.ui.FilesTable.java
License:Open Source License
public FileHeaderDTO getSelectedRowObject(RowSelectionEvent event) { Set<Row> set = event.getSelectedRows(); if (set.size() == 1) { int rowIdx = set.iterator().next().getRowIndex(); String id = pagingScrollTable.getDataTable().getHTML(rowIdx, 0); FileHeaderDTO m = tableModel.getUserById(Long.parseLong(id)); return m; }/*from ww w . ja v a 2s . c o m*/ return null; }
From source file:org.gss_project.gss.admin.client.ui.UsersTable.java
License:Open Source License
public UserDTO getSelectedRowObject(RowSelectionEvent event) { Set<Row> set = event.getSelectedRows(); if (set.size() == 1) { int rowIdx = set.iterator().next().getRowIndex(); String id = pagingScrollTable.getDataTable().getHTML(rowIdx, 0); UserDTO m = tableModel.getUserById(Long.parseLong(id)); return m; }/*from w w w .j a v a2 s . com*/ return null; }
From source file:org.zanata.webtrans.client.editor.table.TableEditorView.java
License:Open Source License
public TableEditorView(RedirectingCachedTableModel<TransUnit> tableModel, TableEditorTableDefinition tableDefinition) { super(tableModel, tableDefinition); this.cachedTableModel = tableModel; this.tableDefinition = tableDefinition; setStylePrimaryName("TableEditorWrapper"); setSize("100%", "100%"); setPageSize(10);//w w w. j a v a 2 s .co m setEmptyTableWidget(new HTML("There is no data to display")); // Setup the bulk renderer FixedWidthGridBulkRenderer<TransUnit> bulkRenderer = new FixedWidthGridBulkRenderer<TransUnit>( getDataTable(), this); setBulkRenderer(bulkRenderer); // Setup the formatting setCellPadding(3); setCellSpacing(0); setResizePolicy(ScrollTable.ResizePolicy.FILL_WIDTH); getDataTable().setStylePrimaryName("TableEditor"); getDataTable().setSelectionPolicy(SelectionPolicy.ONE_ROW); getDataTable().setCellPadding(3); getDataTable().addRowSelectionHandler(new RowSelectionHandler() { @Override public void onRowSelection(RowSelectionEvent event) { if (!event.getSelectedRows().isEmpty()) { Row row = event.getSelectedRows().iterator().next(); TransUnit tu = getRowValue(row.getRowIndex()); SelectionEvent.fire(TableEditorView.this, tu); } } }); }