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

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

Introduction

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

Prototype

public CellTable(int pageSize, ProvidesKey<T> keyProvider) 

Source Link

Document

Constructs a table with the given page size and the given ProvidesKey key provider .

Usage

From source file:TaskListPresenter.java

License:Open Source License

private void initializeResultsTable() {
    if (resultsTable != null) {
        return;/*from   w w  w.  j ava  2 s  . c  o m*/
    }
    resultsTable = new CellTable<Task>(15, CellTableResources.get.resources);
    resultsTable.setSelectionModel(new NoSelectionModel<Task>());
    resultsTable.setPageSize(ProjectTasksPlace.DEFAULT_PAGESIZE);
    resultsTable.setStyleName("tasks");
    resultsTable.setRowStyles(new RowStyles<Task>() {
        public String getStyleNames(Task row, int rowIndex) {
            if (row.getStatus().getValue().equals("NEW")) {
                return "new";
            }
            return null;
        }
    });

    taskListView.pager.setDisplay(resultsTable);

    taskListColumnConfiguration = new TaskListColumnConfiguration(this, resultsTable, selectionModel);
    taskListColumnConfiguration.configureFromRequest();
    taskListColumnConfiguration.apply();
    taskListView.tasksPanel.add(resultsTable);

}

From source file:com.codenvy.ide.client.propertiespanel.common.namespace.NameSpaceEditorViewImpl.java

License:Open Source License

private CellTable<NameSpace> createTable(@Nonnull CellTableResources resource) {
    CellTable<NameSpace> table = new CellTable<>(0, resource);

    Column<NameSpace, String> nameSpace = new Column<NameSpace, String>(new TextCell()) {
        @Override/*from  w  w w. j a  va2 s. com*/
        public String getValue(NameSpace object) {
            return object.toString();
        }
    };

    table.setLoadingIndicator(null);

    table.addColumn(nameSpace);
    table.setColumnWidth(nameSpace, 570, Style.Unit.PX);

    final SingleSelectionModel<NameSpace> selectionModel = new SingleSelectionModel<>();
    selectionModel.addSelectionChangeHandler(new SelectionChangeEvent.Handler() {
        @Override
        public void onSelectionChange(SelectionChangeEvent event) {
            delegate.onSelectedNameSpace(selectionModel.getSelectedObject());
        }
    });
    table.setSelectionModel(selectionModel);

    return table;
}

From source file:com.codenvy.ide.client.propertiespanel.common.propertyconfig.PropertyConfigViewImpl.java

License:Open Source License

/**
 * Returns cell table entity. Adds column names and values to table. Sets selection model to table.
 *
 * @param localizationConstant//from   w  w  w .  ja v a 2  s.c  o m
 *         localization constant which contains special names of element in current table
 */
private CellTable<Property> createTable(@Nonnull final WSO2EditorLocalizationConstant localizationConstant,
        @Nonnull CellTableResources resource) {

    final CellTable<Property> table = new CellTable<>(0, resource);

    final SingleSelectionModel<Property> selectionModel = new SingleSelectionModel<>();
    selectionModel.addSelectionChangeHandler(new SelectionChangeEvent.Handler() {
        @Override
        public void onSelectionChange(SelectionChangeEvent event) {
            delegate.onSelectedProperty(selectionModel.getSelectedObject());
        }
    });
    table.setSelectionModel(selectionModel);

    TextColumn<Property> name = new TextColumn<Property>() {
        @Override
        public String getValue(Property property) {
            String name = property.getProperty(NAME);

            return name == null ? "" : name;
        }
    };

    TextColumn<Property> expression = new TextColumn<Property>() {
        @Override
        public String getValue(Property property) {
            String value = property.getProperty(VALUE);

            return value == null ? "" : value;
        }
    };

    TextColumn<Property> type = new TextColumn<Property>() {
        @Override
        public String getValue(Property property) {
            ValueType type = property.getProperty(TYPE);

            return type == null ? "" : type.name();
        }
    };

    table.addColumn(name, localizationConstant.columnName());
    table.addColumn(type, localizationConstant.columnType());
    table.addColumn(expression, localizationConstant.columnExpression());

    table.setColumnWidth(name, 210, Style.Unit.PX);
    table.setColumnWidth(type, 120, Style.Unit.PX);
    table.setColumnWidth(expression, 210, Style.Unit.PX);

    table.setLoadingIndicator(null);

    return table;
}

