Search in sources :

Example 36 with Column

use of com.google.gwt.user.cellview.client.Column in project perun by CESNET.

the class GetCompleteRichMembers method getEmptyTable.

/**
	 * Returns empty table
	 *
	 * @return CellTable widget
	 */
public CellTable<RichMember> getEmptyTable() {
    // Table data provider.
    dataProvider = new ListDataProvider<RichMember>(list);
    // Cell table
    table = new PerunTable<RichMember>(list);
    // Connect the table to the data provider.
    dataProvider.addDataDisplay(table);
    // Sorting
    ListHandler<RichMember> columnSortHandler = new ListHandler<RichMember>(dataProvider.getList());
    table.addColumnSortHandler(columnSortHandler);
    // table selection
    table.setSelectionModel(selectionModel, DefaultSelectionEventManager.<RichMember>createCheckboxManager());
    // set empty content & loader
    table.setEmptyTableWidget(loaderImage);
    if (PerunEntity.VIRTUAL_ORGANIZATION.equals(entity)) {
        loaderImage.setEmptyResultMessage("VO has no members.");
    } else {
        loaderImage.setEmptyResultMessage("Group has no members.");
    }
    Column<RichMember, RichMember> checkBoxColumn = new Column<RichMember, RichMember>(new PerunCheckboxCell<RichMember>(true, false, indirectCheckable)) {

        @Override
        public RichMember getValue(RichMember object) {
            // Get the value from the selection model.
            object.setChecked(selectionModel.isSelected(object));
            return object;
        }
    };
    // updates the columns size
    table.setColumnWidth(checkBoxColumn, 40.0, Style.Unit.PX);
    // Add the columns
    // Checkbox column header
    CheckboxCell cb = new CheckboxCell();
    Header<Boolean> checkBoxHeader = new Header<Boolean>(cb) {

        public Boolean getValue() {
            //return true to see a checked checkbox.
            return false;
        }
    };
    checkBoxHeader.setUpdater(new ValueUpdater<Boolean>() {

        public void update(Boolean value) {
            // sets selected to all, if value = true, unselect otherwise
            for (RichMember obj : list) {
                if (!"INDIRECT".equalsIgnoreCase(obj.getMembershipType())) {
                    selectionModel.setSelected(obj, value);
                }
            }
        }
    });
    if (checkable) {
        table.addColumn(checkBoxColumn, checkBoxHeader);
    }
    MemberColumnProvider columnProvider = new MemberColumnProvider(dataProvider, backupList, table, tableFieldUpdater);
    IsClickableCell<RichMember> authz = new IsClickableCell<RichMember>() {

        @Override
        public boolean isClickable(RichMember object) {
            return true;
        }

        @Override
        public String linkUrl(RichMember object) {
            return null;
        }
    };
    columnProvider.addIdColumn(authz, 110);
    columnProvider.addUserIdColumn(authz, 110);
    columnProvider.addStatusColumn(authz, 20);
    columnProvider.addNameColumn(authz);
    columnProvider.addOrganizationColumn(authz);
    columnProvider.addEmailColumn(authz);
    columnProvider.addLoginsColumn(authz);
    return table;
}
Also used : ListHandler(com.google.gwt.user.cellview.client.ColumnSortEvent.ListHandler) MemberColumnProvider(cz.metacentrum.perun.webgui.json.columnProviders.MemberColumnProvider) RichMember(cz.metacentrum.perun.webgui.model.RichMember) Header(com.google.gwt.user.cellview.client.Header) Column(com.google.gwt.user.cellview.client.Column) IsClickableCell(cz.metacentrum.perun.webgui.json.columnProviders.IsClickableCell) CheckboxCell(com.google.gwt.cell.client.CheckboxCell) PerunCheckboxCell(cz.metacentrum.perun.webgui.widgets.cells.PerunCheckboxCell)

Example 37 with Column

use of com.google.gwt.user.cellview.client.Column in project che by eclipse.

