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() 

Source Link

Document

Constructs a table with a default page size of 50.

Usage

From source file:com.google.gwt.sample.mobilewebapp.client.desktop.DesktopTaskListView.java

License:Apache License

/**
 * Construct a new {@link DesktopTaskListView}.
 *//*  w  w  w  .  j a v a  2s.  c  o m*/
public DesktopTaskListView() {

    // Create the CellTable.
    taskList = new DataGrid<TaskProxy>();
    taskList.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.DISABLED);
    taskList.setWidth("100%");

    // Add the task name column.
    Column<TaskProxy, String> nameColumn = new TextColumn<TaskProxy>() {
        @Override
        public String getValue(TaskProxy object) {
            return (object == null) ? null : object.getName();
        }
    };
    taskList.addColumn(nameColumn, "Task");

    // Add the task notes column.
    Column<TaskProxy, String> notesColumn = new TextColumn<TaskProxy>() {
        @Override
        public String getValue(TaskProxy object) {
            return (object == null) ? "" : object.getNotes();
        }
    };
    taskList.addColumn(notesColumn, "Description");

    // Add the task due date column.
    Column<TaskProxy, Date> dateColumn = new Column<TaskProxy, Date>(new DateCell()) {
        @Override
        public Date getValue(TaskProxy object) {
            return (object == null) ? null : object.getDueDate();
        }
    };
    taskList.addColumn(dateColumn, "Due Date");

    /*
     * Inform the presenter when the user selects a task from the task list.
     */
    final NoSelectionModel<TaskProxy> selectionModel = new NoSelectionModel<TaskProxy>();
    taskList.setSelectionModel(selectionModel);
    selectionModel.addSelectionChangeHandler(new SelectionChangeEvent.Handler() {
        @Override
        public void onSelectionChange(SelectionChangeEvent event) {
            // Edit the task.
            if (presenter != null) {
                presenter.selectTask(selectionModel.getLastSelectedObject());
            }
        }
    });

    // Initialize the widget.
    initWidget(taskList);
}

From source file:com.gwt2go.dev.client.ui.table.DataGridImpl1.java

License:Apache License

public DataGridImpl1() {

    // Create a CellTable.
    DataGrid<Contact> table = new DataGrid<Contact>();
    table.setWidth("100%");
    table.setHeight("100px");

    //      table.setRowStyles(new RowStyles<DataGridImpl1.Contact>() {         
    //         @Override
    //         public String getStyleNames(Contact row, int rowIndex) {
    //            return "headcol";
    //         }//from  w  w w  . ja va2  s . c o m
    //      });

    table.setEmptyTableWidget(new Label("No Information to show"));
    table.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.ENABLED);

    // Add a text column to show the name.
    TextColumn<Contact> nameColumn = new TextColumn<Contact>() {
        @Override
        public String getValue(Contact object) {
            return object.name;
        }
    };
    table.addColumn(nameColumn, "Name");

    // Add a date column to show the birthday.
    DateCell dateCell = new DateCell();
    Column<Contact, Date> dateColumn = new Column<Contact, Date>(dateCell) {
        @Override
        public Date getValue(Contact object) {
            return object.birthday;
        }
    };

    table.addColumn(dateColumn, "Birthday");

    // Add a text column to show the address.
    TextColumn<Contact> addressColumn = new TextColumn<Contact>() {
        @Override
        public String getValue(Contact object) {
            return object.address;
        }
    };
    table.addColumn(addressColumn, "Address");

    // Add a selection model to handle user selection.
    final SingleSelectionModel<Contact> selectionModel = new SingleSelectionModel<Contact>();
    table.setSelectionModel(selectionModel);
    selectionModel.addSelectionChangeHandler(new SelectionChangeEvent.Handler() {
        public void onSelectionChange(SelectionChangeEvent event) {
            Contact selected = selectionModel.getSelectedObject();
            if (selected != null) {
                Window.alert("You selected: " + selected.name);
            }
        }
    });

    // Set the total row count. This isn't strictly necessary, but it
    // affects
    // paging calculations, so its good habit to keep the row count up to
    // date.
    table.setRowCount(CONTACTS.size(), true);

    // Push the data into the widget.
    table.setRowData(0, CONTACTS);

    // -- END TABLE

    // viewPanel.getElement().appendChild(nameSpan);

    viewPanel.add(table);
    viewPanel.setSize("30em", "10em");

    initWidget(viewPanel);

}