From source file:com.codenvy.ide.client.propertiespanel.endpoints.address.property.PropertyViewImpl.java

License:Open Source License

/** Adds columns names and values to table. Sets selection model to table. */
private CellTable<Property> createTable(@Nonnull CellTableResources resource) {
    CellTable<Property> table = new CellTable<>(0, resource);

    final SingleSelectionModel<Property> selectionModel = new SingleSelectionModel<>();
    selectionModel.addSelectionChangeHandler(new SelectionChangeEvent.Handler() {
        @Override//from  w  w  w  .  ja v  a2 s .  c  o m
        public void onSelectionChange(SelectionChangeEvent event) {
            delegate.onPropertySelected(selectionModel.getSelectedObject());
        }
    });
    table.setSelectionModel(selectionModel);

    TextColumn<Property> name = new TextColumn<Property>() {
        @Override
        public String getValue(Property property) {
            return property.getProperty(NAME);
        }
    };

    TextColumn<Property> value = new TextColumn<Property>() {
        @Override
        public String getValue(Property property) {
            if (ValueType.LITERAL.equals(property.getProperty(TYPE))) {
                return property.getProperty(VALUE);
            }

            return property.getProperty(EXPRESSION);
        }
    };

    TextColumn<Property> type = new TextColumn<Property>() {
        @Override
        public String getValue(Property property) {
            ValueType type = property.getProperty(TYPE);

            if (type == null) {
                return "";
            }

            return type.name();
        }
    };

    TextColumn<Property> scope = new TextColumn<Property>() {
        @Override
        public String getValue(Property property) {
            Property.Scope scope = property.getProperty(SCOPE);

            if (scope == null) {
                return "";
            }

            return scope.getValue();
        }
    };

    table.addColumn(name, locale.columnName());
    table.addColumn(value, locale.columnValue());
    table.addColumn(type, locale.columnType());
    table.addColumn(scope, locale.columnScope());

    table.setColumnWidth(name, 150, Style.Unit.PX);
    table.setColumnWidth(value, 150, Style.Unit.PX);
    table.setColumnWidth(type, 60, Style.Unit.PX);
    table.setColumnWidth(scope, 100, Style.Unit.PX);

    table.setLoadingIndicator(null);

    return table;
}

From source file:com.codenvy.ide.client.propertiespanel.mediators.arguments.ArgumentsConfigViewImpl.java

License:Open Source License

private CellTable<Arg> createTable(@Nonnull final WSO2EditorLocalizationConstant localizationConstant,
        @Nonnull CellTableResources resource) {

    final CellTable<Arg> table = new CellTable<>(0, resource);

    final SingleSelectionModel<Arg> selectionModel = new SingleSelectionModel<>();
    selectionModel.addSelectionChangeHandler(new SelectionChangeEvent.Handler() {
        @Override/* w  w  w.j  ava  2s  .  c  o  m*/
        public void onSelectionChange(SelectionChangeEvent event) {
            delegate.onSelectedArg(selectionModel.getSelectedObject());
        }
    });
    table.setSelectionModel(selectionModel);

    TextColumn<Arg> value = new TextColumn<Arg>() {
        @Override
        public String getValue(Arg object) {
            return object.getProperty(ARG_VALUE);
        }
    };

    TextColumn<Arg> type = new TextColumn<Arg>() {
        @Override
        public String getValue(Arg arg) {
            ArgType argType = arg.getProperty(ARG_TYPE);

            return argType == null ? "" : argType.getValue();
        }
    };

    TextColumn<Arg> evaluator = new TextColumn<Arg>() {
        @Override
        public String getValue(Arg arg) {
            Evaluator evaluator = arg.getProperty(ARG_EVALUATOR);

            return evaluator == null ? "" : evaluator.getValue();
        }
    };

    table.addColumn(type, localizationConstant.columnType());
    table.addColumn(value, localizationConstant.columnValue());
    table.addColumn(evaluator, localizationConstant.columnEvaluator());

    table.setColumnWidth(type, 120, PX);
    table.setColumnWidth(value, 210, PX);
    table.setColumnWidth(evaluator, 120, PX);

    table.setLoadingIndicator(null);

    return table;
}

