Search in sources :

Example 26 with TextCell

use of com.google.gwt.cell.client.TextCell 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)

Example 27 with TextCell

use of com.google.gwt.cell.client.TextCell in project perun by CESNET.

the class JsonUtils method addColumn.

/**
 * Returns a column with a header and with automatic cell selection
 *
 * @param <R> the row type
 * @param getter the value getter for the cell
 * @param fieldUpdater Field updater - on click action
 */
public static <R> Column<R, String> addColumn(final GetValue<R, String> getter, final FieldUpdater<R, String> fieldUpdater) {
    Cell<String> cell;
    if (fieldUpdater == null) {
        cell = new TextCell();
    } else {
        cell = new CustomClickableTextCell();
    }
    Column<R, String> column = new Column<R, String>(cell) {

        @Override
        public String getValue(R object) {
            return getter.getValue(object);
        }

        @Override
        public String getCellStyleNames(Cell.Context context, R object) {
            if (fieldUpdater != null) {
                return super.getCellStyleNames(context, object) + " pointer";
            } else {
                return super.getCellStyleNames(context, object);
            }
        }
    };
    if (fieldUpdater != null) {
        column.setFieldUpdater(fieldUpdater);
    }
    return column;
}
Also used : CustomClickableTextCell(cz.metacentrum.perun.webgui.widgets.cells.CustomClickableTextCell) Column(com.google.gwt.user.cellview.client.Column) JsArrayString(com.google.gwt.core.client.JsArrayString) TextCell(com.google.gwt.cell.client.TextCell) CustomClickableTextCell(cz.metacentrum.perun.webgui.widgets.cells.CustomClickableTextCell)

Example 28 with TextCell

use of com.google.gwt.cell.client.TextCell in project mvp4g2-examples by mvp4g.

the class ListView method createView.

public void createView() {
    panel = new ScrollPanel();
    FlowPanel resultPanel = new FlowPanel();
    resultPanel.addStyleName(style.resultPanel());
    panel.add(resultPanel);
    Label headline = new Label(ApplicationConstants.CONSTANTS.resultHeadline());
    headline.addStyleName(style.headline());
    resultPanel.add(headline);
    resultTable = new CellTable<Person>();
    resultPanel.add(resultTable);
    resultTable.setEmptyTableWidget(new HTML(ApplicationConstants.CONSTANTS.resultText()));
    Column<Person, String> nameColumn = addColumn(new ClickableTextCell(), ApplicationConstants.CONSTANTS.columnName(), new GetValue<String>() {

        @Override
        public String getValue(Person person) {
            return person.getName() + ", " + person.getFirstName();
        }
    }, new FieldUpdater<Person, String>() {

        @Override
        public void update(int index, Person object, String value) {
            getPresenter().doUpdate(object);
        }
    });
    Column<Person, String> streetColumn = addColumn(new TextCell(), ApplicationConstants.CONSTANTS.columnStreet(), new GetValue<String>() {

        @Override
        public String getValue(Person person) {
            return person.getAddress().getStreet();
        }
    }, null);
    Column<Person, String> plzColumn = addColumn(new TextCell(), ApplicationConstants.CONSTANTS.columnPlz(), new GetValue<String>() {

        @Override
        public String getValue(Person person) {
            return person.getAddress().getZip();
        }
    }, null);
    plzColumn.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_RIGHT);
    Column<Person, String> cityColumn = addColumn(new TextCell(), ApplicationConstants.CONSTANTS.columnCity(), new GetValue<String>() {

        @Override
        public String getValue(Person person) {
            return person.getAddress().getCity();
        }
    }, null);
    // Tabellen und Spalten-Breite setzen
    resultTable.setWidth("100%");
    resultTable.setColumnWidth(nameColumn, "40%");
    resultTable.setColumnWidth(streetColumn, "25%");
    resultTable.setColumnWidth(plzColumn, "10%");
    resultTable.setColumnWidth(cityColumn, "25%");
    resetTable();
}
Also used : ClickableTextCell(com.google.gwt.cell.client.ClickableTextCell) TextCell(com.google.gwt.cell.client.TextCell) ClickableTextCell(com.google.gwt.cell.client.ClickableTextCell) Person(de.gishmo.gwt.example.mvp4g2.simpleapplication.shared.dto.Person)

Aggregations

TextCell (com.google.gwt.cell.client.TextCell)28 Column (com.google.gwt.user.cellview.client.Column)26 PopoverTextCell (org.uberfire.ext.widgets.common.client.tables.PopoverTextCell)5 SafeHtmlBuilder (com.google.gwt.safehtml.shared.SafeHtmlBuilder)4 SelectionChangeEvent (com.google.gwt.view.client.SelectionChangeEvent)4 ContainerConfigParamsView_ArtifactIdColumn (org.guvnor.ala.ui.client.resources.i18n.GuvnorAlaUIConstants.ContainerConfigParamsView_ArtifactIdColumn)4 ContainerConfigParamsView_ContainerNameColumn (org.guvnor.ala.ui.client.resources.i18n.GuvnorAlaUIConstants.ContainerConfigParamsView_ContainerNameColumn)4 ContainerConfigParamsView_GroupIdColumn (org.guvnor.ala.ui.client.resources.i18n.GuvnorAlaUIConstants.ContainerConfigParamsView_GroupIdColumn)4 ContainerConfigParamsView_VersionColumn (org.guvnor.ala.ui.client.resources.i18n.GuvnorAlaUIConstants.ContainerConfigParamsView_VersionColumn)4 Revision (org.eclipse.che.api.git.shared.Revision)3 NotificationRow (org.kie.workbench.common.stunner.bpmn.client.forms.fields.model.NotificationRow)3 ButtonCell (com.google.gwt.cell.client.ButtonCell)2 Context (com.google.gwt.cell.client.Cell.Context)2 EditTextCell (com.google.gwt.cell.client.EditTextCell)2 DoubleClickEvent (com.google.gwt.event.dom.client.DoubleClickEvent)2 DoubleClickHandler (com.google.gwt.event.dom.client.DoubleClickHandler)2 SingleSelectionModel (com.google.gwt.view.client.SingleSelectionModel)2 SshPairDto (org.eclipse.che.api.ssh.shared.dto.SshPairDto)2 TemplateParamsTableView_ParamNameColumn (org.guvnor.ala.ui.openshift.client.resources.i18n.GuvnorAlaOpenShiftUIConstants.TemplateParamsTableView_ParamNameColumn)2 TemplateParamsTableView_ParamRequiredColumn (org.guvnor.ala.ui.openshift.client.resources.i18n.GuvnorAlaOpenShiftUIConstants.TemplateParamsTableView_ParamRequiredColumn)2