the class RemoteViewImpl method initRepositoriesTable.

/**
     * Initialize the columns of the grid.
     *
     * @param ideResources
     */
private void initRepositoriesTable(org.eclipse.che.ide.Resources ideResources) {
    repositories = new CellTable<>(15, ideResources);
    Column<Remote, String> nameColumn = new Column<Remote, String>(new TextCell()) {

        @Override
        public String getValue(Remote remote) {
            return remote.getName();
        }

        @Override
        public void render(Cell.Context context, Remote remote, SafeHtmlBuilder sb) {
            sb.appendHtmlConstant("<div id=\"" + UIObject.DEBUG_ID_PREFIX + "git-remotes-remotes-cellTable-" + context.getIndex() + "\">");
            super.render(context, remote, sb);
        }
    };
    Column<Remote, String> urlColumn = new Column<Remote, String>(new TextCell()) {

        @Override
        public String getValue(Remote remote) {
            return remote.getUrl();
        }
    };
    repositories.addColumn(nameColumn, locale.remoteGridNameField());
    repositories.setColumnWidth(nameColumn, "20%");
    repositories.addColumn(urlColumn, locale.remoteGridLocationField());
    repositories.setColumnWidth(urlColumn, "80%");
    final SingleSelectionModel<Remote> selectionModel = new SingleSelectionModel<Remote>();
    selectionModel.addSelectionChangeHandler(new SelectionChangeEvent.Handler() {

        @Override
        public void onSelectionChange(SelectionChangeEvent event) {
            selectedObject = selectionModel.getSelectedObject();
            delegate.onRemoteSelected(selectedObject);
        }
    });
    repositories.setSelectionModel(selectionModel);
}
Also used : SingleSelectionModel(com.google.gwt.view.client.SingleSelectionModel) Remote(org.eclipse.che.api.git.shared.Remote) SafeHtmlBuilder(com.google.gwt.safehtml.shared.SafeHtmlBuilder) TextCell(com.google.gwt.cell.client.TextCell) SelectionChangeEvent(com.google.gwt.view.client.SelectionChangeEvent) Column(com.google.gwt.user.cellview.client.Column)

Example 38 with Column

use of com.google.gwt.user.cellview.client.Column in project che by eclipse.

the class RevisionListViewImpl method createRevisionsTable.

private void createRevisionsTable(org.eclipse.che.ide.Resources coreRes) {
    Column<Revision, String> idColumn = new Column<Revision, String>(new TextCell()) {

        @Override
        public String getValue(Revision revision) {
            return revision.getId().substring(0, 8) + "...";
        }
    };
    Column<Revision, String> timeColumn = new Column<Revision, String>(new TextCell()) {

        @Override
        public String getValue(Revision revision) {
            return dateTimeFormatter.getFormattedDate(revision.getCommitTime());
        }
    };
    Column<Revision, String> authorColumn = new Column<Revision, String>(new TextCell()) {

        @Override
        public String getValue(Revision revision) {
            return revision.getCommitter().getName();
        }
    };
    Column<Revision, String> titleColumn = new Column<Revision, String>(new TextCell()) {

        @Override
        public String getValue(Revision revision) {
            return revision.getMessage().substring(0, 50);
        }
    };
    revisions = new CellTable<>(15, coreRes);
    revisions.setWidth("100%");
    revisions.addColumn(idColumn, locale.viewCompareRevisionTableIdTitle());
    revisions.addColumn(timeColumn, locale.viewCompareRevisionTableTimeTitle());
    revisions.addColumn(authorColumn, locale.viewCompareRevisionTableAuthorTitle());
    revisions.addColumn(titleColumn, locale.viewCompareRevisionTableTitleTitle());
    selectionModel = new SingleSelectionModel<Revision>();
    selectionModel.addSelectionChangeHandler(new SelectionChangeEvent.Handler() {

        @Override
        public void onSelectionChange(SelectionChangeEvent event) {
            description.setText(selectionModel.getSelectedObject().getMessage());
            delegate.onRevisionSelected(selectionModel.getSelectedObject());
        }
    });
    revisions.setSelectionModel(selectionModel);
    revisions.addDomHandler(new DoubleClickHandler() {

        @Override
        public void onDoubleClick(DoubleClickEvent event) {
            delegate.onRevisionDoubleClicked();
        }
    }, DoubleClickEvent.getType());
    this.revisionsPanel.add(revisions);
}
Also used : Revision(org.eclipse.che.api.git.shared.Revision) Column(com.google.gwt.user.cellview.client.Column) DoubleClickHandler(com.google.gwt.event.dom.client.DoubleClickHandler) DoubleClickEvent(com.google.gwt.event.dom.client.DoubleClickEvent) TextCell(com.google.gwt.cell.client.TextCell) SelectionChangeEvent(com.google.gwt.view.client.SelectionChangeEvent)

