use of org.ovirt.engine.ui.webadmin.widget.table.column.AbstractPercentColumn in project ovirt-engine by oVirt.
the class MainHostView method initTable.
void initTable() {
getTable().enableColumnResizing();
HostStatusColumn<VDS> statusIconColumn = new HostStatusColumn<>();
statusIconColumn.setContextMenuTitle(constants.statusIconHost());
// $NON-NLS-1$
getTable().addColumn(statusIconColumn, constants.empty(), "35px");
HostAdditionalStatusColumn additionalStatusColumn = new HostAdditionalStatusColumn();
additionalStatusColumn.setContextMenuTitle(constants.additionalStatusHost());
// $NON-NLS-1$
getTable().addColumn(additionalStatusColumn, constants.empty(), "60px");
AbstractTextColumn<VDS> nameColumn = new AbstractLinkColumn<VDS>(new FieldUpdater<VDS, String>() {
@Override
public void update(int index, VDS host, String value) {
Map<String, String> parameters = new HashMap<>();
parameters.put(FragmentParams.NAME.getName(), host.getName());
// The link was clicked, now fire an event to switch to details.
getPlaceTransitionHandler().handlePlaceTransition(WebAdminApplicationPlaces.hostGeneralSubTabPlace, parameters);
}
}) {
@Override
public String getValue(VDS object) {
return object.getName();
}
};
nameColumn.makeSortable(VdsConditionFieldAutoCompleter.NAME);
// $NON-NLS-1$
getTable().addColumn(nameColumn, constants.nameHost(), "150px");
CommentColumn<VDS> commentColumn = new CommentColumn<>();
getTable().addColumnWithHtmlHeader(commentColumn, SafeHtmlUtils.fromSafeConstant(constants.commentLabel()), // $NON-NLS-1$
"75px");
AbstractTextColumn<VDS> hostColumn = new AbstractTextColumn<VDS>() {
@Override
public String getValue(VDS object) {
return object.getHostName();
}
};
hostColumn.makeSortable(VdsConditionFieldAutoCompleter.ADDRESS);
// $NON-NLS-1$
getTable().addColumn(hostColumn, constants.ipHost(), "150px");
AbstractTextColumn<VDS> clusterColumn = new AbstractLinkColumn<VDS>(new FieldUpdater<VDS, String>() {
@Override
public void update(int index, VDS host, String value) {
Map<String, String> parameters = new HashMap<>();
parameters.put(FragmentParams.NAME.getName(), host.getClusterName());
getPlaceTransitionHandler().handlePlaceTransition(WebAdminApplicationPlaces.clusterGeneralSubTabPlace, parameters);
}
}) {
@Override
public String getValue(VDS object) {
return object.getClusterName();
}
};
clusterColumn.makeSortable(VdsConditionFieldAutoCompleter.CLUSTER);
// $NON-NLS-1$
getTable().addColumn(clusterColumn, constants.clusterHost(), "150px");
if (ApplicationModeHelper.getUiMode() != ApplicationMode.GlusterOnly) {
AbstractTextColumn<VDS> dcColumn = new AbstractLinkColumn<VDS>(new FieldUpdater<VDS, String>() {
@Override
public void update(int index, VDS host, String value) {
Map<String, String> parameters = new HashMap<>();
parameters.put(FragmentParams.NAME.getName(), host.getStoragePoolName());
getPlaceTransitionHandler().handlePlaceTransition(WebAdminApplicationPlaces.dataCenterStorageSubTabPlace, parameters);
}
}) {
@Override
public String getValue(VDS object) {
return object.getStoragePoolName();
}
};
dcColumn.makeSortable(VdsConditionFieldAutoCompleter.DATACENTER);
// $NON-NLS-1$
getTable().addColumn(dcColumn, constants.dcHost(), "150px");
}
AbstractTextColumn<VDS> statusColumn = new AbstractEnumColumn<VDS, VDSStatus>() {
@Override
public VDSStatus getRawValue(VDS object) {
return object.getStatus();
}
};
ReasonColumn<VDS> reasonColumn = new ReasonColumn<VDS>() {
@Override
protected String getReason(VDS value) {
return value.getMaintenanceReason();
}
};
List<HasCell<VDS, ?>> list = new ArrayList<>();
list.add(statusColumn);
list.add(reasonColumn);
Cell<VDS> compositeCell = new StatusCompositeCell<>(list);
AbstractColumn<VDS, VDS> statusTextColumn = new AbstractColumn<VDS, VDS>(compositeCell) {
@Override
public VDS getValue(VDS object) {
return object;
}
@Override
public SafeHtml getTooltip(VDS value) {
String maintenanceReason = value.getMaintenanceReason();
if (maintenanceReason != null && !maintenanceReason.trim().isEmpty()) {
return SafeHtmlUtils.fromString(maintenanceReason);
}
return null;
}
};
statusTextColumn.makeSortable(VdsConditionFieldAutoCompleter.STATUS);
// $NON-NLS-1$
getTable().addColumn(statusTextColumn, constants.statusHost(), "100px");
if (ApplicationModeHelper.getUiMode() != ApplicationMode.GlusterOnly) {
VmCountColumn vmCountColumn = new VmCountColumn();
vmCountColumn.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
vmCountColumn.makeSortable(VdsConditionFieldAutoCompleter.ACTIVE_VMS);
// $NON-NLS-1$
getTable().addColumn(vmCountColumn, constants.vmsCount(), "110px");
}
AbstractPercentColumn<VDS> memColumn = new AbstractPercentColumn<VDS>() {
@Override
public Integer getProgressValue(VDS object) {
return object.getUsageMemPercent();
}
};
memColumn.makeSortable(VdsConditionFieldAutoCompleter.MEM_USAGE);
// $NON-NLS-1$
getTable().addColumn(memColumn, constants.memoryHost(), "80px");
AbstractPercentColumn<VDS> cpuColumn = new AbstractPercentColumn<VDS>() {
@Override
public Integer getProgressValue(VDS object) {
return object.getUsageCpuPercent();
}
};
cpuColumn.makeSortable(VdsConditionFieldAutoCompleter.CPU_USAGE);
// $NON-NLS-1$
getTable().addColumn(cpuColumn, constants.cpuHost(), "80px");
AbstractPercentColumn<VDS> netColumn = new AbstractPercentColumn<VDS>() {
@Override
public Integer getProgressValue(VDS object) {
return object.getUsageNetworkPercent();
}
};
netColumn.makeSortable(VdsConditionFieldAutoCompleter.NETWORK_USAGE);
// $NON-NLS-1$
getTable().addColumn(netColumn, constants.networkHost(), "80px");
if (ApplicationModeHelper.getUiMode() != ApplicationMode.GlusterOnly) {
AbstractTextColumn<VDS> spmColumn = new AbstractTextColumn<VDS>() {
@Override
public String getValue(VDS object) {
int value = object.getVdsSpmPriority();
int lowValue = defaultSpmPriority / 2;
int highValue = defaultSpmPriority + (maxSpmPriority - defaultSpmPriority) / 2;
if (object.getSpmStatus() != VdsSpmStatus.None) {
return object.getSpmStatus().name();
}
if (value == -1) {
return constants.spmNeverText();
} else if (value == lowValue) {
return constants.spmLowText();
} else if (value == defaultSpmPriority) {
return constants.spmNormalText();
} else if (value == highValue) {
return constants.spmHighText();
}
return constants.spmCustomText();
}
};
// $NON-NLS-1$
getTable().addColumn(spmColumn, constants.spmPriorityHost(), "100px");
}
}
use of org.ovirt.engine.ui.webadmin.widget.table.column.AbstractPercentColumn in project ovirt-engine by oVirt.
the class SubTabDiskVmView method initTable.
void initTable() {
getTable().enableColumnResizing();
AbstractImageResourceColumn<VM> pluggedColumn = new AbstractImageResourceColumn<VM>() {
@Override
public ImageResource getValue(VM object) {
boolean isDiskPlugged = getDetailModel().isDiskPluggedToVm(object);
return isDiskPlugged ? resources.upImage() : resources.downImage();
}
@Override
public SafeHtml getTooltip(VM object) {
if (getDetailModel().isDiskPluggedToVm(object)) {
return SafeHtmlUtils.fromSafeConstant(constants.active());
}
return SafeHtmlUtils.fromSafeConstant(constants.inactive());
}
};
pluggedColumn.setContextMenuTitle(constants.pluggedVm());
// $NON-NLS-1$
getTable().addColumn(pluggedColumn, constants.empty(), "30px");
AbstractTextColumn<VM> nameColumn = new AbstractTextColumn<VM>() {
@Override
public String getValue(VM object) {
return object.getName();
}
};
nameColumn.makeSortable();
// $NON-NLS-1$
getTable().addColumn(nameColumn, constants.nameVm(), "140px");
VmTypeColumn typeColumn = new VmTypeColumn();
typeColumn.setContextMenuTitle(constants.typeVm());
// $NON-NLS-1$
getTable().addColumn(typeColumn, constants.empty(), "60px");
AbstractTextColumn<VM> clusterColumn = new AbstractTextColumn<VM>() {
@Override
public String getValue(VM object) {
return object.getClusterName();
}
};
clusterColumn.makeSortable();
// $NON-NLS-1$
getTable().addColumn(clusterColumn, constants.clusterVm(), "140px");
AbstractTextColumn<VM> ipColumn = new AbstractTextColumn<VM>() {
@Override
public String getValue(VM object) {
return object.getIp();
}
};
ipColumn.makeSortable();
// $NON-NLS-1$
getTable().addColumn(ipColumn, constants.ipVm(), "140px");
AbstractTextColumn<VM> fqdnColumn = new AbstractTextColumn<VM>() {
@Override
public String getValue(VM object) {
return object.getFqdn();
}
};
fqdnColumn.makeSortable();
// $NON-NLS-1$
getTable().addColumn(fqdnColumn, constants.fqdn(), "140px");
AbstractPercentColumn<VM> memColumn = new AbstractPercentColumn<VM>() {
@Override
public Integer getProgressValue(VM object) {
return object.getUsageMemPercent();
}
};
// $NON-NLS-1$
getTable().addColumn(memColumn, constants.memoryVm(), "140px");
AbstractPercentColumn<VM> cpuColumn = new AbstractPercentColumn<VM>() {
@Override
public Integer getProgressValue(VM object) {
return object.getUsageCpuPercent();
}
};
// $NON-NLS-1$
getTable().addColumn(cpuColumn, constants.cpuVm(), "140px");
AbstractPercentColumn<VM> netColumn = new AbstractPercentColumn<VM>() {
@Override
public Integer getProgressValue(VM object) {
return object.getUsageNetworkPercent();
}
};
// $NON-NLS-1$
getTable().addColumn(netColumn, constants.networkVm(), "140px");
AbstractTextColumn<VM> statusColumn = new AbstractEnumColumn<VM, VMStatus>() {
@Override
protected VMStatus getRawValue(VM object) {
return object.getStatus();
}
};
statusColumn.makeSortable();
// $NON-NLS-1$
getTable().addColumn(statusColumn, constants.statusVm(), "140px");
AbstractTextColumn<VM> hostColumn = new AbstractUptimeColumn<VM>() {
@Override
protected Double getRawValue(VM object) {
return object.getElapsedTime();
}
};
hostColumn.makeSortable();
// $NON-NLS-1$
getTable().addColumn(hostColumn, constants.uptimeVm(), "140px");
}
Aggregations