Example usage for com.google.gwt.user.cellview.client Column setFieldUpdater

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

Introduction

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

Prototype

public void setFieldUpdater(FieldUpdater<T, C> fieldUpdater) 

Source Link

Document

Set the FieldUpdater used for updating values in the column.

Usage

From source file:org.kie.workbench.common.screens.projecteditor.client.forms.DependencyGridViewImpl.java

License:Apache License

private void addGroupIdColumn() {
    Column<Dependency, String> column = new Column<Dependency, String>(
            new WaterMarkEditTextCell(ProjectEditorResources.CONSTANTS.EnterAGroupID())) {
        @Override//from  ww  w.  j av  a 2  s  .c om
        public String getValue(Dependency dependency) {
            if (dependency.getGroupId() != null) {
                return dependency.getGroupId();
            } else {
                return "";
            }
        }
    };

    // BZ-1007894: If field value is not correct, do not update the model and the widget cell value.
    DependencyFieldUpdater fieldUpdater = new DependencyFieldUpdater((WaterMarkEditTextCell) column.getCell());
    fieldUpdater.emptyHandler = new DependencyFieldUpdaterHandler() {
        @Override
        public void handle(Dependency dep, String value) {
            Window.alert(ProjectEditorResources.CONSTANTS.GroupIdMissing());
        }
    };
    fieldUpdater.notValidValueHandler = new DependencyFieldUpdaterHandler() {
        @Override
        public void handle(Dependency dep, String value) {
            Window.alert(ProjectEditorResources.CONSTANTS.XMLMarkIsNotAllowed());
        }
    };
    fieldUpdater.validHandler = new DependencyFieldUpdaterHandler() {
        @Override
        public void handle(Dependency dep, String value) {
            dep.setGroupId(value);
        }
    };

    column.setFieldUpdater(fieldUpdater);

    dataGrid.addColumn(column, ProjectEditorResources.CONSTANTS.GroupID());
}

From source file:org.kie.workbench.common.screens.projecteditor.client.forms.DependencyGridViewImpl.java

License:Apache License

private void addArtifactIdColumn() {
    final Column<Dependency, String> column = new Column<Dependency, String>(
            new WaterMarkEditTextCell(ProjectEditorResources.CONSTANTS.EnterAnArtifactID())) {

        @Override//w ww  .ja  v  a2 s. c  o m
        public String getValue(Dependency dependency) {
            if (dependency.getArtifactId() != null) {
                return dependency.getArtifactId();
            } else {
                return "";
            }
        }
    };

    // BZ-1007894: If field value is not correct, do not update the model and the widet cell value.
    DependencyFieldUpdater fieldUpdater = new DependencyFieldUpdater((WaterMarkEditTextCell) column.getCell());
    fieldUpdater.emptyHandler = new DependencyFieldUpdaterHandler() {
        @Override
        public void handle(Dependency dep, String value) {
            Window.alert(ProjectEditorResources.CONSTANTS.ArtifactIdMissing());
        }
    };
    fieldUpdater.notValidValueHandler = new DependencyFieldUpdaterHandler() {
        @Override
        public void handle(Dependency dep, String value) {
            Window.alert(ProjectEditorResources.CONSTANTS.XMLMarkIsNotAllowed());
        }
    };
    fieldUpdater.validHandler = new DependencyFieldUpdaterHandler() {
        @Override
        public void handle(Dependency dep, String value) {
            dep.setArtifactId(value);
        }
    };

    column.setFieldUpdater(fieldUpdater);

    dataGrid.addColumn(column, ProjectEditorResources.CONSTANTS.ArtifactID());
}

From source file:org.kie.workbench.common.screens.projecteditor.client.forms.DependencyGridViewImpl.java

License:Apache License