From source file:com.codenvy.ide.ext.github.client.importer.page.GithubImporterPageViewImpl.java

License:Open Source License

/**
 * Creates table what contains list of available repositories.
 *
 * @param ideResources//from  w  w  w. j  a v  a 2 s  .  com
 */
private void createRepositoriesTable(@Nonnull Resources ideResources) {
    repositories = new CellTable<ProjectData>(15, ideResources);

    Column<ProjectData, ImageResource> iconColumn = new Column<ProjectData, ImageResource>(
            new ImageResourceCell()) {
        @Override
        public ImageResource getValue(ProjectData item) {
            return resources.project();
        }
    };

    Column<ProjectData, SafeHtml> repositoryColumn = new Column<ProjectData, SafeHtml>(new SafeHtmlCell()) {
        @Override
        public SafeHtml getValue(final ProjectData item) {
            return SafeHtmlUtils.fromString(item.getName());
        }
    };

    Column<ProjectData, SafeHtml> descriptionColumn = new Column<ProjectData, SafeHtml>(new SafeHtmlCell()) {
        @Override
        public SafeHtml getValue(final ProjectData item) {
            return new SafeHtmlBuilder().appendHtmlConstant("<span>").appendEscaped(item.getDescription())
                    .appendHtmlConstant("</span>").toSafeHtml();
        }
    };

    repositories.addColumn(iconColumn, SafeHtmlUtils.fromSafeConstant("<br/>"));
    repositories.setColumnWidth(iconColumn, 28, Style.Unit.PX);

    repositories.addColumn(repositoryColumn, locale.samplesListRepositoryColumn());
    repositories.addColumn(descriptionColumn, locale.samplesListDescriptionColumn());

    // don't show loading indicator
    repositories.setLoadingIndicator(null);

    final SingleSelectionModel<ProjectData> selectionModel = new SingleSelectionModel<ProjectData>();
    selectionModel.addSelectionChangeHandler(new SelectionChangeEvent.Handler() {
        @Override
        public void onSelectionChange(SelectionChangeEvent event) {
            ProjectData selectedObject = selectionModel.getSelectedObject();
            delegate.onRepositorySelected(selectedObject);
        }
    });
    repositories.setSelectionModel(selectionModel);
}

From source file:com.codenvy.ide.ext.github.client.projectimporter.importerpage.GithubImporterPageViewImpl.java

License:Open Source License

/** Creates table what contains list of available repositories.
 * @param ideResources*///from   w  ww.  j  a va  2 s. c  om
private void createRepositoriesTable(Resources ideResources) {
    repositories = new CellTable<ProjectData>(15, ideResources);

    Column<ProjectData, ImageResource> iconColumn = new Column<ProjectData, ImageResource>(
            new ImageResourceCell()) {
        @Override
        public ImageResource getValue(ProjectData item) {
            return resources.project();
        }
    };

    Column<ProjectData, SafeHtml> repositoryColumn = new Column<ProjectData, SafeHtml>(new SafeHtmlCell()) {
        @Override
        public SafeHtml getValue(final ProjectData item) {
            return new SafeHtml() {
                public String asString() {
                    return item.getName();
                }
            };
        }
    };

    Column<ProjectData, SafeHtml> descriptionColumn = new Column<ProjectData, SafeHtml>(new SafeHtmlCell()) {
        @Override
        public SafeHtml getValue(final ProjectData item) {
            return new SafeHtml() {
                public String asString() {
                    return "<span>" + item.getDescription() + "</span>";
                }
            };
        }
    };

    repositories.addColumn(iconColumn, SafeHtmlUtils.fromSafeConstant("<br/>"));
    repositories.setColumnWidth(iconColumn, 28, Style.Unit.PX);

    repositories.addColumn(repositoryColumn, locale.samplesListRepositoryColumn());
    repositories.addColumn(descriptionColumn, locale.samplesListDescriptionColumn());

    // don't show loading indicator
    repositories.setLoadingIndicator(null);

    final SingleSelectionModel<ProjectData> selectionModel = new SingleSelectionModel<ProjectData>();
    selectionModel.addSelectionChangeHandler(new SelectionChangeEvent.Handler() {
        @Override
        public void onSelectionChange(SelectionChangeEvent event) {
            ProjectData selectedObject = selectionModel.getSelectedObject();
            delegate.onRepositorySelected(selectedObject);
        }
    });
    repositories.setSelectionModel(selectionModel);
}

