diff --git a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/MainStorageView.java b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/MainStorageView.java index 3b530c0eb5d..d8a67631b6e 100644 --- a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/MainStorageView.java +++ b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/MainStorageView.java @@ -1,5 +1,6 @@ package org.ovirt.engine.ui.webadmin.section.main.view; +import java.util.Comparator; import java.util.HashMap; import java.util.Map; @@ -130,6 +131,7 @@ public Long getRawValue(StorageDomain object) { return totalSpace == null ? null : Long.valueOf(totalSpace); } }; + totalSpaceColumn.makeSortable(StorageDomainFieldAutoCompleter.TOTAL_SIZE); getTable().addColumn(totalSpaceColumn, constants.totalSpaceStorage(), "130px"); //$NON-NLS-1$ AbstractStorageSizeColumn freeSpaceColumn = new AbstractStorageSizeColumn() { @@ -158,6 +160,22 @@ public SafeHtml getTooltip(StorageDomain object) { return SafeHtmlUtils.fromString(constants.confirmedFreeSpaceStorageThinTooltip()); } }; + confirmedFreeSpaceColumn.makeSortable(new Comparator() { + @Override + public int compare(StorageDomain storage1, StorageDomain storage2) { + if (storage1.getConfirmedAvailableDiskSize() == null && storage2.getConfirmedAvailableDiskSize() == null + && storage1.getAvailableDiskSize() != null && storage2.getAvailableDiskSize() != null) { + return storage1.getAvailableDiskSize().compareTo(storage2.getAvailableDiskSize()); + } else if (storage1.getConfirmedAvailableDiskSize() != null && storage2.getConfirmedAvailableDiskSize() != null) { + return storage1.getConfirmedAvailableDiskSize().compareTo(storage2.getConfirmedAvailableDiskSize()); + } else if (storage1.getConfirmedAvailableDiskSize() != null && storage2.getAvailableDiskSize() != null) { + return storage1.getConfirmedAvailableDiskSize().compareTo(storage2.getAvailableDiskSize()); + } else if (storage2.getConfirmedAvailableDiskSize() != null && storage1.getAvailableDiskSize() != null) { + return storage1.getAvailableDiskSize().compareTo(storage2.getConfirmedAvailableDiskSize()); + } + return storage2.getName().compareTo(storage1.getName()); + } + }); getTable().addColumn(confirmedFreeSpaceColumn, constants.confirmedFreeSpaceStorage(), "180px"); //$NON-NLS-1$ AbstractStorageSizeColumn allocatedSpaceColumn = new AbstractStorageSizeColumn() { @@ -167,6 +185,7 @@ public Long getRawValue(StorageDomain object) { return allocatedSpace == null ? null : Long.valueOf(allocatedSpace); } }; + allocatedSpaceColumn.makeSortable(StorageDomainFieldAutoCompleter.COMMITTED); getTable().addColumn(allocatedSpaceColumn, constants.allocatedSpaceStorage(), "130px"); //$NON-NLS-1$ AbstractTextColumn descriptionColumn = new AbstractTextColumn() {