use of org.ovirt.engine.ui.common.widget.table.column.AbstractTextColumn in project ovirt-engine by oVirt.
the class DisksViewColumns method getQoutaColumn.
public static AbstractTextColumn<Disk> getQoutaColumn(String sortBy) {
AbstractTextColumn<Disk> column = new AbstractTextColumn<Disk>() {
@Override
public String getValue(Disk object) {
String value = "";
if (object.getDiskStorageType() == DiskStorageType.IMAGE) {
DiskImage diskImage = (DiskImage) object;
List<String> quotaNamesArr = diskImage.getQuotaNames();
if (quotaNamesArr != null) {
// $NON-NLS-1$
value = String.join(", ", quotaNamesArr);
}
}
return value;
}
};
return makeSortable(column, sortBy);
}
use of org.ovirt.engine.ui.common.widget.table.column.AbstractTextColumn in project ovirt-engine by oVirt.
the class MainVirtualMachineView method initTable.
void initTable() {
getTable().enableColumnResizing();
VmStatusColumn<VM> statusIconColumn = new VmStatusColumn<>();
statusIconColumn.setContextMenuTitle(constants.statusIconVm());
statusIconColumn.makeSortable(VmConditionFieldAutoCompleter.STATUS);
// $NON-NLS-1$
getTable().addColumn(statusIconColumn, constants.empty(), "35px");
VmTypeColumn typeColumn = new VmTypeColumn();
typeColumn.setContextMenuTitle(constants.typeVm());
typeColumn.makeSortable(VmConditionFieldAutoCompleter.TYPE);
// $NON-NLS-1$
getTable().addColumn(typeColumn, constants.empty(), "60px");
AbstractTextColumn<VM> nameColumn = new AbstractLinkColumn<VM>(new FieldUpdater<VM, String>() {
@Override
public void update(int index, VM vm, String value) {
Map<String, String> parameters = new HashMap<>();
parameters.put(FragmentParams.NAME.getName(), vm.getName());
// The link was clicked, now fire an event to switch to details.
getPlaceTransitionHandler().handlePlaceTransition(WebAdminApplicationPlaces.virtualMachineGeneralSubTabPlace, parameters);
}
}) {
@Override
public String getValue(VM object) {
return object.getName();
}
};
nameColumn.makeSortable(VmConditionFieldAutoCompleter.NAME);
// $NON-NLS-1$
getTable().addColumn(nameColumn, constants.nameVm(), "120px");
CommentColumn<VM> commentColumn = new CommentColumn<>();
getTable().addColumnWithHtmlHeader(commentColumn, SafeHtmlUtils.fromSafeConstant(constants.commentLabel()), // $NON-NLS-1$
"75px");
AbstractTextColumn<VM> hostColumn = new AbstractLinkColumn<VM>(new FieldUpdater<VM, String>() {
@Override
public void update(int index, VM vm, String value) {
Map<String, String> parameters = new HashMap<>();
parameters.put(FragmentParams.NAME.getName(), vm.getRunOnVdsName());
getPlaceTransitionHandler().handlePlaceTransition(WebAdminApplicationPlaces.hostGeneralSubTabPlace, parameters);
}
}) {
@Override
public String getValue(VM object) {
return object.getRunOnVdsName();
}
};
hostColumn.makeSortable(VmConditionFieldAutoCompleter.HOST);
// $NON-NLS-1$
getTable().addColumn(hostColumn, constants.hostVm(), "120px");
AbstractTextColumn<VM> ipColumn = new AbstractTextColumn<VM>() {
@Override
public String getValue(VM object) {
return object.getIp();
}
};
ipColumn.makeSortable(VmConditionFieldAutoCompleter.IP);
// $NON-NLS-1$
getTable().addColumn(ipColumn, constants.ipVm(), "120px");
AbstractTextColumn<VM> fqdnColumn = new AbstractTextColumn<VM>() {
@Override
public String getValue(VM object) {
return object.getFqdn();
}
};
fqdnColumn.makeSortable(VmConditionFieldAutoCompleter.FQDN);
// $NON-NLS-1$
getTable().addColumn(fqdnColumn, constants.fqdn(), "120px");
AbstractTextColumn<VM> clusterColumn = new AbstractLinkColumn<VM>(new FieldUpdater<VM, String>() {
@Override
public void update(int index, VM vm, String value) {
Map<String, String> parameters = new HashMap<>();
parameters.put(FragmentParams.NAME.getName(), vm.getClusterName());
getPlaceTransitionHandler().handlePlaceTransition(WebAdminApplicationPlaces.clusterGeneralSubTabPlace, parameters);
}
}) {
@Override
public String getValue(VM object) {
return object.getClusterName();
}
};
clusterColumn.makeSortable(VmConditionFieldAutoCompleter.CLUSTER);
// $NON-NLS-1$
getTable().addColumn(clusterColumn, constants.clusterVm(), "120px");
AbstractTextColumn<VM> dcColumn = new AbstractLinkColumn<VM>(new FieldUpdater<VM, String>() {
@Override
public void update(int index, VM vm, String value) {
Map<String, String> parameters = new HashMap<>();
parameters.put(FragmentParams.NAME.getName(), vm.getStoragePoolName());
getPlaceTransitionHandler().handlePlaceTransition(WebAdminApplicationPlaces.dataCenterStorageSubTabPlace, parameters);
}
}) {
@Override
public String getValue(VM object) {
return object.getStoragePoolName();
}
};
dcColumn.makeSortable(VmConditionFieldAutoCompleter.DATACENTER);
// $NON-NLS-1$
getTable().addColumn(dcColumn, constants.dcVm(), "120px");
getTable().addColumn(new ColumnResizeTableLineChartProgressBar<VM>(getTable(), VmConditionFieldAutoCompleter.MEM_USAGE) {
@Override
protected List<Integer> getProgressValues(VM object) {
return object.getMemoryUsageHistory();
}
}, constants.memoryVm(), // $NON-NLS-1$
"80px");
getTable().addColumn(new ColumnResizeTableLineChartProgressBar<VM>(getTable(), VmConditionFieldAutoCompleter.CPU_USAGE) {
@Override
protected List<Integer> getProgressValues(VM object) {
return object.getCpuUsageHistory();
}
}, constants.cpuVm(), // $NON-NLS-1$
"80px");
getTable().addColumn(new ColumnResizeTableLineChartProgressBar<VM>(getTable(), VmConditionFieldAutoCompleter.NETWORK_USAGE) {
@Override
protected List<Integer> getProgressValues(VM object) {
return object.getNetworkUsageHistory();
}
}, constants.networkVm(), // $NON-NLS-1$
"80px");
AbstractTextColumn<VM> graphicsColumn = new AbstractEnumColumn<VM, UnitVmModel.GraphicsTypes>() {
@Override
protected UnitVmModel.GraphicsTypes getRawValue(VM vm) {
if ((vm.getStatus() == VMStatus.Down) || (vm.getStatus() == VMStatus.ImageLocked)) {
return UnitVmModel.GraphicsTypes.NONE;
}
Map<GraphicsType, GraphicsInfo> graphicsInfos = vm.getGraphicsInfos();
return UnitVmModel.GraphicsTypes.fromGraphicsTypes(graphicsInfos.keySet());
}
};
// $NON-NLS-1$
getTable().addColumn(graphicsColumn, constants.graphicsVm(), "70px");
AbstractTextColumn<VM> statusColumn = new AbstractEnumColumn<VM, VMStatus>() {
@Override
public VMStatus getRawValue(VM object) {
return object.getStatus();
}
@Override
public String getValue(VM vm) {
if (vm.getStatus() == VMStatus.MigratingFrom) {
// will be rendered by progress column
return null;
}
if (vm.getBackgroundOperationDescription() != null) {
// will be rendered by progress column
return null;
}
return super.getValue(vm);
}
};
MigrationProgressColumn migrationProgressColumn = new MigrationProgressColumn();
ImportProgressColumn importProgressColumn = new ImportProgressColumn();
ReasonColumn<VM> reasonColumn = new ReasonColumn<VM>() {
@Override
protected String getReason(VM value) {
return value.getStopReason();
}
};
List<HasCell<VM, ?>> list = new ArrayList<>();
list.add(statusColumn);
list.add(reasonColumn);
list.add(migrationProgressColumn);
list.add(importProgressColumn);
Cell<VM> compositeCell = new StatusCompositeCell<>(list);
AbstractColumn<VM, VM> statusTextColumn = new AbstractColumn<VM, VM>(compositeCell) {
@Override
public VM getValue(VM object) {
return object;
}
@Override
public SafeHtml getTooltip(VM value) {
String stopReason = value.getStopReason();
if (stopReason != null && !stopReason.trim().isEmpty()) {
return SafeHtmlUtils.fromString(stopReason);
}
return null;
}
};
statusTextColumn.makeSortable(VmConditionFieldAutoCompleter.STATUS);
// $NON-NLS-1$
getTable().addColumn(statusTextColumn, constants.statusVm(), "120px");
AbstractTextColumn<VM> uptimeColumn = new AbstractUptimeColumn<VM>() {
@Override
public Double getRawValue(VM object) {
return object.getElapsedTime();
}
};
uptimeColumn.makeSortable(VmConditionFieldAutoCompleter.UPTIME);
// $NON-NLS-1$
getTable().addColumn(uptimeColumn, constants.uptimeVm(), "100px");
AbstractTextColumn<VM> descriptionColumn = new AbstractTextColumn<VM>() {
@Override
public String getValue(VM object) {
return object.getDescription();
}
};
descriptionColumn.makeSortable(VmConditionFieldAutoCompleter.DESCRIPTION);
// $NON-NLS-1$
getTable().addColumn(descriptionColumn, constants.description(), "150px");
}
use of org.ovirt.engine.ui.common.widget.table.column.AbstractTextColumn in project ovirt-engine by oVirt.
the class MainVolumeView method initTable.
void initTable(VolumeListModel model) {
getTable().enableColumnResizing();
VolumeStatusColumn statusColumn = new VolumeStatusColumn(model.getStartCommand());
statusColumn.setContextMenuTitle(constants.statusVolume());
statusColumn.makeSortable(Comparator.comparingInt(g -> GlusterVolumeUtils.getVolumeStatus(g).ordinal()));
// $NON-NLS-1$
getTable().addColumn(statusColumn, constants.empty(), "30px");
AbstractTextColumn<GlusterVolumeEntity> nameColumn = new AbstractLinkColumn<GlusterVolumeEntity>(new FieldUpdater<GlusterVolumeEntity, String>() {
@Override
public void update(int index, GlusterVolumeEntity volume, String value) {
Map<String, String> parameters = new HashMap<>();
parameters.put(FragmentParams.NAME.getName(), volume.getName());
// The link was clicked, now fire an event to switch to details.
getPlaceTransitionHandler().handlePlaceTransition(WebAdminApplicationPlaces.volumeGeneralSubTabPlace, parameters);
}
}) {
@Override
public String getValue(GlusterVolumeEntity object) {
return object.getName();
}
};
nameColumn.makeSortable();
// $NON-NLS-1$
getTable().addColumn(nameColumn, constants.nameVolume(), "150px");
AbstractTextColumn<GlusterVolumeEntity> clusterColumn = new AbstractTextColumn<GlusterVolumeEntity>() {
@Override
public String getValue(GlusterVolumeEntity object) {
return object.getClusterName();
}
};
clusterColumn.makeSortable();
// $NON-NLS-1$
getTable().addColumn(clusterColumn, constants.clusterVolume(), "150px");
AbstractTextColumn<GlusterVolumeEntity> volumeTypeColumn = new AbstractEnumColumn<GlusterVolumeEntity, GlusterVolumeType>() {
@Override
protected GlusterVolumeType getRawValue(GlusterVolumeEntity object) {
return object.getVolumeType();
}
};
volumeTypeColumn.makeSortable();
// $NON-NLS-1$
getTable().addColumn(volumeTypeColumn, constants.volumeTypeVolume(), "150px");
// $NON-NLS-1$
getTable().addColumn(new VolumeBrickStatusColumn(), constants.bricksStatusVolume(), "150px");
// $NON-NLS-1$
getTable().addColumn(new VolumeInfoColumn(), constants.volumeInfoVolume(), "100px");
MenuCell<GlusterTaskSupport> rebalanceMenuCell = getRebalanceActivityMenu();
MenuCell<GlusterTaskSupport> removeBricksMenuCell = getRemoveBrickActivityMenu();
List<HasCell<GlusterTaskSupport, ?>> list = new ArrayList<>();
list.add(new VolumeActivityStatusColumn<>());
list.add(new Column<GlusterTaskSupport, GlusterTaskSupport>(new VolumeActivitySeperatorCell<GlusterTaskSupport>()) {
@Override
public GlusterTaskSupport getValue(GlusterTaskSupport object) {
return object;
}
});
list.add(new Column<GlusterTaskSupport, GlusterTaskSupport>(rebalanceMenuCell) {
@Override
public GlusterTaskSupport getValue(GlusterTaskSupport object) {
return object;
}
});
list.add(new Column<GlusterTaskSupport, GlusterTaskSupport>(removeBricksMenuCell) {
@Override
public GlusterTaskSupport getValue(GlusterTaskSupport object) {
return object;
}
});
List<HasCell<GlusterTaskSupport, ?>> compositeList = new ArrayList<>();
compositeList.add(new Column<GlusterTaskSupport, GlusterTaskSupport>(new VolumeTaskWaitingCell<>()) {
@Override
public GlusterTaskSupport getValue(GlusterTaskSupport object) {
return object;
}
});
compositeList.add(new Column<GlusterTaskSupport, GlusterTaskSupport>(new VolumeActivityCompositeCell<>(list)) {
@Override
public GlusterTaskSupport getValue(GlusterTaskSupport object) {
return object;
}
});
Column<GlusterVolumeEntity, GlusterVolumeEntity> capacityColumn = new Column<GlusterVolumeEntity, GlusterVolumeEntity>(new VolumeCapacityCell()) {
@Override
public GlusterVolumeEntity getValue(GlusterVolumeEntity object) {
return object;
}
};
// $NON-NLS-1$
getTable().addColumn(capacityColumn, constants.volumeCapacity(), "100px");
getTable().addColumn(new VolumeActivityColumn<GlusterVolumeEntity>(new VolumeActivityCompositeCell<GlusterTaskSupport>(compositeList)), constants.activitiesOnVolume(), // $NON-NLS-1$
"100px");
AbstractTextColumn<GlusterVolumeEntity> snapshotCountColumn = new AbstractTextColumn<GlusterVolumeEntity>() {
@Override
public String getValue(GlusterVolumeEntity object) {
return object.getSnapshotsCount().toString();
}
};
snapshotCountColumn.makeSortable();
// $NON-NLS-1$
getTable().addColumn(snapshotCountColumn, constants.noOfSnapshotsLabel(), "100px");
}
use of org.ovirt.engine.ui.common.widget.table.column.AbstractTextColumn in project ovirt-engine by oVirt.
the class RoleView method initRoleTable.
private void initRoleTable() {
roleTable.enableColumnResizing();
// $NON-NLS-1$
roleTable.addColumn(new IsLockedImageTypeColumn(), constants.empty(), "25px");
// $NON-NLS-1$
roleTable.addColumn(new RoleTypeColumn(), constants.empty(), "25px");
AbstractTextColumn<Role> nameColumn = new AbstractTextColumn<Role>() {
@Override
public String getValue(Role object) {
return object.getName();
}
};
nameColumn.makeSortable();
// $NON-NLS-1$
roleTable.addColumn(nameColumn, constants.nameRole(), "175px");
AbstractTextColumn<Role> descColumn = new AbstractTextColumn<Role>() {
@Override
public String getValue(Role object) {
return object.getDescription();
}
};
descColumn.makeSortable();
// $NON-NLS-1$
roleTable.addColumn(descColumn, constants.descriptionRole(), "500px");
roleTable.getSelectionModel().addSelectionChangeHandler(event -> {
roleModelProvider.setSelectedItems(roleTable.getSelectionModel().getSelectedObjects());
if (roleTable.getSelectionModel().getSelectedObjects().size() > 0) {
setSubTabVisibility(true);
} else {
setSubTabVisibility(false);
}
});
roleTablePanel.add(roleTable);
}
use of org.ovirt.engine.ui.common.widget.table.column.AbstractTextColumn in project ovirt-engine by oVirt.
the class SystemPermissionView method initTable.
private void initTable(SystemPermissionActionPanelPresenterWidget actionPanel) {
table.enableColumnResizing();
// $NON-NLS-1$
table.addColumn(new PermissionTypeColumn(), constants.empty(), "30px");
AbstractTextColumn<Permission> userColumn = new AbstractTextColumn<Permission>() {
@Override
public String getValue(Permission object) {
return object.getOwnerName();
}
};
userColumn.makeSortable((u1, u2) -> u1.getOwnerName().compareTo(u2.getObjectName()));
// $NON-NLS-1$
table.addColumn(userColumn, constants.userPermission(), "270px");
AbstractTextColumn<Permission> authzColumn = new AbstractTextColumn<Permission>() {
@Override
public String getValue(Permission object) {
return object.getAuthz();
}
};
authzColumn.makeSortable((a1, a2) -> a1.getAuthz().compareTo(a2.getAuthz()));
// $NON-NLS-1$
table.addColumn(authzColumn, constants.authz(), "180px");
AbstractTextColumn<Permission> namespaceColumn = new AbstractTextColumn<Permission>() {
@Override
public String getValue(Permission object) {
return object.getNamespace();
}
};
namespaceColumn.makeSortable((ns1, ns2) -> ns1.getNamespace().compareTo(ns1.getNamespace()));
// $NON-NLS-1$
table.addColumn(namespaceColumn, constants.namespace(), "170px");
AbstractTextColumn<Permission> roleColumn = new AbstractTextColumn<Permission>() {
@Override
public String getValue(Permission object) {
return object.getRoleName();
}
};
roleColumn.makeSortable((r1, r2) -> r1.getRoleName().compareTo(r2.getRoleName()));
// $NON-NLS-1$
table.addColumn(roleColumn, constants.rolePermission(), "110px");
table.getSelectionModel().addSelectionChangeHandler(event -> modelProvider.setSelectedItems(table.getSelectionModel().getSelectedObjects()));
tablePanel.add(actionPanel);
tablePanel.add(table);
table.table.setHeight(360 + Unit.PX.getType());
}
Aggregations