Example usage for com.google.gwt.user.cellview.client DataGrid DataGrid

List of usage examples for com.google.gwt.user.cellview.client DataGrid DataGrid

Introduction

In this page you can find the example usage for com.google.gwt.user.cellview.client DataGrid DataGrid.

Prototype

public DataGrid(int pageSize, Resources resources) 

Source Link

Document

Constructs a table with the given page size with the specified Resources .

Usage

From source file:cimav.client.view.nomina.HorasExtrasUI.java

private void buildGrid() {

    List<HoraExtra> list = new ArrayList<>();
    provider = new ListDataProvider<>(list);

    ICustomDataGridResource dataGridResource = GWT.create(ICustomDataGridResource.class);
    dataGridResource.dataGridStyle().ensureInjected();

    dataGrid = new DataGrid<>(60, dataGridResource);

    //dataGrid = new DataGrid<>(provider.getKeyProvider());
    dataGrid.getElement().setId("idDataGrid");

    dataGrid.setAutoHeaderRefreshDisabled(true);

    dataGrid.setEmptyTableWidget(new Label("Sin Horas Extras"));

    dataGrid.setPageSize(20);// w w  w  . ja v  a2  s. c  o m

    diaCell = new DatePickerCell(DateTimeFormat.getFormat(DateTimeFormat.PredefinedFormat.DATE_MEDIUM));
    horasCell = new NomCantidadInputCell();

    initTableColumns();

    // Add the CellList to the adapter in the database.
    provider.addDataDisplay(dataGrid);

    dataGrid.addRowHoverHandler(new RowHoverEvent.Handler() {
        @Override
        public void onRowHover(RowHoverEvent event) {
            TableRowElement rowEle = event.getHoveringRow();
            Element removeHoraExtraEle = rowEle.getElementsByTagName("a").getItem(0);
            if (event.isUnHover()) {
                GQuery.$(removeHoraExtraEle).css(CSS.VISIBILITY.with(Style.Visibility.HIDDEN));
            } else {
                GQuery.$(removeHoraExtraEle).css(CSS.VISIBILITY.with(Style.Visibility.VISIBLE));
            }
        }
    });

}

From source file:cimav.client.view.nomina.NominaFaltasUI.java

private void buildGrid() {

    List<Incidencia> list = new ArrayList<>();
    provider = new ListDataProvider<>(list);

    ICustomDataGridResource dataGridResource = GWT.create(ICustomDataGridResource.class);
    dataGridResource.dataGridStyle().ensureInjected();

    dataGrid = new DataGrid<>(60, dataGridResource);

    //dataGrid = new DataGrid<>(provider.getKeyProvider());
    dataGrid.getElement().setId("idDataGrid");

    dataGrid.setAutoHeaderRefreshDisabled(true);

    dataGrid.setEmptyTableWidget(new Label("Sin incidencias"));

    dataGrid.setPageSize(20);/*from  w  w  w. j  a  v a2 s  . c om*/

    fechaInicioCell = new DatePickerCell(DateTimeFormat.getFormat(PredefinedFormat.DATE_MEDIUM));
    diasCell = new NomIntegerInputCell("80");
    folioCell = new NomTextInputCell();

    initTableColumns();

    //        // Add the CellList to the adapter in the database.
    provider.addDataDisplay(dataGrid);

    dataGrid.addRowHoverHandler(new RowHoverEvent.Handler() {
        @Override
        public void onRowHover(RowHoverEvent event) {
            TableRowElement rowEle = event.getHoveringRow();
            Element removeFaltaEle = rowEle.getElementsByTagName("a").getItem(0);
            if (event.isUnHover()) {
                GQuery.$(removeFaltaEle).css(CSS.VISIBILITY.with(Style.Visibility.HIDDEN));
            } else {
                GQuery.$(removeFaltaEle).css(CSS.VISIBILITY.with(Style.Visibility.VISIBLE));
            }
        }
    });

}

From source file:cimav.client.view.nomina.NominaMovimientosUI.java