From source file:com.mvp4g.example.client.views.desktop.list.MailListView.java

License:Apache License

@SuppressWarnings("unused")
private MailListView() {
    list = new DataGrid<MailItem>();

    initWidget(binder.createAndBindUi(this));

    createGrid();//from w w w.j  a v  a 2s . co  m
}

From source file:gov.nist.appvet.gwt.client.gui.table.PagingDataGrid.java

License:Open Source License

public PagingDataGrid() {
    initWidget(dock);/*  w w  w  .j a v  a  2s .c om*/
    dataGrid = new DataGrid<T>();
    dataGrid.setWidth("100%");
    final SimplePager.Resources pagerResources = GWT.create(SimplePager.Resources.class);
    pager = new SimplePager(TextLocation.CENTER, pagerResources, false, 0, true);
    pager.setDisplay(dataGrid);
    dataProvider = new ListDataProvider<T>();
    dataProvider.setList(new ArrayList<T>());
    dataGrid.setEmptyTableWidget(new HTML("No Data to Display"));
    final ListHandler<T> sortHandler = new ListHandler<T>(dataProvider.getList());
    initTableColumns(dataGrid, sortHandler);
    dataGrid.addColumnSortHandler(sortHandler);
    dataProvider.addDataDisplay(dataGrid);
    pager.setVisible(true);
    dataGrid.setVisible(true);
    dock.add(dataGrid, DockPanel.CENTER);
    dock.add(pager, DockPanel.SOUTH);
    dock.setWidth("100%");
    dock.setCellWidth(dataGrid, "100%");
    dock.setCellWidth(pager, "100%");
}

From source file:org.cloudcoder.app.client.view.CompilerDiagnosticListView.java

License:Open Source License

public CompilerDiagnosticListView() {
    cellTable = new DataGrid<CompilerDiagnostic>();

    // Add columns
    cellTable.addColumn(new MessageColumn(), "Message");
    cellTable.addColumn(new LineColumn(), "Line number");

    initWidget(cellTable);//from   w  w  w .  ja  v a2  s  . c  o  m
}

From source file:org.cloudcoder.app.client.view.CourseAdminProblemListView.java

License:Open Source License

/**
 * Constructor.//from  www .  jav a2  s . c om
 */
public CourseAdminProblemListView(CloudCoderPage page) {
    this.page = page;
    grid = new DataGrid<ProblemAndModule>();
    grid.addColumn(new ProblemIdColumn(), "Id");
    grid.addColumn(new ProblemNameColumn(), "Name");
    grid.addColumn(new ProblemBriefDescriptionColumn(), "Description");
    grid.addColumn(new ProblemTypeColumn(), "Type");
    grid.addColumn(new ProblemWhenAssignedColumn(), "Assigned");
    grid.addColumn(new ProblemWhenDueColumn(), "Due");
    grid.addColumn(new ProblemVisibleColumn(), "Visible");
    grid.addColumn(new ProblemLicense(), "License");
    grid.addColumn(new ProblemSharedColumn(), "Shared");

    grid.setColumnWidth(0, 5.0, Unit.PCT);
    grid.setColumnWidth(1, 12.5, Unit.PCT);
    grid.setColumnWidth(2, 22.0, Unit.PCT);
    grid.setColumnWidth(3, 12.5, Unit.PCT);
    grid.setColumnWidth(4, 9.0, Unit.PCT);
    grid.setColumnWidth(5, 9.0, Unit.PCT);
    grid.setColumnWidth(6, 60.0, Unit.PX);
    grid.setColumnWidth(7, 10.0, Unit.PCT);
    grid.setColumnWidth(8, 60.0, Unit.PX);
    grid.setColumnWidth(9, 20.0, Unit.PCT);

    // The column displaying the module name allows editing, and invokes
    // a callback when the module name changes.
    ProblemModuleNameColumn moduleNameColumn = new ProblemModuleNameColumn();
    grid.addColumn(moduleNameColumn, "Module (click to edit)");
    moduleNameColumn.setFieldUpdater(new FieldUpdater<ProblemAndModule, String>() {
        @Override
        public void update(int index, ProblemAndModule object, String value) {
            if (!value.equals(object.getModule().getName())) {
                object.getModule().setName(value);
                if (editModuleNameCallback != null) {
                    editModuleNameCallback.call(object);
                }
            }
        }
    });
    initWidget(grid);
}

