Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Copyright 2011 JBoss Inc
   * 
   * Licensed under the Apache License, Version 2.0 (the "License"); you may not
   * use this file except in compliance with the License. You may obtain a copy of
   * the License at
   * 
   * http://www.apache.org/licenses/LICENSE-2.0
   * 
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  * License for the specific language governing permissions and limitations under
  * the License.
  */
 
 package org.drools.guvnor.client.widgets.tables;
 
 import java.util.List;
 
 
A composite Widget that shows rows of data (not-paged) and a "column picker" to allow columns to be hidden from view. Columns can also be sorted.
 
 public abstract class AbstractSimpleTable<T extends AbstractPageRowextends Composite
     implements
     HasData<T> {
 
     // Usual suspects
     protected static final ConstantsCore constants = GWT.createConstantsCore.class );
 
     @UiField(provided = true)
     public ToggleButton           columnPickerButton;
 
     @UiField(provided = true)
     public CellTable<T>           cellTable;
 
     public AbstractSimpleTable() {
         doCellTable();
         initWidgetmakeWidget() );
     }

    
Refresh table programmatically
 
     public void refresh() {
                                                true );
     }

    
Override to add additional columns to the table

Parameters:
columnPicker
sortableHeaderGroup
 
     protected abstract void addAncillaryColumns(ColumnPicker<T> columnPicker,
                                                 SortableHeaderGroup<T> sortableHeaderGroup);

    
Set up table with zero columns. Additional columns can be appended by overriding addAncillaryColumns()
 
     protected void doCellTable() {
 
          = new CellTable<T>();
 
         ColumnPicker<T> columnPicker = new ColumnPicker<T>(  );
         SortableHeaderGroup<T> sortableHeaderGroup = new SortableHeaderGroup<T>(  );
 
         // Add any additional columns
         addAncillaryColumnscolumnPicker,
                              sortableHeaderGroup );
 
         .setWidth"100%" );
          = columnPicker.createToggleButton();
     }

    
Instantiate the Widget for this Composite

Returns:
    protected abstract Widget makeWidget();
    public HandlerRegistration addCellPreviewHandler(Handler<T> handler) {
        return .addCellPreviewHandlerhandler );
    }
        return .addRangeChangeHandlerhandler );
    }
        return .addRowCountChangeHandlerhandler );
    }
    public int getRowCount() {
        return .getRowCount();
    }
    public Range getVisibleRange() {
        return .getVisibleRange();
    }
    public boolean isRowCountExact() {
        return .isRowCountExact();
    }
    public void setRowCount(int count) {
        .setRowCountcount );
    }
    public void setRowCount(int count,
                            boolean isExact) {
        .setRowCountcount,
                               isExact );
    }
    public void setVisibleRange(int start,
                                int length) {
        .setVisibleRangestart,
                                   length );
    }
    public void setVisibleRange(Range range) {
        .setVisibleRangerange );
    }
    public SelectionModel< ? super T> getSelectionModel() {
        return .getSelectionModel();
    }
    public T getVisibleItem(int indexOnPage) {
        return .getVisibleItemindexOnPage );
    }
    public int getVisibleItemCount() {
        return .getVisibleItemCount();
    }
    public Iterable<T> getVisibleItems() {
        return .getVisibleItems();
    }
    public void setRowData(int start,
                           List< ? extends T> values) {
        .setRowDatastart,
                              values );
    }
    public void setSelectionModel(SelectionModel< ? super T> selectionModel) {
        .setSelectionModelselectionModel );
    }
    public void setVisibleRangeAndClearData(Range range,
                                            boolean forceRangeChangeEvent) {
        .setVisibleRangeAndClearDatarange,
                                               forceRangeChangeEvent );
    }

    
Convenience method to allow data to easily set

Parameters:
values
    public void setRowData(List< ? extends T> values) {
        setRowCountvalues.size() );
        setVisibleRange( 0,
                         values.size() );
        setRowData( 0,
                    values );
    }
New to GrepCode? Check out our FAQ X