List of usage examples for com.google.gwt.user.cellview.client Column setFieldUpdater
public void setFieldUpdater(FieldUpdater<T, C> fieldUpdater)
From source file:org.teiid.webui.client.widgets.table.ColumnNamesTable.java
License:Apache License
/** * Create the panel/*from w w w. j a v a2 s. co m*/ * @return the panel widget */ protected Widget createTablePanel() { table = new SimpleTable<CheckableNameTypeRow>(TABLE_HEIGHT_PX, TABLE_WIDTH_PX, TABLE_VISIBLE_ROWS); // Add Checkbox column Column<CheckableNameTypeRow, Boolean> checkboxColumn = new Column<CheckableNameTypeRow, Boolean>( new CheckboxCell(true, false)) { @Override public Boolean getValue(CheckableNameTypeRow object) { if (object == null) return false; return object.isChecked(); } }; checkboxColumn.setFieldUpdater(new FieldUpdater<CheckableNameTypeRow, Boolean>() { public void update(int index, CheckableNameTypeRow object, Boolean value) { object.setChecked(value); boolean allRowsSame = true; List<CheckableNameTypeRow> tableRows = table.getRowData(); boolean firstState = false; for (int i = 0; i < tableRows.size(); i++) { CheckableNameTypeRow row = tableRows.get(i); if (i == 0) { firstState = row.isChecked(); } else { boolean thisState = row.isChecked(); if (thisState != firstState) { allRowsSame = false; break; } } } if (allRowsSame) { cbHeader.setValue(firstState); } else { cbHeader.setValue(false); } table.redrawHeaders(); fireCheckboxEvent(); } }); // Checkbox Header cbHeader = createCBHeader(false); table.addColumn(checkboxColumn, cbHeader); table.setColumnWidth(checkboxColumn, 40, Unit.PX); // -------------- // Name Column // -------------- TextColumn<CheckableNameTypeRow> nameColumn = new TextColumn<CheckableNameTypeRow>() { public String getValue(CheckableNameTypeRow row) { return row.getName(); } }; table.addColumn(nameColumn, COLUMN_HEADER_NAME); table.setColumnWidth(nameColumn, 200, Unit.PX); VerticalPanel verticalPanel = new VerticalPanel(); verticalPanel.add(table); return verticalPanel; }
From source file:org.teiid.webui.client.widgets.table.TableNamesTable.java
License:Apache License
/** * Create the panel/*from ww w.j a v a 2 s. c o m*/ * @return the panel widget */ protected Widget createTablePanel() { table = new SimpleTable<CheckableNameTypeRow>(TABLE_HEIGHT_PX, TABLE_WIDTH_PX, TABLE_VISIBLE_ROWS); // Add Checkbox column Column<CheckableNameTypeRow, Boolean> checkboxColumn = new Column<CheckableNameTypeRow, Boolean>( checkboxCell) { @Override public Boolean getValue(CheckableNameTypeRow object) { if (object == null) return false; return object.isChecked(); } }; checkboxColumn.setFieldUpdater(new FieldUpdater<CheckableNameTypeRow, Boolean>() { public void update(int index, CheckableNameTypeRow object, Boolean value) { object.setChecked(value); boolean allRowsSame = true; List<CheckableNameTypeRow> tableRows = table.getRowData(); boolean firstState = false; for (int i = 0; i < tableRows.size(); i++) { CheckableNameTypeRow row = tableRows.get(i); if (i == 0) { firstState = row.isChecked(); } else { boolean thisState = row.isChecked(); if (thisState != firstState) { allRowsSame = false; break; } } } if (allRowsSame) { cbHeader.setValue(firstState); } else { cbHeader.setValue(false); } table.redrawHeaders(); fireCheckboxEvent(object.getName(), value); } }); // Checkbox Header cbHeader = createCBHeader(false); if (showHeader) { table.addColumn(checkboxColumn, cbHeader); } else { table.addColumn(checkboxColumn); } table.setColumnWidth(checkboxColumn, 40, Unit.PX); // -------------- // Name Column // -------------- TextColumn<CheckableNameTypeRow> nameColumn = new TextColumn<CheckableNameTypeRow>() { public String getValue(CheckableNameTypeRow row) { return row.getName(); } }; if (showHeader) { table.addColumn(nameColumn, COLUMN_HEADER_NAME); } else { table.addColumn(nameColumn); } table.setColumnWidth(nameColumn, 200, Unit.PX); VerticalPanel verticalPanel = new VerticalPanel(); verticalPanel.add(table); return verticalPanel; }
From source file:org.uberfire.client.workbench.widgets.tables.AbstractPathPagedTable.java
License:Apache License
/** * Set up table and common columns. Additional columns can be appended * between the "checkbox" and "open" columns by overriding * <code>addAncillaryColumns()</code> *///from w w w . j a v a 2 s.c o m @Override protected void doCellTable() { final ProvidesKey<T> providesKey = new ProvidesKey<T>() { public Object getKey(T row) { return row.getPath(); } }; cellTable = new CellTable<T>(providesKey); selectionModel = new MultiSelectionModel<T>(providesKey); cellTable.setSelectionModel(selectionModel); SelectionColumn.createAndAddSelectionColumn(cellTable); ColumnPicker<T> columnPicker = new ColumnPicker<T>(cellTable); SortableHeaderGroup<T> sortableHeaderGroup = new SortableHeaderGroup<T>(cellTable); // Add any additional columns addAncillaryColumns(columnPicker, sortableHeaderGroup); final TextColumn<T> uriColumn = new TextColumn<T>() { public String getValue(T row) { return row.getPath().toURI(); } }; columnPicker.addColumn(uriColumn, new SortableHeader<T, String>(sortableHeaderGroup, CommonConstants.INSTANCE.AbstractTableFileURI(), uriColumn), false); // Add "Open" button column Column<T, String> openColumn = new Column<T, String>(new ButtonCell(ButtonSize.SMALL)) { public String getValue(T row) { return CommonConstants.INSTANCE.AbstractTableOpen(); } }; openColumn.setFieldUpdater(new FieldUpdater<T, String>() { public void update(int index, T row, String value) { getPlaceManager().goTo(row.getPath()); } }); columnPicker.addColumn(openColumn, new TextHeader(CommonConstants.INSTANCE.AbstractTableOpen()), true); cellTable.setWidth("100%"); columnPickerButton = columnPicker.createToggleButton(); }
From source file:org.uberfire.ext.editor.commons.client.history.VersionHistoryPresenterViewImpl.java
License:Apache License
public VersionHistoryPresenterViewImpl() { initWidget(table);/*from ww w . j av a2 s . c o m*/ table.getElement().setAttribute("data-uf-lock", "false"); Column<VersionRecord, String> column = new Column<VersionRecord, String>(new ButtonCell()) { @Override public String getValue(VersionRecord object) { if (version.equals(object.id())) { return CommonConstants.INSTANCE.Current(); } else { return CommonConstants.INSTANCE.Select(); } } }; table.addColumn(column, ""); column.setFieldUpdater(new FieldUpdater<VersionRecord, String>() { @Override public void update(int index, VersionRecord record, String value) { presenter.onSelect(record); } }); table.addColumn(new Column<VersionRecord, Date>(new DateCell()) { @Override public Date getValue(VersionRecord object) { return object.date(); } }, CommonConstants.INSTANCE.Date()); table.addColumn(new Column<VersionRecord, String>(new TextCell()) { @Override public String getValue(VersionRecord object) { return object.comment(); } }, CommonConstants.INSTANCE.CommitMessage()); table.addColumn(new Column<VersionRecord, String>(new TextCell()) { @Override public String getValue(VersionRecord object) { return object.author(); } }, CommonConstants.INSTANCE.Author()); }
From source file:org.uberfire.ext.plugin.client.editor.DynamicMenuEditorView.java
License:Apache License
private void initTable(final AbstractCellTable<DynamicMenuItem> dynamicMenuTable) { dynamicMenuTable.setEmptyTableWidget(new Label(CommonConstants.INSTANCE.MenusNoMenuItems())); //We need to inform the SelectionModel that the ButtonCell (i.e. Delete) column is excluded from selecting a row final DefaultSelectionEventManager<DynamicMenuItem> manager = DefaultSelectionEventManager .createBlacklistManager(4);//from w w w . j a v a2 s. c o m dynamicMenuTable.setSelectionModel(selectionModel, manager); //Furthermore we cannot have a KeyboardSelectionPolicy with a ButtonCell and a SelectionModel dynamicMenuTable.setKeyboardSelectionPolicy(HasKeyboardSelectionPolicy.KeyboardSelectionPolicy.DISABLED); { final IconCell iCell = new IconCell(IconType.ARROW_UP); iCell.setTooltip(CommonConstants.INSTANCE.MenusMoveUpHint()); final Column<DynamicMenuItem, String> iconColumn = new Column<DynamicMenuItem, String>(iCell) { public String getValue(DynamicMenuItem object) { return ""; } }; iconColumn.setFieldUpdater(new FieldUpdater<DynamicMenuItem, String>() { @Override public void update(final int index, final DynamicMenuItem object, final String value) { presenter.updateIndex(object, index, DynamicMenuEditorPresenter.UpdateIndexOperation.UP); } }); dynamicMenuTable.addColumn(iconColumn); dynamicMenuTable.setColumnWidth(iconColumn, "25px"); } { final IconCell iCell = new IconCell(IconType.ARROW_DOWN); iCell.setTooltip(CommonConstants.INSTANCE.MenusMoveDownHint()); final Column<DynamicMenuItem, String> iconColumn = new Column<DynamicMenuItem, String>(iCell) { public String getValue(DynamicMenuItem object) { return ""; } }; iconColumn.setFieldUpdater(new FieldUpdater<DynamicMenuItem, String>() { @Override public void update(final int index, final DynamicMenuItem object, final String value) { presenter.updateIndex(object, index, DynamicMenuEditorPresenter.UpdateIndexOperation.DOWN); } }); dynamicMenuTable.addColumn(iconColumn); dynamicMenuTable.setColumnWidth(iconColumn, "25px"); } { final TextColumn<DynamicMenuItem> activityCol = new TextColumn<DynamicMenuItem>() { @Override public String getValue(DynamicMenuItem object) { return String.valueOf(object.getActivityId()); } }; dynamicMenuTable.addColumn(activityCol, CommonConstants.INSTANCE.MenusActivityID()); } { final TextColumn<DynamicMenuItem> labelCol = new TextColumn<DynamicMenuItem>() { @Override public String getValue(DynamicMenuItem object) { return object.getMenuLabel(); } }; dynamicMenuTable.addColumn(labelCol, CommonConstants.INSTANCE.MenusLabel()); } { final ButtonCell buttonCell = new ButtonCell(IconType.REMOVE, ButtonType.DANGER, ButtonSize.EXTRA_SMALL); final Column<DynamicMenuItem, String> buttonCol = new Column<DynamicMenuItem, String>(buttonCell) { @Override public String getValue(DynamicMenuItem object) { return CommonConstants.INSTANCE.MenusDelete(); } }; buttonCol.setFieldUpdater(new FieldUpdater<DynamicMenuItem, String>() { @Override public void update(final int index, final DynamicMenuItem object, final String value) { if (selectionModel.isSelected(object)) { selectionModel.clear(); } presenter.removeObject(object); } }); dynamicMenuTable.addColumn(buttonCol); dynamicMenuTable.setColumnWidth(buttonCol, "80px"); } selectionModel.addSelectionChangeHandler(new Handler() { @Override public void onSelectionChange(SelectionChangeEvent event) { //ListDataProvider raises this event with a null item when a item is removed if (selectionModel.getSelectedObject() == null) { editedItem = null; setMenuItem(new DynamicMenuItem()); } else { editedItem = selectionModel.getSelectedObject(); setMenuItem(new DynamicMenuItem(selectionModel.getSelectedObject().getActivityId(), selectionModel.getSelectedObject().getMenuLabel())); } } }); presenter.setDataDisplay(dynamicMenuTable); }
From source file:org.uberfire.ext.security.management.client.widgets.management.editor.user.UserAttributesEditor.java
License:Apache License
protected com.google.gwt.user.cellview.client.Column<Entry<String, String>, String> createAttributeNameColumn( ColumnSortEvent.ListHandler<Entry<String, String>> sortHandler) { // Attribute name. final Cell<String> nameCell = canManageAttributes() ? new EditTextCell() : new TextCell(); final com.google.gwt.user.cellview.client.Column<Entry<String, String>, String> keyColumn = new com.google.gwt.user.cellview.client.Column<Entry<String, String>, String>( nameCell) {// w w w. ja v a 2 s .c om @Override public String getValue(final Entry<String, String> object) { return object.getKey() != null ? object.getKey() : ""; } }; keyColumn.setSortable(true); sortHandler.setComparator(keyColumn, new Comparator<Entry<String, String>>() { @Override public int compare(Entry<String, String> o1, Entry<String, String> o2) { return o1.getKey().compareTo(o2.getKey()); } }); keyColumn.setFieldUpdater(canManageAttributes() ? keyModifiedEventHandler : null); return keyColumn; }
From source file:org.uberfire.ext.security.management.client.widgets.management.editor.user.UserAttributesEditor.java
License:Apache License
protected com.google.gwt.user.cellview.client.Column<Entry<String, String>, String> createAttributeValueColumn( ColumnSortEvent.ListHandler<Entry<String, String>> sortHandler) { // Attribute value. final Cell<String> valueCell = canManageAttributes() ? new EditTextCell() : new TextCell(); final com.google.gwt.user.cellview.client.Column<Entry<String, String>, String> valueColumn = new com.google.gwt.user.cellview.client.Column<Entry<String, String>, String>( valueCell) {//from ww w . j ava 2 s . c o m @Override public String getValue(final Entry<String, String> object) { return object.getValue() != null ? object.getValue() : ""; } }; valueColumn.setSortable(true); sortHandler.setComparator(valueColumn, new Comparator<Entry<String, String>>() { @Override public int compare(Entry<String, String> o1, Entry<String, String> o2) { return o1.getValue().compareTo(o2.getValue()); } }); valueColumn.setFieldUpdater(canManageAttributes() ? valueModifiedEventHandler : null); return valueColumn; }
From source file:org.uberfire.ext.security.management.client.widgets.management.editor.user.UserAttributesEditor.java
License:Apache License
protected com.google.gwt.user.cellview.client.Column<Entry<String, String>, String> createAttributeRemoveColumn() { // On read mode, remove button not present. if (!canManageAttributes()) { return null; }/*from w ww . jav a2s .c om*/ // Create remove button column. final ButtonCell removeButtonCell = new ButtonCell(IconType.CLOSE, ButtonType.LINK, ButtonSize.SMALL); final com.google.gwt.user.cellview.client.Column<Entry<String, String>, String> removeColumn = new com.google.gwt.user.cellview.client.Column<Entry<String, String>, String>( removeButtonCell) { @Override public String getValue(final Entry<String, String> object) { // if can be removed return empty string, if not, return null if (object != null) { final UserManager.UserAttribute attribute = getAttribute(object.getKey()); if (attribute != null && !attribute.isMandatory() && attribute.isEditable()) { removeButtonCell.setEnabled(true); return ""; } } removeButtonCell.setEnabled(false); return null; } }; removeColumn.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER); removeColumn.setFieldUpdater(canManageAttributes() ? removeButtonHandler : null); return removeColumn; }
From source file:org.uberfire.ext.wires.bpmn.client.explorer.BpmnExplorerViewImpl.java
License:Apache License
@Override public void setContent(final List<Path> files) { table.setStriped(true);/*from w w w . j ava2 s . c o m*/ table.setCondensed(true); table.setBordered(true); table.setEmptyTableWidget(new Label(BpmnEditorConstants.INSTANCE.bpmnExplorerNoFilesFound())); //Columns final TextColumn<Path> urlColumn = new TextColumn<Path>() { @Override public String getValue(final Path file) { return file.toURI(); } }; final ButtonCell openButton = new ButtonCell(IconType.EDIT, ButtonType.PRIMARY, ButtonSize.SMALL); final Column<Path, String> openColumn = new Column<Path, String>(openButton) { @Override public String getValue(final Path global) { return BpmnEditorConstants.INSTANCE.bpmnExplorerNoFilesOpen(); } }; openColumn.setFieldUpdater(new FieldUpdater<Path, String>() { public void update(final int index, final Path file, final String value) { presenter.openFile(file); } }); table.addColumn(urlColumn, new TextHeader(BpmnEditorConstants.INSTANCE.bpmnExplorerFileUrl())); table.addColumn(openColumn); //Link data dataProvider.addDataDisplay(table); dataProvider.setList(files); }
From source file:org.wte4j.ui.client.templates.mapping.MappingPanel.java
License:Apache License
private Column<MappingDto, String> createModelIdColumn() { Column<MappingDto, String> column = new Column<MappingDto, String>(new SelectionCell(modelIdOptions)) { @Override/*w ww.j a v a 2 s .c o m*/ public String getValue(MappingDto mapping) { return mapping.getModelKey(); } }; column.setFieldUpdater(new FieldUpdater<MappingDto, String>() { @Override public void update(int index, MappingDto mapping, String value) { mapping.setModelKey(value); } }); return column; }