Example 39 with Column

use of com.google.gwt.user.cellview.client.Column in project che by eclipse.

the class HistoryViewImpl method createRevisionsTable.

private void createRevisionsTable(org.eclipse.che.ide.Resources coreRes) {
    Column<Revision, String> idColumn = new Column<Revision, String>(new TextCell()) {

        @Override
        public String getValue(Revision revision) {
            return revision.getId().substring(0, 8) + "...";
        }
    };
    Column<Revision, String> timeColumn = new Column<Revision, String>(new TextCell()) {

        @Override
        public String getValue(Revision revision) {
            return dateTimeFormatter.getFormattedDate(revision.getCommitTime());
        }
    };
    Column<Revision, String> authorColumn = new Column<Revision, String>(new TextCell()) {

        @Override
        public String getValue(Revision revision) {
            return revision.getCommitter().getName();
        }
    };
    Column<Revision, String> titleColumn = new Column<Revision, String>(new TextCell()) {

        @Override
        public String getValue(Revision revision) {
            return revision.getMessage().substring(0, 50);
        }
    };
    revisions = new CellTable<>(15, coreRes);
    revisions.setWidth("100%");
    revisions.addColumn(idColumn, locale.viewCompareRevisionTableIdTitle());
    revisions.addColumn(timeColumn, locale.viewCompareRevisionTableTimeTitle());
    revisions.addColumn(authorColumn, locale.viewCompareRevisionTableAuthorTitle());
    revisions.addColumn(titleColumn, locale.viewCompareRevisionTableTitleTitle());
    selectionModel = new SingleSelectionModel<Revision>();
    selectionModel.addSelectionChangeHandler(new SelectionChangeEvent.Handler() {

        @Override
        public void onSelectionChange(SelectionChangeEvent event) {
            description.setText(selectionModel.getSelectedObject().getMessage());
            delegate.onRevisionSelected(selectionModel.getSelectedObject());
        }
    });
    revisions.setSelectionModel(selectionModel);
    revisions.addDomHandler(new DoubleClickHandler() {

        @Override
        public void onDoubleClick(DoubleClickEvent event) {
            delegate.onRevisionDoubleClicked();
        }
    }, DoubleClickEvent.getType());
    this.revisionsPanel.add(revisions);
}
Also used : Revision(org.eclipse.che.api.git.shared.Revision) Column(com.google.gwt.user.cellview.client.Column) DoubleClickHandler(com.google.gwt.event.dom.client.DoubleClickHandler) DoubleClickEvent(com.google.gwt.event.dom.client.DoubleClickEvent) TextCell(com.google.gwt.cell.client.TextCell) SelectionChangeEvent(com.google.gwt.view.client.SelectionChangeEvent)

Example 40 with Column

use of com.google.gwt.user.cellview.client.Column in project che by eclipse.

the class ResetToCommitViewImpl method createCommitsTable.

