List of usage examples for com.google.gwt.user.cellview.client Column setHorizontalAlignment
@Override public void setHorizontalAlignment(HorizontalAlignmentConstant align)
The new horizontal alignment will apply the next time the table is rendered.
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; }//ww w . jav a 2 s . c o m // 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:uk.ac.ebi.fg.annotare2.web.gwt.common.client.view.DataFileListPanel.java
License:Apache License
public DataFileListPanel() { grid = new CustomDataGrid<>(MAX_FILES, false); grid.addStyleName("gwt-DataGrid"); grid.setWidth("100%"); grid.setHeight("100%"); selectionModel = new MultiSelectionModel<>(new ProvidesKey<DataFileRow>() { @Override/*from w w w.ja v a2 s . c om*/ public Object getKey(DataFileRow item) { return item.getIdentity(); } }); grid.setSelectionModel(selectionModel, DefaultSelectionEventManager.<DataFileRow>createCheckboxManager()); Column<DataFileRow, Boolean> checkboxColumn = new Column<DataFileRow, Boolean>( new CheckboxCell(true, false)) { @Override public Boolean getValue(DataFileRow object) { return grid.getSelectionModel().isSelected(object); } }; checkboxHeader = new CheckboxHeader(); checkboxHeader.addValueChangeHandler(new ValueChangeHandler<Boolean>() { @Override public void onValueChange(ValueChangeEvent<Boolean> event) { selectAllRows(event.getValue()); } }); grid.addColumn(checkboxColumn, checkboxHeader); grid.setColumnWidth(checkboxColumn, 40, Style.Unit.PX); emptyTableWidget = new HTML( "<br><br><br>Drag files here to start upload<br>or press \"Upload Files\" button<br>to open selection dialog..."); emptyTableWidget.addStyleName("empty"); final EditSuggestCell nameCell = new EditSuggestCell(null) { @Override public boolean validateInput(String value, int rowIndex) { if (null == value || trimValue(value).isEmpty()) { NotificationPopupPanel.error("Empty file name is not permitted.", true, false); return false; } if (!value.matches("^[_a-zA-Z0-9\\-\\.]+$")) { NotificationPopupPanel.error( "File name should only contain alphanumeric characters, underscores and dots.", true, false); return false; } if (isDuplicated(value, rowIndex)) { NotificationPopupPanel.error("File with the name '" + value + "' already exists.", true, false); return false; } return true; } }; Column<DataFileRow, String> nameColumn = new Column<DataFileRow, String>(nameCell) { @Override public String getValue(DataFileRow row) { return row.getName(); } }; nameColumn.setFieldUpdater(new FieldUpdater<DataFileRow, String>() { @Override public void update(int index, DataFileRow row, String value) { final String oldName = row.getName(); String newName = trimValue(value); presenter.renameFile(row, newName, new AsyncCallback<Void>() { @Override public void onFailure(Throwable throwable) { NotificationPopupPanel.error("Unable to rename file '" + oldName + "'", true, false); } @Override public void onSuccess(Void aVoid) { } }); } }); grid.addColumn(nameColumn, "Name"); Column<DataFileRow, Date> dateColumn = new Column<DataFileRow, Date>( new DateCell(DateTimeFormat.getFormat("dd/MM/yy HH:mm"))) { @Override public Date getValue(DataFileRow object) { return object.getCreated(); } }; grid.addColumn(dateColumn, "Date"); grid.setColumnWidth(dateColumn, 110, Style.Unit.PX); Column<DataFileRow, DataFileRow> statusText = new Column<DataFileRow, DataFileRow>( new DownloadLinkStatusCell(this)) { @Override public DataFileRow getValue(DataFileRow object) { return object; } }; statusText.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER); grid.addColumn(statusText, "Status"); grid.setColumnWidth(statusText, 100, Style.Unit.PX); dataProvider = new ListDataProvider<>(); dataProvider.addDataDisplay(grid); grid.setLoadingIndicator(new LoadingIndicator()); grid.setEmptyTableWidget(emptyTableWidget); add(grid); }