private void buildGrid() {

    List<Movimiento> nominaQuincenalList = new ArrayList<>();
    provider = new ListDataProvider<>(nominaQuincenalList);

    ICustomDataGridResource dataGridResource = GWT.create(ICustomDataGridResource.class);
    dataGridResource.dataGridStyle().ensureInjected();

    dataGrid = new DataGrid<>(60, dataGridResource);

    dataGrid.setAutoHeaderRefreshDisabled(true);

    dataGrid.setEmptyTableWidget(new Label("Sin movimientos de momento"));

    dataGrid.setPageSize(20);/*from   ww w.  j av  a2 s  . c  o m*/
    dataGrid.setMinimumTableWidth(400, Style.Unit.PX);

    initTableColumns();

    provider.addDataDisplay(dataGrid);

}

From source file:cimav.client.view.nomina.NominaRepercucionesUI.java

private void buildGrid() {

    List<Movimiento> nominaQuincenalList = new ArrayList<>();
    provider = new ListDataProvider<>(nominaQuincenalList);

    ICustomDataGridResource dataGridResource = GWT.create(ICustomDataGridResource.class);
    dataGridResource.dataGridStyle().ensureInjected();

    dataGrid = new DataGrid<>(60, dataGridResource);

    dataGrid.setAutoHeaderRefreshDisabled(true);

    dataGrid.setEmptyTableWidget(new Label("Sin repercuciones de momento"));

    dataGrid.setPageSize(20);//from w w  w.  ja va  2s .c om
    dataGrid.setMinimumTableWidth(400, Style.Unit.PX);

    initTableColumns();

    provider.addDataDisplay(dataGrid);

}

From source file:cimav.client.view.nomina.NominaSaldoUI.java

private void buildGrid() {

    List<Movimiento> nominaQuincenalList = new ArrayList<>();
    provider = new ListDataProvider<>(nominaQuincenalList);

    ICustomDataGridResource dataGridResource = GWT.create(ICustomDataGridResource.class);
    dataGridResource.dataGridStyle().ensureInjected();

    dataGrid = new DataGrid<>(60, dataGridResource);

    //dataGrid = new DataGrid<>(provider.getKeyProvider());

    dataGrid.getElement().setId("idDataGrid");

    dataGrid.setAutoHeaderRefreshDisabled(true);

    dataGrid.setEmptyTableWidget(new Label("Sin movimientos"));

    dataGrid.setPageSize(20);//  ww  w  . j  ava 2 s .  c om

    quincenasCell = new NomIntegerInputCell("24");
    saldoCell = new NomCantidadInputCell();
    permanenteCell = new CheckboxCell();

    initTableColumns();

    // Add the CellList to the adapter in the database.
    provider.addDataDisplay(dataGrid);

    dataGrid.addRowHoverHandler(new RowHoverEvent.Handler() {
        @Override
        public void onRowHover(RowHoverEvent event) {
            TableRowElement rowEle = event.getHoveringRow();
            Element removeSaldoEle = rowEle.getElementsByTagName("a").getItem(0);
            if (event.isUnHover()) {
                GQuery.$(removeSaldoEle).css(CSS.VISIBILITY.with(Style.Visibility.HIDDEN));
            } else {
                GQuery.$(removeSaldoEle).css(CSS.VISIBILITY.with(Style.Visibility.VISIBLE));
            }
        }
    });

}

From source file:com.goodow.web.dev.client.ui.TreeNodeListView.java

License:Apache License

