本文整理了Java中com.vaadin.ui.Grid.getContainerDataSource()
方法的一些代码示例,展示了Grid.getContainerDataSource()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Grid.getContainerDataSource()
方法的具体详情如下:
包路径:com.vaadin.ui.Grid
类名称:Grid
方法名:getContainerDataSource
暂无
代码示例来源:origin: stackoverflow.com
@Override
protected void init(VaadinRequest request) {
BeanContainer<Long, DecemberBean> dataSource = new BeanContainer<Long, DecemberBean>(DecemberBean.class);
Grid grid = new Grid(dataSource);
Runnable r = () -> {
while (true) {
System.out.println("update");
try{Thread.sleep(2000);}catch(Exception e){e.printStackTrace();};
UI.getCurrent().access(() -> {
for (Long item : dataSource.getItemIds()) {
DecemberBean k = dataSource.getItem(item).getBean();
k.setNumber(k.getNumber() + 100);
}
grid.sort(grid.getContainerDataSource().getContainerPropertyIds().iterator().next());
});
}
};
dataSource.setBeanIdResolver(bean -> new Long(bean.getNumber()));
for (int i = 0; i < 100; i++) {
dataSource.addBean(new DecemberBean(i));
}
setContent(grid);
new Thread(r).start();
}
代码示例来源:origin: eclipse/hawkbit
private void restoreState() {
final Indexed container = grid.getContainerDataSource();
container.removeAllItems();
for (final FileUploadProgress fileUploadProgress : artifactUploadState
.getAllFileUploadProgressValuesFromOverallUploadProcessList()) {
updateUploadProgressInfoRowObject(fileUploadProgress);
}
}
代码示例来源:origin: org.eclipse.hawkbit/hawkbit-ui
private void restoreState() {
final Indexed container = grid.getContainerDataSource();
container.removeAllItems();
for (final FileUploadProgress fileUploadProgress : artifactUploadState
.getAllFileUploadProgressValuesFromOverallUploadProcessList()) {
updateUploadProgressInfoRowObject(fileUploadProgress);
}
}
代码示例来源:origin: eclipse/hawkbit
protected Item updateItemInGrid(final String key) {
final IndexedContainer metadataContainer = (IndexedContainer) metaDataGrid.getContainerDataSource();
final Item item = metadataContainer.getItem(key);
item.getItemProperty(VALUE).setValue(valueTextArea.getValue());
return item;
}
代码示例来源:origin: org.eclipse.hawkbit/hawkbit-ui
protected Item updateItemInGrid(final String key) {
final IndexedContainer metadataContainer = (IndexedContainer) metaDataGrid.getContainerDataSource();
final Item item = metadataContainer.getItem(key);
item.getItemProperty(VALUE).setValue(valueTextArea.getValue());
return item;
}
代码示例来源:origin: org.eclipse.hawkbit/hawkbit-ui
private void handleOkDeleteMetadata(final RendererClickEvent event, final String key) {
deleteMetadata(getSelectedEntity(), key);
uiNotification.displaySuccess(i18n.getMessage("message.metadata.deleted.successfully", key));
final Object selectedRow = metaDataGrid.getSelectedRow();
metaDataGrid.getContainerDataSource().removeItem(event.getItemId());
// force grid to refresh
metaDataGrid.clearSortOrder();
if (!metaDataGrid.getContainerDataSource().getItemIds().isEmpty()) {
if (selectedRow != null) {
if (selectedRow.equals(event.getItemId())) {
metaDataGrid.select(metaDataGrid.getContainerDataSource().getIdByIndex(0));
} else {
metaDataGrid.select(selectedRow);
}
}
} else {
resetFields();
}
}
代码示例来源:origin: eclipse/hawkbit
private void setUpDetails(final Long swId, final String metaDatakey) {
resetDetails();
metadataWindow.clearOriginalValues();
if (swId != null) {
metaDataGrid.getContainerDataSource().removeAllItems();
populateGrid();
metaDataGrid.getSelectionModel().reset();
if (!metaDataGrid.getContainerDataSource().getItemIds().isEmpty()) {
if (metaDatakey == null) {
metaDataGrid.select(metaDataGrid.getContainerDataSource().getIdByIndex(0));
} else {
metaDataGrid.select(metaDatakey);
}
} else if (hasCreatePermission()) {
enableEditing();
addIcon.setEnabled(false);
}
}
}
代码示例来源:origin: eclipse/hawkbit
private void handleOkDeleteMetadata(final RendererClickEvent event, final String key) {
deleteMetadata(getSelectedEntity(), key);
uiNotification.displaySuccess(i18n.getMessage("message.metadata.deleted.successfully", key));
final Object selectedRow = metaDataGrid.getSelectedRow();
metaDataGrid.getContainerDataSource().removeItem(event.getItemId());
// force grid to refresh
metaDataGrid.clearSortOrder();
if (!metaDataGrid.getContainerDataSource().getItemIds().isEmpty()) {
if (selectedRow != null) {
if (selectedRow.equals(event.getItemId())) {
metaDataGrid.select(metaDataGrid.getContainerDataSource().getIdByIndex(0));
} else {
metaDataGrid.select(selectedRow);
}
}
} else {
resetFields();
}
}
代码示例来源:origin: org.eclipse.hawkbit/hawkbit-ui
private void setUpDetails(final Long swId, final String metaDatakey) {
resetDetails();
metadataWindow.clearOriginalValues();
if (swId != null) {
metaDataGrid.getContainerDataSource().removeAllItems();
populateGrid();
metaDataGrid.getSelectionModel().reset();
if (!metaDataGrid.getContainerDataSource().getItemIds().isEmpty()) {
if (metaDatakey == null) {
metaDataGrid.select(metaDataGrid.getContainerDataSource().getIdByIndex(0));
} else {
metaDataGrid.select(metaDatakey);
}
} else if (hasCreatePermission()) {
enableEditing();
addIcon.setEnabled(false);
}
}
}
代码示例来源:origin: eclipse/hawkbit
@Override
protected Grid createMetadataGrid() {
final Grid metadataGrid = super.createMetadataGrid();
metadataGrid.getContainerDataSource().addContainerProperty(TARGET_VISIBLE, Boolean.class, Boolean.FALSE);
metadataGrid.getColumn(TARGET_VISIBLE).setHeaderCaption(i18n.getMessage("metadata.targetvisible"));
metadataGrid.getColumn(TARGET_VISIBLE).setHidden(true);
return metadataGrid;
}
代码示例来源:origin: com.holon-platform.vaadin7/holon-vaadin
/**
* Adds an {@link ItemSetChangeListener} to internal component container.
* @param listener Listener to add
*/
public void addItemSetChangeListener(Container.ItemSetChangeListener listener) {
Container container = null;
switch (getRenderingMode()) {
case GRID:
container = getGrid().getContainerDataSource();
break;
case TABLE:
container = getTable().getContainerDataSource();
break;
default:
break;
}
if (container != null && container instanceof ItemSetChangeNotifier) {
((ItemSetChangeNotifier) container).addItemSetChangeListener(listener);
}
}
代码示例来源:origin: org.eclipse.hawkbit/hawkbit-ui
@Override
protected Grid createMetadataGrid() {
final Grid metadataGrid = super.createMetadataGrid();
metadataGrid.getContainerDataSource().addContainerProperty(TARGET_VISIBLE, Boolean.class, Boolean.FALSE);
metadataGrid.getColumn(TARGET_VISIBLE).setHeaderCaption(i18n.getMessage("metadata.targetvisible"));
metadataGrid.getColumn(TARGET_VISIBLE).setHidden(true);
return metadataGrid;
}
代码示例来源:origin: org.eclipse.hawkbit/hawkbit-ui
protected Item addItemToGrid(final M metaData) {
final IndexedContainer metadataContainer = (IndexedContainer) metaDataGrid.getContainerDataSource();
final Item item = metadataContainer.addItem(metaData.getKey());
item.getItemProperty(VALUE).setValue(metaData.getValue());
item.getItemProperty(KEY).setValue(metaData.getKey());
return item;
}
代码示例来源:origin: eclipse/hawkbit
protected Item addItemToGrid(final M metaData) {
final IndexedContainer metadataContainer = (IndexedContainer) metaDataGrid.getContainerDataSource();
final Item item = metadataContainer.addItem(metaData.getKey());
item.getItemProperty(VALUE).setValue(metaData.getValue());
item.getItemProperty(KEY).setValue(metaData.getKey());
return item;
}
代码示例来源:origin: eclipse/hawkbit
protected Item popualateKeyValue(final Object metadataCompositeKey) {
if (metadataCompositeKey != null) {
final Item item = metaDataGrid.getContainerDataSource().getItem(metadataCompositeKey);
keyTextField.setValue((String) item.getItemProperty(KEY).getValue());
valueTextArea.setValue((String) item.getItemProperty(VALUE).getValue());
keyTextField.setEnabled(false);
if (hasUpdatePermission()) {
valueTextArea.setEnabled(true);
}
return item;
}
return null;
}
代码示例来源:origin: org.eclipse.hawkbit/hawkbit-ui
protected Item popualateKeyValue(final Object metadataCompositeKey) {
if (metadataCompositeKey != null) {
final Item item = metaDataGrid.getContainerDataSource().getItem(metadataCompositeKey);
keyTextField.setValue((String) item.getItemProperty(KEY).getValue());
valueTextArea.setValue((String) item.getItemProperty(VALUE).getValue());
keyTextField.setEnabled(false);
if (hasUpdatePermission()) {
valueTextArea.setEnabled(true);
}
return item;
}
return null;
}
代码示例来源:origin: org.eclipse.hawkbit/hawkbit-ui
private void onDelete(final RendererClickEvent event) {
final Item item = metaDataGrid.getContainerDataSource().getItem(event.getItemId());
final String key = (String) item.getItemProperty(KEY).getValue();
final ConfirmationDialog confirmDialog = new ConfirmationDialog(
i18n.getMessage("caption.entity.delete.action.confirmbox"),
i18n.getMessage("message.confirm.delete.metadata", key), i18n.getMessage(UIMessageIdProvider.BUTTON_OK),
i18n.getMessage(UIMessageIdProvider.BUTTON_CANCEL), ok -> {
if (ok) {
handleOkDeleteMetadata(event, key);
}
});
UI.getCurrent().addWindow(confirmDialog.getWindow());
confirmDialog.getWindow().bringToFront();
}
代码示例来源:origin: eclipse/hawkbit
private void onDelete(final RendererClickEvent event) {
final Item item = metaDataGrid.getContainerDataSource().getItem(event.getItemId());
final String key = (String) item.getItemProperty(KEY).getValue();
final ConfirmationDialog confirmDialog = new ConfirmationDialog(
i18n.getMessage("caption.entity.delete.action.confirmbox"),
i18n.getMessage("message.confirm.delete.metadata", key), i18n.getMessage(UIMessageIdProvider.BUTTON_OK),
i18n.getMessage(UIMessageIdProvider.BUTTON_CANCEL), ok -> {
if (ok) {
handleOkDeleteMetadata(event, key);
}
});
UI.getCurrent().addWindow(confirmDialog.getWindow());
confirmDialog.getWindow().bringToFront();
}
代码示例来源:origin: org.eclipse.hawkbit/hawkbit-ui
Item item = uploads.getItem(fileUploadId);
if (item == null) {
item = grid.getContainerDataSource().addItem(fileUploadId);
item.getItemProperty(COLUMN_FILE_NAME).setValue(fileUploadId.getFilename());
item.getItemProperty(SPUILabelDefinitions.NAME_VERSION).setValue(HawkbitCommonUtil.getFormattedNameVersion(
代码示例来源:origin: eclipse/hawkbit
@SuppressWarnings("unchecked")
private void updateUploadProgressInfoRowObject(final FileUploadProgress fileUploadProgress) {
final FileUploadId fileUploadId = fileUploadProgress.getFileUploadId();
Item item = uploads.getItem(fileUploadId);
if (item == null) {
item = grid.getContainerDataSource().addItem(fileUploadId);
item.getItemProperty(COLUMN_FILE_NAME).setValue(fileUploadId.getFilename());
item.getItemProperty(SPUILabelDefinitions.NAME_VERSION).setValue(HawkbitCommonUtil.getFormattedNameVersion(
fileUploadId.getSoftwareModuleName(), fileUploadId.getSoftwareModuleVersion()));
}
final String status;
final FileUploadStatus uploadStatus = fileUploadProgress.getFileUploadStatus();
if (uploadStatus == FileUploadStatus.UPLOAD_FAILED) {
status = STATUS_FAILED;
} else if (uploadStatus == FileUploadStatus.UPLOAD_SUCCESSFUL) {
status = STATUS_FINISHED;
} else {
status = STATUS_INPROGRESS;
}
item.getItemProperty(COLUMN_STATUS).setValue(status);
item.getItemProperty(COLUMN_REASON).setValue(getFailureReason(fileUploadId));
final long bytesRead = fileUploadProgress.getBytesRead();
final long fileSize = fileUploadProgress.getContentLength();
if (bytesRead > 0 && fileSize > 0) {
item.getItemProperty(COLUMN_PROGRESS).setValue((double) bytesRead / (double) fileSize);
}
}
内容来源于网络,如有侵权,请联系作者删除!