use of org.ovirt.engine.ui.common.widget.table.column.AbstractTextColumn in project ovirt-engine by oVirt.
the class MainClusterView method initTable.
void initTable() {
getTable().enableColumnResizing();
AbstractTextColumn<Cluster> nameColumn = new AbstractLinkColumn<Cluster>(new FieldUpdater<Cluster, String>() {
@Override
public void update(int index, Cluster cluster, String value) {
Map<String, String> parameters = new HashMap<>();
parameters.put(FragmentParams.NAME.getName(), cluster.getName());
// The link was clicked, now fire an event to switch to details.
getPlaceTransitionHandler().handlePlaceTransition(WebAdminApplicationPlaces.clusterGeneralSubTabPlace, parameters);
}
}) {
@Override
public String getValue(Cluster object) {
return object.getName();
}
};
nameColumn.makeSortable(ClusterConditionFieldAutoCompleter.NAME);
// $NON-NLS-1$
getTable().addColumn(nameColumn, constants.nameCluster(), "150px");
ClusterAdditionalStatusColumn additionalStatusColumn = new ClusterAdditionalStatusColumn();
additionalStatusColumn.setContextMenuTitle(constants.additionalStatusCluster());
// $NON-NLS-1$
getTable().addColumn(additionalStatusColumn, constants.empty(), "30px");
CommentColumn<Cluster> commentColumn = new CommentColumn<>();
getTable().addColumnWithHtmlHeader(commentColumn, SafeHtmlUtils.fromSafeConstant(constants.commentLabel()), // $NON-NLS-1$
"75px");
if (ApplicationModeHelper.getUiMode() != ApplicationMode.GlusterOnly) {
AbstractTextColumn<Cluster> dataCenterColumn = new AbstractTextColumn<Cluster>() {
@Override
public String getValue(Cluster object) {
return object.getStoragePoolName();
}
};
// $NON-NLS-1$
getTable().addColumn(dataCenterColumn, constants.dcCluster(), "150px");
}
AbstractTextColumn<Cluster> versionColumn = new AbstractTextColumn<Cluster>() {
@Override
public String getValue(Cluster object) {
return object.getCompatibilityVersion().getValue();
}
};
// $NON-NLS-1$
getTable().addColumn(versionColumn, constants.comptVersCluster(), "150px");
AbstractTextColumn<Cluster> descColumn = new AbstractTextColumn<Cluster>() {
@Override
public String getValue(Cluster object) {
return object.getDescription();
}
};
descColumn.makeSortable(ClusterConditionFieldAutoCompleter.DESCRIPTION);
// $NON-NLS-1$
getTable().addColumn(descColumn, constants.descriptionCluster(), "300px");
if (ApplicationModeHelper.getUiMode() != ApplicationMode.GlusterOnly) {
AbstractTextColumn<Cluster> cpuTypeColumn = new AbstractTextColumn<Cluster>() {
@Override
public String getValue(Cluster object) {
return object.getCpuName();
}
};
// $NON-NLS-1$
getTable().addColumn(cpuTypeColumn, constants.cpuTypeCluster(), "150px");
}
AbstractTextColumn<Cluster> hostCountColumn = new AbstractTextColumn<Cluster>() {
@Override
public String getValue(Cluster object) {
if (object.getClusterHostsAndVms() == null) {
// $NON-NLS-1$
return "";
}
// $NON-NLS-1$
return object.getClusterHostsAndVms().getHosts() + "";
}
};
// $NON-NLS-1$
getTable().addColumn(hostCountColumn, constants.hostCount(), "150px");
AbstractTextColumn<Cluster> vmCountColumn = new AbstractTextColumn<Cluster>() {
@Override
public String getValue(Cluster object) {
if (object.getClusterHostsAndVms() == null) {
// $NON-NLS-1$
return "";
}
// $NON-NLS-1$
return object.getClusterHostsAndVms().getVms() + "";
}
};
// $NON-NLS-1$
getTable().addColumn(vmCountColumn, constants.vmCount(), "150px");
}
use of org.ovirt.engine.ui.common.widget.table.column.AbstractTextColumn in project ovirt-engine by oVirt.
the class ImportNetworksPopupView method initEntityModelCellTables.
void initEntityModelCellTables() {
providerNetworks.addColumn(new AbstractTextColumn<ExternalNetwork>() {
@Override
public String getValue(ExternalNetwork model) {
return model.getDisplayName();
}
}, constants.nameNetworkHeader());
importedNetworks.addColumn(new AbstractEditTextColumn<ExternalNetwork>((index, model, value) -> model.setDisplayName(value)) {
@Override
public String getValue(ExternalNetwork model) {
return model.getDisplayName();
}
}, constants.nameNetworkHeader());
Column<ExternalNetwork, String> idColumn = new AbstractTextColumn<ExternalNetwork>() {
@Override
public String getValue(ExternalNetwork model) {
return model.getNetwork().getProvidedBy().getExternalId();
}
};
providerNetworks.addColumn(idColumn, constants.idNetworkHeader());
importedNetworks.addColumn(idColumn, constants.idNetworkHeader());
dcColumn = new AbstractListModelListBoxColumn<ExternalNetwork, StoragePool>(new NameRenderer<StoragePool>()) {
@Override
public ListModel<StoragePool> getValue(ExternalNetwork network) {
return network.getDataCenters();
}
};
importedNetworks.addColumn(dcColumn, constants.dcNetworkHeader());
AbstractCheckboxHeader publicAllHeader = new AbstractCheckboxHeader() {
@Override
protected void selectionChanged(Boolean value) {
for (ExternalNetwork model : getAllImportedNetworks()) {
model.setPublicUse(value);
}
refreshImportedNetworks();
}
@Override
public Boolean getValue() {
for (ExternalNetwork model : getAllImportedNetworks()) {
if (!model.isPublicUse()) {
return false;
}
}
return true;
}
@Override
public boolean isEnabled() {
return true;
}
@Override
public void render(Context context, SafeHtmlBuilder sb) {
super.render(context, sb);
sb.append(ImportNetworksPopupView.templates.tableHeaderInlineImage(SafeHtmlUtils.fromTrustedString(new InfoIcon(SafeHtmlUtils.EMPTY_SAFE_HTML).toString())));
}
@Override
public SafeHtml getTooltip() {
return ImportNetworksPopupView.templates.textForCheckBoxHeader(constants.publicNetworkTooltip());
}
@Override
public String getLabel() {
return constants.publicNetwork();
}
};
importedNetworks.addColumn(new AbstractCheckboxColumn<ExternalNetwork>((index, model, value) -> {
model.setPublicUse(value);
refreshImportedNetworks();
}) {
@Override
public Boolean getValue(ExternalNetwork model) {
return model.isPublicUse();
}
@Override
protected boolean canEdit(ExternalNetwork model) {
return true;
}
@Override
public void render(Context context, ExternalNetwork object, SafeHtmlBuilder sb) {
super.render(context, object, sb);
// $NON-NLS-1$
sb.append(templates.textForCheckBox(""));
}
}, publicAllHeader, // $NON-NLS-1$
"80px");
}
use of org.ovirt.engine.ui.common.widget.table.column.AbstractTextColumn in project ovirt-engine by oVirt.
the class ImportVmFromExportDomainPopupView method initMainTable.
protected void initMainTable() {
this.table = new ListModelObjectCellTable<>();
table.enableColumnResizing();
AbstractImageResourceColumn<Object> isProblematicImportVmColumn = new AbstractImageResourceColumn<Object>() {
@Override
public ImageResource getValue(Object object) {
ImportVmData importVmData = (ImportVmData) object;
if (importVmData.getError() != null || importVmData.isNameExistsInTheSystem()) {
return resources.errorImage();
}
if (importVmData.getWarning() != null) {
return resources.alertImage();
}
return null;
}
@Override
public SafeHtml getTooltip(Object object) {
ImportVmData importVmData = (ImportVmData) object;
String problem = null;
if (importVmData.getError() != null) {
problem = importVmData.getError();
} else {
problem = importVmData.isNameExistsInTheSystem() ? ConstantsManager.getInstance().getConstants().nameMustBeUniqueInvalidReason() : importVmData.getWarning();
}
return problem != null ? SafeHtmlUtils.fromSafeConstant(problem) : null;
}
};
// $NON-NLS-1$
table.addColumn(isProblematicImportVmColumn, constants.empty(), "30px");
AbstractTextColumn<Object> nameColumn = new AbstractTextColumn<Object>() {
@Override
public String getValue(Object object) {
String originalName = ((ImportVmData) object).getName();
String givenName = ((ImportVmData) object).getVm().getName();
return originalName.equals(givenName) ? givenName : // $NON-NLS-1$ //$NON-NLS-2$
givenName + " (" + originalName + ")";
}
};
// $NON-NLS-1$
table.addColumn(nameColumn, constants.nameVm(), "150px");
AbstractCheckboxColumn<Object> collapseSnapshotsColumn = new AbstractCheckboxColumn<Object>((index, model, value) -> {
((ImportVmData) model).getCollapseSnapshots().setEntity(value);
customSelectionCellFormatType.setEnabled(value);
diskTable.asEditor().edit(importModel.getImportDiskListModel());
}) {
@Override
public Boolean getValue(Object model) {
return ((ImportVmData) model).getCollapseSnapshots().getEntity();
}
@Override
protected boolean canEdit(Object model) {
return ((ImportVmData) model).getCollapseSnapshots().getIsChangable();
}
@Override
protected String getDisabledMessage(Object model) {
return ((ImportVmData) model).getCollapseSnapshots().getChangeProhibitionReason();
}
@Override
public SafeHtml getTooltip(Object object) {
SafeHtml superTooltip = super.getTooltip(object);
if (superTooltip == null) {
return SafeHtmlUtils.fromSafeConstant(constants.importAllocationModifiedCollapse());
}
return superTooltip;
}
};
// $NON-NLS-1$
table.addColumn(collapseSnapshotsColumn, constants.collapseSnapshots(), "130px");
AbstractCheckboxColumn<Object> cloneVMColumn = new AbstractCheckboxColumn<Object>((index, model, value) -> {
((ImportVmData) model).getClone().setEntity(value);
table.asEditor().edit(importModel);
}) {
@Override
public Boolean getValue(Object model) {
return ((ImportVmData) model).getClone().getEntity();
}
@Override
protected boolean canEdit(Object model) {
return ((ImportVmData) model).getClone().getIsChangable();
}
@Override
protected String getDisabledMessage(Object model) {
return ((ImportVmData) model).getClone().getChangeProhibitionReason();
}
};
// $NON-NLS-1$
table.addColumn(cloneVMColumn, constants.cloneVM(), "50px");
AbstractTextColumn<Object> originColumn = new AbstractEnumColumn<Object, OriginType>() {
@Override
protected OriginType getRawValue(Object object) {
return ((ImportVmData) object).getVm().getOrigin();
}
};
// $NON-NLS-1$
table.addColumn(originColumn, constants.originVm(), "100px");
table.addColumn(new AbstractSafeHtmlColumn<Object>() {
@Override
public SafeHtml getValue(Object object) {
return VmTypeColumn.getRenderedValue(((ImportVmData) object).getVm());
}
}, constants.empty(), // $NON-NLS-1$
"30px");
AbstractTextColumn<Object> memoryColumn = new AbstractTextColumn<Object>() {
@Override
public String getValue(Object object) {
return messages.megabytes(String.valueOf(((ImportVmData) object).getVm().getVmMemSizeMb()));
}
};
// $NON-NLS-1$
table.addColumn(memoryColumn, constants.memoryVm(), "90px");
AbstractTextColumn<Object> cpuColumn = new AbstractTextColumn<Object>() {
@Override
public String getValue(Object object) {
return String.valueOf(((ImportVmData) object).getVm().getNumOfCpus());
}
};
// $NON-NLS-1$
table.addColumn(cpuColumn, constants.cpusVm(), "50px");
AbstractTextColumn<Object> archColumn = new AbstractTextColumn<Object>() {
@Override
public String getValue(Object object) {
return String.valueOf(((ImportVmData) object).getVm().getClusterArch());
}
};
// $NON-NLS-1$
table.addColumn(archColumn, constants.architectureVm(), "100px");
AbstractTextColumn<Object> diskColumn = new AbstractTextColumn<Object>() {
@Override
public String getValue(Object object) {
return String.valueOf(((ImportVmData) object).getVm().getDiskMap().size());
}
};
// $NON-NLS-1$
table.addColumn(diskColumn, constants.disksVm(), "55px");
isObjectInSystemColumn = new AbstractImageResourceColumn<Object>() {
@Override
public ImageResource getValue(Object object) {
return ((ImportVmData) object).isExistsInSystem() ? resources.logNormalImage() : null;
}
};
// $NON-NLS-1$
table.addColumn(isObjectInSystemColumn, constants.vmInSetup(), "100px");
table.getSelectionModel().addSelectionChangeHandler(event -> {
ImportVmData selectedObject = ((SingleSelectionModel<ImportVmData>) event.getSource()).getSelectedObject();
customSelectionCellFormatType.setEnabled(selectedObject.getCollapseSnapshots().getEntity());
});
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 MainDataCenterView method initTable.
void initTable() {
getTable().enableColumnResizing();
DcStatusColumn statusIconColumn = new DcStatusColumn();
statusIconColumn.setContextMenuTitle(constants.statusIconDc());
// $NON-NLS-1$
getTable().addColumn(statusIconColumn, constants.empty(), "30px");
DcAdditionalStatusColumn additionalStatusColumn = new DcAdditionalStatusColumn();
additionalStatusColumn.setContextMenuTitle(constants.additionalStatusDataCenter());
// $NON-NLS-1$
getTable().addColumn(additionalStatusColumn, constants.empty(), "30px");
AbstractTextColumn<StoragePool> nameColumn = new AbstractLinkColumn<StoragePool>(new FieldUpdater<StoragePool, String>() {
@Override
public void update(int index, StoragePool storagePool, String value) {
Map<String, String> parameters = new HashMap<>();
parameters.put(FragmentParams.NAME.getName(), storagePool.getName());
// The link was clicked, now fire an event to switch to details.
getPlaceTransitionHandler().handlePlaceTransition(WebAdminApplicationPlaces.dataCenterStorageSubTabPlace, parameters);
}
}) {
@Override
public String getValue(StoragePool object) {
return object.getName();
}
};
nameColumn.makeSortable(StoragePoolFieldAutoCompleter.NAME);
// $NON-NLS-1$
getTable().addColumn(nameColumn, constants.nameDc(), "150px");
CommentColumn<StoragePool> commentColumn = new CommentColumn<>();
getTable().addColumnWithHtmlHeader(commentColumn, SafeHtmlUtils.fromSafeConstant(constants.commentLabel()), // $NON-NLS-1$
"75px");
AbstractTextColumn<StoragePool> storageTypeColumn = new AbstractBooleanColumn<StoragePool>(constants.storageTypeLocal(), constants.storageTypeShared()) {
@Override
protected Boolean getRawValue(StoragePool object) {
return object.isLocal();
}
};
storageTypeColumn.makeSortable(StoragePoolFieldAutoCompleter.LOCAL);
// $NON-NLS-1$
getTable().addColumn(storageTypeColumn, constants.storgeTypeDc(), "150px");
AbstractTextColumn<StoragePool> statusColumn = new AbstractEnumColumn<StoragePool, StoragePoolStatus>() {
@Override
public StoragePoolStatus getRawValue(StoragePool object) {
return object.getStatus();
}
};
statusColumn.makeSortable(StoragePoolFieldAutoCompleter.STATUS);
// $NON-NLS-1$
getTable().addColumn(statusColumn, constants.statusDc(), "150px");
AbstractTextColumn<StoragePool> versionColumn = new AbstractTextColumn<StoragePool>() {
@Override
public String getValue(StoragePool object) {
return object.getCompatibilityVersion().getValue();
}
};
versionColumn.makeSortable(StoragePoolFieldAutoCompleter.COMPATIBILITY_VERSION);
// $NON-NLS-1$
getTable().addColumn(versionColumn, constants.comptVersDc(), "150px");
AbstractTextColumn<StoragePool> descColumn = new AbstractTextColumn<StoragePool>() {
@Override
public String getValue(StoragePool object) {
return object.getdescription();
}
};
descColumn.makeSortable(StoragePoolFieldAutoCompleter.DESCRIPTION);
// $NON-NLS-1$
getTable().addColumn(descColumn, constants.descriptionDc(), "300px");
}
use of org.ovirt.engine.ui.common.widget.table.column.AbstractTextColumn 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");
}
}
Aggregations