private void addVersionColumn() {
    Column<Dependency, String> column = new Column<Dependency, String>(
            new WaterMarkEditTextCell(ProjectEditorResources.CONSTANTS.EnterAVersion())) {
        @Override//from w  w w  . j a  v  a  2s.  c  o  m
        public String getValue(Dependency dependency) {
            if (dependency.getVersion() != null) {
                return dependency.getVersion();
            } else {
                return "";
            }
        }
    };

    // BZ-1007894: If field value is not correct, do not update the model and the widget cell value.
    DependencyFieldUpdater fieldUpdater = new DependencyFieldUpdater((WaterMarkEditTextCell) column.getCell());
    fieldUpdater.emptyHandler = new DependencyFieldUpdaterHandler() {
        @Override
        public void handle(Dependency dep, String value) {
            Window.alert(ProjectEditorResources.CONSTANTS.VersionMissing());
        }
    };
    fieldUpdater.notValidValueHandler = new DependencyFieldUpdaterHandler() {
        @Override
        public void handle(Dependency dep, String value) {
            Window.alert(ProjectEditorResources.CONSTANTS.XMLMarkIsNotAllowed());
        }
    };
    fieldUpdater.validHandler = new DependencyFieldUpdaterHandler() {
        @Override
        public void handle(Dependency dep, String value) {
            dep.setVersion(value);
        }
    };

    column.setFieldUpdater(fieldUpdater);

    dataGrid.addColumn(column, ProjectEditorResources.CONSTANTS.Version());
}

From source file:org.kie.workbench.common.screens.projecteditor.client.forms.DependencyGridViewImpl.java

License:Apache License

private void addRemoveRowColumn() {
    Column<Dependency, String> column = new Column<Dependency, String>(new TrashCanImageCell()) {
        @Override/*  w w  w  .j  av  a  2 s .  c om*/
        public String getValue(Dependency dependency) {
            return CommonConstants.INSTANCE.Delete();
        }
    };

    column.setFieldUpdater(new FieldUpdater<Dependency, String>() {
        @Override
        public void update(int index, Dependency dependency, String value) {
            presenter.onRemoveDependency(dependency);
        }
    });

    dataGrid.addColumn(column, CommonConstants.INSTANCE.Delete());
}

From source file:org.kie.workbench.common.screens.projecteditor.client.forms.DependencyListWidget.java

License:Apache License

@AfterInitialization
public void init() {
    dependencyPagedJarTable = IOC.getBeanManager().lookupBean(ArtifactListPresenter.class).getInstance();

    final Column<JarListPageRow, String> selectColumn = new Column<JarListPageRow, String>(new ButtonCell() {
        {/*from   w w  w . jav a  2  s .c om*/
            setSize(ButtonSize.MINI);
        }
    }) {
        public String getValue(JarListPageRow row) {
            return "Select";
        }
    };
    selectColumn.setFieldUpdater(new FieldUpdater<JarListPageRow, String>() {
        public void update(final int index, final JarListPageRow row, final String value) {
            onPathSelect.execute(row.getPath());
        }
    });
    dependencyPagedJarTable.getView().addColumn(selectColumn, "Select");

    dependencyPagedJarTable.getView().setContentHeight("200px");

    panel.add(dependencyPagedJarTable.getView());
}

From source file:org.kie.workbench.common.screens.projecteditor.client.forms.KSessionsPanelViewImpl.java

License:Apache License

private void setUpNameColumn() {
    final EditTextCell cell = new EditTextCell();
    Column<KSessionModel, String> column = new Column<KSessionModel, String>(cell) {
        @Override/*  ww w  .  j  av a2 s . co m*/
        public String getValue(KSessionModel kSessionModel) {
            return kSessionModel.getName();
        }
    };
    dataGrid.addColumn(column, ProjectEditorResources.CONSTANTS.Name());
    dataGrid.setColumnWidth(column, 40, Style.Unit.PCT);

    column.setFieldUpdater(new FieldUpdater<KSessionModel, String>() {
        @Override
        public void update(int row, KSessionModel kSessionModel, String value) {

            cell.clearViewData(KEY_PROVIDER.getKey(kSessionModel));

            presenter.onRename(kSessionModel, value);
        }
    });
}

From source file:org.kie.workbench.common.screens.projecteditor.client.forms.KSessionsPanelViewImpl.java

License:Apache License

