List of usage examples for com.google.gwt.gen2.table.event.client PageLoadHandler PageLoadHandler
PageLoadHandler
From source file:com.google.gwt.gen2.demo.scrolltable.client.option.log.LogOption.java
License:Apache License
@Override protected Widget onInitialize() { layout = new FlexTable(); // Create the log area logLabel = new HTML(); logLabel.setHeight("200px"); DOM.setStyleAttribute(logLabel.getElement(), "font", "8pt/10pt courier"); ScrollPanel scrollPanel = new ScrollPanel(logLabel); scrollPanel.setPixelSize(500, 200);//from w w w . ja va 2s . c om DOM.setStyleAttribute(scrollPanel.getElement(), "border", "1px solid black"); layout.setWidget(0, 0, scrollPanel); layout.getFlexCellFormatter().setColSpan(0, 0, 2); // Add a clear button Button clearButton = new Button("Clear Log", new ClickHandler() { public void onClick(ClickEvent event) { logLabel.setHTML(""); lineCount = 0; } }); layout.setWidget(1, 0, clearButton); layout.getFlexCellFormatter().setColSpan(1, 0, 2); // Add labels for highlighting final Label highlightedCellLabel = new Label("Highlighted cell:"); final Label highlightedRowLabel = new Label("Highlighted row:"); final Label unhighlightedCellLabel = new Label("Last unhighlighted cell:"); final Label unhighlightedRowLabel = new Label("Last unhighlighted row:"); layout.setWidget(2, 0, highlightedCellLabel); layout.setWidget(3, 0, highlightedRowLabel); layout.setWidget(2, 1, unhighlightedRowLabel); layout.setWidget(3, 1, unhighlightedCellLabel); // Add all of the listeners FixedWidthGrid dataTable = ScrollTableDemo.get().getDataTable(); dataTable.addTableListener(new TableListener() { public void onCellClicked(SourcesTableEvents sender, int row, int cell) { addLogEntry("cell clicked: (" + row + "," + cell + ")", "#ff00ff"); } }); dataTable.addColumnSortHandler(new ColumnSortHandler() { public void onColumnSorted(ColumnSortEvent event) { ColumnSortList sortList = event.getColumnSortList(); int column = -1; boolean ascending = true; if (sortList != null) { column = sortList.getPrimaryColumn(); ascending = sortList.isPrimaryAscending(); } if (ascending) { addLogEntry("sorted column: " + column + " (ascending)", "black"); } else { addLogEntry("sorted column: " + column, "black"); } } }); dataTable.addCellHighlightHandler(new CellHighlightHandler() { public void onCellHighlight(CellHighlightEvent event) { Cell cell = event.getValue(); highlightedCellLabel .setText("Highlighted cell: (" + cell.getRowIndex() + "," + cell.getCellIndex() + ")"); } }); dataTable.addCellUnhighlightHandler(new CellUnhighlightHandler() { public void onCellUnhighlight(CellUnhighlightEvent event) { Cell cell = event.getValue(); unhighlightedCellLabel.setText( "Last unhighlighted cell: (" + cell.getRowIndex() + "," + cell.getCellIndex() + ")"); } }); dataTable.addRowHighlightHandler(new RowHighlightHandler() { public void onRowHighlight(RowHighlightEvent event) { Row cell = event.getValue(); highlightedRowLabel.setText("Highlighted row: (" + cell.getRowIndex() + ")"); } }); dataTable.addRowUnhighlightHandler(new RowUnhighlightHandler() { public void onRowUnhighlight(RowUnhighlightEvent event) { Row cell = event.getValue(); unhighlightedRowLabel.setText("Last unhighlighted row: (" + cell.getRowIndex() + ")"); } }); dataTable.addRowSelectionHandler(new RowSelectionHandler() { public void onRowSelection(RowSelectionEvent event) { // Show the previously selected rows Set<Row> deselectedRows = event.getDeselectedRows(); String previous = "Previously selected rows: "; for (Row row : event.getOldValue()) { if (deselectedRows.contains(row)) { previous += "-"; } previous += row.getRowIndex() + ", "; } addLogEntry(previous, "green"); // Show the currently selected rows Set<Row> selectedRows = event.getSelectedRows(); String current = "Currently selected rows: "; for (Row row : event.getNewValue()) { if (selectedRows.contains(row)) { current += "+"; } current += row.getRowIndex() + ", "; } addLogEntry(current, "green"); } }); // Paging specific options if (PagingScrollTableDemo.get() != null) { PagingScrollTable<Student> pagingScrollTable = PagingScrollTableDemo.get().getPagingScrollTable(); if (pagingScrollTable != null) { pagingScrollTable.addPageChangeHandler(new PageChangeHandler() { public void onPageChange(PageChangeEvent event) { pageLoadDuration = new Duration(); } }); pagingScrollTable.addPageLoadHandler(new PageLoadHandler() { public void onPageLoad(PageLoadEvent event) { // Convert to 1 based index int page = event.getPage() + 1; int duration = -1; if (pageLoadDuration != null) { duration = pageLoadDuration.elapsedMillis(); pageLoadDuration = null; } String text = "Page " + page + " loaded in " + duration + "ms"; addLogEntry(text, "black"); } }); } } return layout; }
From source file:com.qualogy.qafe.gwt.client.component.QPagingOptions.java
License:Apache License
/** * Constructor.// w ww. ja v a 2 s .co m * * @param table * the table being affected * @param images * the images to use */ public QPagingOptions(PagingScrollTable<?> table, PagingOptionsImages images) { this.table = table; if (this.table instanceof QPagingScrollTable) { ((QPagingScrollTable) this.table).setPagingOptions(this); } // Create the main widget HorizontalPanel hPanel = new HorizontalPanel(); initWidget(hPanel); hPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE); setStyleName(DEFAULT_STYLENAME); // Create the paging image buttons createPageButtons(images); // Create the current page box createCurPageBox(); // Create the page count label numPagesLabel = new HTML(); // Create the loading image loadingImage = new Image(GWT.getModuleBaseURL() + "scrollTableLoading.gif"); loadingImage.setVisible(false); // Create the error label errorLabel = new HTML(); errorLabel.setStylePrimaryName("errorMessage"); // Add the widgets to the panel hPanel.add(createSpacer()); hPanel.add(firstImage); hPanel.add(createSpacer()); hPanel.add(prevImage); hPanel.add(createSpacer()); hPanel.add(curPageBox); hPanel.add(createSpacer()); hPanel.add(numPagesLabel); hPanel.add(createSpacer()); hPanel.add(nextImage); hPanel.add(createSpacer()); hPanel.add(lastImage); hPanel.add(createSpacer()); hPanel.add(loadingImage); hPanel.add(errorLabel); // Add handlers to the table table.addPageLoadHandler(new PageLoadHandler() { public void onPageLoad(PageLoadEvent event) { loadingImage.setVisible(false); errorLabel.setHTML(""); } }); table.addPageChangeHandler(new PageChangeHandler() { public void onPageChange(PageChangeEvent event) { curPageBox.setText((event.getNewPage() + 1) + ""); loadingImage.setVisible(true); errorLabel.setHTML(""); } }); table.addPagingFailureHandler(new PagingFailureHandler() { public void onPagingFailure(PagingFailureEvent event) { loadingImage.setVisible(false); errorLabel.setHTML(event.getException().getMessage()); } }); table.addPageCountChangeHandler(new PageCountChangeHandler() { public void onPageCountChange(PageCountChangeEvent event) { setPageCount(event.getNewPageCount()); } }); setPageCount(table.getPageCount()); }
From source file:edu.caltech.ipac.firefly.ui.table.PagingPanel.java
License:Apache License
/** * Constructor./*www .ja v a 2 s . c o m*/ * * @param table the table being affected * @param images the images to use */ public PagingPanel(PagingScrollTable<?> table, PagingOptions.PagingOptionsImages images) { this.table = table; // Create the main widget HorizontalPanel hPanel = new HorizontalPanel(); initWidget(hPanel); hPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE); setStyleName(DEFAULT_STYLENAME); // Create the paging image buttons createPageButtons(images); // Create the current page box createCurPageBox(); // Create the page count label numPagesLabel = new HTML(); // Create the loading image loadingImage = new Image(GWT.getModuleBaseURL() + "scrollTableLoading.gif"); loadingImage.setVisible(false); // Create the error label errorLabel = new HTML(); errorLabel.setStylePrimaryName("errorMessage"); // display status status = new Label(); status.addStyleName("status"); status.setWordWrap(false); // Add the widgets to the panel hPanel.add(createSpacer()); hPanel.add(firstImage); hPanel.add(createSpacer()); hPanel.add(prevImage); hPanel.add(createSpacer()); hPanel.add(curPageBox); hPanel.add(createSpacer()); hPanel.add(numPagesLabel); hPanel.add(createSpacer()); hPanel.add(nextImage); hPanel.add(createSpacer()); hPanel.add(lastImage); hPanel.add(createSpacer()); hPanel.add(status); hPanel.add(createSpacer()); hPanel.add(loadingImage); hPanel.add(errorLabel); // Add handlers to the table table.addPageLoadHandler(new PageLoadHandler() { public void onPageLoad(PageLoadEvent event) { setIsLoading(false); } }); table.addPageChangeHandler(new PageChangeHandler() { public void onPageChange(PageChangeEvent event) { curPageBox.setText((event.getNewPage() + 1) + ""); setIsLoading(true); } }); table.addPagingFailureHandler(new PagingFailureHandler() { public void onPagingFailure(PagingFailureEvent event) { loadingImage.setVisible(false); errorLabel.setHTML(event.getException().getMessage()); } }); table.addPageCountChangeHandler(new PageCountChangeHandler() { public void onPageCountChange(PageCountChangeEvent event) { setPageCount(event.getNewPageCount()); } }); setPageCount(table.getPageCount()); }
From source file:edu.caltech.ipac.firefly.ui.table.PagingToolbar.java
public PagingToolbar(TablePanel table) { this.table = table; // Create the main widget mainPanel = new FlexTable(); initWidget(mainPanel);/*from w w w . j ava 2s. c o m*/ setStyleName(DEFAULT_STYLENAME); FlexTable.FlexCellFormatter formatter = mainPanel.getFlexCellFormatter(); // paging controls pagingBar = new PagingPanel(table.getTable(), new Images()); mainPanel.setWidget(0, 0, pagingBar); formatter.setVerticalAlignment(0, 0, HasVerticalAlignment.ALIGN_TOP); // formatter.setHorizontalAlignment(0, 0, HasHorizontalAlignment.ALIGN_LEFT); // display status addtlButtons = new HorizontalPanel(); mainPanel.setWidget(0, 1, addtlButtons); formatter.setVerticalAlignment(0, 1, HasVerticalAlignment.ALIGN_MIDDLE); // formatter.setHorizontalAlignment(0, 1, HasHorizontalAlignment.ALIGN_CENTER); // Add handlers to the table table.getTable().addPageLoadHandler(new PageLoadHandler() { public void onPageLoad(PageLoadEvent event) { PagingToolbar.this.onPageLoad(); // pageSize.setValue(PagingToolbar.this.table.getTable().getPageSize()+""); } }); table.getTable().addPageChangeHandler(new PageChangeHandler() { public void onPageChange(PageChangeEvent event) { PagingToolbar.this.onPageChange(); } }); table.getTable().addPagingFailureHandler(new PagingFailureHandler() { public void onPagingFailure(PagingFailureEvent event) { PagingToolbar.this.onPagingFailure(); } }); table.getTable().addPageCountChangeHandler(new PageCountChangeHandler() { public void onPageCountChange(PageCountChangeEvent event) { PagingToolbar.this.onPageCountChange(); } }); onPageLoad(); }
From source file:edu.caltech.ipac.firefly.ui.table.TablePanel.java
protected void addListeners() { WebEventListener handler = new WebEventListener() { public void eventNotify(WebEvent ev) { if (ev.getName().equals(ON_PAGE_LOAD)) { if (isActiveView(TableView.NAME)) { if (GwtUtil.isOnDisplay(table) && getTable().getDataTable().getRowCount() > 0) { if (getTable().getDataTable().isSelectionEnabled()) { getTable().getDataTable().selectRow(0, true); filters.reinit(); }//from w ww . j a va2 s . c o m } } } else if (ev.getName().equals(ON_SHOW)) { if (isActiveView(TableView.NAME)) { table.onShow(); filters.reinit(); if (table.getRowCount() > 0 && table.getDataTable().getSelectedRows().size() == 0) { Scheduler.get().scheduleDeferred(new Scheduler.ScheduledCommand() { public void execute() { table.getDataTable().selectRow(0, true); table.scrollHighlightedIntoView(); } }); } else { table.scrollHighlightedIntoView(); } } } } }; getEventManager().addListener(ON_PAGE_LOAD, handler); getEventManager().addListener(ON_SHOW, handler); getEventManager().addListener(ON_HIDE, handler); bindDataViewToTable(getDataset()); // listen to table's events table.addPageChangeHandler(new PageChangeHandler() { public void onPageChange(PageChangeEvent event) { mask("Loading...", maskDelayMillSec); if (!expanded) { getEventManager().fireEvent(new WebEvent(TablePanel.this, ON_PAGE_CHANGE)); } } }); table.addPageCountChangeHandler(new PageCountChangeHandler() { public void onPageCountChange(PageCountChangeEvent event) { updateTableStatus(); if (!expanded) { getEventManager().fireEvent(new WebEvent(TablePanel.this, ON_PAGECOUNT_CHANGE)); } } }); table.addPageLoadHandler(new PageLoadHandler() { public void onPageLoad(PageLoadEvent event) { unmask(); updateHasAccessRows(); if (!expanded && handleEvent) { getEventManager().fireEvent(new WebEvent(TablePanel.this, ON_PAGE_LOAD)); } } }); table.addPagingFailureHandler(new PagingFailureHandler() { public void onPagingFailure(PagingFailureEvent event) { unmask(); if (!expanded) { getEventManager().fireEvent(new WebEvent(TablePanel.this, ON_PAGE_ERROR)); } } }); table.getDataTable().addRowSelectionHandler(new RowSelectionHandler() { public void onRowSelection(RowSelectionEvent event) { if (!expanded && (GwtUtil.isOnDisplay(TablePanel.this) && handleEvent)) { Scheduler.get().scheduleDeferred(new Scheduler.ScheduledCommand() { public void execute() { getEventManager().fireEvent(new WebEvent(TablePanel.this, ON_ROWHIGHLIGHT_CHANGE)); } }); } } }); }
From source file:org.apache.hupa.widgets.ui.PagingOptions.java
License:Apache License
public PagingOptions(final PagingScrollTable<?> table, PagingOptionsConstants constants, Loading loading) { this.loading = loading; firstLink = new EnableHyperlink("<< " + constants.pageFirst(), ""); prevLink = new EnableHyperlink("< " + constants.pagePrev(), ""); lastLink = new EnableHyperlink(constants.pageLast() + " >>", ""); nextLink = new EnableHyperlink(constants.pageNext() + " >", ""); pagingPanel.setSpacing(3);/* w ww. ja va 2s . c o m*/ pagingPanel.add(panel); pagingPanel.add(firstLink); pagingPanel.add(prevLink); pagingPanel.add(nextLink); pagingPanel.add(lastLink); panel.setWidget(text); panel.setWidth("100px"); pagingPanel.setCellHorizontalAlignment(panel, HorizontalPanel.ALIGN_CENTER); firstLink.setEnabled(false); prevLink.setEnabled(false); lastLink.setEnabled(false); nextLink.setEnabled(false); table.addPageCountChangeHandler(new PageCountChangeHandler() { public void onPageCountChange(PageCountChangeEvent event) { int startCount = currentPage * table.getPageSize() + 1; int endCount = currentPage * table.getPageSize() + table.getPageSize(); int rows = table.getTableModel().getRowCount(); updateControl(startCount, endCount, rows); } }); table.addPageChangeHandler(new PageChangeHandler() { public void onPageChange(PageChangeEvent event) { loading(true); currentPage = event.getNewPage(); int startCount = currentPage * table.getPageSize() + 1; int endCount = currentPage * table.getPageSize() + table.getPageSize(); int rows = table.getTableModel().getRowCount(); updateControl(startCount, endCount, rows); } }); table.addPageLoadHandler(new PageLoadHandler() { public void onPageLoad(PageLoadEvent event) { loading(false); } }); table.addPagingFailureHandler(new PagingFailureHandler() { public void onPagingFailure(PagingFailureEvent event) { loading(false); } }); firstLink.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { table.gotoFirstPage(); } }); prevLink.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { table.gotoPreviousPage(); } }); nextLink.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { table.gotoNextPage(); } }); lastLink.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { table.gotoLastPage(); } }); table.getTableModel().addRowCountChangeHandler(new RowCountChangeHandler() { public void onRowCountChange(RowCountChangeEvent event) { int startCount = currentPage * table.getPageSize() + 1; int endCount = currentPage * table.getPageSize() + table.getPageSize(); int rows = event.getNewRowCount(); updateControl(startCount, endCount, rows); } }); initWidget(pagingPanel); }
From source file:sk.seges.acris.widget.client.table.PagingOptions.java
License:Apache License
/** * Constructor.//from w w w . j a v a 2 s . c o m * * @param table * the table being affected * @param resources * the images to use */ public PagingOptions(PagingScrollTable<?> table, PagingOptionsResources resources, boolean pageCountAvailable) { this.table = table; this.resources = resources; Css css = resources.getStyle().css(); // if (Gen2CssInjector.isInjectionEnabled()) { // Gen2CssInjector.inject(css); // } // Create the main widget HorizontalPanel pagingPanel = new HorizontalPanel(); initWidget(pagingPanel); pagingPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE); pagingPanel.setWidth("100%"); setStyleName(resources.getStyle().css().defaultStyleName()); // Create the paging image buttons createPageButtons(); if (pageCountAvailable) { // Create the current page box createCurrentPageBox(); pageSlider.setStepSize(1.0); // pageSlider.addStyleName("acris-PagingOptions-pageSlider"); pageSlider.setWidth("120px"); pageSlider.setMaxValue(getPageCount()); pageSlider.addValueChangeHandler(new ValueChangeHandler<Double>() { private Timer timer; @Override public void onValueChange(ValueChangeEvent<Double> event) { final int currentPage = (int) pageSlider.getCurrentValue(); pageSlider.setTitle( PagingOptions.this.resources.getMessages().currentOfPages(currentPage, getPageCount())); if (timer != null) { timer.cancel(); } timer = new Timer() { public void run() { PagingOptions.this.table.gotoPage(currentPage - 1, false); } }; timer.schedule(250); } }); } // Create the loading image loadingImage = new Image("acris-images/scrollTableLoading.gif"); loadingImage.setVisible(false); // Create the error label errorLabel = new HTML(); errorLabel.setStylePrimaryName("errorMessage"); buttonPanel = new HorizontalPanel(); buttonPanel.setSpacing(3); buttonPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE); buttonPanel.add(firstPageButton); buttonPanel.add(previousPageButton); currentPageBox.addStyleName("acris-bean-table-currentPageBox"); if (pageCountAvailable) { buttonPanel.add(pageSlider); buttonPanel.add(currentPageBox); } buttonPanel.add(nextPageButton); if (pageCountAvailable) { buttonPanel.add(lastPageButton); } buttonPanel.add(loadingImage); pagingPanel.add(buttonPanel); // Add the widgets to the panel pagingPanel.add(errorLabel); // Add handlers to the table table.addPageLoadHandler(new PageLoadHandler() { public void onPageLoad(PageLoadEvent event) { loadingImage.setVisible(false); errorLabel.setHTML(""); updateButtonState(); } }); table.addPageChangeHandler(new PageChangeHandler() { public void onPageChange(PageChangeEvent event) { currentPageBox.setText((event.getNewPage() + 1) + ""); loadingImage.setVisible(true); errorLabel.setHTML(""); } }); table.addPagingFailureHandler(new PagingFailureHandler() { public void onPagingFailure(PagingFailureEvent event) { loadingImage.setVisible(false); errorLabel.setHTML(event.getException().getMessage()); } }); table.addPageCountChangeHandler(new PageCountChangeHandler() { public void onPageCountChange(PageCountChangeEvent event) { setPageCount(event.getNewPageCount()); updateButtonState(); } }); setPageCount(table.getPageCount()); }