From source file:com.eucalyptus.webui.client.view.SearchResultTable.java

License:Open Source License

private void buildTable(int pageSize) {
    CellTable.Resources resources = GWT.create(TableResources.class);

    cellTable = new CellTable<SearchResultRow>(pageSize, resources);
    cellTable.setWidth("100%", true);
    // Initialize columns
    for (int i = 0; i < this.fieldDescs.size(); i++) {
        SearchResultFieldDesc desc = this.fieldDescs.get(i);
        if (desc.getTableDisplay() != TableDisplay.MANDATORY) {
            continue;
        }//from   w w w.  ja v a 2  s. c  om
        final int index = i;
        TextColumn<SearchResultRow> col = new TextColumn<SearchResultRow>() {
            @Override
            public String getValue(SearchResultRow data) {
                if (data == null) {
                    return "";
                } else {
                    return data.getField(index);
                }
            }
        };
        col.setSortable(desc.getSortable());
        cellTable.addColumn(col, desc.getTitle());
        cellTable.setColumnWidth(col, desc.getWidth());
        tableColIdx.add(i);
    }

    cellTable.setSelectionModel(selectionModel);
}

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

License:Apache License

@UiConstructor
public TimeSlotListWidget() {
    table = new CellTable<TimeSlotListPresenter.ScheduleRow>(TimeSlotListPresenter.ROWS_IN_A_DAY,
            GWT.<TableResources>create(TableResources.class));
    table.addColumn(new WeekDayColumn(null), "Hour");
    final WeekDay[] dayValues = WeekDay.values();
    for (WeekDay day : dayValues) {
        WeekDayColumn col = new WeekDayColumn(day);

        class Updater implements FieldUpdater<TimeSlotListPresenter.ScheduleRow, String> {
            private WeekDay columnDay;

            public Updater(WeekDay day) {
                columnDay = day;//from  w  w w.  j  av a2 s. c  o  m
            }

            @Override
            public void update(int index, TimeSlotListPresenter.ScheduleRow row, String value) {
                if (acceptClicks) {
                    row.toggleInUse(columnDay);
                }
            }
        }

        FieldUpdater<TimeSlotListPresenter.ScheduleRow, String> fieldUpdater = new Updater(day);
        col.setFieldUpdater(fieldUpdater);
        table.addColumn(col, day.getShortName());
    }

    table.setRowCount(TimeSlotListPresenter.ROWS_IN_A_DAY, false);
    table.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.DISABLED);
    initWidget(GWT.<TimeSlotListWidgetUiBinder>create(TimeSlotListWidgetUiBinder.class).createAndBindUi(this));
}

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

License:Apache License

public TimeSlotListWidget(DynaTableRequestFactory factory) {
    this.factory = factory;
    table = new CellTable<TimeSlotListWidget.ScheduleRow>(ROWS_IN_A_DAY,
            GWT.<TableResources>create(TableResources.class));
    table.addColumn(new WeekDayColumn(null), "Hour");
    for (WeekDay day : WeekDay.values()) {
        WeekDayColumn col = new WeekDayColumn(day);

        class Updater implements FieldUpdater<ScheduleRow, String> {
            private WeekDay columnDay;

            public Updater(WeekDay day) {
                columnDay = day;/* w  w w. ja  v a  2s . co  m*/
            }

            @Override
            public void update(int index, ScheduleRow row, String value) {
                if (acceptClicks) {
                    row.toggleInUse(columnDay);
                }
            }
        }

        FieldUpdater<ScheduleRow, String> fieldUpdater = new Updater(day);
        col.setFieldUpdater(fieldUpdater);
        table.addColumn(col, day.getShortName());
    }

    table.setRowCount(ROWS_IN_A_DAY, false);
    table.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.DISABLED);
    initWidget(uiBinder.createAndBindUi(this));
}