List of usage examples for com.google.gwt.user.cellview.client Column setFieldUpdater
public void setFieldUpdater(FieldUpdater<T, C> fieldUpdater)
From source file:org.eclipse.che.ide.ext.openshift.client.service.add.wizard.page.configure.ConfigureServiceViewImpl.java
License:Open Source License
private CellTable<Parameter> createVariablesTable(final CellTableResources tableResources) { envVariablesTable = new CellTable<>(50, tableResources); envVariablesTable.setTableLayoutFixed(true); envVariablesTable.setKeyboardSelectionPolicy(HasKeyboardSelectionPolicy.KeyboardSelectionPolicy.DISABLED); envVariablesProvider.addDataDisplay(envVariablesTable); Column<Parameter, String> nameColumn = new Column<Parameter, String>(new TextCell()) { @Override/* ww w . ja v a2 s . c o m*/ public String getValue(Parameter parameter) { return parameter.getName(); } }; TextInputCellWithPlaceHolder variablesCell = new TextInputCellWithPlaceHolder( locale.environmentVarialbesValuePlaceholder()); Column<Parameter, String> valueColumn = new Column<Parameter, String>(variablesCell) { @Override public void onBrowserEvent(Cell.Context context, Element elem, Parameter parameter, NativeEvent event) { super.onBrowserEvent(context, elem, parameter, event); if (event.getType().equals(BrowserEvents.KEYUP)) { TextInputCellWithPlaceHolder cell = (TextInputCellWithPlaceHolder) envVariablesTable .getColumn(context.getColumn()).getCell(); String newValue = cell.getViewData(context.getKey()).getCurrentValue(); if (parameter.getGenerate() == null && Strings.isNullOrEmpty(newValue)) { elem.getParentElement().addClassName(resources.css().applicationTableError()); } else { elem.getParentElement().removeClassName(resources.css().applicationTableError()); } getFieldUpdater().update(context.getIndex(), parameter, newValue); delegate.updateControls(); } } @Override public String getCellStyleNames(Cell.Context context, Parameter parameter) { if (parameter != null && parameter.getGenerate() == null && Strings.isNullOrEmpty(parameter.getValue())) { return resources.css().applicationTableError(); } return null; } @Override public void render(Cell.Context context, Parameter parameter, SafeHtmlBuilder sb) { if (parameter.getGenerate() == null) { String value = parameter.getValue() == null ? "" : parameter.getValue(); sb.append(template.input(value)); } else { super.render(context, parameter, sb); } } @Override public String getValue(Parameter parameter) { return parameter.getValue(); } }; valueColumn.setFieldUpdater(new FieldUpdater<Parameter, String>() { @Override public void update(int index, Parameter parameter, String value) { parameter.setValue(value); delegate.updateControls(); } }); envVariablesTable.addColumn(nameColumn); envVariablesTable.setColumnWidth(nameColumn, 15, Style.Unit.PCT); envVariablesTable.addColumn(valueColumn); envVariablesTable.setColumnWidth(valueColumn, 20, Style.Unit.PCT); return envVariablesTable; }
From source file:org.eclipse.che.ide.ext.openshift.client.service.add.wizard.page.configure.ConfigureServiceViewImpl.java
License:Open Source License
private CellTable<KeyValue> createLabelsTable(CellTableResources tableResources, final Predicate<String> labelValidator) { labelsTable = new CellTable<>(50, tableResources); labelsTable.setTableLayoutFixed(true); labelsTable.setKeyboardSelectionPolicy(HasKeyboardSelectionPolicy.KeyboardSelectionPolicy.DISABLED); labelsProvider.addDataDisplay(labelsTable); final ValidatedInputCell keyTextInputCell = new ValidatedInputCell(labelValidator, locale.labelNamePlaceholder()); final Column<KeyValue, String> keyColumn = new Column<KeyValue, String>(keyTextInputCell) { @Override//from ww w . j a va2 s. c o m public String getCellStyleNames(Cell.Context context, KeyValue keyValue) { if (!labelValidator.apply(keyValue.getKey())) { return resources.css().applicationTableError(); } return null; } @Override public String getValue(KeyValue keyValue) { return keyValue.getKey(); } }; keyColumn.setFieldUpdater(new FieldUpdater<KeyValue, String>() { @Override public void update(int index, KeyValue keyValue, String value) { keyValue.setKey(value); delegate.updateControls(); } }); ValidatedInputCell valueTextInputCell = new ValidatedInputCell(labelValidator, locale.labelValuePlaceholder()); Column<KeyValue, String> valueColumn = new Column<KeyValue, String>(valueTextInputCell) { @Override public String getCellStyleNames(Cell.Context context, KeyValue keyValue) { if (!labelValidator.apply(keyValue.getValue())) { return resources.css().applicationTableError(); } return null; } @Override public String getValue(KeyValue keyValue) { return keyValue.getValue(); } }; valueColumn.setFieldUpdater(new FieldUpdater<KeyValue, String>() { @Override public void update(int index, KeyValue keyValue, String value) { keyValue.setValue(value); delegate.updateControls(); } }); Column<KeyValue, String> removeColumn = new Column<KeyValue, String>(new ButtonCell()) { @Override public String getValue(KeyValue value) { return "-"; } @Override public void render(Cell.Context context, KeyValue keyValue, SafeHtmlBuilder sb) { Button removeButton = new Button(); super.render(context, keyValue, sb.appendHtmlConstant(removeButton.getHTML())); } }; removeColumn.setFieldUpdater(new FieldUpdater<KeyValue, String>() { @Override public void update(int index, KeyValue keyValue, String value) { labelsProvider.getList().remove(keyValue); labelsProvider.refresh(); delegate.updateControls(); } }); labelsTable.addColumn(keyColumn); labelsTable.setColumnWidth(keyColumn, 20, Style.Unit.PCT); labelsTable.addColumn(valueColumn); labelsTable.setColumnWidth(valueColumn, 20, Style.Unit.PCT); labelsTable.addColumn(removeColumn); labelsTable.setColumnWidth(removeColumn, 1, Style.Unit.PCT); removeColumn.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER); return labelsTable; }
From source file:org.eclipse.che.ide.ext.ssh.client.manage.SshKeyManagerViewImpl.java
License:Open Source License
/** Creates table what contains list of available ssh keys. */ private void initSshKeyTable(final CellTable.Resources res) { keys = new CellTable<>(20, res); Column<SshPairDto, String> hostColumn = new Column<SshPairDto, String>(new TextCell()) { @Override/*from w w w .j av a 2 s .c o m*/ public String getValue(SshPairDto object) { return object.getName(); } @Override public void render(Context context, SshPairDto object, SafeHtmlBuilder sb) { sb.appendHtmlConstant("<div id=\"" + UIObject.DEBUG_ID_PREFIX + "-sshKeys-cellTable-title-" + context.getIndex() + "\">"); super.render(context, object, sb); } }; hostColumn.setSortable(true); Column<SshPairDto, String> publicKeyColumn = new Column<SshPairDto, String>(new ButtonCell()) { @Override public String getValue(SshPairDto object) { return "View"; } @Override public void render(Context context, SshPairDto object, SafeHtmlBuilder sb) { sb.appendHtmlConstant("<div id=\"" + UIObject.DEBUG_ID_PREFIX + "-sshKeys-cellTable-key-" + context.getIndex() + "\">"); if (object != null && object.getPublicKey() != null) { super.render(context, object, sb); } } }; // Creates handler on button clicked publicKeyColumn.setFieldUpdater(new FieldUpdater<SshPairDto, String>() { @Override public void update(int index, SshPairDto object, String value) { delegate.onViewClicked(object); } }); Column<SshPairDto, String> deleteKeyColumn = new Column<SshPairDto, String>(new ButtonCell()) { @Override public String getValue(SshPairDto object) { return "Delete"; } @Override public void render(Context context, SshPairDto object, SafeHtmlBuilder sb) { sb.appendHtmlConstant("<div id=\"" + UIObject.DEBUG_ID_PREFIX + "-sshKeys-cellTable-delete-" + context.getIndex() + "\">"); super.render(context, object, sb); } }; // Creates handler on button clicked deleteKeyColumn.setFieldUpdater(new FieldUpdater<SshPairDto, String>() { @Override public void update(int index, SshPairDto object, String value) { delegate.onDeleteClicked(object); } }); keys.addColumn(hostColumn, "Title"); keys.addColumn(publicKeyColumn, "Public Key"); keys.addColumn(deleteKeyColumn, "Delete"); keys.setColumnWidth(hostColumn, 50, Style.Unit.PCT); keys.setColumnWidth(publicKeyColumn, 30, Style.Unit.PX); keys.setColumnWidth(deleteKeyColumn, 30, Style.Unit.PX); // don't show loading indicator keys.setLoadingIndicator(null); }
From source file:org.eclipse.che.plugin.docker.ext.client.manage.CredentialsPreferencesViewImpl.java
License:Open Source License
private void initCredentialsTable(CellTable.Resources res) { keys = new CellTable<>(15, res); Column<AuthConfig, String> serverAddressColumn = new Column<AuthConfig, String>(new TextCell()) { @Override/* w ww . j a v a 2s. c o m*/ public String getValue(AuthConfig object) { return object.getServeraddress(); } @Override public void render(Cell.Context context, AuthConfig object, SafeHtmlBuilder sb) { sb.appendHtmlConstant("<div id=\"" + UIObject.DEBUG_ID_PREFIX + "preferences-docker-credentials-cellTable-serveraddress-" + context.getIndex() + "\">"); super.render(context, object, sb); } }; serverAddressColumn.setSortable(true); Column<AuthConfig, String> editColumn = new Column<AuthConfig, String>(new ButtonCell()) { @Override public String getValue(AuthConfig object) { return "Edit"; } @Override public void render(Cell.Context context, AuthConfig object, SafeHtmlBuilder sb) { if (object != null) { sb.appendHtmlConstant("<div id=\"" + UIObject.DEBUG_ID_PREFIX + "preferences-docker-credentials-cellTable-edit-" + context.getIndex() + "\">"); super.render(context, object, sb); } } }; // Creates handler on button clicked editColumn.setFieldUpdater(new FieldUpdater<AuthConfig, String>() { @Override public void update(int index, AuthConfig object, String value) { delegate.onEditClicked(object); } }); Column<AuthConfig, String> deleteColumn = new Column<AuthConfig, String>(new ButtonCell()) { @Override public String getValue(AuthConfig object) { return "Delete"; } @Override public void render(Cell.Context context, AuthConfig object, SafeHtmlBuilder sb) { if (object != null) { sb.appendHtmlConstant("<div id=\"" + UIObject.DEBUG_ID_PREFIX + "preferences-docker-credentials-cellTable-delete-" + context.getIndex() + "\">"); super.render(context, object, sb); } } }; // Creates handler on button clicked deleteColumn.setFieldUpdater(new FieldUpdater<AuthConfig, String>() { @Override public void update(int index, AuthConfig object, String value) { delegate.onDeleteClicked(object); } }); keys.addColumn(serverAddressColumn, "Server Address"); keys.addColumn(editColumn, "");//Do not show label for edit column keys.addColumn(deleteColumn, "");//Do not show label for delete column keys.setColumnWidth(serverAddressColumn, 70, Style.Unit.PCT); keys.setColumnWidth(editColumn, 20, Style.Unit.PX); keys.setColumnWidth(deleteColumn, 20, Style.Unit.PX); // don't show loading indicator keys.setLoadingIndicator(null); }
From source file:org.eclipse.che.plugin.ssh.key.client.manage.SshKeyManagerViewImpl.java
License:Open Source License
/** Creates table what contains list of available ssh keys. */ private void initSshKeyTable(final CellTable.Resources res) { keys = new CellTable<>(15, res); Column<SshPairDto, String> hostColumn = new Column<SshPairDto, String>(new TextCell()) { @Override/*from www . j a va 2 s. c om*/ public String getValue(SshPairDto object) { return object.getName(); } @Override public void render(Context context, SshPairDto object, SafeHtmlBuilder sb) { sb.appendHtmlConstant("<div id=\"" + UIObject.DEBUG_ID_PREFIX + "-sshKeys-cellTable-host-" + context.getIndex() + "\">"); super.render(context, object, sb); } }; hostColumn.setSortable(true); Column<SshPairDto, String> publicKeyColumn = new Column<SshPairDto, String>(new ButtonCell()) { @Override public String getValue(SshPairDto object) { return "View"; } @Override public void render(Context context, SshPairDto object, SafeHtmlBuilder sb) { sb.appendHtmlConstant("<div id=\"" + UIObject.DEBUG_ID_PREFIX + "-sshKeys-cellTable-key-" + context.getIndex() + "\">"); if (object != null && object.getPublicKey() != null) { super.render(context, object, sb); } } }; // Creates handler on button clicked publicKeyColumn.setFieldUpdater(new FieldUpdater<SshPairDto, String>() { @Override public void update(int index, SshPairDto object, String value) { delegate.onViewClicked(object); } }); Column<SshPairDto, String> deleteKeyColumn = new Column<SshPairDto, String>(new ButtonCell()) { @Override public String getValue(SshPairDto object) { return "Delete"; } @Override public void render(Context context, SshPairDto object, SafeHtmlBuilder sb) { sb.appendHtmlConstant("<div id=\"" + UIObject.DEBUG_ID_PREFIX + "-sshKeys-cellTable-delete-" + context.getIndex() + "\">"); super.render(context, object, sb); } }; // Creates handler on button clicked deleteKeyColumn.setFieldUpdater(new FieldUpdater<SshPairDto, String>() { @Override public void update(int index, SshPairDto object, String value) { delegate.onDeleteClicked(object); } }); keys.addColumn(hostColumn, "Host"); keys.addColumn(publicKeyColumn, "Public Key"); keys.addColumn(deleteKeyColumn, "Delete"); keys.setColumnWidth(hostColumn, 50, Style.Unit.PCT); keys.setColumnWidth(publicKeyColumn, 30, Style.Unit.PX); keys.setColumnWidth(deleteKeyColumn, 30, Style.Unit.PX); // don't show loading indicator keys.setLoadingIndicator(null); }
From source file:org.eclipse.che.plugin.yaml.ide.preferences.YamlExtensionManagerViewImpl.java
License:Open Source License
/** * Creates table which contains list of available preferences * * @param res Celltable resources//from w ww .j a v a 2 s. c o m */ private void initYamlExtensionTable(final CellTable.Resources res) { yamlPreferenceCellTable = new CellTable<YamlPreference>(20, res); Column<YamlPreference, String> urlColumn = new Column<YamlPreference, String>(new EditTextCell()) { @Override public String getValue(YamlPreference object) { return object.getUrl(); } @Override public void render(Context context, YamlPreference object, SafeHtmlBuilder sb) { sb.appendHtmlConstant("<div id=\"" + UIObject.DEBUG_ID_PREFIX + "-preferences-cellTable-url-" + context.getIndex() + "\">"); super.render(context, object, sb); } }; urlColumn.setFieldUpdater(new FieldUpdater<YamlPreference, String>() { @Override public void update(int index, YamlPreference object, String value) { object.setUrl(value); delegate.nowDirty(); } }); Column<YamlPreference, String> globColumn = new Column<YamlPreference, String>(new EditTextCell()) { @Override public String getValue(YamlPreference object) { return object.getGlob(); } @Override public void render(Context context, YamlPreference object, SafeHtmlBuilder sb) { sb.appendHtmlConstant("<div id=\"" + UIObject.DEBUG_ID_PREFIX + "-preferences-cellTable-glob-" + context.getIndex() + "\">"); if (object != null) { super.render(context, object, sb); } } }; globColumn.setFieldUpdater(new FieldUpdater<YamlPreference, String>() { @Override public void update(int index, YamlPreference object, String value) { object.setGlob(value); delegate.nowDirty(); } }); Column<YamlPreference, String> deletePreferenceColumn = new Column<YamlPreference, String>( new ButtonCell()) { @Override public String getValue(YamlPreference object) { return "Delete"; } @Override public void render(Context context, YamlPreference object, SafeHtmlBuilder sb) { sb.appendHtmlConstant("<div id=\"" + UIObject.DEBUG_ID_PREFIX + "-preferences-cellTable-delete-" + context.getIndex() + "\">"); super.render(context, object, sb); } }; // Creates handler on button clicked deletePreferenceColumn.setFieldUpdater(new FieldUpdater<YamlPreference, String>() { @Override public void update(int index, YamlPreference object, String value) { delegate.onDeleteClicked(object); } }); yamlPreferenceCellTable.addColumn(urlColumn, local.urlColumnHeader()); yamlPreferenceCellTable.addColumn(globColumn, local.globColumnHeader()); yamlPreferenceCellTable.addColumn(deletePreferenceColumn, local.deleteColumnHeader()); yamlPreferenceCellTable.setWidth("100%", true); yamlPreferenceCellTable.setColumnWidth(urlColumn, 45, Style.Unit.PCT); yamlPreferenceCellTable.setColumnWidth(globColumn, 30, Style.Unit.PCT); yamlPreferenceCellTable.setColumnWidth(deletePreferenceColumn, 25, Style.Unit.PCT); // don't show loading indicator yamlPreferenceCellTable.setLoadingIndicator(null); }
From source file:org.eclipse.kura.web.client.ui.Network.TabWirelessUi.java
License:Open Source License
private void initGrid() { // CHECKBOXES Column<GwtWifiChannelModel, Boolean> checkColumn = new Column<GwtWifiChannelModel, Boolean>( new CheckboxCell()) { @Override//w w w. ja v a 2 s . c o m public Boolean getValue(GwtWifiChannelModel object) { return TabWirelessUi.this.channelGrid.getSelectionModel().isSelected(object); } }; checkColumn.setFieldUpdater(new FieldUpdater<GwtWifiChannelModel, Boolean>() { @Override public void update(int index, GwtWifiChannelModel object, Boolean value) { TabWirelessUi.this.channelGrid.getSelectionModel().setSelected(object, value); TabWirelessUi.this.channelDataProvider.refresh(); } }); checkColumn.setCellStyleNames("status-table-row"); this.channelGrid.addColumn(checkColumn); // ALL AVAILABLE CHANNELS TextColumn<GwtWifiChannelModel> col1 = new TextColumn<GwtWifiChannelModel>() { @Override public String getValue(GwtWifiChannelModel object) { return object.getName(); } }; col1.setCellStyleNames("status-table-row"); this.channelGrid.addColumn(col1, "All Available Channels"); // FREQUENCY TextColumn<GwtWifiChannelModel> col2 = new TextColumn<GwtWifiChannelModel>() { @Override public String getValue(GwtWifiChannelModel object) { return String.valueOf(object.getFrequency()); } }; col2.setCellStyleNames("status-table-row"); this.channelGrid.addColumn(col2, "Frequency (MHz)"); // SPECTRUM BAND TextColumn<GwtWifiChannelModel> col3 = new TextColumn<GwtWifiChannelModel>() { @Override public String getValue(GwtWifiChannelModel object) { return String.valueOf(object.getBand()); } }; col3.setCellStyleNames("status-table-row"); this.channelGrid.addColumn(col3, "Frequency (MHz)"); this.channelGrid.setSelectionModel(this.selectionModel); this.channelDataProvider.addDataDisplay(this.channelGrid); loadChannelData(); }
From source file:org.guvnor.ala.ui.client.wizard.container.ContainerConfigParamsView.java
License:Apache License
private void addRemoveRowColumn() { ButtonCell buttonCell = new ButtonCell(IconType.TRASH, ButtonType.DANGER, ButtonSize.SMALL); Column<ContainerConfig, String> column = new Column<ContainerConfig, String>(buttonCell) { @Override// w ww. j a v a2 s . c om public String getValue(ContainerConfig containerConfig) { return translationService.getTranslation(ContainerConfigParamsView_Delete); } }; column.setFieldUpdater((index, containerConfig, value) -> presenter.onDeleteContainer(containerConfig)); dataGrid.addColumn(column, ""); dataGrid.setColumnWidth(column, 90, Style.Unit.PX); }
From source file:org.guvnor.ala.ui.openshift.client.pipeline.template.table.TemplateParamsTableView.java
License:Apache License
private void addParamValueColumn() { final Column<TemplateParam, String> column = new Column<TemplateParam, String>(new EditTextCell()) { @Override/*from ww w . j a v a2 s .co m*/ public String getValue(TemplateParam templateParam) { if (templateParam.getValue() != null) { return templateParam.getValue(); } else { return EMPTY_STRING; } } }; column.setFieldUpdater(new ParamValueFieldUpdater((EditTextCell) column.getCell())); dataGrid.addColumn(column, translationService.getTranslation(TemplateParamsTableView_ParamValueColumn)); dataGrid.setColumnWidth(column, 55, Style.Unit.PCT); }
From source file:org.guvnor.asset.management.client.editors.project.structure.widgets.ProjectModulesViewImpl.java
License:Apache License
private void addDeleteModuleColumn() { final ButtonCell deleteModuleButton = new ButtonCell(IconType.TRASH, ButtonType.DANGER, ButtonSize.SMALL); final Column<ProjectModuleRow, String> deleteModuleColumn = new Column<ProjectModuleRow, String>( deleteModuleButton) {//w ww . j a va 2s . c o m @Override public String getValue(final ProjectModuleRow moduleRow) { return Constants.INSTANCE.DeleteModule(); } }; deleteModuleColumn.setFieldUpdater(new FieldUpdater<ProjectModuleRow, String>() { public void update(final int index, final ProjectModuleRow moduleRow, final String value) { if (presenter != null && actionsEnabled) { presenter.onDeleteModule(moduleRow); } } }); modulesTable.addColumn(deleteModuleColumn, ""); modulesTable.setColumnWidth(deleteModuleColumn, 15, Style.Unit.PCT); }