use of org.ovirt.engine.ui.common.widget.table.column.AbstractTextColumn in project ovirt-engine by oVirt.
the class MainSessionView method initTable.
void initTable() {
getTable().enableColumnResizing();
AbstractTextColumn<UserSession> sessionDbIdColumn = new AbstractTextColumn<UserSession>() {
@Override
public String getValue(UserSession session) {
return Long.toString(session.getId());
}
};
sessionDbIdColumn.makeSortable(SessionConditionFieldAutoCompleter.SESSION_DB_ID);
// $NON-NLS-1$
getTable().addColumn(sessionDbIdColumn, constants.sessionDbId(), "100px");
AbstractTextColumn<UserSession> userNameColumn = new AbstractTextColumn<UserSession>() {
@Override
public String getValue(UserSession session) {
return session.getUserName();
}
};
userNameColumn.makeSortable(SessionConditionFieldAutoCompleter.USER_NAME);
// $NON-NLS-1$
getTable().addColumn(userNameColumn, constants.userNameUser(), "200px");
AbstractTextColumn<UserSession> authzNameColumn = new AbstractTextColumn<UserSession>() {
@Override
public String getValue(UserSession session) {
return session.getAuthzName();
}
};
authzNameColumn.makeSortable(SessionConditionFieldAutoCompleter.AUTHZ_NAME);
// $NON-NLS-1$
getTable().addColumn(authzNameColumn, constants.authorizationProvider(), "300px");
AbstractTextColumn<UserSession> userIdColumn = new AbstractTextColumn<UserSession>() {
@Override
public String getValue(UserSession session) {
return session.getUserId().toString();
}
};
userIdColumn.makeSortable(SessionConditionFieldAutoCompleter.USER_ID);
// $NON-NLS-1$
getTable().addColumn(userIdColumn, constants.userId(), "200px");
AbstractTextColumn<UserSession> sourceIpColumn = new AbstractTextColumn<UserSession>() {
@Override
public String getValue(UserSession session) {
return session.getSourceIp();
}
};
sourceIpColumn.makeSortable(SessionConditionFieldAutoCompleter.SOURCE_IP);
// $NON-NLS-1$
getTable().addColumn(sourceIpColumn, constants.sourceIp(), "200px");
final DateTimeFormat dateFormat = DateTimeFormat.getFormat(DateTimeFormat.PredefinedFormat.DATE_TIME_MEDIUM);
AbstractTextColumn<UserSession> sessionStartColumn = new AbstractTextColumn<UserSession>() {
@Override
public String getValue(UserSession session) {
return session.getSessionStartTime() == null ? // $NON-NLS-1$
"" : dateFormat.format(session.getSessionStartTime());
}
};
sessionStartColumn.makeSortable(Comparator.comparing(UserSession::getSessionStartTime));
// $NON-NLS-1$
getTable().addColumn(sessionStartColumn, constants.sessionStartTime(), "200px");
AbstractTextColumn<UserSession> sessionLastActiveColumn = new AbstractTextColumn<UserSession>() {
@Override
public String getValue(UserSession session) {
return session.getSessionLastActiveTime() == null ? // $NON-NLS-1$
"" : dateFormat.format(session.getSessionLastActiveTime());
}
};
sessionLastActiveColumn.makeSortable(Comparator.comparing(UserSession::getSessionLastActiveTime));
// $NON-NLS-1$
getTable().addColumn(sessionLastActiveColumn, constants.sessionLastActiveTime(), "200px");
}
use of org.ovirt.engine.ui.common.widget.table.column.AbstractTextColumn in project ovirt-engine by oVirt.
the class SubTabUserQuotaView method initTable.
void initTable() {
getTable().enableColumnResizing();
QuotaDcStatusColumn dcStatusColumn = new QuotaDcStatusColumn();
dcStatusColumn.setContextMenuTitle(constants.dcStatusQuota());
// $NON-NLS-1$
getTable().addColumn(dcStatusColumn, constants.empty(), "30px");
AbstractTextColumn<Quota> nameColumn = new AbstractTextColumn<Quota>() {
@Override
public String getValue(Quota object) {
// $NON-NLS-1$
return object.getQuotaName() == null ? "" : object.getQuotaName();
}
};
nameColumn.makeSortable(QuotaComparator.NAME);
// $NON-NLS-1$
getTable().addColumn(nameColumn, constants.nameQuota(), "300px");
AbstractTextColumn<Quota> descriptionColumn = new AbstractTextColumn<Quota>() {
@Override
public String getValue(Quota object) {
// $NON-NLS-1$
return object.getDescription() == null ? "" : object.getDescription();
}
};
descriptionColumn.makeSortable(QuotaComparator.DESCRIPTION);
// $NON-NLS-1$
getTable().addColumn(descriptionColumn, constants.descriptionQuota(), "300px");
AbstractTextColumn<Quota> datacenterColumn = new AbstractTextColumn<Quota>() {
@Override
public String getValue(Quota object) {
// $NON-NLS-1$
return object.getStoragePoolName() == null ? "" : object.getStoragePoolName();
}
};
datacenterColumn.makeSortable(QuotaComparator.DATA_CENTER);
// $NON-NLS-1$
getTable().addColumn(datacenterColumn, constants.dcQuota(), "300px");
}
use of org.ovirt.engine.ui.common.widget.table.column.AbstractTextColumn in project ovirt-engine by oVirt.
the class VmDiskAttachPopupWidget method initDiskImagesTable.
private void initDiskImagesTable() {
imageDiskTable.enableColumnResizing();
AbstractTextColumn<EntityModel> aliasColumn = new AbstractTextColumn<EntityModel>() {
@Override
public String getValue(EntityModel object) {
DiskImage diskImage = (DiskImage) ((DiskModel) object.getEntity()).getDisk();
return diskImage.getDiskAlias();
}
};
// $NON-NLS-1$
imageDiskTable.addColumn(aliasColumn, constants.aliasVmDiskTable(), "85px");
AbstractTextColumn<EntityModel> descriptionColumn = new AbstractTextColumn<EntityModel>() {
@Override
public String getValue(EntityModel object) {
DiskImage diskImage = (DiskImage) ((DiskModel) object.getEntity()).getDisk();
return diskImage.getDiskDescription();
}
};
// $NON-NLS-1$
imageDiskTable.addColumn(descriptionColumn, constants.descriptionVmDiskTable(), "85px");
AbstractTextColumn<EntityModel> idColumn = new AbstractTextColumn<EntityModel>() {
@Override
public String getValue(EntityModel object) {
DiskImage diskImage = (DiskImage) ((DiskModel) object.getEntity()).getDisk();
return diskImage.getId().toString();
}
};
// $NON-NLS-1$
imageDiskTable.addColumn(idColumn, constants.idVmDiskTable(), "85px");
AbstractDiskSizeColumn<EntityModel> sizeColumn = new AbstractDiskSizeColumn<EntityModel>() {
@Override
protected Long getRawValue(EntityModel object) {
DiskImage diskImage = (DiskImage) ((DiskModel) object.getEntity()).getDisk();
return diskImage.getSize();
}
};
// $NON-NLS-1$
imageDiskTable.addColumn(sizeColumn, constants.provisionedSizeVmDiskTable(), "100px");
AbstractDiskSizeColumn<EntityModel> actualSizeColumn = new AbstractDiskSizeColumn<EntityModel>() {
@Override
protected Long getRawValue(EntityModel object) {
DiskImage diskImage = (DiskImage) ((DiskModel) object.getEntity()).getDisk();
return diskImage.getActualSizeInBytes();
}
};
// $NON-NLS-1$
imageDiskTable.addColumn(actualSizeColumn, constants.sizeVmDiskTable(), "100px");
AbstractTextColumn<EntityModel> storageDomainColumn = new AbstractTextColumn<EntityModel>() {
@Override
public String getValue(EntityModel object) {
DiskImage diskImage = (DiskImage) ((DiskModel) object.getEntity()).getDisk();
return diskImage.getStoragesNames().get(0);
}
};
// $NON-NLS-1$
imageDiskTable.addColumn(storageDomainColumn, constants.storageDomainVmDiskTable(), "100px");
// $NON-NLS-1$
imageDiskTable.addColumn(getDiskInterfaceSelectionColumn(), constants.interfaceVmDiskPopup(), "115px");
imageDiskTable.addColumn(getReadOnlyCheckBoxColumn(), new ImageResourceHeader(resources.readOnlyDiskIcon(), SafeHtmlUtils.fromTrustedString(constants.readOnly())), // $NON-NLS-1$
"30px");
imageDiskTable.addColumn(getBootCheckBoxColumn(), new ImageResourceHeader(resources.bootableDiskIcon(), SafeHtmlUtils.fromTrustedString(constants.bootableDisk())), // $NON-NLS-1$
"30px");
imageDiskTable.addColumn(new AbstractImageResourceColumn<EntityModel>() {
@Override
public ImageResource getValue(EntityModel object) {
Disk disk = ((DiskModel) object.getEntity()).getDisk();
return disk.isShareable() ? resources.shareableDiskIcon() : null;
}
@Override
public SafeHtml getTooltip(EntityModel object) {
Disk disk = ((DiskModel) object.getEntity()).getDisk();
if (disk.isShareable()) {
return SafeHtmlUtils.fromSafeConstant(constants.shareable());
}
return null;
}
}, new ImageResourceHeader(resources.shareableDiskIcon(), SafeHtmlUtils.fromTrustedString(constants.shareable())), // $NON-NLS-1$
"30px");
// $NON-NLS-1$
imageDiskTable.setWidth("100%");
imageDiskTable.setEmptyTableWidget(new NoItemsLabel());
}
use of org.ovirt.engine.ui.common.widget.table.column.AbstractTextColumn in project ovirt-engine by oVirt.
the class VmSnapshotCustomPreviewPopupWidget method createPreviewTable.
private void createPreviewTable() {
previewTable.addColumn(new AbstractFullDateTimeColumn<SnapshotModel>() {
@Override
protected Date getRawValue(SnapshotModel snapshotModel) {
return snapshotModel.getEntity().getCreationDate();
}
}, constants.dateSnapshot(), // $NON-NLS-1$
"140px");
previewTable.addColumn(new AbstractTextColumn<SnapshotModel>() {
@Override
public String getValue(SnapshotModel snapshotModel) {
return snapshotModel.getEntity().getDescription();
}
}, constants.descriptionSnapshot(), // $NON-NLS-1$
"100px");
previewTable.setSelectionModel(new NoSelectionModel());
Column<SnapshotModel, Boolean> vmConfColumn = new Column<SnapshotModel, Boolean>(new RadioboxCell()) {
@Override
public Boolean getValue(SnapshotModel model) {
Snapshot snapshotVmConf = model.getEntity();
Snapshot toPreviewVmConf = previewSnapshotModel.getSnapshotModel().getEntity();
if (snapshotVmConf == null && toPreviewVmConf == null) {
return true;
}
return snapshotVmConf != null && snapshotVmConf.equals(toPreviewVmConf);
}
@Override
public void render(Context context, SnapshotModel snapshotModel, SafeHtmlBuilder sb) {
if (!snapshotModel.getEntity().isVmConfigurationBroken()) {
super.render(context, snapshotModel, sb);
} else {
sb.appendEscaped(constants.notAvailableLabel());
}
}
};
vmConfColumn.setFieldUpdater((index, snapshotModel, value) -> {
previewSnapshotModel.setSnapshotModel(snapshotModel);
previewSnapshotModel.clearMemorySelection();
updateWarnings();
refreshTable(previewTable);
if (snapshotModel.getVm() == null) {
snapshotModel.updateVmConfiguration(returnValue -> updateInfoPanel());
} else {
updateInfoPanel();
}
});
previewTable.addColumn(vmConfColumn, new ImageResourceHeader(resources.vmConfIcon(), SafeHtmlUtils.fromTrustedString(constants.vmConfiguration())), // $NON-NLS-1$
"30px");
AbstractCheckboxColumn<SnapshotModel> memoryColumn = new AbstractCheckboxColumn<SnapshotModel>((index, snapshotModel, value) -> {
previewSnapshotModel.getSnapshotModel().getMemory().setEntity(value);
refreshTable(previewTable);
updateWarnings();
}) {
@Override
public Boolean getValue(SnapshotModel snapshotModel) {
return snapshotModel.getMemory().getEntity();
}
@Override
protected boolean canEdit(SnapshotModel snapshotModel) {
boolean containsMemory = snapshotModel.getEntity().containsMemory();
SnapshotModel selectedSnapshotModel = previewSnapshotModel.getSnapshotModel();
return containsMemory && snapshotModel == selectedSnapshotModel;
}
@Override
public void render(Context context, SnapshotModel snapshotModel, SafeHtmlBuilder sb) {
if (snapshotModel.getEntity().containsMemory()) {
super.render(context, snapshotModel, sb);
} else {
sb.appendEscaped(constants.notAvailableLabel());
}
}
};
previewTable.addColumn(memoryColumn, templates.iconWithText(imageResourceToSafeHtml(resources.memorySmallIcon()), constants.memorySnapshot()), // $NON-NLS-1$
"100px");
AbstractCheckboxColumn<SnapshotModel> vmLeaseColumn = new AbstractCheckboxColumn<SnapshotModel>((index, snapshotModel, value) -> {
snapshotModel.getLeaseExists().setEntity(value);
refreshTable(previewTable);
updateWarnings();
}) {
@Override
public Boolean getValue(SnapshotModel model) {
if (model.getLeaseExists() != null) {
return model.getLeaseExists().getEntity();
}
return false;
}
@Override
protected boolean canEdit(SnapshotModel snapshotModel) {
// prevent from selecting more then one leases in case many snapshots have leases
if (snapshotModel.getLeaseExists() != null) {
SnapshotModel result = previewSnapshotModel.getSnapshots().getItems().stream().filter(model -> model.getEntity().getId() != snapshotModel.getEntity().getId()).filter(model -> model.getLeaseExists().getEntity() != null).filter(model -> model.getLeaseExists().getEntity()).findFirst().orElse(null);
return result == null;
}
return false;
}
@Override
public void render(Context context, SnapshotModel snapshotModel, SafeHtmlBuilder sb) {
if (snapshotModel.getLeaseExists().getEntity() != null) {
super.render(context, snapshotModel, sb);
} else {
sb.appendEscaped(constants.notAvailableLabel());
}
}
};
// $NON-NLS-1$
previewTable.addColumn(vmLeaseColumn, constants.leaseSnapshot(), "80px");
List<DiskImage> disks = previewSnapshotModel.getAllDisks();
Collections.sort(disks, new DiskByDiskAliasComparator());
for (final DiskImage disk : disks) {
previewTable.addColumn(new AbstractCheckboxColumn<SnapshotModel>((index, snapshotModel, value) -> {
ListModel diskListModel = previewSnapshotModel.getDiskSnapshotsMap().get(disk.getId());
DiskImage image = snapshotModel.getImageByDiskId(disk.getId());
diskListModel.setSelectedItem(Boolean.TRUE.equals(value) ? image : null);
refreshTable(previewTable);
updateWarnings();
updateInfoPanel();
}) {
@Override
public Boolean getValue(SnapshotModel snapshotModel) {
ListModel diskListModel = previewSnapshotModel.getDiskSnapshotsMap().get(disk.getId());
DiskImage image = snapshotModel.getImageByDiskId(disk.getId());
return image != null ? image.equals(diskListModel.getSelectedItem()) : false;
}
@Override
protected boolean canEdit(SnapshotModel model) {
return true;
}
@Override
public void render(Context context, SnapshotModel snapshotModel, SafeHtmlBuilder sb) {
DiskImage image = snapshotModel.getImageByDiskId(disk.getId());
if (image == null) {
sb.appendEscaped(constants.notAvailableLabel());
} else if (image.getImageStatus() == ImageStatus.ILLEGAL) {
sb.append(templates.text(constants.notAvailableLabel()));
} else {
super.render(context, snapshotModel, sb);
}
}
@Override
public SafeHtml getTooltip(SnapshotModel model) {
if (disk != null && disk.getId() != null) {
DiskImage image = model.getImageByDiskId(disk.getId());
if (image != null && image.getImageStatus() == ImageStatus.ILLEGAL) {
return SafeHtmlUtils.fromSafeConstant(constants.illegalStatus());
}
}
return null;
}
}, new SafeHtmlHeader(templates.iconWithText(imageResourceToSafeHtml(resources.diskIcon()), disk.getDiskAlias()), SafeHtmlUtils.fromString(disk.getId().toString())), // $NON-NLS-1$
"120px");
// Edit preview table
previewTable.asEditor().edit(previewSnapshotModel.getSnapshots());
}
previewTable.addCellPreviewHandler(new CellPreviewEvent.Handler<EntityModel>() {
long lastClick = -1000;
@Override
public void onCellPreview(CellPreviewEvent<EntityModel> event) {
NativeEvent nativeEvent = event.getNativeEvent();
long clickAt = System.currentTimeMillis();
if (BrowserEvents.CLICK.equals(nativeEvent.getType())) {
if (clickAt - lastClick < 300) {
// double click: 2 clicks detected within 300 ms
SnapshotModel selectedSnapshotModel = (SnapshotModel) event.getValue();
if (!selectedSnapshotModel.getEntity().isVmConfigurationBroken()) {
previewSnapshotModel.clearSelection(selectedSnapshotModel.getEntity().getId());
previewSnapshotModel.selectSnapshot(selectedSnapshotModel.getEntity().getId());
updateWarnings();
refreshTable(previewTable);
}
}
lastClick = System.currentTimeMillis();
}
}
});
}
use of org.ovirt.engine.ui.common.widget.table.column.AbstractTextColumn in project ovirt-engine by oVirt.
the class VmSnapshotInfoPanel method initAppsTable.
private void initAppsTable() {
appsTable = new EntityModelCellTable<>(false, true);
AbstractTextColumn<String> appNameColumn = new AbstractTextColumn<String>() {
@Override
public String getValue(String appName) {
return appName;
}
};
appsTable.addColumn(appNameColumn, constants.nameSnapshot());
appsTable.setRowData(new ArrayList<EntityModel>());
// $NON-NLS-1$
appsTable.setWidth("100%");
appsTable.setSelectionModel(new NoSelectionModel());
}
Aggregations