From source file:org.cloudcoder.app.client.view.CoursesListView.java

License:Open Source License

public CoursesListView() {

    grid = new DataGrid<CourseAndCourseRegistration>();
    grid.addColumn(new TextColumn<CourseAndCourseRegistration>() {

        @Override/*from w  w  w .j a  v a  2 s . co m*/
        public String getValue(CourseAndCourseRegistration course) {
            return course.getCourse().getNameAndTitle();
        }

    }, "Course Name");

    grid.addColumn(new TextColumn<CourseAndCourseRegistration>() {

        @Override
        public String getValue(CourseAndCourseRegistration course) {
            return course.getCourse().getTermAndYear().toString();
        }
    }, "Term and year");

    initWidget(grid);
}

From source file:org.cloudcoder.app.client.view.ImportCourseSelectionView.java

License:Open Source License

/**
 * Constructor./*from  ww w  . ja  v  a 2s  . c o  m*/
 * 
 * @param session the {@link Session}
 */
public ImportCourseSelectionView(Session session) {
    this.session = session;
    this.instructorCourseList = new ArrayList<CourseAndCourseRegistration>();

    populateInstructorCourseList();

    instructorCourseGrid = new DataGrid<CourseAndCourseRegistration>();
    instructorCourseGrid.addColumn(new TermAndYearColumn(), "Term");
    instructorCourseGrid.addColumn(new CourseNameColumn(), "Course");

    instructorCourseGrid.setRowData(0, instructorCourseList);

    selectionModel = new SingleSelectionModel<CourseAndCourseRegistration>();
    instructorCourseGrid.setSelectionModel(selectionModel);

    initWidget(instructorCourseGrid);
}

From source file:org.cloudcoder.app.client.view.PlaygroundResultListView.java

License:Open Source License

public PlaygroundResultListView() {
    cellTable = new DataGrid<PlaygroundTestResult>();
    cellTable.addColumn(new TestNumberColumn(), "Test Number");
    cellTable.addColumn(new InputColumn(), "Input");
    cellTable.addColumn(new OutputColumn(new ExtractOutputText<PlaygroundTestResult>() {
        @Override/* ww  w  .j  ava  2 s  . c o  m*/
        public String getOutputText(PlaygroundTestResult testResult) {
            return testResult.getStdout();
        }
    }), "Output");
    cellTable.addColumn(new OutputColumn(new ExtractOutputText<PlaygroundTestResult>() {
        @Override
        public String getOutputText(PlaygroundTestResult testResult) {
            return testResult.getStderr();
        }
    }), "Error Output");
    initWidget(cellTable);
}

From source file:org.cloudcoder.app.client.view.ProblemListView2.java

License:Open Source License

/**
 * Constructor.//from ww  w .j  a  va 2s  .  c  om
 * 
 * @param page the {@link CloudCoderPage} that will contain this view
 */
public ProblemListView2(CloudCoderPage page) {
    this.page = page;

    cellTable = new DataGrid<ProblemAndSubmissionReceipt>();

    // Configure the DataGrid that will show the problems
    cellTable.addColumn(new TestNameColumn(), "Name");
    cellTable.addColumn(new BriefDescriptionColumn(), "Description");
    cellTable.addColumn(new WhenAssignedColumn(), "Assigned");
    cellTable.addColumn(new WhenDueColumn(), "Due");
    cellTable.addColumn(new SubmissionStatusColumn(), "Status");

    initWidget(cellTable);
}