Java源码示例:com.vaadin.ui.Table
示例1
/**
* Apply style for status label in target table.
*
* @param targetTable
* target table
* @param pinBtn
* pin button used for status display and pin on mouse over
* @param itemId
* id of the tabel row
*/
public static void applyStatusLblStyle(final Table targetTable, final Button pinBtn, final Object itemId) {
final Item item = targetTable.getItem(itemId);
if (item != null) {
final TargetUpdateStatus updateStatus = (TargetUpdateStatus) item
.getItemProperty(SPUILabelDefinitions.VAR_TARGET_STATUS).getValue();
pinBtn.removeStyleName("statusIconRed statusIconBlue statusIconGreen statusIconYellow statusIconLightBlue");
if (updateStatus == TargetUpdateStatus.ERROR) {
pinBtn.addStyleName(SPUIStyleDefinitions.STATUS_ICON_RED);
} else if (updateStatus == TargetUpdateStatus.UNKNOWN) {
pinBtn.addStyleName(SPUIStyleDefinitions.STATUS_ICON_BLUE);
} else if (updateStatus == TargetUpdateStatus.IN_SYNC) {
pinBtn.addStyleName(SPUIStyleDefinitions.STATUS_ICON_GREEN);
} else if (updateStatus == TargetUpdateStatus.PENDING) {
pinBtn.addStyleName(SPUIStyleDefinitions.STATUS_ICON_YELLOW);
} else if (updateStatus == TargetUpdateStatus.REGISTERED) {
pinBtn.addStyleName(SPUIStyleDefinitions.STATUS_ICON_LIGHT_BLUE);
}
}
}
示例2
private static void addGeneratedColumn(final Table table) {
table.addGeneratedColumn(CREATE_MODIFIED_DATE_UPLOAD, new ColumnGenerator() {
private static final long serialVersionUID = 1L;
@Override
public String generateCell(final Table source, final Object itemId, final Object columnId) {
final Long createdDate = (Long) table.getContainerDataSource().getItem(itemId)
.getItemProperty(CREATED_DATE).getValue();
final Long modifiedDATE = (Long) table.getContainerDataSource().getItem(itemId)
.getItemProperty(LAST_MODIFIED_DATE).getValue();
if (modifiedDATE != null) {
return SPDateTimeUtil.getFormattedDate(modifiedDATE);
}
return SPDateTimeUtil.getFormattedDate(createdDate);
}
});
}
示例3
private Button getArtifactDownloadButton(final Table table, final Object itemId) {
final String fileName = (String) table.getContainerDataSource().getItem(itemId)
.getItemProperty(PROVIDED_FILE_NAME).getValue();
final Button downloadIcon = SPUIComponentProvider.getButton(
fileName + "-" + UIComponentIdProvider.ARTIFACT_FILE_DOWNLOAD_ICON, "",
i18n.getMessage(UIMessageIdProvider.TOOLTIP_ARTIFACT_DOWNLOAD), ValoTheme.BUTTON_TINY + " " + "blueicon",
true, FontAwesome.DOWNLOAD, SPUIButtonStyleNoBorder.class);
downloadIcon.setData(itemId);
FileDownloader fileDownloader = new FileDownloader(createStreamResource((Long) itemId));
fileDownloader.extend(downloadIcon);
fileDownloader.setErrorHandler(new ErrorHandler() {
/**
* Error handler for file downloader
*/
private static final long serialVersionUID = 4030230501114422570L;
@Override
public void error(com.vaadin.server.ErrorEvent event) {
uINotification.displayValidationError(i18n.getMessage(UIMessageIdProvider.ARTIFACT_DOWNLOAD_FAILURE_MSG));
}
});
return downloadIcon;
}
示例4
private void setTableColumnDetails(final Table table) {
table.setColumnHeader(PROVIDED_FILE_NAME, i18n.getMessage(UIMessageIdProvider.CAPTION_ARTIFACT_FILENAME));
table.setColumnHeader(SIZE, i18n.getMessage(UIMessageIdProvider.CAPTION_ARTIFACT_FILESIZE_BYTES));
if (fullWindowMode) {
table.setColumnHeader(SHA1HASH, i18n.getMessage("upload.sha1"));
table.setColumnHeader(MD5HASH, i18n.getMessage("upload.md5"));
}
table.setColumnHeader(CREATE_MODIFIED_DATE_UPLOAD, i18n.getMessage("upload.last.modified.date"));
if (!readOnly) {
table.setColumnHeader(ACTION, i18n.getMessage(UIMessageIdProvider.MESSAGE_UPLOAD_ACTION));
}
table.setColumnExpandRatio(PROVIDED_FILE_NAME, 3.5F);
table.setColumnExpandRatio(SIZE, 2F);
if (fullWindowMode) {
table.setColumnExpandRatio(SHA1HASH, 2.8F);
table.setColumnExpandRatio(MD5HASH, 2.4F);
}
table.setColumnExpandRatio(CREATE_MODIFIED_DATE_UPLOAD, 3F);
if (!readOnly) {
table.setColumnExpandRatio(ACTION, 2.5F);
}
table.setVisibleColumns(getVisbleColumns().toArray());
}
示例5
@AutoGenerated
private VerticalLayout buildMainLayout() {
// common part: create layout
mainLayout = new VerticalLayout();
mainLayout.setImmediate(false);
mainLayout.setWidth("100%");
mainLayout.setHeight("-1px");
mainLayout.setMargin(false);
// top-level component properties
setWidth("100.0%");
setHeight("-1px");
// horizontalLayoutToolbar
horizontalLayoutToolbar = buildHorizontalLayoutToolbar();
mainLayout.addComponent(horizontalLayoutToolbar);
// tableUsers
tableUsers = new Table();
tableUsers.setImmediate(false);
tableUsers.setWidth("100.0%");
tableUsers.setHeight("-1px");
mainLayout.addComponent(tableUsers);
return mainLayout;
}
示例6
@Override
protected DropHandler getFilterButtonDropHandler() {
return new DropHandler() {
private static final long serialVersionUID = 1L;
@Override
public AcceptCriterion getAcceptCriterion() {
return managementViewClientCriterion;
}
@Override
public void drop(final DragAndDropEvent event) {
if (validate(event) && isNoTagAssigned(event)) {
final TableTransferable tbl = (TableTransferable) event.getTransferable();
final Table source = tbl.getSourceComponent();
if (source.getId().equals(UIComponentIdProvider.TARGET_TABLE_ID)) {
UI.getCurrent().access(() -> processTargetDrop(event));
}
}
}
};
}
示例7
private void filterByDroppedDist(final DragAndDropEvent event) {
if (doValidations(event)) {
final TableTransferable tableTransferable = (TableTransferable) event.getTransferable();
final Table source = tableTransferable.getSourceComponent();
if (!UIComponentIdProvider.DIST_TABLE_ID.equals(source.getId())) {
return;
}
final Set<Long> distributionIdSet = getDropppedDistributionDetails(tableTransferable);
if (CollectionUtils.isEmpty(distributionIdSet)) {
return;
}
final Long distributionSetId = distributionIdSet.iterator().next();
final Optional<DistributionSet> distributionSet = distributionSetManagement.get(distributionSetId);
if (!distributionSet.isPresent()) {
notification.displayWarning(i18n.getMessage("distributionset.not.exists"));
return;
}
final DistributionSetIdName distributionSetIdName = new DistributionSetIdName(distributionSet.get());
getManagementUIState().getTargetTableFilters().setDistributionSet(distributionSetIdName);
addFilterTextField(distributionSetIdName);
}
}
示例8
/**
* Validation for drag event.
*
* @param dragEvent
* @return
*/
private Boolean doValidations(final DragAndDropEvent dragEvent) {
final Component compsource = dragEvent.getTransferable().getSourceComponent();
Boolean isValid = Boolean.TRUE;
if (compsource instanceof Table && !isComplexFilterViewDisplayed) {
final TableTransferable transferable = (TableTransferable) dragEvent.getTransferable();
final Table source = transferable.getSourceComponent();
if (!source.getId().equals(UIComponentIdProvider.DIST_TABLE_ID)) {
notification.displayValidationError(i18n.getMessage(UIMessageIdProvider.MESSAGE_ACTION_NOT_ALLOWED));
isValid = Boolean.FALSE;
} else {
if (getDropppedDistributionDetails(transferable).size() > 1) {
notification.displayValidationError(i18n.getMessage("message.onlyone.distribution.dropallowed"));
isValid = Boolean.FALSE;
}
}
} else {
notification.displayValidationError(i18n.getMessage(UIMessageIdProvider.MESSAGE_ACTION_NOT_ALLOWED));
isValid = Boolean.FALSE;
}
return isValid;
}
示例9
private void buildSelectedTable() {
selectedTable = new Table();
selectedTable.setId(SPUIDefinitions.TWIN_TABLE_SELECTED_ID);
selectedTable.setSelectable(true);
selectedTable.setMultiSelect(true);
selectedTable.setSortEnabled(false);
selectedTable.addStyleName(ValoTheme.TABLE_NO_HORIZONTAL_LINES);
selectedTable.addStyleName(ValoTheme.TABLE_NO_STRIPES);
selectedTable.addStyleName(ValoTheme.TABLE_NO_VERTICAL_LINES);
selectedTable.addStyleName(ValoTheme.TABLE_SMALL);
selectedTable.addStyleName("dist_type_twin-table");
selectedTable.setSizeFull();
createSelectedTableContainer();
selectedTable.setContainerDataSource(selectedTableContainer);
addTooltTipToSelectedTable();
selectedTable.setImmediate(true);
selectedTable.setVisibleColumns(DIST_TYPE_NAME, DIST_TYPE_MANDATORY);
selectedTable.setColumnHeaders(i18n.getMessage("header.dist.twintable.selected"), STAR);
selectedTable.setColumnExpandRatio(DIST_TYPE_NAME, 0.75F);
selectedTable.setColumnExpandRatio(DIST_TYPE_MANDATORY, 0.25F);
selectedTable.setRequired(true);
}
示例10
private void buildSourceTable() {
sourceTable = new Table();
sourceTable.setId(SPUIDefinitions.TWIN_TABLE_SOURCE_ID);
sourceTable.setSelectable(true);
sourceTable.setMultiSelect(true);
sourceTable.addStyleName(ValoTheme.TABLE_NO_HORIZONTAL_LINES);
sourceTable.addStyleName(ValoTheme.TABLE_NO_STRIPES);
sourceTable.addStyleName(ValoTheme.TABLE_NO_VERTICAL_LINES);
sourceTable.addStyleName(ValoTheme.TABLE_SMALL);
sourceTable.setImmediate(true);
sourceTable.setSizeFull();
sourceTable.addStyleName("dist_type_twin-table");
sourceTable.setSortEnabled(false);
sourceTableContainer = new IndexedContainer();
sourceTableContainer.addContainerProperty(DIST_TYPE_NAME, String.class, "");
sourceTableContainer.addContainerProperty(DIST_TYPE_DESCRIPTION, String.class, "");
sourceTable.setContainerDataSource(sourceTableContainer);
sourceTable.setVisibleColumns(DIST_TYPE_NAME);
sourceTable.setColumnHeaders(i18n.getMessage("header.dist.twintable.available"));
sourceTable.setColumnExpandRatio(DIST_TYPE_NAME, 1.0F);
createSourceTableData();
addTooltip();
sourceTable.select(sourceTable.firstItemId());
}
示例11
/**
* adds a listener to a component. Depending on the type of component a
* valueChange-, textChange- or itemSetChangeListener will be added.
*/
public void addComponentListeners() {
// avoid duplicate registration
removeListeners();
for (final AbstractField<?> field : allComponents) {
if (field instanceof TextChangeNotifier) {
((TextChangeNotifier) field).addTextChangeListener(new ChangeListener(field));
}
if (field instanceof Table) {
((Table) field).addItemSetChangeListener(new ChangeListener(field));
}
field.addValueChangeListener(new ChangeListener(field));
}
}
示例12
/**
* Gets the selected item id or in multiselect mode the selected ids.
*
* @param table
* the table to retrieve the selected ID(s)
* @return the ID(s) which are selected in the table
*/
@SuppressWarnings("unchecked")
public static <T> Set<T> getTableValue(final Table table) {
final Object value = table.getValue();
Set<T> idsReturn;
if (value == null) {
idsReturn = Collections.emptySet();
} else if (value instanceof Collection) {
final Collection<T> ids = (Collection<T>) value;
idsReturn = ids.stream().filter(Objects::nonNull).collect(Collectors.toSet());
} else {
final T id = (T) value;
idsReturn = Collections.singleton(id);
}
return idsReturn;
}
示例13
public void loadData( Table userTable ){
ModuleDao moduleDao = InjectorFactory.getInstance( ModuleDao.class );
List<Module> modules = moduleDao.getAll();
for( final Module module : modules ) {
Label groupLabel = new Label( module.getGroupId( ) );
Label artifactLabel = new Label( module.getArtifactId( ) );
Label versionLabel = new Label( module.getVersion( ) );
Button detailsField = new Button( "show details" );
detailsField.addStyleName( "link" );
detailsField.addClickListener( new Button.ClickListener( ) {
@Override
public void buttonClick( Button.ClickEvent event ) {
onItemClick( module.getId() );
}
} );
userTable.addItem( new Object[]{ groupLabel, artifactLabel, versionLabel, detailsField }, module.getId( ) );
}
}
示例14
protected boolean isDropValid(final DragAndDropEvent dragEvent) {
final Transferable transferable = dragEvent.getTransferable();
final Component compsource = transferable.getSourceComponent();
final List<String> missingPermissions = hasMissingPermissionsForDrop();
if (!missingPermissions.isEmpty()) {
notification.displayValidationError(i18n.getMessage("message.permission.insufficient", missingPermissions));
return false;
}
if (compsource instanceof Table) {
return validateTable((Table) compsource)
&& validateDropList(getDraggedTargetList((TableTransferable) transferable, (Table) compsource));
}
if (compsource instanceof DragAndDropWrapper) {
return validateDragAndDropWrapper((DragAndDropWrapper) compsource)
&& validateDropList(getDraggedTargetList(dragEvent));
}
notification.displayValidationError(i18n.getMessage(UIMessageIdProvider.MESSAGE_ACTION_NOT_ALLOWED));
return false;
}
示例15
@Override
public void attach() {
// テーブル基本設定
setCaption(ViewProperties.getCaption("table.selectService"));
setWidth("440px");
setPageLength(4);
setSortDisabled(true);
setColumnHeaderMode(Table.COLUMN_HEADER_MODE_HIDDEN);
setColumnReorderingAllowed(false);
setColumnCollapsingAllowed(false);
setSelectable(true);
setMultiSelect(false);
setNullSelectionAllowed(false);
setImmediate(true);
addStyleName("win-service-add-service");
// カラム設定
addContainerProperty("No", Integer.class, null);
addContainerProperty("Service", Label.class, new Label());
addContainerProperty("Description", String.class, null);
setColumnExpandRatio("Description", 100);
setCellStyleGenerator(new StandardCellStyleGenerator());
}
示例16
@Override
public void attach() {
// テーブル基本設定
setWidth("100%");
addStyleName("win-mycloud-add-temp");
setCaption(ViewProperties.getCaption("table.selectTemplate"));
setPageLength(4);
setColumnHeaderMode(Table.COLUMN_HEADER_MODE_HIDDEN);
setSortDisabled(true);
setColumnReorderingAllowed(false);
setColumnCollapsingAllowed(false);
setSelectable(true);
setMultiSelect(false);
setNullSelectionAllowed(false);
setImmediate(true);
// カラム設定
addContainerProperty("No", Integer.class, null);
addContainerProperty("Name", Label.class, new Label());
setColumnExpandRatio("Name", 100);
// テーブルのカラムに対してStyleNameを設定
setCellStyleGenerator(new StandardCellStyleGenerator());
}
示例17
@Override
public void attach() {
// テーブル基本設定
setCaption(ViewProperties.getCaption("table.selectCloud"));
setWidth("470px");
setPageLength(4);
setColumnHeaderMode(Table.COLUMN_HEADER_MODE_HIDDEN);
setSortDisabled(true);
setColumnReorderingAllowed(false);
setColumnCollapsingAllowed(false);
setSelectable(true);
setMultiSelect(false);
setNullSelectionAllowed(false);
setImmediate(true);
addStyleName("win-server-add-cloud");
// カラム設定
addContainerProperty("No", Integer.class, null);
addContainerProperty("Cloud", Label.class, new Label());
setColumnExpandRatio("Cloud", 100);
setCellStyleGenerator(new StandardCellStyleGenerator());
}
示例18
@Override
public void attach() {
// テーブル基本設定
setCaption(ViewProperties.getCaption("table.selectImage"));
setWidth("470px");
if (enableService) {
setPageLength(3);
} else {
setPageLength(6);
}
setColumnHeaderMode(Table.COLUMN_HEADER_MODE_HIDDEN);
setSortDisabled(true);
setColumnReorderingAllowed(false);
setColumnCollapsingAllowed(false);
setSelectable(true);
setMultiSelect(false);
setNullSelectionAllowed(false);
setImmediate(true);
addStyleName("win-server-add-os");
// カラム設定
addContainerProperty("No", Integer.class, null);
addContainerProperty("Image", Label.class, new Label());
setColumnExpandRatio("Image", 100);
setCellStyleGenerator(new StandardCellStyleGenerator());
}
示例19
@Override
public void attach() {
// テーブル基本設定
setCaption(ViewProperties.getCaption("table.availableService"));
setWidth("100%");
setHeight("100px");
setPageLength(3);
setColumnHeaderMode(Table.COLUMN_HEADER_MODE_HIDDEN);
setSortDisabled(true);
setColumnReorderingAllowed(false);
setColumnCollapsingAllowed(false);
setSelectable(false);
setMultiSelect(false);
setImmediate(true);
addStyleName("win-server-add-service");
//カラム設定
addContainerProperty("Service", Label.class, new Label());
addContainerProperty("Description", String.class, null);
setColumnExpandRatio("Service", 100);
setCellStyleGenerator(new StandardCellStyleGenerator());
}
示例20
@Override
public void attach() {
// テーブル基本設定
addStyleName("service-desc-detail-param");
setCaption(ViewProperties.getCaption("label.serviceDetailParams"));
setColumnHeaderMode(Table.COLUMN_HEADER_MODE_EXPLICIT);
setSortDisabled(true);
setMultiSelect(false);
setImmediate(false);
// カラム設定
addContainerProperty("Kind", String.class, null);
addContainerProperty("Name", String.class, null);
addContainerProperty("Value", String.class, null);
setColumnExpandRatio("Value", 100);
setCellStyleGenerator(new StandardCellStyleGenerator());
}
示例21
@Override
public void attach() {
// テーブル基本設定
setCaption(ViewProperties.getCaption("table.selectCloud"));
setWidth("260px");
setPageLength(6);
setColumnHeaderMode(Table.COLUMN_HEADER_MODE_HIDDEN);
setSortDisabled(true);
setColumnReorderingAllowed(false);
setColumnCollapsingAllowed(false);
setSelectable(true);
setMultiSelect(false);
setNullSelectionAllowed(false);
setImmediate(true);
addStyleName("win-server-add-cloud");
//カラム設定
addContainerProperty("No", Integer.class, null);
addContainerProperty("Cloud", Label.class, new Label());
setColumnExpandRatio("Cloud", 100);
setCellStyleGenerator(new StandardCellStyleGenerator());
}
示例22
public Component generateCell(Table source, final Object itemId,
Object columnId) {
Button link = new Button("Output");
link.setStyleName(BaseTheme.BUTTON_LINK);
link.setDescription("Show job output");
link.addClickListener(new Button.ClickListener() {
public void buttonClick(ClickEvent event) {
select(itemId);
view.showOutput(itemId);
}
});
return link;
}
示例23
@Override
public void attach() {
// テーブル基本設定
setCaption(ViewProperties.getCaption("table.selectCloud"));
setWidth("340px");
setPageLength(3);
setColumnHeaderMode(Table.COLUMN_HEADER_MODE_HIDDEN);
setSortDisabled(true);
setColumnReorderingAllowed(false);
setColumnCollapsingAllowed(false);
setSelectable(true);
setMultiSelect(false);
setNullSelectionAllowed(false);
setImmediate(true);
addStyleName("loadbalancer-add-table");
// カラム設定
addContainerProperty("No", Integer.class, null);
addContainerProperty("Cloud", Label.class, new Label());
setColumnExpandRatio("Cloud", 100);
setCellStyleGenerator(new StandardCellStyleGenerator());
}
示例24
private void addGroup( RunnerGroup group, Table runnersTable ) {
Module module = moduleDao.get( group.getModuleId() );
if (module == null) {
return;
}
String caption = String.format( "%s / %s / %s: commit[%s], user[%s]",
module.getGroupId(),
module.getArtifactId(),
module.getVersion(),
StringUtils.abbreviate( group.getCommitId(), 10 ),
group.getUser()
);
accordion.addTab( runnersTable, caption );
}
示例25
public Component generateCell(Table source, final Object itemId,
Object columnId) {
Property<?> prop = source.getItem(itemId).getItemProperty(columnId);
if (prop != null && prop.getType() != null && prop.getType().equals(Integer.class)) {
Integer wallClockTime = (Integer) prop.getValue();
if (wallClockTime != null) {
return new Label(StringUtils.formatMinutes(wallClockTime));
} else {
return new Label();
}
}
return null;
}
示例26
@Override
public void attach() {
//テーブル基本設定
setWidth("100%");
setPageLength(4);
setColumnHeaderMode(Table.COLUMN_HEADER_MODE_HIDDEN);
setSortDisabled(true);
setColumnReorderingAllowed(false);
setColumnCollapsingAllowed(false);
setSelectable(true);
setMultiSelect(false);
setNullSelectionAllowed(false);
setImmediate(true);
addStyleName("win-mycloud-edit-table");
//カラム設定
addContainerProperty("No", Integer.class, null);
addContainerProperty("Name", Label.class, new Label());
addContainerProperty("Description", String.class, null);
setColumnExpandRatio("Name", 40);
setColumnExpandRatio("Description", 60);
//テーブルのカラムに対してStyleNameを設定
setCellStyleGenerator(new StandardCellStyleGenerator());
}
示例27
protected void initializeTable(Status status) {
//
// Setup the table
//
this.tableChanges.setContainerDataSource(this.container);
this.tableChanges.setPageLength(this.container.size());
this.tableChanges.setImmediate(true);
//
// Generate column
//
this.tableChanges.addGeneratedColumn("Entry", new ColumnGenerator() {
private static final long serialVersionUID = 1L;
@Override
public Object generateCell(Table source, Object itemId, Object columnId) {
Item item = self.container.getItem(itemId);
assert(item != null);
if (item instanceof StatusItem) {
return self.generateGitEntryComponent(((StatusItem) item).getGitEntry());
}
assert(item instanceof StatusItem);
return null;
}
});
}
示例28
@Override
protected void init(VaadinRequest vaadinRequest) {
getPage().setTitle("Root UI");
Table table = new Table("Customer Table");
table.addContainerProperty("firstName", String.class, null);
table.addContainerProperty("lastName", String.class, null);
table.addContainerProperty("id", Long.class, null);
for (Customer c : this.customerRepository.findAll())
table.addItem(new Object[]{c.getFirstName(), c.getLastName(), c.getId()}, c.getId());
table.setSizeFull();
table.setColumnHeader("firstName", "First Name");
table.setColumnHeader("lastName", "First Name");
setContent(table);
}
示例29
@Override
public Class<?> getType(Object propertyId) {
if (propertyId.equals(PROPERTY_ID)) {
return String.class;
}
if (propertyId.equals(PROPERTY_CATEGORY)) {
return Category.class;
}
if (propertyId.equals(PROPERTY_DATATYPE)) {
return Datatype.class;
}
if (propertyId.equals(PROPERTY_VALUES)) {
return Table.class;
}
return null;
}
示例30
@Override
public String generateDescription(final Component source, final Object itemId, final Object propertyId) {
final DistributionSet distributionSet;
final Item item = ((Table) source).getItem(itemId);
if (propertyId != null) {
if (propertyId.equals(SPUILabelDefinitions.ASSIGNED_DISTRIBUTION_NAME_VER)) {
distributionSet = (DistributionSet) item.getItemProperty(ASSIGN_DIST_SET).getValue();
return getDSDetails(distributionSet);
} else if (propertyId.equals(SPUILabelDefinitions.INSTALLED_DISTRIBUTION_NAME_VER)) {
distributionSet = (DistributionSet) item.getItemProperty(INSTALL_DIST_SET).getValue();
return getDSDetails(distributionSet);
}
}
return null;
}