private void setUpClockColumn() {
    ArrayList<String> options = new ArrayList<String>();
    options.add(ProjectEditorResources.CONSTANTS.Realtime());
    options.add(ProjectEditorResources.CONSTANTS.Pseudo());

    Column<KSessionModel, String> column = new Column<KSessionModel, String>(new SelectionCell(options)) {
        @Override//from w  w w  .  j a va 2 s  . co m
        public String getValue(KSessionModel kSessionModel) {
            if (kSessionModel.getClockType().equals(ClockTypeOption.PSEUDO)) {
                return ProjectEditorResources.CONSTANTS.Pseudo();
            } else if (kSessionModel.getClockType().equals(ClockTypeOption.REALTIME)) {
                return ProjectEditorResources.CONSTANTS.Realtime();
            } else {
                return kSessionModel.getClockType().toString();
            }
        }
    };

    column.setFieldUpdater(new FieldUpdater<KSessionModel, String>() {
        @Override
        public void update(int index, KSessionModel model, String value) {
            if (value.equals(ProjectEditorResources.CONSTANTS.Pseudo())) {
                model.setClockType(ClockTypeOption.PSEUDO);
            } else {
                model.setClockType(ClockTypeOption.REALTIME);
            }
        }
    });

    dataGrid.addColumn(column, ProjectEditorResources.CONSTANTS.Clock());
    dataGrid.setColumnWidth(column, 60, Style.Unit.PCT);
}

From source file:org.kie.workbench.common.screens.projecteditor.client.forms.KSessionsPanelViewImpl.java

License:Apache License

private void setUpStateColumn() {
    ArrayList<String> options = new ArrayList<String>();
    options.add(ProjectEditorResources.CONSTANTS.Stateful());
    options.add(ProjectEditorResources.CONSTANTS.Stateless());

    Column<KSessionModel, String> column = new Column<KSessionModel, String>(new SelectionCell(options)) {
        @Override//from   ww  w .  jav a 2 s.  c  o  m
        public String getValue(KSessionModel kSessionModel) {
            if (kSessionModel.getType() == null) {
                return ProjectEditorResources.CONSTANTS.Stateful();
            } else if (kSessionModel.getType().equals("stateful")) {
                return ProjectEditorResources.CONSTANTS.Stateful();
            } else if (kSessionModel.getType().equals("stateless")) {
                return ProjectEditorResources.CONSTANTS.Stateless();
            } else {
                return kSessionModel.getType();
            }
        }
    };

    column.setFieldUpdater(new FieldUpdater<KSessionModel, String>() {
        @Override
        public void update(int index, KSessionModel model, String value) {
            if (value.equals(ProjectEditorResources.CONSTANTS.Stateful())) {
                model.setType("stateful");
            } else {
                model.setType("stateless");
            }
        }
    });

    dataGrid.addColumn(column, ProjectEditorResources.CONSTANTS.State());
    dataGrid.setColumnWidth(column, 60, Style.Unit.PCT);
}

From source file:org.kie.workbench.common.screens.projecteditor.client.forms.KSessionsPanelViewImpl.java

License:Apache License

private void setUpDefaultColumn() {
    Column<KSessionModel, Boolean> column = new Column<KSessionModel, Boolean>(new CheckboxCell()) {
        @Override/*from   w w  w .j a  v  a  2s.  c  o m*/
        public Boolean getValue(KSessionModel model) {
            return model.isDefault();
        }
    };

    column.setFieldUpdater(new FieldUpdater<KSessionModel, Boolean>() {
        @Override
        public void update(int index, KSessionModel model, Boolean value) {
            model.setDefault(value);
            presenter.onDefaultChanged(model);
        }
    });

    column.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);

    dataGrid.addColumn(column, ProjectEditorResources.CONSTANTS.Default());
    dataGrid.setColumnWidth(column, 80, Style.Unit.PX);
}

From source file:org.kie.workbench.common.screens.projecteditor.client.forms.KSessionsPanelViewImpl.java

License:Apache License

private void setUpOptionsColumn() {
    final ButtonCell typeImageCell = new ButtonCell(ButtonType.DEFAULT, IconType.EDIT);
    final Column<KSessionModel, String> column = new Column<KSessionModel, String>(typeImageCell) {
        @Override// w  ww. j  av a  2s .c  o m
        public String getValue(KSessionModel model) {
            return "";
        }
    };

    column.setFieldUpdater(new FieldUpdater<KSessionModel, String>() {
        @Override
        public void update(int index, KSessionModel model, String value) {
            presenter.onOptionsSelectedForKSessions(model);
        }
    });

    column.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);

    dataGrid.addColumn(column, CommonConstants.INSTANCE.Edit());
    dataGrid.setColumnWidth(column, 60, Style.Unit.PX);
}