@Inject
TreeNodeListView(final TreeNodeFactory f, final SingleSelectionModel<TreeNodeProxy> selectionModel,
        final PlaceController placeController, final Provider<BasePlace> place,
        final TreeNodeDataProvider dtatProvider) {
    this.placeController = placeController;
    this.place = place;
    this.dtatProvider = dtatProvider;
    this.f = f;// w w  w.  ja v  a  2  s .  com

    grid = new DataGrid<TreeNodeProxy>(NUM_ROWS, GWT.<TableResources>create(TableResources.class));

    grid.setSelectionModel(selectionModel);
    grid.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.DISABLED);

    PathCol pathCol = new PathCol();
    // ?????
    pathCol.setName("path");
    pathCol.setSortable(true);
    grid.addColumn(pathCol, "Path");
    grid.setColumnWidth(pathCol, "40ex");

    NameCol nameCol = new NameCol();
    nameCol.setName("name");
    nameCol.setSortable(true);
    grid.addColumn(nameCol, "Name");
    grid.setColumnWidth(nameCol, "25ex");

    grid.addColumnSortHandler(new ColumnSortEvent.AsyncHandler(grid));
    grid.setRowCount(NUM_ROWS, false);
    dtatProvider.addDataDisplay(grid);
    pager.setDisplay(grid);
    selectionModel.addSelectionChangeHandler(new SelectionChangeEvent.Handler() {
        @Override
        public void onSelectionChange(final SelectionChangeEvent event) {
            TreeNodeProxy proxy = selectionModel.getSelectedObject();
            BasePlace newPlace = place.get().setParameter(state.getName(), f.getHistoryToken(proxy.stableId()));
            placeController.goTo(newPlace);
        }
    });
    initWidget(binder.createAndBindUi(this));
}

From source file:com.google.gwt.sample.dynatablemvp.client.widgets.SummaryWidget.java

License:Apache License

@UiConstructor
public SummaryWidget() {
    pager = new SimplePager(SimplePager.TextLocation.CENTER);
    table = new DataGrid<PersonProxy>(0, GWT.<TableResources>create(TableResources.class));
    initWidget(GWT.<Binder>create(Binder.class).createAndBindUi(this));

    Column<PersonProxy, String> nameColumn = new NameColumn();
    table.addColumn(nameColumn, "Name");
    table.setColumnWidth(nameColumn, "25ex");
    Column<PersonProxy, String> descriptionColumn = new DescriptionColumn();
    table.addColumn(descriptionColumn, "Description");
    table.setColumnWidth(descriptionColumn, "40ex");
    table.addColumn(new ScheduleColumn(), "Schedule");
    table.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.DISABLED);

    table.setRowStyles(new RowStyles<PersonProxy>() {
        @Override//from w  w w  .  j a v a 2  s .  co  m
        public String getStyleNames(PersonProxy row, int rowIndex) {
            if (selectedItem != null) {
                if (row.getId() == selectedItem) {
                    previousSelected = rowIndex;
                    selectedItem = -1;
                    return "selectedLine";
                }
            }
            return null;
        }

    });
}

From source file:com.google.gwt.sample.dynatablerf.client.widgets.SummaryWidget.java

License:Apache License

public SummaryWidget(EventBus eventBus, DynaTableRequestFactory requestFactory, int numRows) {
    this.eventBus = eventBus;
    this.requestFactory = requestFactory;
    this.numRows = numRows;

    table = new DataGrid<PersonProxy>(numRows, GWT.<TableResources>create(TableResources.class));
    initWidget(GWT.<Binder>create(Binder.class).createAndBindUi(this));

    Column<PersonProxy, String> nameColumn = new NameColumn();
    table.addColumn(nameColumn, "Name");
    table.setColumnWidth(nameColumn, "25ex");
    Column<PersonProxy, String> descriptionColumn = new DescriptionColumn();
    table.addColumn(descriptionColumn, "Description");
    table.setColumnWidth(descriptionColumn, "40ex");
    table.addColumn(new ScheduleColumn(), "Schedule");
    table.setRowCount(numRows, false);/*from w w  w .  j av a2 s  .c om*/
    table.setSelectionModel(selectionModel);
    table.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.DISABLED);

    EntityProxyChange.registerForProxyType(eventBus, PersonProxy.class,
            new EntityProxyChange.Handler<PersonProxy>() {
                @Override
                public void onProxyChange(EntityProxyChange<PersonProxy> event) {
                    SummaryWidget.this.onPersonChanged(event);
                }
            });

    FilterChangeEvent.register(eventBus, new FilterChangeEvent.Handler() {
        @Override
        public void onFilterChanged(FilterChangeEvent e) {
            filter.set(e.getDay(), e.isSelected());
            if (!pending) {
                pending = true;
                Scheduler.get().scheduleFinally(new ScheduledCommand() {
                    @Override
                    public void execute() {
                        pending = false;
                        fetch(0);
                    }
                });
            }
        }
    });

    selectionModel.addSelectionChangeHandler(new SelectionChangeEvent.Handler() {
        @Override
        public void onSelectionChange(SelectionChangeEvent event) {
            SummaryWidget.this.refreshSelection();
        }
    });

    fetch(0);
}

