List of usage examples for com.google.gwt.user.cellview.client CellTable setColumnWidth
@Override public void setColumnWidth(Column<T, ?> column, double width, Unit unit)
The layout behavior depends on whether or not the table is using fixed layout.
From source file:org.pepstock.jem.gwt.client.panels.roles.RolesTable.java
License:Open Source License
/** * Adds all columns to table, defining the sort columns too. *//* ww w. ja v a 2 s. c o m*/ @Override public IndexedColumnComparator<Role> initCellTable(CellTable<Role> table) { @SuppressWarnings("unchecked") final SelectionModel<Role> selectionModel = (SelectionModel<Role>) table.getSelectionModel(); Column<Role, Boolean> checkColumn = new Column<Role, Boolean>(new CheckboxCell(true, false)) { @Override public Boolean getValue(Role role) { return selectionModel.isSelected(role); } }; CheckboxCell headerCheckBox = new CheckboxCell(true, false); Header<Boolean> checkHeader = new Header<Boolean>(headerCheckBox) { // imposta lo stato dell'header! @Override public Boolean getValue() { // se e' vuoto, niente e' selezionato/selezionabile if (getTable().getVisibleItems().isEmpty()) { return false; } // altrimenti testo for (Role r : getTable().getVisibleItems()) { // se almeno un elemento non e' selezionato, l'header non deve essere selezionato if (!getTable().getSelectionModel().isSelected(r)) { return false; } } // altrimenti se arrivo qui, tutti gli elementi sono selezionati return true; } }; // updater che seleziona o deseleziona tutti gli elementi visibili in base al "valore" dell'header checkHeader.setUpdater(new ValueUpdater<Boolean>() { @Override public void update(Boolean value) { for (Role r : getTable().getVisibleItems()) { getTable().getSelectionModel().setSelected(r, value); } } }); table.setColumnWidth(checkColumn, 23, Unit.PX); table.addColumn(checkColumn, checkHeader); AnchorTextColumn<Role> name = new AnchorTextColumn<Role>() { @Override public void onClick(int index, Role object, String value) { getInspectListener().inspect(object); } @Override public String getValue(Role role) { return role.getName(); } }; name.setSortable(true); table.addColumn(name, new TextFilterableHeader("Name", RoleFilterFields.NAME.getName())); TextColumn<Role> removable = new TextColumn<Role>() { @Override public String getValue(Role role) { return String.valueOf(role.isRemovable()); } }; removable.setSortable(true); table.addColumn(removable, new TextFilterableHeader("Removable", RoleFilterFields.REMOVABLE.getName())); PermissionsColumn permissions = new PermissionsColumn(); table.addColumn(permissions, new TextFilterableHeader("Permissions", RoleFilterFields.PERMISSIONS.getName())); UsersColumn users = new UsersColumn(); table.addColumn(users, new TextFilterableHeader("Users", RoleFilterFields.USERS.getName())); TextColumn<Role> lastModified = new TextColumn<Role>() { @Override public String getValue(Role role) { if (role.getLastModified() == null) { return ""; } return JemConstants.DATE_TIME_FULL.format(role.getLastModified()); } }; lastModified.setSortable(true); table.addColumn(lastModified, new TextFilterableHeader("Modified", RoleFilterFields.MODIFIED.getName(), RoleFilterFields.MODIFIED.getPattern())); TextColumn<Role> user = new TextColumn<Role>() { @Override public String getValue(Role role) { return role.getUser() != null ? role.getUser() : ""; } }; user.setSortable(true); table.addColumn(user, new TextFilterableHeader("Modified by", RoleFilterFields.MODIFIED_BY.getName())); return new RolesComparator(1); }
From source file:org.roda.wui.client.common.lists.AIPList.java
@Override protected void configureDisplay(CellTable<IndexedAIP> display) { levelColumn = new Column<IndexedAIP, SafeHtml>(new SafeHtmlCell()) { @Override/* w w w. j a v a 2s .c om*/ public SafeHtml getValue(IndexedAIP aip) { SafeHtml ret; if (aip == null) { logger.error("Trying to display a NULL item"); ret = null; } else { ret = DescriptionLevelUtils.getElementLevelIconSafeHtml(aip.getLevel(), true); } return ret; } }; titleColumn = new TextColumn<IndexedAIP>() { @Override public String getValue(IndexedAIP aip) { return aip != null ? aip.getTitle() : null; } }; datesColumn = new TextColumn<IndexedAIP>() { @Override public String getValue(IndexedAIP aip) { return Humanize.getDatesText(aip.getDateInitial(), aip.getDateFinal(), false); } }; hasRepresentationsColumn = new Column<IndexedAIP, SafeHtml>(new SafeHtmlCell()) { @Override public SafeHtml getValue(IndexedAIP aip) { SafeHtml ret; if (aip == null) { logger.error("Trying to display a NULL item"); ret = null; } else if (aip.getHasRepresentations()) { // TODO set title and aria ret = HAS_REPRESENTATIONS_ICON; } else { ret = null; } return ret; } }; levelColumn.setSortable(true); titleColumn.setSortable(true); datesColumn.setSortable(true); hasRepresentationsColumn.setSortable(true); display.addColumn(levelColumn, SafeHtmlUtils.fromSafeConstant("<i class='fa fa-tag'></i> " + messages.aipLevel())); display.addColumn(titleColumn, messages.aipGenericTitle()); display.addColumn(datesColumn, messages.aipDates()); display.addColumn(hasRepresentationsColumn, HAS_REPRESENTATIONS_ICON); Label emptyInfo = new Label(messages.noItemsToDisplay()); display.setEmptyTableWidget(emptyInfo); // define default sorting display.getColumnSortList().push(new ColumnSortInfo(datesColumn, true)); display.setColumnWidth(levelColumn, 7.0, Unit.EM); display.setColumnWidth(datesColumn, 13.0, Unit.EM); display.setColumnWidth(hasRepresentationsColumn, 3.0, Unit.EM); levelColumn.setCellStyleNames("nowrap"); datesColumn.setCellStyleNames("nowrap"); addStyleName("my-collections-table"); emptyInfo.addStyleName("my-collections-empty-info"); }
From source file:org.roda.wui.client.common.lists.DIPFileList.java
@Override protected void configureDisplay(CellTable<DIPFile> display) { iconColumn = new Column<DIPFile, SafeHtml>(new SafeHtmlCell()) { @Override// ww w .java 2 s.c o m public SafeHtml getValue(DIPFile file) { if (file != null) { if (file.isDirectory()) { return SafeHtmlUtils.fromSafeConstant("<i class='fa fa-folder-o'></i>"); } else { return SafeHtmlUtils.fromSafeConstant("<i class='fa fa-file-o'></i>"); } } else { logger.error("Trying to display a NULL item"); } return null; } }; idColumn = new TextColumn<DIPFile>() { @Override public String getValue(DIPFile file) { return file != null ? file.getId() : null; } }; iconColumn.setSortable(true); idColumn.setSortable(true); addColumn(iconColumn, SafeHtmlUtils.fromSafeConstant("<i class='fa fa-files-o'></i>"), false, false, 2); display.addColumn(idColumn, messages.fileName()); Label emptyInfo = new Label(messages.noItemsToDisplay()); display.setEmptyTableWidget(emptyInfo); // define default sorting display.getColumnSortList().push(new ColumnSortInfo(idColumn, true)); display.setColumnWidth(iconColumn, 2.5, Unit.EM); addStyleName("my-collections-table"); emptyInfo.addStyleName("my-collections-empty-info"); }
From source file:org.roda.wui.client.common.lists.DIPList.java
@Override protected void configureDisplay(CellTable<IndexedDIP> display) { dateCreated = new Column<IndexedDIP, Date>( new DateCell(DateTimeFormat.getFormat(PredefinedFormat.DATE_TIME_MEDIUM))) { @Override/*from w w w . j a va 2 s . c om*/ public Date getValue(IndexedDIP dip) { return dip != null ? dip.getDateCreated() : null; } }; lastModified = new Column<IndexedDIP, Date>( new DateCell(DateTimeFormat.getFormat(PredefinedFormat.DATE_TIME_MEDIUM))) { @Override public Date getValue(IndexedDIP dip) { return dip != null ? dip.getLastModified() : null; } }; titleColumn = new TextColumn<IndexedDIP>() { @Override public String getValue(IndexedDIP dip) { return dip != null ? dip.getTitle() : null; } }; titleColumn.setSortable(true); dateCreated.setSortable(true); lastModified.setSortable(true); display.addColumn(titleColumn, messages.aipGenericTitle()); display.addColumn(dateCreated, messages.dipCreatedDate()); display.addColumn(lastModified, messages.dipLastModified()); Label emptyInfo = new Label(messages.noItemsToDisplay()); display.setEmptyTableWidget(emptyInfo); // define default sorting display.getColumnSortList().push(new ColumnSortInfo(titleColumn, true)); display.setColumnWidth(dateCreated, 13.0, Unit.EM); display.setColumnWidth(lastModified, 13.0, Unit.EM); dateCreated.setCellStyleNames("nowrap"); lastModified.setCellStyleNames("nowrap"); addStyleName("my-collections-table"); emptyInfo.addStyleName("my-collections-empty-info"); }
From source file:org.roda.wui.client.common.lists.SearchFileList.java
@Override protected void configureDisplay(CellTable<IndexedFile> display) { iconColumn = new Column<IndexedFile, SafeHtml>(new SafeHtmlCell()) { @Override/*www . ja v a 2 s . com*/ public SafeHtml getValue(IndexedFile file) { if (file != null) { if (file.isDirectory()) { return SafeHtmlUtils.fromSafeConstant("<i class='fa fa-folder-open'></i>"); } else { return SafeHtmlUtils.fromSafeConstant("<i class='fa fa-file-o'></i>"); } } else { logger.error("Trying to display a NULL item"); } return null; } }; pathColumn = new Column<IndexedFile, SafeHtml>(new SafeHtmlCell()) { @Override public SafeHtml getValue(IndexedFile file) { SafeHtmlBuilder b = new SafeHtmlBuilder(); if (file != null) { List<String> filePath = file.getPath(); String fileName = file.getOriginalName() != null ? file.getOriginalName() : file.getId(); List<String> fullpath = new ArrayList<>(filePath); fullpath.add(fileName); b.append(SafeHtmlUtils.fromSafeConstant("<div title='")); b.append(SafeHtmlUtils.fromString(StringUtils.join(fullpath, "/"))); b.append(SafeHtmlUtils.fromSafeConstant("'>")); if (showFilePath && filePath != null && !filePath.isEmpty()) { String path = StringUtils.join(filePath, "/"); b.append(SafeHtmlUtils.fromSafeConstant("<span class='file-path'>")); b.append(SafeHtmlUtils.fromString(path)); b.append(SafeHtmlUtils.fromSafeConstant("/")); b.append(SafeHtmlUtils.fromSafeConstant("</span>")); } b.append(SafeHtmlUtils.fromString(fileName)); b.append(SafeHtmlUtils.fromSafeConstant("</div>")); } return b.toSafeHtml(); } }; formatColumn = new TextColumn<IndexedFile>() { @Override public String getValue(IndexedFile file) { if (file != null && file.getFileFormat() != null) { FileFormat format = file.getFileFormat(); String ret; if (StringUtils.isNotBlank(format.getFormatDesignationName())) { ret = format.getFormatDesignationName(); if (StringUtils.isNotBlank(format.getFormatDesignationVersion())) { ret = ret + " " + format.getFormatDesignationVersion(); } } else if (StringUtils.isNotBlank(format.getPronom())) { ret = format.getPronom(); } else if (StringUtils.isNotBlank(format.getMimeType())) { ret = format.getMimeType(); } else { ret = null; } return ret; } else { return null; } } }; sizeColumn = new TextColumn<IndexedFile>() { @Override public String getValue(IndexedFile file) { return (file != null && file.getSize() > 0) ? Humanize.readableFileSize(file.getSize()) : ""; } }; /* add sortable */ iconColumn.setSortable(true); pathColumn.setSortable(true); formatColumn.setSortable(true); sizeColumn.setSortable(true); addColumn(iconColumn, SafeHtmlUtils.fromSafeConstant("<i class='fa fa-files-o'></i>"), false, false, 3); addColumn(pathColumn, messages.filePath(), true, false); addColumn(formatColumn, messages.fileFormat(), true, false); addColumn(sizeColumn, messages.fileSize(), true, false, 7); // define column width priority display.setColumnWidth(iconColumn, 3.0, Unit.EM); display.setColumnWidth(sizeColumn, 6.0, Unit.EM); pathColumn.setCellStyleNames("text-align-left"); formatColumn.setCellStyleNames("text-align-left"); sizeColumn.setCellStyleNames("text-align-right"); // define default sorting display.getColumnSortList().push(new ColumnSortInfo(pathColumn, true)); addStyleName("my-files-table"); }
From source file:org.roda.wui.client.common.lists.SimpleFileList.java
@Override protected void configureDisplay(CellTable<IndexedFile> display) { iconColumn = new Column<IndexedFile, SafeHtml>(new SafeHtmlCell()) { @Override// w w w .j a v a2 s .com public SafeHtml getValue(IndexedFile file) { if (file != null) { if (file.isDirectory()) { return SafeHtmlUtils.fromSafeConstant("<i class='fa fa-folder-o'></i>"); } else { return SafeHtmlUtils.fromSafeConstant("<i class='fa fa-file-o'></i>"); } } else { logger.error("Trying to display a NULL item"); } return null; } }; filenameColumn = new TextColumn<IndexedFile>() { @Override public String getValue(IndexedFile file) { String fileName = null; if (file != null) { fileName = file.getOriginalName() != null ? file.getOriginalName() : file.getId(); } return fileName; } }; /* add sortable */ iconColumn.setSortable(true); filenameColumn.setSortable(true); addColumn(iconColumn, SafeHtmlUtils.fromSafeConstant("<i class='fa fa-files-o'></i>"), false, false, 2); addColumn(filenameColumn, messages.fileName(), false, false); display.setColumnWidth(iconColumn, 2.5, Unit.EM); // define default sorting display.getColumnSortList().push(new ColumnSortInfo(filenameColumn, false)); addStyleName("my-files-table"); }
From source file:org.rstudio.studio.client.workbench.views.packages.ui.CheckForUpdatesDialog.java
License:Open Source License
protected void addTableColumns(CellTable<PendingAction> table) { TextColumn<PendingAction> nameColumn = new TextColumn<PendingAction>() { public String getValue(PendingAction action) { return action.getActionInfo().getPackageName(); }/*from w ww . jav a 2 s . co m*/ }; table.addColumn(nameColumn, "Package"); table.setColumnWidth(nameColumn, 28, Unit.PCT); TextColumn<PendingAction> installedColumn = new TextColumn<PendingAction>() { public String getValue(PendingAction action) { return action.getActionInfo().getInstalled(); } }; table.addColumn(installedColumn, "Installed"); table.setColumnWidth(installedColumn, 28, Unit.PCT); TextColumn<PendingAction> availableColumn = new TextColumn<PendingAction>() { public String getValue(PendingAction action) { return action.getActionInfo().getAvailable(); } }; table.addColumn(availableColumn, "Available"); table.setColumnWidth(availableColumn, 28, Unit.PCT); ImageButtonColumn<PendingAction> newsColumn = new ImageButtonColumn<PendingAction>( AbstractImagePrototype.create(ThemeResources.INSTANCE.newsButton()), new OperationWithInput<PendingAction>() { public void execute(PendingAction action) { GlobalDisplay.NewWindowOptions options = new GlobalDisplay.NewWindowOptions(); options.setName("_rstudio_package_news"); globalDisplay_.openWindow(action.getActionInfo().getNewsUrl(), options); } }, "Show package NEWS") { @Override protected boolean showButton(PendingAction action) { return !StringUtil.isNullOrEmpty(action.getActionInfo().getNewsUrl()); } }; table.addColumn(newsColumn, "NEWS"); table.setColumnWidth(newsColumn, 16, Unit.PCT); }
From source file:org.rstudio.studio.client.workbench.views.packages.ui.CleanUnusedDialog.java
License:Open Source License
@Override protected void addTableColumns(CellTable<PendingAction> table) { TextColumn<PendingAction> nameColumn = new TextColumn<PendingAction>() { public String getValue(PendingAction action) { return action.getActionInfo().getPackage(); }// www . j a v a2s. c o m }; table.addColumn(nameColumn, "Package"); table.setColumnWidth(nameColumn, 65, Unit.PCT); TextColumn<PendingAction> installedColumn = new TextColumn<PendingAction>() { public String getValue(PendingAction action) { return action.getActionInfo().getLibraryVersion(); } }; table.addColumn(installedColumn, "Version"); table.setColumnWidth(installedColumn, 35, Unit.PCT); }
From source file:uk.ac.ebi.fg.annotare2.web.gwt.editor.client.view.widget.MultiSelectListDialog.java
License:Apache License
private CellTable<String> createCellTable(Map<String, Boolean> items) { CellTable<String> cellTable = new CellTable<String>(); cellTable.setWidth("100%", true); cellTable.setEmptyTableWidget(new Label("empty list")); cellTable.setVisibleRange(0, items.size()); selectionModel = new MultiSelectionModel<String>(); cellTable.setSelectionModel(selectionModel, DefaultSelectionEventManager.<String>createCheckboxManager()); Column<String, Boolean> checkboxColumn = new Column<String, Boolean>(new CheckboxCell(true, false)) { @Override/*from w w w . j a va2 s. c o m*/ public Boolean getValue(String object) { return selectionModel.isSelected(object); } }; cellTable.addColumn(checkboxColumn); cellTable.setColumnWidth(checkboxColumn, 40, Style.Unit.PX); Column<String, String> valueColumn = new Column<String, String>(new TextCell()) { @Override public String getValue(String object) { return object; } }; cellTable.addColumn(valueColumn); dataProvider = new ListDataProvider<String>(); dataProvider.addDataDisplay(cellTable); dataProvider.setList(new ArrayList<String>(items.keySet())); for (String item : items.keySet()) { selectionModel.setSelected(item, items.get(item)); } return cellTable; }