/** Creates table what contains list of available commits. */
private void createCommitsTable() {
    commits = new CellTable<Revision>(15, tableRes);
    Column<Revision, String> dateColumn = new Column<Revision, String>(new TextCell()) {

        @Override
        public String getValue(Revision revision) {
            return DateTimeFormat.getFormat(DateTimeFormat.PredefinedFormat.DATE_TIME_MEDIUM).format(new Date((long) revision.getCommitTime()));
        }

        @Override
        public void render(Cell.Context context, Revision revision, SafeHtmlBuilder sb) {
            sb.appendHtmlConstant("<div id=\"" + UIObject.DEBUG_ID_PREFIX + "git-reset-cellTable-" + context.getIndex() + "\">");
            super.render(context, revision, sb);
        }
    };
    Column<Revision, String> commiterColumn = new Column<Revision, String>(new TextCell()) {

        @Override
        public String getValue(Revision revision) {
            if (revision.getCommitter() == null) {
                return "";
            }
            return revision.getCommitter().getName();
        }
    };
    Column<Revision, String> commentColumn = new Column<Revision, String>(new TextCell()) {

        @Override
        public String getValue(Revision revision) {
            return revision.getMessage();
        }
    };
    commits.addColumn(dateColumn, locale.commitGridDate());
    commits.setColumnWidth(dateColumn, "20%");
    commits.addColumn(commiterColumn, locale.commitGridCommiter());
    commits.setColumnWidth(commiterColumn, "20%");
    commits.addColumn(commentColumn, locale.commitGridComment());
    commits.setColumnWidth(commentColumn, "60%");
    final SingleSelectionModel<Revision> selectionModel = new SingleSelectionModel<Revision>();
    selectionModel.addSelectionChangeHandler(new SelectionChangeEvent.Handler() {

        @Override
        public void onSelectionChange(SelectionChangeEvent event) {
            Revision selectedObject = selectionModel.getSelectedObject();
            delegate.onRevisionSelected(selectedObject);
        }
    });
    commits.setSelectionModel(selectionModel);
}
Also used : SingleSelectionModel(com.google.gwt.view.client.SingleSelectionModel) SafeHtmlBuilder(com.google.gwt.safehtml.shared.SafeHtmlBuilder) Date(java.util.Date) TextCell(com.google.gwt.cell.client.TextCell) SelectionChangeEvent(com.google.gwt.view.client.SelectionChangeEvent) Revision(org.eclipse.che.api.git.shared.Revision) Column(com.google.gwt.user.cellview.client.Column)

Aggregations

Column (com.google.gwt.user.cellview.client.Column)56 ListHandler (com.google.gwt.user.cellview.client.ColumnSortEvent.ListHandler)28 CheckboxCell (com.google.gwt.cell.client.CheckboxCell)18 Header (com.google.gwt.user.cellview.client.Header)15 PerunCheckboxCell (cz.metacentrum.perun.webgui.widgets.cells.PerunCheckboxCell)14 JavaScriptObject (com.google.gwt.core.client.JavaScriptObject)10 GeneralObject (cz.metacentrum.perun.webgui.model.GeneralObject)10 SafeHtmlBuilder (com.google.gwt.safehtml.shared.SafeHtmlBuilder)9 TextColumn (com.google.gwt.user.cellview.client.TextColumn)9 TextCell (com.google.gwt.cell.client.TextCell)8 CustomClickableTextCell (cz.metacentrum.perun.webgui.widgets.cells.CustomClickableTextCell)8 SafeHtml (com.google.gwt.safehtml.shared.SafeHtml)7 FieldUpdater (com.google.gwt.cell.client.FieldUpdater)6 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)6 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)6 SelectionChangeEvent (com.google.gwt.view.client.SelectionChangeEvent)6 Attribute (cz.metacentrum.perun.webgui.model.Attribute)6 Group (cz.metacentrum.perun.webgui.model.Group)6 Confirm (cz.metacentrum.perun.webgui.widgets.Confirm)6 ImageResource (com.google.gwt.resources.client.ImageResource)5