List of usage examples for com.google.gwt.user.cellview.client Column setFieldUpdater
public void setFieldUpdater(FieldUpdater<T, C> fieldUpdater)
From source file:org.drools.guvnor.client.widgets.tables.PropertiesEditorSimpleTable.java
License:Apache License
@Override protected void addAncillaryColumns(ColumnPicker<PropertyHolderAdaptor> columnPicker, SortableHeaderGroup<PropertyHolderAdaptor> sortableHeaderGroup) { Column<PropertyHolderAdaptor, String> propertyNameColumn = new Column<PropertyHolderAdaptor, String>( new PopupTextEditCell()) { @Override/* w w w . ja v a 2 s . c o m*/ public String getValue(PropertyHolderAdaptor object) { return object.getName(); } }; propertyNameColumn.setFieldUpdater(new FieldUpdater<PropertyHolderAdaptor, String>() { public void update(int index, PropertyHolderAdaptor object, String value) { object.setName(value); } }); columnPicker.addColumn(propertyNameColumn, new SortableHeader<PropertyHolderAdaptor, String>( sortableHeaderGroup, constants.Item(), propertyNameColumn), true); Column<PropertyHolderAdaptor, String> propertyValueColumn = new Column<PropertyHolderAdaptor, String>( new PopupTextEditCell()) { @Override public String getValue(PropertyHolderAdaptor object) { return object.getValue(); } }; propertyValueColumn.setFieldUpdater(new FieldUpdater<PropertyHolderAdaptor, String>() { public void update(int index, PropertyHolderAdaptor object, String value) { object.setValue(value); } }); columnPicker.addColumn(propertyValueColumn, new SortableHeader<PropertyHolderAdaptor, String>( sortableHeaderGroup, constants.Value(), propertyValueColumn), true); }
From source file:org.drools.guvnor.client.widgets.tables.SnapshotComparisonPagedTable.java
License:Apache License
@Override protected void doCellTable() { ProvidesKey<SnapshotComparisonPageRow> providesKey = new ProvidesKey<SnapshotComparisonPageRow>() { public Object getKey(SnapshotComparisonPageRow row) { return row.getDiff().leftUuid; }//from w w w .j a v a 2s . co m }; cellTable = new CellTable<SnapshotComparisonPageRow>(providesKey); selectionModel = new MultiSelectionModel<SnapshotComparisonPageRow>(providesKey); cellTable.setSelectionModel(selectionModel); SelectionColumn.createAndAddSelectionColumn(cellTable); ColumnPicker<SnapshotComparisonPageRow> columnPicker = new ColumnPicker<SnapshotComparisonPageRow>( cellTable); SortableHeaderGroup<SnapshotComparisonPageRow> sortableHeaderGroup = new SortableHeaderGroup<SnapshotComparisonPageRow>( cellTable); final TextColumn<SnapshotComparisonPageRow> uuidNumberColumn = new TextColumn<SnapshotComparisonPageRow>() { public String getValue(SnapshotComparisonPageRow row) { return row.getDiff().rightUuid; } }; columnPicker.addColumn(uuidNumberColumn, new SortableHeader<SnapshotComparisonPageRow, String>( sortableHeaderGroup, constants.uuid(), uuidNumberColumn), false); // Add any additional columns addAncillaryColumns(columnPicker, sortableHeaderGroup); // Add "Open" button column Column<SnapshotComparisonPageRow, String> openColumn = new Column<SnapshotComparisonPageRow, String>( new ButtonCell()) { public String getValue(SnapshotComparisonPageRow row) { return constants.Open(); } }; openColumn.setFieldUpdater(new FieldUpdater<SnapshotComparisonPageRow, String>() { public void update(int index, SnapshotComparisonPageRow row, String value) { openSelectedCommand.open(row.getDiff().rightUuid); } }); columnPicker.addColumn(openColumn, new TextHeader(constants.Open()), true); cellTable.setWidth("100%"); columnPickerButton = columnPicker.createToggleButton(); }
From source file:org.drools.workbench.screens.enums.client.editor.EnumEditorViewImpl.java
License:Apache License
@PostConstruct public void init() { final CellTable<EnumRow> cellTable = new CellTable<EnumRow>(Integer.MAX_VALUE); cellTable.setStriped(true);/* w w w . j av a2 s . co m*/ cellTable.setCondensed(true); cellTable.setBordered(true); cellTable.setEmptyTableWidget(new Label(EnumEditorConstants.INSTANCE.noEnumsDefined())); cellTable.setWidth("100%"); final VerticalPanel panel = new VerticalPanel(); panel.setWidth("100%"); //Column definitions final Column<EnumRow, String> factNameColumn = new Column<EnumRow, String>(new EditTextCell()) { @Override public String getValue(final EnumRow enumRow) { return enumRow.getFactName(); } }; final Column<EnumRow, String> fieldNameColumn = new Column<EnumRow, String>(new EditTextCell()) { @Override public String getValue(final EnumRow enumRow) { return enumRow.getFieldName(); } }; final Column<EnumRow, String> contextColumn = new Column<EnumRow, String>(new EditTextCell()) { @Override public String getValue(final EnumRow enumRow) { return enumRow.getContext(); } }; //See https://bugzilla.redhat.com/show_bug.cgi?id=1167360 //Replaced image-based ButtonCell with a button due to IE10 interpreting it as a form-submit button and hence responding to ENTER key presses. //See http://stackoverflow.com/questions/12325066/button-click-event-fires-when-pressing-enter-key-in-different-input-no-forms final ButtonCell deleteEnumButton = new ButtonCell(ButtonSize.SMALL); deleteEnumButton.setType(ButtonType.DANGER); deleteEnumButton.setIcon(IconType.MINUS_SIGN); final Column<EnumRow, String> deleteEnumColumn = new Column<EnumRow, String>(deleteEnumButton) { @Override public String getValue(final EnumRow global) { return EnumEditorConstants.INSTANCE.remove(); } }; //Write updates back to the model deleteEnumColumn.setFieldUpdater(new FieldUpdater<EnumRow, String>() { @Override public void update(final int index, final EnumRow object, final String value) { dataProvider.getList().remove(index); } }); factNameColumn.setFieldUpdater(new FieldUpdater<EnumRow, String>() { @Override public void update(final int index, final EnumRow object, final String value) { object.setFactName(value); } }); fieldNameColumn.setFieldUpdater(new FieldUpdater<EnumRow, String>() { @Override public void update(final int index, final EnumRow object, final String value) { object.setFieldName(value); } }); contextColumn.setFieldUpdater(new FieldUpdater<EnumRow, String>() { @Override public void update(final int index, final EnumRow object, final String value) { object.setContext(value); } }); cellTable.addColumn(factNameColumn, EnumEditorConstants.INSTANCE.FactColumnHeader()); cellTable.addColumn(fieldNameColumn, EnumEditorConstants.INSTANCE.FieldColumnHeader()); cellTable.addColumn(contextColumn, EnumEditorConstants.INSTANCE.ContextColumnHeader()); cellTable.addColumn(deleteEnumColumn); // Connect the table to the data provider. dataProvider.addDataDisplay(cellTable); final Button addButton = new Button(EnumEditorConstants.INSTANCE.AddEnum(), new ClickHandler() { public void onClick(ClickEvent clickEvent) { final EnumRow enumRow = new EnumRow(); dataProvider.getList().add(enumRow); } }); panel.add(addButton); panel.add(cellTable); initWidget(panel); }
From source file:org.drools.workbench.screens.guided.scorecard.client.widget.GuidedScoreCardEditor.java
License:Apache License
private Widget addAttributeCellTable(final FlexTable cGrid, final Characteristic characteristic, final boolean enumColumn, final String dataType, final List<String> operators) { String[] enumValues = null;/*w w w. ja v a2 s .co m*/ if (characteristic != null) { //enum values if (enumColumn) { String factName = characteristic.getFact(); String fieldName = characteristic.getField(); enumValues = oracle.getEnumValues(factName, fieldName); } } final CellTable<Attribute> attributeCellTable = new CellTable<Attribute>(); //Operators column final DynamicSelectionCell categoryCell = new DynamicSelectionCell(operators); final Column<Attribute, String> operatorColumn = new Column<Attribute, String>(categoryCell) { public String getValue(final Attribute object) { return object.getOperator(); } }; operatorColumn.setFieldUpdater(new FieldUpdater<Attribute, String>() { public void update(int index, Attribute object, String value) { object.setOperator(value); attributeCellTable.redraw(); } }); //Value column Column<Attribute, String> valueColumn = null; if (enumValues != null && enumValues.length > 0) { valueColumn = new Column<Attribute, String>(new DynamicSelectionCell(Arrays.asList(enumValues))) { public String getValue(final Attribute object) { return object.getValue(); } }; valueColumn.setFieldUpdater(new FieldUpdater<Attribute, String>() { public void update(int index, Attribute object, String value) { object.setValue(value); attributeCellTable.redraw(); } }); } if (valueColumn == null) { valueColumn = new Column<Attribute, String>(new CustomEditTextCell()) { public String getValue(final Attribute attribute) { return attribute.getValue(); } }; valueColumn.setFieldUpdater(new FieldUpdater<Attribute, String>() { public void update(int index, Attribute object, String value) { object.setValue(value); attributeCellTable.redraw(); } }); } //Partial Score column final EditTextCell partialScoreCell = new EditTextCell(); final Column<Attribute, String> partialScoreColumn = new Column<Attribute, String>(partialScoreCell) { public String getValue(final Attribute attribute) { return "" + attribute.getPartialScore(); } }; partialScoreColumn.setFieldUpdater(new FieldUpdater<Attribute, String>() { public void update(int index, Attribute object, String value) { try { double d = Double.parseDouble(value); object.setPartialScore(d); } catch (Exception e1) { partialScoreCell.clearViewData(object); } attributeCellTable.redraw(); } }); //Reason Code column final Column<Attribute, String> reasonCodeColumn = new Column<Attribute, String>(new EditTextCell()) { public String getValue(final Attribute attribute) { return attribute.getReasonCode(); } }; reasonCodeColumn.setFieldUpdater(new FieldUpdater<Attribute, String>() { public void update(int index, Attribute object, String value) { object.setReasonCode(value); attributeCellTable.redraw(); } }); final ActionCell.Delegate<Attribute> delegate = new ActionCell.Delegate<Attribute>() { public void execute(final Attribute attribute) { if (Window.confirm(GuidedScoreCardConstants.INSTANCE.promptDeleteAttribute())) { final List<Attribute> list = characteristicsAttrMap.get(cGrid).getList(); list.remove(attribute); if ("boolean".equalsIgnoreCase(dataType)) { ((Button) cGrid.getWidget(0, 3)).setEnabled(list.size() != 2); } attributeCellTable.redraw(); } } }; final Cell<Attribute> actionCell = new ActionCell<Attribute>(GuidedScoreCardConstants.INSTANCE.remove(), delegate); final Column<Attribute, String> actionColumn = new IdentityColumn(actionCell); // Add the columns. attributeCellTable.addColumn(operatorColumn, GuidedScoreCardConstants.INSTANCE.operator()); attributeCellTable.addColumn(valueColumn, GuidedScoreCardConstants.INSTANCE.value()); attributeCellTable.addColumn(partialScoreColumn, GuidedScoreCardConstants.INSTANCE.partialScore()); attributeCellTable.addColumn(reasonCodeColumn, GuidedScoreCardConstants.INSTANCE.reasonCode()); attributeCellTable.addColumn(actionColumn, GuidedScoreCardConstants.INSTANCE.actions()); attributeCellTable.setWidth("100%", true); attributeCellTable.setColumnWidth(operatorColumn, 20.0, Style.Unit.PCT); attributeCellTable.setColumnWidth(valueColumn, 20.0, Style.Unit.PCT); attributeCellTable.setColumnWidth(partialScoreColumn, 20.0, Style.Unit.PCT); attributeCellTable.setColumnWidth(reasonCodeColumn, 20.0, Style.Unit.PCT); attributeCellTable.setColumnWidth(actionColumn, 20.0, Style.Unit.PCT); ListDataProvider<Attribute> dataProvider = new ListDataProvider<Attribute>(); dataProvider.addDataDisplay(attributeCellTable); characteristicsAttrMap.put(cGrid, dataProvider); if ("boolean".equalsIgnoreCase(dataType)) { CustomEditTextCell etc = (CustomEditTextCell) attributeCellTable.getColumn(1).getCell(); etc.setEnabled(false); } return (attributeCellTable); }
From source file:org.eclipse.che.ide.ext.datasource.client.newdatasource.connector.nuodb.NuoDBDatasourceConnectorViewImpl.java
License:Open Source License
@Inject public NuoDBDatasourceConnectorViewImpl(final NuoDBDatasourceViewImplUiBinder uiBinder, final DataGridResourcesInvisible dataGridResources, final NewDatasourceWizardMessages messages) { numberBoxStyle = dataGridResources.dataGridStyle().portNuoDb(); this.messages = messages; final ProvidesKey<NuoDBBroker> keyProvider = new ProvidesKey<NuoDBBroker>() { @Override//from w w w .j a va 2 s . c o m public Object getKey(final NuoDBBroker item) { return item.getId(); } }; brokerList = new DataGrid<NuoDBBroker>(20, dataGridResources, keyProvider); initWidget(uiBinder.createAndBindUi(this)); // first column : host final TextInputCell hostCell = new StyledTextInputCell(); Column<NuoDBBroker, String> hostColumn = new Column<NuoDBBroker, String>(hostCell) { @Override public String getValue(final NuoDBBroker broker) { return broker.getHost(); } }; hostColumn.setFieldUpdater(new FieldUpdater<NuoDBBroker, String>() { @Override public void update(final int index, final NuoDBBroker broker, final String value) { // update host value in model broker.setHost(value); } }); brokerList.addColumn(hostColumn, new TextHeader("Host")); // second column : port final TextInputCell portCell = new StyledNumberInputCell(); Column<NuoDBBroker, String> portColumn = new Column<NuoDBBroker, String>(portCell) { @Override public String getValue(final NuoDBBroker broker) { if (broker.getPort() != null) { return Integer.toString(broker.getPort()); } else { return ""; } } }; portColumn.setFieldUpdater(new FieldUpdater<NuoDBBroker, String>() { @Override public void update(final int index, final NuoDBBroker broker, final String value) { try { // update port value in model int port = Integer.parseInt(value); broker.setPort(port); } catch (final NumberFormatException e) { // invalid input, cancel change broker.setPort(null); portCell.clearViewData(broker.getId()); } brokerList.redraw(); } }); brokerList.addColumn(portColumn, new TextHeader("Port")); brokerList.addDomHandler(new Handler(), KeyPressEvent.getType()); // manage selection final MultiSelectionModel<NuoDBBroker> selectionModel = new MultiSelectionModel<>(keyProvider); brokerList.setSelectionModel(selectionModel); radioUserPref.setValue(true); radioProject.setEnabled(false); projectsList.setEnabled(false); projectsList.setWidth("100px"); }
From source file:org.eclipse.che.ide.ext.datasource.client.ssl.SslKeyStoreManagerViewImpl.java
License:Open Source License
protected void initSslKeyTable(CellTable.Resources res) { clientKeys = new CellTable<SslKeyStoreEntry>(15, res); addAliasColumn(clientKeys, locale.headerKeyList()); addTypeColumn(clientKeys, ""); Column<SslKeyStoreEntry, String> deleteColumn = addDeleteColumn(clientKeys, ""); // Creates handler on button clicked deleteColumn.setFieldUpdater(new FieldUpdater<SslKeyStoreEntry, String>() { @Override/* w w w. j a v a 2 s . co m*/ public void update(int index, SslKeyStoreEntry object, String value) { delegate.onClientKeyDeleteClicked(object); } }); // don't show loading indicator clientKeys.setLoadingIndicator(null); }
From source file:org.eclipse.che.ide.ext.datasource.client.ssl.SslKeyStoreManagerViewImpl.java
License:Open Source License
protected void initSslCertTable(CellTable.Resources res) { serverCerts = new CellTable<SslKeyStoreEntry>(15, res); addAliasColumn(serverCerts, locale.headerTrustList()); addTypeColumn(serverCerts, ""); Column<SslKeyStoreEntry, String> deleteColumn = addDeleteColumn(serverCerts, ""); // Creates handler on button clicked deleteColumn.setFieldUpdater(new FieldUpdater<SslKeyStoreEntry, String>() { @Override//from w w w. j a va2 s.c o m public void update(int index, SslKeyStoreEntry object, String value) { delegate.onServerCertDeleteClicked(object); } }); // don't show loading indicator serverCerts.setLoadingIndicator(null); }
From source file:org.eclipse.che.ide.ext.git.client.reset.files.ResetFilesViewImpl.java
License:Open Source License
/** Initialize the columns of the grid. */ private void initColumns() { indexFiles = new CellTable<IndexFile>(); // Create files column: Column<IndexFile, String> filesColumn = new Column<IndexFile, String>(new TextCell()) { @Override/*from w w w . j a va 2s . c om*/ public String getValue(IndexFile file) { return file.getPath(); } }; // Create column with checkboxes: Column<IndexFile, Boolean> checkColumn = new Column<IndexFile, Boolean>(new CheckboxCell(false, true)) { @Override public Boolean getValue(IndexFile file) { return !file.isIndexed(); } }; // Create bean value updater: FieldUpdater<IndexFile, Boolean> checkFieldUpdater = new FieldUpdater<IndexFile, Boolean>() { @Override public void update(int index, IndexFile file, Boolean value) { file.setIndexed(!value); } }; checkColumn.setFieldUpdater(checkFieldUpdater); filesColumn.setHorizontalAlignment(ALIGN_LEFT); indexFiles.addColumn(checkColumn, new SafeHtml() { @Override public String asString() { return " "; } }); indexFiles.setColumnWidth(checkColumn, 1, Style.Unit.PCT); indexFiles.addColumn(filesColumn, FILES); indexFiles.setColumnWidth(filesColumn, 35, Style.Unit.PCT); indexFiles.addStyleName(resources.gitCSS().cells()); }
From source file:org.eclipse.che.ide.ext.git.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<>(15, res); Column<SshPairDto, String> hostColumn = new Column<SshPairDto, String>(new TextCell()) { @Override//from ww w . ja va 2s .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 + "-gitSshKeys-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 + "-gitSshKeys-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 + "-gitSshKeys-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.ide.ext.openshift.client.deploy._new.NewApplicationViewImpl.java
License:Open Source License
private CellTable<KeyValue> createCellTable(CellTableResources cellTableResources, final ListDataProvider<KeyValue> dataProvider, final Predicate<String> keyValidator, final Predicate<String> valueValidator) { final CellTable<KeyValue> table = new CellTable<>(50, cellTableResources); table.setKeyboardSelectionPolicy(HasKeyboardSelectionPolicy.KeyboardSelectionPolicy.DISABLED); dataProvider.addDataDisplay(table);/* w w w .j av a 2s . c o m*/ TextInputCell keyCell = new TextInputCell() { @Override public void onBrowserEvent(Context context, com.google.gwt.dom.client.Element parent, String value, NativeEvent event, ValueUpdater<String> valueUpdater) { super.onBrowserEvent(context, parent, value, event, valueUpdater); if (event.getType().equals(BrowserEvents.KEYUP)) { String newValue = getInputElement(parent).getValue(); if (!keyValidator.apply(newValue)) { parent.getParentElement().addClassName(resources.css().deployApplicationTableError()); } else { parent.getParentElement().removeClassName(resources.css().deployApplicationTableError()); } valueUpdater.update(newValue); delegate.updateControls(); } } }; Column<KeyValue, String> nameColumn = new Column<KeyValue, String>(keyCell) { @Override public String getCellStyleNames(Cell.Context context, KeyValue object) { if (!keyValidator.apply(object.getKey())) { return resources.css().deployApplicationTableError(); } return null; } @Override public String getValue(KeyValue object) { return object.getKey(); } }; nameColumn.setFieldUpdater(new FieldUpdater<KeyValue, String>() { @Override public void update(int index, KeyValue object, String value) { object.setKey(value); } }); TextInputCell valueCell = new TextInputCell() { @Override public void onBrowserEvent(Cell.Context context, com.google.gwt.dom.client.Element parent, String value, NativeEvent event, ValueUpdater<String> valueUpdater) { super.onBrowserEvent(context, parent, value, event, valueUpdater); if (event.getType().equals(BrowserEvents.KEYUP)) { String newValue = getInputElement(parent).getValue(); if (!valueValidator.apply(newValue)) { parent.getParentElement().addClassName(resources.css().deployApplicationTableError()); } else { parent.getParentElement().removeClassName(resources.css().deployApplicationTableError()); } valueUpdater.update(newValue); delegate.updateControls(); } } }; Column<KeyValue, String> valueColumn = new Column<KeyValue, String>(valueCell) { @Override public String getCellStyleNames(Cell.Context context, KeyValue object) { if (!valueValidator.apply(object.getValue())) { return resources.css().deployApplicationTableError(); } return null; } @Override public String getValue(KeyValue object) { return object.getValue(); } }; valueColumn.setFieldUpdater(new FieldUpdater<KeyValue, String>() { @Override public void update(int index, KeyValue object, String value) { object.setValue(value); } }); Column<KeyValue, String> removeColumn = new Column<KeyValue, String>(new ButtonCell()) { @Override public String getValue(KeyValue object) { return "-"; } @Override public void render(Cell.Context context, KeyValue object, SafeHtmlBuilder sb) { Button removeButton = new Button(); super.render(context, object, sb.appendHtmlConstant(removeButton.getHTML())); } }; removeColumn.setFieldUpdater(new FieldUpdater<KeyValue, String>() { @Override public void update(int index, KeyValue object, String value) { dataProvider.getList().remove(object); delegate.updateControls(); } }); table.addColumn(nameColumn); table.setColumnWidth(nameColumn, 35, Style.Unit.PCT); table.addColumn(valueColumn); table.setColumnWidth(valueColumn, 55, Style.Unit.PCT); table.addColumn(removeColumn); table.setColumnWidth(removeColumn, 10, Style.Unit.PCT); removeColumn.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER); return table; }