use of org.ovirt.engine.ui.common.widget.table.column.AbstractTextColumn in project ovirt-engine by oVirt.
the class ErrataTableView method initErrataGrid.
/**
* Setup the columns in the errata grid. This configuration is also used in MainEngineErrataView.
*/
@SuppressWarnings({ "rawtypes", "unchecked" })
public static void initErrataGrid(HasColumns grid, boolean isEngineErrataView, final PlaceTransitionHandler transitionHandler) {
grid.enableColumnResizing();
AbstractIconTypeColumn<Erratum> errataTypeColumn = new AbstractIconTypeColumn<Erratum>() {
@Override
public IconType getValue(Erratum erratum) {
if (erratum.getType() == ErrataType.BUGFIX) {
getCell().setColor(SafeHtmlUtils.fromTrustedString(ErrataType.BUGFIX.getColor()));
return IconType.BUG;
} else if (erratum.getType() == ErrataType.ENHANCEMENT) {
getCell().setColor(SafeHtmlUtils.fromTrustedString(ErrataType.ENHANCEMENT.getColor()));
return IconType.PLUS_SQUARE;
} else if (erratum.getType() == ErrataType.SECURITY) {
getCell().setColor(SafeHtmlUtils.fromTrustedString(ErrataType.SECURITY.getColor()));
return IconType.WARNING;
}
return null;
}
};
errataTypeColumn.makeSortable(new ErrataTypeComparator());
// $NON-NLS-1$ //$NON-NLS-2$
grid.addColumn(errataTypeColumn, "", "30px");
AbstractTextColumn errataTypeTextColumn = new AbstractTextColumn<Erratum>() {
@Override
public String getValue(Erratum erratum) {
if (erratum.getType() == ErrataType.BUGFIX) {
return constants.bug();
} else if (erratum.getType() == ErrataType.ENHANCEMENT) {
return constants.enhancement();
} else if (erratum.getType() == ErrataType.SECURITY) {
return constants.security();
}
return constants.unknown();
}
};
errataTypeTextColumn.makeSortable();
// $NON-NLS-1$
grid.addColumn(errataTypeTextColumn, constants.errataType(), "150px");
AbstractTextColumn<Erratum> errataSeverityColumn = new AbstractTextColumn<Erratum>() {
@Override
public String getValue(Erratum erratum) {
if (erratum.getSeverity() == ErrataSeverity.CRITICAL) {
return constants.critical();
} else if (erratum.getSeverity() == ErrataSeverity.IMPORTANT) {
return constants.important();
} else if (erratum.getSeverity() == ErrataSeverity.MODERATE) {
return constants.moderate();
}
return constants.unknown();
}
};
errataSeverityColumn.makeSortable();
// $NON-NLS-1$
grid.addColumn(errataSeverityColumn, constants.errataSeverity(), "150px");
AbstractFullDateTimeColumn<Erratum> dateIssuedColumn = new AbstractFullDateTimeColumn<Erratum>(false) {
@Override
protected Date getRawValue(Erratum erratum) {
return erratum.getIssued();
}
};
dateIssuedColumn.makeSortable();
// $NON-NLS-1$
grid.addColumn(dateIssuedColumn, constants.errataDateIssued(), "100px");
AbstractTextColumn<Erratum> errataIdColumn;
if (!isEngineErrataView) {
errataIdColumn = new AbstractTextColumn<Erratum>() {
@Override
public String getValue(Erratum erratum) {
return erratum.getId();
}
};
} else {
errataIdColumn = new AbstractLinkColumn<Erratum>(new FieldUpdater<Erratum, String>() {
@Override
public void update(int index, Erratum erratum, String value) {
Map<String, String> parameters = new HashMap<>();
parameters.put(FragmentParams.NAME.getName(), erratum.getName());
// The link was clicked, now fire an event to switch to details.
transitionHandler.handlePlaceTransition(WebAdminApplicationPlaces.errataDetailsSubTabPlace, parameters);
}
}) {
@Override
public String getValue(Erratum erratum) {
return erratum.getId();
}
};
}
errataIdColumn.makeSortable();
// $NON-NLS-1$
grid.addColumn(errataIdColumn, constants.errataId(), "115px");
AbstractTextColumn<Erratum> titleColumn = new AbstractTextColumn<Erratum>() {
@Override
public String getValue(Erratum erratum) {
return erratum.getTitle();
}
};
titleColumn.makeSortable();
// $NON-NLS-1$
grid.addColumn(titleColumn, constants.errataTitle(), "290px");
}
use of org.ovirt.engine.ui.common.widget.table.column.AbstractTextColumn in project ovirt-engine by oVirt.
the class MainQuotaView 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 AbstractLinkColumn<Quota>(new FieldUpdater<Quota, String>() {
@Override
public void update(int index, Quota quota, String value) {
Map<String, String> parameters = new HashMap<>();
parameters.put(FragmentParams.NAME.getName(), quota.getName());
parameters.put(FragmentParams.DATACENTER.getName(), quota.getStoragePoolName());
// The link was clicked, now fire an event to switch to details.
getPlaceTransitionHandler().handlePlaceTransition(WebAdminApplicationPlaces.quotaClusterSubTabPlace, parameters);
}
}) {
@Override
public String getValue(Quota object) {
// $NON-NLS-1$
return object.getQuotaName() == null ? "" : object.getQuotaName();
}
};
nameColumn.makeSortable(QuotaConditionFieldAutoCompleter.NAME);
// $NON-NLS-1$
getTable().addColumn(nameColumn, constants.nameQuota(), "120px");
AbstractTextColumn<Quota> dataCenterColumn = new AbstractTextColumn<Quota>() {
@Override
public String getValue(Quota object) {
return object.getStoragePoolName() == null ? "" : object.getStoragePoolName();
}
};
dataCenterColumn.makeSortable(QuotaConditionFieldAutoCompleter.STORAGEPOOLNAME);
// $NON-NLS-1$
getTable().addColumn(dataCenterColumn, constants.dcQuota(), "120px");
AbstractTextColumn<Quota> descriptionColumn = new AbstractTextColumn<Quota>() {
@Override
public String getValue(Quota object) {
// $NON-NLS-1$
return object.getDescription() == null ? "" : object.getDescription();
}
};
descriptionColumn.makeSortable(QuotaConditionFieldAutoCompleter.DESCRIPTION);
// $NON-NLS-1$
getTable().addColumn(descriptionColumn, constants.descriptionQuota(), "120px");
getTable().addColumn(new AbstractQuotaPercentColumn<Quota>() {
@Override
protected Integer getProgressValue(Quota object) {
int value;
long allocated = 0;
long used = 0;
if (object.getGlobalQuotaCluster() != null) {
allocated = object.getGlobalQuotaCluster().getMemSizeMB();
used = object.getGlobalQuotaCluster().getMemSizeMBUsage();
} else {
for (QuotaCluster quotaCluster : object.getQuotaClusters()) {
if (!QuotaCluster.UNLIMITED_MEM.equals(quotaCluster.getMemSizeMB())) {
allocated += quotaCluster.getMemSizeMB() != null ? quotaCluster.getMemSizeMB() : 0;
used += quotaCluster.getMemSizeMBUsage();
} else {
allocated = QuotaCluster.UNLIMITED_MEM;
break;
}
}
}
if (allocated == 0) {
return 0;
}
value = (int) (((double) used / allocated) * 100);
return allocated < 0 ? -1 : value > 100 ? 100 : value;
}
}, constants.usedMemoryQuota(), // $NON-NLS-1$
"145px");
getTable().addColumn(new AbstractTextColumn<Quota>() {
@Override
public String getValue(Quota object) {
int value;
long allocated = 0;
long used = 0;
if (object.getGlobalQuotaCluster() != null) {
allocated = object.getGlobalQuotaCluster().getMemSizeMB();
used = object.getGlobalQuotaCluster().getMemSizeMBUsage();
} else {
for (QuotaCluster quotaCluster : object.getQuotaClusters()) {
if (!QuotaCluster.UNLIMITED_MEM.equals(quotaCluster.getMemSizeMB())) {
allocated += quotaCluster.getMemSizeMB() != null ? quotaCluster.getMemSizeMB() : 0;
used += quotaCluster.getMemSizeMBUsage();
} else {
allocated = QuotaCluster.UNLIMITED_MEM;
break;
}
}
}
value = (int) (allocated - used);
String returnVal;
if (allocated < 0) {
returnVal = constants.unlimited();
} else if (value <= 0) {
// $NON-NLS-1$
returnVal = messages.megabytes("0");
} else if (value <= 5 * 1024) {
returnVal = messages.megabytes(String.valueOf(value));
} else {
returnVal = messages.gibibytes(decimalFormat.format((double) value / 1024));
}
return returnVal;
}
}, constants.freeMemory(), // $NON-NLS-1$
"100px");
getTable().addColumn(new AbstractQuotaPercentColumn<Quota>() {
@Override
protected Integer getProgressValue(Quota object) {
int value;
int allocated = 0;
int used = 0;
if (object.getGlobalQuotaCluster() != null) {
allocated = object.getGlobalQuotaCluster().getVirtualCpu() != null ? object.getGlobalQuotaCluster().getVirtualCpu() : 0;
used = object.getGlobalQuotaCluster().getVirtualCpuUsage();
} else {
for (QuotaCluster quotaCluster : object.getQuotaClusters()) {
if (!QuotaCluster.UNLIMITED_VCPU.equals(quotaCluster.getVirtualCpu())) {
allocated += quotaCluster.getVirtualCpu();
used += quotaCluster.getVirtualCpuUsage();
} else {
allocated = QuotaCluster.UNLIMITED_VCPU;
break;
}
}
}
if (allocated == 0) {
return 0;
}
value = (int) (((double) used / allocated) * 100);
return allocated < 0 ? -1 : value > 100 ? 100 : value;
}
}, constants.runningCpuQuota(), // $NON-NLS-1$
"135px");
getTable().addColumn(new AbstractTextColumn<Quota>() {
@Override
public String getValue(Quota object) {
int value;
int allocated = 0;
int used = 0;
if (object.getGlobalQuotaCluster() != null) {
allocated = object.getGlobalQuotaCluster().getVirtualCpu() != null ? object.getGlobalQuotaCluster().getVirtualCpu() : 0;
used = object.getGlobalQuotaCluster().getVirtualCpuUsage();
} else {
for (QuotaCluster quotaCluster : object.getQuotaClusters()) {
if (!QuotaCluster.UNLIMITED_VCPU.equals(quotaCluster.getVirtualCpu())) {
allocated += quotaCluster.getVirtualCpu();
used += quotaCluster.getVirtualCpuUsage();
} else {
allocated = QuotaCluster.UNLIMITED_VCPU;
break;
}
}
}
value = allocated - used;
String returnVal;
if (allocated < 0) {
returnVal = constants.unlimited();
} else if (value <= 0) {
// $NON-NLS-1$
returnVal = "0";
} else {
// $NON-NLS-1$
returnVal = value + "";
}
return returnVal;
}
}, constants.freeVcpu(), // $NON-NLS-1$
"100px");
getTable().addColumn(new AbstractQuotaPercentColumn<Quota>() {
@Override
protected Integer getProgressValue(Quota object) {
int value;
double allocated = 0;
double used = 0;
if (object.getGlobalQuotaStorage() != null) {
allocated = object.getGlobalQuotaStorage().getStorageSizeGB();
used = object.getGlobalQuotaStorage().getStorageSizeGBUsage();
} else {
for (QuotaStorage quotaStorage : object.getQuotaStorages()) {
if (!QuotaStorage.UNLIMITED.equals(quotaStorage.getStorageSizeGB())) {
allocated += quotaStorage.getStorageSizeGB();
used += quotaStorage.getStorageSizeGBUsage();
} else {
allocated = QuotaStorage.UNLIMITED;
break;
}
}
}
if (allocated == 0) {
return 0;
}
value = (int) ((used / allocated) * 100);
return allocated < 0 ? -1 : value > 100 ? 100 : value;
}
}, constants.usedStorageQuota(), // $NON-NLS-1$
"155px");
getTable().addColumn(new AbstractTextColumn<Quota>() {
@Override
public String getValue(Quota object) {
double value;
double allocated = 0;
double used = 0;
if (object.getGlobalQuotaStorage() != null) {
allocated = object.getGlobalQuotaStorage().getStorageSizeGB();
used = object.getGlobalQuotaStorage().getStorageSizeGBUsage();
} else {
for (QuotaStorage quotaStorage : object.getQuotaStorages()) {
if (!QuotaStorage.UNLIMITED.equals(quotaStorage.getStorageSizeGB())) {
allocated += quotaStorage.getStorageSizeGB();
used += quotaStorage.getStorageSizeGBUsage();
} else {
allocated = QuotaStorage.UNLIMITED;
break;
}
}
}
value = allocated - used;
String returnVal;
if (allocated < 0) {
returnVal = constants.unlimited();
} else if (value <= 0) {
// $NON-NLS-1$
returnVal = messages.gibibytes("0");
} else {
returnVal = diskSizeRenderer.render(value);
}
return returnVal;
}
}, constants.freeStorage(), // $NON-NLS-1$
"100px");
}
use of org.ovirt.engine.ui.common.widget.table.column.AbstractTextColumn in project ovirt-engine by oVirt.
the class ImportTemplatePopupView method initMainTable.
@Override
protected void initMainTable() {
this.table = new ListModelObjectCellTable<>();
AbstractCheckboxColumn<Object> cloneTemplateColumn = new AbstractCheckboxColumn<Object>((index, model, value) -> {
((ImportTemplateData) model).getClone().setEntity(value);
table.asEditor().edit(importModel);
}) {
@Override
public Boolean getValue(Object model) {
return ((ImportTemplateData) model).getClone().getEntity();
}
@Override
protected boolean canEdit(Object model) {
return ((ImportTemplateData) model).getClone().getIsChangable();
}
};
// $NON-NLS-1$
table.addColumn(cloneTemplateColumn, constants.cloneVM(), "50px");
AbstractTextColumn<Object> nameColumn = new AbstractTextColumn<Object>() {
@Override
public String getValue(Object object) {
return ((ImportTemplateData) object).getTemplate().getName();
}
};
// $NON-NLS-1$
table.addColumn(nameColumn, constants.nameTemplate(), "150px");
AbstractTextColumn<Object> versionNameColumn = new AbstractTextColumn<Object>() {
@Override
public String getValue(Object object) {
VmTemplate template = ((ImportTemplateData) object).getTemplate();
if (template.isBaseTemplate()) {
// $NON-NLS-1$
return "";
}
return // $NON-NLS-1$
StringFormat.format(// $NON-NLS-1$
"%s (%s)", // $NON-NLS-1$
template.getTemplateVersionName() != null ? template.getTemplateVersionName() : "", template.getTemplateVersionNumber());
}
};
// $NON-NLS-1$
table.addColumn(versionNameColumn, constants.versionTemplate(), "150px");
AbstractTextColumn<Object> originColumn = new AbstractEnumColumn<Object, OriginType>() {
@Override
protected OriginType getRawValue(Object object) {
return ((ImportTemplateData) object).getTemplate().getOrigin();
}
};
// $NON-NLS-1$
table.addColumn(originColumn, constants.originTemplate(), "100px");
AbstractTextColumn<Object> memoryColumn = new AbstractTextColumn<Object>() {
@Override
public String getValue(Object object) {
return messages.megabytes(String.valueOf(((ImportTemplateData) object).getTemplate().getMemSizeMb()));
}
};
// $NON-NLS-1$
table.addColumn(memoryColumn, constants.memoryTemplate(), "100px");
AbstractTextColumn<Object> cpuColumn = new AbstractTextColumn<Object>() {
@Override
public String getValue(Object object) {
return String.valueOf(((ImportTemplateData) object).getTemplate().getNumOfCpus());
}
};
// $NON-NLS-1$
table.addColumn(cpuColumn, constants.cpusTemplate(), "50px");
AbstractTextColumn<Object> archColumn = new AbstractTextColumn<Object>() {
@Override
public String getValue(Object object) {
return String.valueOf(((ImportTemplateData) object).getTemplate().getClusterArch());
}
};
// $NON-NLS-1$
table.addColumn(archColumn, constants.architectureTemplate(), "50px");
AbstractTextColumn<Object> diskColumn = new AbstractTextColumn<Object>() {
@Override
public String getValue(Object object) {
return String.valueOf(((ImportTemplateData) object).getTemplate().getDiskList().size());
}
};
// $NON-NLS-1$
table.addColumn(diskColumn, constants.disksTemplate(), "50px");
isObjectInSystemColumn = new AbstractImageResourceColumn<Object>() {
@Override
public ImageResource getValue(Object object) {
return ((ImportTemplateData) object).isExistsInSystem() ? resources.logNormalImage() : null;
}
};
// $NON-NLS-1$
table.addColumn(isObjectInSystemColumn, constants.templateInSetup(), "60px");
ScrollPanel sp = new ScrollPanel();
sp.add(table);
splitLayoutPanel.add(sp);
table.getElement().getStyle().setPosition(Position.RELATIVE);
}
use of org.ovirt.engine.ui.common.widget.table.column.AbstractTextColumn in project ovirt-engine by oVirt.
the class ImportVmFromExportDomainPopupView method initDiskTable.
private void initDiskTable() {
diskTable = new ListModelObjectCellTable<>();
diskTable.enableColumnResizing();
AbstractTextColumn<DiskImage> aliasColumn = new AbstractTextColumn<DiskImage>() {
@Override
public String getValue(DiskImage object) {
return object.getDiskAlias();
}
};
// $NON-NLS-1$
diskTable.addColumn(aliasColumn, constants.aliasDisk(), "100px");
AbstractImageResourceColumn<DiskImage> bootableDiskColumn = new AbstractImageResourceColumn<DiskImage>() {
@Override
public ImageResource getValue(DiskImage object) {
return object.getDiskVmElements().iterator().next().isBoot() ? getDefaultImage() : null;
}
@Override
public ImageResource getDefaultImage() {
return resources.bootableDiskIcon();
}
@Override
public SafeHtml getTooltip(DiskImage object) {
if (object.getDiskVmElements().iterator().next().isBoot()) {
return SafeHtmlUtils.fromSafeConstant(constants.bootableDisk());
}
return null;
}
};
diskTable.addColumn(bootableDiskColumn, new ImageResourceHeader(DisksViewColumns.bootableDiskColumn.getDefaultImage(), SafeHtmlUtils.fromSafeConstant(constants.bootableDisk())), // $NON-NLS-1$
"30px");
AbstractDiskSizeColumn<DiskImage> sizeColumn = new AbstractDiskSizeColumn<DiskImage>() {
@Override
protected Long getRawValue(DiskImage object) {
return object.getSize();
}
};
// $NON-NLS-1$
diskTable.addColumn(sizeColumn, constants.provisionedSizeDisk(), "130px");
AbstractDiskSizeColumn<DiskImage> actualSizeColumn = new AbstractDiskSizeColumn<DiskImage>() {
@Override
protected Long getRawValue(DiskImage object) {
return object.getActualSizeInBytes();
}
};
// $NON-NLS-1$
diskTable.addColumn(actualSizeColumn, constants.sizeDisk(), "130px");
AbstractTextColumn<DiskImage> dateCreatedColumn = new AbstractFullDateTimeColumn<DiskImage>() {
@Override
protected Date getRawValue(DiskImage object) {
return object.getCreationDate();
}
};
// $NON-NLS-1$
diskTable.addColumn(dateCreatedColumn, constants.dateCreatedInterface(), "120px");
diskTable.setSelectionModel(new NoSelectionModel<DiskImage>());
addAllocationColumn();
diskTable.getElement().getStyle().setPosition(Position.RELATIVE);
}
use of org.ovirt.engine.ui.common.widget.table.column.AbstractTextColumn in project ovirt-engine by oVirt.
the class ManagePolicyUnitPopupView method initTable.
private void initTable() {
policyUnitTable = new ListModelObjectCellTable<>();
policyUnitTable.enableColumnResizing();
policyUnitTableContainer.add(policyUnitTable);
policyUnitTable.addColumn(new AbstractImageResourceColumn<PolicyUnit>() {
@Override
public ImageResource getValue(PolicyUnit object) {
if (object.isInternal()) {
return resources.lockImage();
}
return resources.exteranlPolicyUnitImage();
}
@Override
public SafeHtml getTooltip(PolicyUnit object) {
String tooltipContent = null;
if (object.isInternal()) {
tooltipContent = constants.internalPolicyUnit();
} else {
tooltipContent = constants.externalPolicyUnit();
}
return SafeHtmlUtils.fromSafeConstant(tooltipContent);
}
}, constants.empty(), // $NON-NLS-1$
"20px");
policyUnitTable.addColumn(new AbstractTextColumn<PolicyUnit>() {
@Override
public String getValue(PolicyUnit object) {
return object.getName();
}
}, constants.policyUnitName(), // $NON-NLS-1$
"180px");
policyUnitTable.addColumn(new AbstractTextColumn<PolicyUnit>() {
@Override
public String getValue(PolicyUnit object) {
return EnumTranslator.getInstance().translate(object.getPolicyUnitType());
}
}, constants.policyUnitType(), // $NON-NLS-1$
"100px");
policyUnitTable.addColumn(new AbstractTextColumn<PolicyUnit>() {
@Override
public String getValue(PolicyUnit object) {
return object.isEnabled() ? constants.enabledPolicyUnit() : constants.disabledPolicyUnit();
}
}, constants.policyUnitEnabledStatus(), // $NON-NLS-1$
"75px");
Column<PolicyUnit, String> removeButtonColumn = new Column<PolicyUnit, String>(new NullableButtonCell()) {
@Override
public String getValue(PolicyUnit object) {
if (!object.isEnabled()) {
return constants.removePolicyUnit();
}
return null;
}
};
// $NON-NLS-1$
policyUnitTable.addColumn(removeButtonColumn, constants.removePolicyUnit(), "80px");
removeButtonColumn.setFieldUpdater((index, object, value) -> model.remove(object));
}
Aggregations