From source file:com.google.gwt.sample.showcase.client.content.cell.CwCellSampler.java

License:Apache License

/**
 * Initialize this example.//from   w ww  .ja v a 2s.c  om
 */
@ShowcaseSource
@Override
public Widget onInitialize() {
    Images images = GWT.create(Images.class);

    // Create the table.
    editableCells = new ArrayList<AbstractEditableCell<?, ?>>();
    contactList = new DataGrid<ContactInfo>(25, ContactInfo.KEY_PROVIDER);
    contactList.setMinimumTableWidth(140, Unit.EM);
    ContactDatabase.get().addDataDisplay(contactList);

    // CheckboxCell.
    final Category[] categories = ContactDatabase.get().queryCategories();
    addColumn(new CheckboxCell(), "Checkbox", new GetValue<Boolean>() {
        @Override
        public Boolean getValue(ContactInfo contact) {
            // Checkbox indicates that the contact is a relative.
            // Index 0 = Family.
            return contact.getCategory() == categories[0];
        }
    }, new FieldUpdater<ContactInfo, Boolean>() {
        @Override
        public void update(int index, ContactInfo object, Boolean value) {
            if (value) {
                // If a relative, use the Family Category.
                pendingChanges.add(new CategoryChange(object, categories[0]));
            } else {
                // If not a relative, use the Contacts Category.
                pendingChanges.add(new CategoryChange(object, categories[categories.length - 1]));
            }
        }
    });

    // TextCell.
    addColumn(new TextCell(), "Text", new GetValue<String>() {
        @Override
        public String getValue(ContactInfo contact) {
            return contact.getFullName();
        }
    }, null);

    // EditTextCell.
    Column<ContactInfo, String> editTextColumn = addColumn(new EditTextCell(), "EditText",
            new GetValue<String>() {
                @Override
                public String getValue(ContactInfo contact) {
                    return contact.getFirstName();
                }
            }, new FieldUpdater<ContactInfo, String>() {
                @Override
                public void update(int index, ContactInfo object, String value) {
                    pendingChanges.add(new FirstNameChange(object, value));
                }
            });
    contactList.setColumnWidth(editTextColumn, 16.0, Unit.EM);

    // TextInputCell.
    Column<ContactInfo, String> textInputColumn = addColumn(new TextInputCell(), "TextInput",
            new GetValue<String>() {
                @Override
                public String getValue(ContactInfo contact) {
                    return contact.getLastName();
                }
            }, new FieldUpdater<ContactInfo, String>() {
                @Override
                public void update(int index, ContactInfo object, String value) {
                    pendingChanges.add(new LastNameChange(object, value));
                }
            });
    contactList.setColumnWidth(textInputColumn, 16.0, Unit.EM);

    // ClickableTextCell.
    addColumn(new ClickableTextCell(), "ClickableText", new GetValue<String>() {
        @Override
        public String getValue(ContactInfo contact) {
            return "Click " + contact.getFirstName();
        }
    }, new FieldUpdater<ContactInfo, String>() {
        @Override
        public void update(int index, ContactInfo object, String value) {
            Window.alert("You clicked " + object.getFullName());
        }
    });

    // ActionCell.
    addColumn(new ActionCell<ContactInfo>("Click Me", new ActionCell.Delegate<ContactInfo>() {
        @Override
        public void execute(ContactInfo contact) {
            Window.alert("You clicked " + contact.getFullName());
        }
    }), "Action", new GetValue<ContactInfo>() {
        @Override
        public ContactInfo getValue(ContactInfo contact) {
            return contact;
        }
    }, null);

    // ButtonCell.
    addColumn(new ButtonCell(), "Button", new GetValue<String>() {
        @Override
        public String getValue(ContactInfo contact) {
            return "Click " + contact.getFirstName();
        }
    }, new FieldUpdater<ContactInfo, String>() {
        @Override
        public void update(int index, ContactInfo object, String value) {
            Window.alert("You clicked " + object.getFullName());
        }
    });

    // DateCell.
    DateTimeFormat dateFormat = DateTimeFormat.getFormat(PredefinedFormat.DATE_MEDIUM);
    addColumn(new DateCell(dateFormat), "Date", new GetValue<Date>() {
        @Override
        public Date getValue(ContactInfo contact) {
            return contact.getBirthday();
        }
    }, null);

    // DatePickerCell.
    addColumn(new DatePickerCell(dateFormat), "DatePicker", new GetValue<Date>() {
        @Override
        public Date getValue(ContactInfo contact) {
            return contact.getBirthday();
        }
    }, new FieldUpdater<ContactInfo, Date>() {
        @Override
        public void update(int index, ContactInfo object, Date value) {
            pendingChanges.add(new BirthdayChange(object, value));
        }
    });

    // NumberCell.
    Column<ContactInfo, Number> numberColumn = addColumn(new NumberCell(), "Number", new GetValue<Number>() {
        @Override
        public Number getValue(ContactInfo contact) {
            return contact.getAge();
        }
    }, null);
    numberColumn.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LOCALE_END);

    // IconCellDecorator.
    addColumn(new IconCellDecorator<String>(images.contactsGroup(), new TextCell()), "Icon",
            new GetValue<String>() {
                @Override
                public String getValue(ContactInfo contact) {
                    return contact.getCategory().getDisplayName();
                }
            }, null);

    // ImageCell.
    addColumn(new ImageCell(), "Image", new GetValue<String>() {
        @Override
        public String getValue(ContactInfo contact) {
            return "contact.jpg";
        }
    }, null);

    // SelectionCell.
    List<String> options = new ArrayList<String>();
    for (Category category : categories) {
        options.add(category.getDisplayName());
    }
    addColumn(new SelectionCell(options), "Selection", new GetValue<String>() {
        @Override
        public String getValue(ContactInfo contact) {
            return contact.getCategory().getDisplayName();
        }
    }, new FieldUpdater<ContactInfo, String>() {
        @Override
        public void update(int index, ContactInfo object, String value) {
            for (Category category : categories) {
                if (category.getDisplayName().equals(value)) {
                    pendingChanges.add(new CategoryChange(object, category));
                    break;
                }
            }
        }
    });

    // Create the UiBinder.
    Binder uiBinder = GWT.create(Binder.class);
    Widget widget = uiBinder.createAndBindUi(this);

    // Add handlers to redraw or refresh the table.
    redrawButton.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            contactList.redraw();
        }
    });
    commitButton.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            // Commit the changes.
            for (PendingChange<?> pendingChange : pendingChanges) {
                pendingChange.commit();
            }
            pendingChanges.clear();

            // Push the changes to the views.
            ContactDatabase.get().refreshDisplays();
        }
    });

    return widget;
}

From source file:com.vividcode.imap.app.client.web.application.admin.users.UsersView.java

License:Apache License

@Inject
UsersView(Binder uiBinder, DataGridStyle dataGridStyle, ListDataProvider<UserVO> dataProvider) {
    this.dataProvider = dataProvider;
    this.userDataGrid = new DataGrid<UserVO>(GlobalParameters.PAGE_SIZE, dataGridStyle);
    this.selectionModel = new SingleSelectionModel<UserVO>();

    userDataGrid.setSelectionModel(selectionModel);
    selectionModel.addSelectionChangeHandler(new SelectionChangeEvent.Handler() {
        @Override/*from  www.j av  a  2s . co  m*/
        public void onSelectionChange(SelectionChangeEvent event) {
            update.setEnabled(true);
            remove.setEnabled(true);
        }
    });

    initWidget(uiBinder.createAndBindUi(this));
    dataProvider.addDataDisplay(userDataGrid);
    initColumns();
}