List of usage examples for com.google.gwt.user.client.ui TableListener TableListener
TableListener
From source file:cc.alcina.framework.gwt.client.gwittir.widget.BoundTableExt.java
License:Open Source License
private void createTable() { String oldStyleNames = ""; if (this.table != null) { oldStyleNames = this.table.getStyleName(); }/*from w w w . ja v a 2s . c o m*/ this.table = createTableImpl(); if ((this.masks & BoundTableExt.SELECT_ROW_MASK) > 0) { this.table.addClickHandler(rowSelectHandler); } this.table.setCellPadding(0); this.table.setCellSpacing(0); table.addTableListener(new TableListener() { public void onCellClicked(SourcesTableEvents sender, int row, int cell) { setActive(true); int startColumn = ((masks & BoundTableExt.ROW_HANDLE_MASK) > 0) ? 1 : 0; if (startColumn == 0) { handleSelect(true, row, cell); } if (((masks & BoundTableExt.SORT_MASK) > 0) && ((masks & BoundTableExt.HEADER_MASK) > 0) && (row == 0) && !(BoundTableExt.this.value == null || BoundTableExt.this.value.isEmpty())) { sortColumn(cell - startColumn); } } }); this.base = this.table; this.setStyleName("gwittir-BoundTable", true); if (Ax.notBlank(oldStyleNames)) { this.setStyleName(oldStyleNames); } if (++setCounter == 5) { // should be number 5 in seq int debug = 3; } esp.setWidget(this.table); }
From source file:cc.kune.colorpicker.client.ColorWebSafePalettePanel.java
License:GNU Affero Public License
/** * Creates the palette./*from w w w . java 2 s . co m*/ */ private void createPalette() { paletteGrid = new Grid(ROWS, COLS); paletteGrid.setCellSpacing(1); // Put color values in the grid cells int row; int col; int n = 0; for (int a = 0; a < COLORS.length; a++) { for (int b = 0; b < COLORS.length; b++) { for (int c = 0; c < COLORS.length; c++) { row = n / COLS; col = n % COLS; final String currentColor = "#" + COLORS[c] + COLORS[a] + COLORS[b]; paletteGrid.setText(row, col, " "); DOM.setStyleAttribute(paletteGrid.getCellFormatter().getElement(row, col), "backgroundColor", currentColor); n++; } } } paletteGrid.addStyleName("kune-WebSafePalette"); paletteGrid.addTableListener(new TableListener() { @Override public void onCellClicked(final SourcesTableEvents sender, final int row, final int col) { presenter.onColorSelected(row, col); } }); }
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 . j a v a 2s .c o m*/ 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.totsp.gwittir.client.ui.calendar.Calendar.java
License:Open Source License
/** Creates a new instance of Calendar */ public Calendar() { this.value = this.renderDate; for (int i = 0; i < 7; i++) { grid.setWidget(0, i, new Label(Calendar.DAYS_OF_WEEK_SHORT[i])); grid.getCellFormatter().setStyleName(0, i, "day"); }//from www. ja va 2 s. c o m grid.setCellSpacing(0); grid.setCellPadding(0); super.initWidget(grid); final Calendar instance = this; this.grid.addTableListener(new TableListener() { public void onCellClicked(SourcesTableEvents sender, int row, int cell) { boolean cancelled = false; for (Iterator it = new ArrayList(eventListeners).iterator(); it.hasNext();) { if (!((CalendarListener) it.next()).onDateClicked(instance, currentDates[row - 1][cell])) { cancelled = true; break; } } if (!cancelled && (currentDates[row - 1][cell].getMonth() == getRenderDate().getMonth())) { setValue(currentDates[row - 1][cell]); } } }); this.setStyleName("gwittir-Calendar"); }
From source file:com.totsp.gwittir.client.ui.table.BoundTable.java
License:Open Source License
private void init(int masksValue) { //GWT.log( "Init "+ +masksValue + " :: "+((masksValue & BoundTable.MULTI_REQUIRES_SHIFT) > 0), null); final BoundTable instance = this; this.topBinding = new Binding(); this.masks = masksValue; this.factory = (this.factory == null) ? new BoundWidgetTypeFactory(true) : this.factory; if (((this.masks & BoundTable.SORT_MASK) > 0) && (this.columns != null)) { this.ascending = new boolean[this.columns.length]; }//from w w w. j a v a 2 s . c om if ((this.masks & BoundTable.MULTIROWSELECT_MASK) > 0) { this.selectedRowStyles = new HashMap(); } if (((this.masks & BoundTable.ROW_HANDLE_MASK) > 0) && ((this.masks & BoundTable.MULTIROWSELECT_MASK) > 0)) { this.allRowsHandle = new Button(" ", new ClickListener() { public void onClick(Widget sender) { if ((getSelected() != null) && (getSelected().size() == 0)) { setSelected(new ArrayList((Collection) getValue())); } else { setSelected(new ArrayList()); } } }); this.allRowsHandle.setStyleName("rowHandle"); this.allRowsHandle.setHeight("100%"); this.allRowsHandle.setWidth("100%"); if ((this.masks & BoundTable.MULTIROWSELECT_MASK) == 0) { this.allRowsHandle.setEnabled(false); } } if ((this.masks & BoundTable.ROW_HANDLE_MASK) > 0) { this.rowHandles = new ArrayList(); } this.table = createTableImpl(); this.table.setCellPadding(0); this.table.setCellSpacing(0); EventingSimplePanel esp = new EventingSimplePanel(); esp.setWidget(table); if ((masks & BoundTable.SCROLL_MASK) > 0) { this.scroll = new ScrollPanel(); this.scroll.setWidget(table); super.initWidget(esp); scroll.addScrollListener(new ScrollListener() { public void onScroll(Widget widget, int scrollLeft, int scrollTop) { //GWT.log("HasProvider: " + (provider != null), null); if ((provider != null) && (inChunk == false) && (scrollTop >= (table.getOffsetHeight() - scroll.getOffsetHeight()))) { //GWT.log("Scroll Event fired. ", null); lastScrollPosition = scrollTop - 1; next(); } } }); } else { super.initWidget(esp); } this.table.setCellSpacing(0); table.addTableListener(new TableListener() { public void onCellClicked(SourcesTableEvents sender, int row, int cell) { setActive(true); int startColumn = ((masks & BoundTable.ROW_HANDLE_MASK) > 0) ? 1 : 0; if (startColumn == 0) { handleSelect(true, row, cell); } if (((masks & BoundTable.SORT_MASK) > 0) && ((masks & BoundTable.HEADER_MASK) > 0) && (row == 0)) { sortColumn(cell - startColumn); } } }); this.base = ((this.scroll == null) ? (Widget) this.table : (Widget) this.scroll); this.value = (this.value == null) ? new ArrayList() : this.value; this.columns = (this.columns == null) ? new Field[0] : this.columns; this.setStyleName("gwittir-BoundTable"); if ((this.provider != null) && (this.getCurrentChunk() == -1)) { this.provider.init(this); this.inChunk = true; } this.addPropertyChangeListener("selected", new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent propertyChangeEvent) { if (getAction() != null) { getAction().execute(instance); } } }); this.addPropertyChangeListener("active", new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent propertyChangeEvent) { boolean newActive = ((Boolean) propertyChangeEvent.getNewValue()).booleanValue(); if ((masks & BoundTable.ROW_HANDLE_MASK) > 0) { for (int i = 0; i < rowHandles.size(); i++) { ((Button) rowHandles.get(i)) .setText((newActive && (i <= 8)) ? Integer.toString(i + 1) : " "); } } for (Iterator it = keyBindings.entrySet().iterator(); it.hasNext();) { Entry entry = (Entry) it.next(); handleBinding(newActive, entry); } for (Iterator it = externalKeyBindings.entrySet().iterator(); it.hasNext();) { Entry entry = (Entry) it.next(); handleBinding(newActive, entry); } } private void handleBinding(boolean newActive, Entry entry) { KeyBinding kb = (KeyBinding) entry.getKey(); Object execute = entry.getValue(); if (newActive) { BoundTable.LOG.log(Level.SPAM, "Registering " + kb, null); try { if (execute instanceof Task) { KeyboardController.INSTANCE.register(kb, (Task) execute); } else if (execute instanceof Action) { KeyboardController.INSTANCE.register(kb, (Action) execute); } else if (execute instanceof BoundWidget) { KeyboardController.INSTANCE.register(kb, (BoundWidget) execute); } } catch (KeyBindingException kbe) { BoundTable.LOG.log(Level.DEBUG, "Unable to register" + kb, kbe); } } else { boolean result = KeyboardController.INSTANCE.unregister(kb); BoundTable.LOG.log(Level.SPAM, "Unregistering " + kb + " " + result, null); } } }); }
From source file:gwtBlocks.client.views.TableView.java
License:Apache License
private FlexTable newBodyTable() { FlexTable body = _bodyBuilder.newTable().getTable(); initBodyTable(_bodyBuilder);/* ww w .j a v a 2 s . co m*/ body.addTableListener(new TableListener() { public void onCellClicked(SourcesTableEvents sender, int row, int cell) { TableListener listener = _cellListeners == null ? null : _cellListeners.get(cell); if (listener == null) editCell(row, cell); else listener.onCellClicked(sender, row, cell); } }); return body; }
From source file:gwtBlocks.client.views.WidgetFactory.java
License:Apache License
public static Widget newIconTextButton(String imageName, String text, final ClickListener listener) { FlexTableBuilder builder = new FlexTableBuilder().styleT("gbk-iconTextButton").formLayout(); final FlexTable table = builder.getTable(); table.addTableListener(new TableListener() { public void onCellClicked(SourcesTableEvents sender, int row, int cell) { listener.onClick(table);// w ww. ja v a 2s .c om } }); builder.set(new Image(imageName)).set(text); return table; }
From source file:net.europa13.taikai.web.client.ui.PlayerContent.java
License:Open Source License
public PlayerContent(final String historyToken) { setTitle("Deltagare"); this.historyToken = historyToken; //********************************************************************* // Toolbar//from w w w . j a va 2 s . c o m btnNewPlayer = new Button("Ny deltagare...", new ClickListener() { public void onClick(Widget arg0) { History.newItem(historyToken + "/new"); } }); addControl(btnNewPlayer); btnImportPlayers = new Button("Importera...", new ClickListener() { public void onClick(Widget arg0) { History.newItem(historyToken + "/import"); } }); addControl(btnImportPlayers); //********************************************************************* // Table playerTable = new PlayerTable(); playerTable.setCaption("Deltagare"); playerTable.addTableListener(new TableListener() { public void onCellClicked(SourcesTableEvents sender, int row, int col) { if (row > 1) { PlayerProxy player = playerList.get(row - 2); History.newItem(historyToken + "/" + player.getId()); } } }); playerDetailsContent = new PlayerDetailsContent(); }
From source file:net.europa13.taikai.web.client.ui.TaikaiListContent.java
License:Open Source License
/** * Constructor./*from w w w. j av a 2 s . c o m*/ */ public TaikaiListContent(String historyToken) { setTitle("Evenemang"); this.historyToken = historyToken; panel = new SimplePanel(); createToolbar(); taikaiTable = new TaikaiTable(); taikaiTable.addTableListener(new TableListener() { public void onCellClicked(SourcesTableEvents sender, int row, int col) { TaikaiProxy taikai = taikaiList.get(row - 1); History.newItem(TaikaiListContent.this.historyToken + "/" + taikai.getId()); } }); // taikaiPanel = new TaikaiPanel(); taikaiDetailsContent = new TaikaiDetailsContent(); panel.setWidget(taikaiTable); }
From source file:net.europa13.taikai.web.client.ui.TaikaiTable.java
License:Open Source License
public TaikaiTable() { super(1, 4);/*from www.ja va2 s .c o m*/ setText(0, 0, "Id"); setText(0, 1, "Namn"); setText(0, 2, "Deltagare"); setText(0, 3, "Turneringar"); setStyleName("taikaiweb-Table"); getRowFormatter().setStyleName(0, "taikaiweb-TableHeader"); getCellFormatter().setStyleName(0, 3, "taikaiweb-TableLastColumn"); addTableListener(new TableListener() { public void onCellClicked(SourcesTableEvents sender, int row, int col) { selectRow(row); } }); }