Gilad Chaplik has uploaded a new change for review.

Change subject: webadmin: Assign quota for disk (#848310)
......................................................................

webadmin: Assign quota for disk (#848310)

https://bugzilla.redhat.com/848310

implemented the rest of the bug, added assign quota to vm & template
disk's sub tab (previously added in disk's main tab).
same logic is implemented here (the button will be shown in iff quota isn't
disalbed and in DC tree context).
Reused the Assign quota view.

Change-Id: Ieb2d52f6caf15c1e7e4b65e75657c0f62438af4b
Signed-off-by: Gilad Chaplik <[email protected]>
---
M 
frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/CommonApplicationConstants.java
M 
frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/uicommon/vm/VmDiskListModelTable.java
M 
frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/templates/TemplateDiskListModel.java
M 
frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/templates/TemplateListModel.java
M 
frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmDiskListModel.java
M 
frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmListModel.java
M 
frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/ApplicationConstants.java
M 
frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/gin/uicommon/TemplateModule.java
M 
frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/gin/uicommon/VirtualMachineModule.java
M 
frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/tab/template/SubTabTemplateDiskView.java
10 files changed, 267 insertions(+), 11 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/81/7681/1

diff --git 
a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/CommonApplicationConstants.java
 
b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/CommonApplicationConstants.java
index 90a28ad..298b648 100644
--- 
a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/CommonApplicationConstants.java
+++ 
b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/CommonApplicationConstants.java
@@ -1009,4 +1009,7 @@
 
     @DefaultStringValue("Name")
     String elementName();
+
+    @DefaultStringValue("Assign Quota")
+    String assignQuota();
 }
diff --git 
a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/uicommon/vm/VmDiskListModelTable.java
 
b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/uicommon/vm/VmDiskListModelTable.java
index e409917..5d48a74 100644
--- 
a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/uicommon/vm/VmDiskListModelTable.java
+++ 
b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/uicommon/vm/VmDiskListModelTable.java
@@ -111,6 +111,13 @@
                 }
             });
         }
+
+        getTable().addActionButton(new 
UiCommandButtonDefinition<Disk>(getEventBus(), constants.assignQuota()) {
+            @Override
+            protected UICommand resolveCommand() {
+                return getModel().getChangeQuotaCommand();
+            }
+        });
     }
 
     protected void attachActivationListenersForModel() {
diff --git 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/templates/TemplateDiskListModel.java
 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/templates/TemplateDiskListModel.java
index 6f33166..9b32231 100644
--- 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/templates/TemplateDiskListModel.java
+++ 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/templates/TemplateDiskListModel.java
@@ -2,10 +2,18 @@
 
 import java.util.ArrayList;
 
+import org.ovirt.engine.core.common.action.ChangeQuotaParameters;
+import org.ovirt.engine.core.common.action.VdcActionParametersBase;
+import org.ovirt.engine.core.common.action.VdcActionType;
+import org.ovirt.engine.core.common.businessentities.Disk;
+import org.ovirt.engine.core.common.businessentities.Disk.DiskStorageType;
 import org.ovirt.engine.core.common.businessentities.DiskImage;
 import org.ovirt.engine.core.common.businessentities.ImageStatus;
+import org.ovirt.engine.core.common.businessentities.Quota;
+import org.ovirt.engine.core.common.businessentities.QuotaEnforcementTypeEnum;
 import org.ovirt.engine.core.common.businessentities.VmTemplate;
 import org.ovirt.engine.core.common.businessentities.storage_domains;
+import org.ovirt.engine.core.common.businessentities.storage_pool;
 import org.ovirt.engine.core.common.queries.GetVmTemplatesDisksParameters;
 import org.ovirt.engine.core.common.queries.VdcQueryType;
 import org.ovirt.engine.core.compat.PropertyChangedEventArgs;
@@ -18,8 +26,14 @@
 import org.ovirt.engine.ui.uicommonweb.Linq.StorageDomainByNameComparer;
 import org.ovirt.engine.ui.uicommonweb.UICommand;
 import org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider;
+import org.ovirt.engine.ui.uicommonweb.models.ISupportSystemTreeContext;
 import org.ovirt.engine.ui.uicommonweb.models.SearchableListModel;
+import org.ovirt.engine.ui.uicommonweb.models.SystemTreeItemType;
+import org.ovirt.engine.ui.uicommonweb.models.quota.ChangeQuotaItemModel;
+import org.ovirt.engine.ui.uicommonweb.models.quota.ChangeQuotaModel;
 import org.ovirt.engine.ui.uicompat.ConstantsManager;
+import org.ovirt.engine.ui.uicompat.FrontendMultipleActionAsyncResult;
+import org.ovirt.engine.ui.uicompat.IFrontendMultipleActionAsyncCallback;
 
 @SuppressWarnings("unused")
 public class TemplateDiskListModel extends SearchableListModel
@@ -34,6 +48,28 @@
     private void setCopyCommand(UICommand value)
     {
         privateCopyCommand = value;
+    }
+
+    ISupportSystemTreeContext systemTreeContext;
+
+    public ISupportSystemTreeContext getSystemTreeContext() {
+        return systemTreeContext;
+    }
+
+    public void setSystemTreeContext(ISupportSystemTreeContext 
systemTreeContext) {
+        this.systemTreeContext = systemTreeContext;
+    }
+
+    private UICommand privateChangeQuotaCommand;
+
+    public UICommand getChangeQuotaCommand()
+    {
+        return privateChangeQuotaCommand;
+    }
+
+    private void setChangeQuotaCommand(UICommand value)
+    {
+        privateChangeQuotaCommand = value;
     }
 
     private VmTemplate getEntityStronglyTyped()
@@ -61,6 +97,8 @@
         setHashName("virtual_disks"); //$NON-NLS-1$
 
         setCopyCommand(new UICommand("Copy", this)); //$NON-NLS-1$
+        setChangeQuotaCommand(new UICommand("changeQuota", this)); 
//$NON-NLS-1$
+        getChangeQuotaCommand().setIsAvailable(false);
 
         UpdateActionAvailability();
 
@@ -171,6 +209,26 @@
     {
         getCopyCommand().setIsExecutionAllowed(getSelectedItems() != null && 
getSelectedItems().size() > 0
                 && isCopyCommandAvailable());
+
+        if (systemTreeContext != null
+                && systemTreeContext.getSystemTreeSelectedItem() != null
+                && systemTreeContext.getSystemTreeSelectedItem().getType() == 
SystemTreeItemType.DataCenter
+                &&
+                ((storage_pool) 
systemTreeContext.getSystemTreeSelectedItem().getEntity()).getQuotaEnforcementType()
 != QuotaEnforcementTypeEnum.DISABLED) {
+            ArrayList<Disk> disks = getSelectedItems() != null ? 
(ArrayList<Disk>) getSelectedItems() : null;
+            getChangeQuotaCommand().setIsAvailable(true);
+            getChangeQuotaCommand().setIsExecutionAllowed(true);
+            if (disks != null && !disks.isEmpty()) {
+                for (Disk diskItem : disks) {
+                    if (diskItem.getDiskStorageType() != 
DiskStorageType.IMAGE) {
+                        getChangeQuotaCommand().setIsExecutionAllowed(false);
+                        break;
+                    }
+                }
+            } else {
+                getChangeQuotaCommand().setIsExecutionAllowed(false);
+            }
+        }
     }
 
     private boolean isCopyCommandAvailable() {
@@ -200,6 +258,10 @@
         else if (StringHelper.stringsEqual(command.getName(), "Cancel")) 
//$NON-NLS-1$
         {
             Cancel();
+        } else if (command == getChangeQuotaCommand()) {
+            changeQuota();
+        } else if (command.getName().equals("onChangeQuota")) { //$NON-NLS-1$
+            onChangeQuota();
         }
     }
 
@@ -238,4 +300,57 @@
     protected String getListName() {
         return "TemplateDiskListModel"; //$NON-NLS-1$
     }
+
+    private void changeQuota() {
+        ArrayList<DiskImage> disks = (ArrayList<DiskImage>) getSelectedItems();
+
+        if (disks == null || getWindow() != null)
+        {
+            return;
+        }
+
+        ChangeQuotaModel model = new ChangeQuotaModel();
+        setWindow(model);
+        
model.setTitle(ConstantsManager.getInstance().getConstants().assignQuotaForDisk());
+        model.setHashName("change_quota_disks"); //$NON-NLS-1$
+        model.StartProgress(null);
+        model.init(disks);
+
+        UICommand command = new UICommand("onChangeQuota", this); //$NON-NLS-1$
+        command.setTitle(ConstantsManager.getInstance().getConstants().ok());
+        command.setIsDefault(true);
+        model.getCommands().add(command);
+        command = new UICommand("Cancel", this); //$NON-NLS-1$
+        
command.setTitle(ConstantsManager.getInstance().getConstants().cancel());
+        command.setIsCancel(true);
+        model.getCommands().add(command);
+    }
+
+    private void onChangeQuota() {
+        ChangeQuotaModel model = (ChangeQuotaModel) getWindow();
+        ArrayList<VdcActionParametersBase> paramerterList = new 
ArrayList<VdcActionParametersBase>();
+
+        for (Object item : model.getItems())
+        {
+            ChangeQuotaItemModel itemModel = (ChangeQuotaItemModel) item;
+            DiskImage disk = (DiskImage) itemModel.getEntity();
+            VdcActionParametersBase parameters =
+                    new ChangeQuotaParameters(((Quota) 
itemModel.getQuota().getSelectedItem()).getId(),
+                            disk.getId(),
+                            disk.getstorage_ids().get(0),
+                            disk.getstorage_pool_id().getValue());
+            paramerterList.add(parameters);
+        }
+
+        model.StartProgress(null);
+
+        Frontend.RunMultipleAction(VdcActionType.ChangeQuotaForDisk, 
paramerterList,
+                new IFrontendMultipleActionAsyncCallback() {
+                    @Override
+                    public void Executed(FrontendMultipleActionAsyncResult 
result) {
+                        Cancel();
+                    }
+                },
+                this);
+    }
 }
diff --git 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/templates/TemplateListModel.java
 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/templates/TemplateListModel.java
index afb2a94..380b985 100644
--- 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/templates/TemplateListModel.java
+++ 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/templates/TemplateListModel.java
@@ -323,7 +323,9 @@
     }
 
     protected void 
addCustomModelsDetailModelList(ObservableCollection<EntityModel> list) {
-        list.add(3, new TemplateDiskListModel());
+        TemplateDiskListModel diskListModel = new TemplateDiskListModel();
+        diskListModel.setSystemTreeContext(this);
+        list.add(3, diskListModel);
         list.add(new TemplateEventListModel());
         list.add(new PermissionListModel());
     }
diff --git 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmDiskListModel.java
 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmDiskListModel.java
index 1b26841..7506a1d 100644
--- 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmDiskListModel.java
+++ 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmDiskListModel.java
@@ -4,6 +4,7 @@
 
 import org.ovirt.engine.core.common.action.AddDiskParameters;
 import org.ovirt.engine.core.common.action.AttachDettachVmDiskParameters;
+import org.ovirt.engine.core.common.action.ChangeQuotaParameters;
 import org.ovirt.engine.core.common.action.HotPlugDiskToVmParameters;
 import org.ovirt.engine.core.common.action.RemoveDiskParameters;
 import org.ovirt.engine.core.common.action.UpdateVmDiskParameters;
@@ -42,6 +43,10 @@
 import org.ovirt.engine.ui.uicommonweb.UICommand;
 import org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider;
 import org.ovirt.engine.ui.uicommonweb.models.EntityModel;
+import org.ovirt.engine.ui.uicommonweb.models.ISupportSystemTreeContext;
+import org.ovirt.engine.ui.uicommonweb.models.SystemTreeItemType;
+import org.ovirt.engine.ui.uicommonweb.models.quota.ChangeQuotaItemModel;
+import org.ovirt.engine.ui.uicommonweb.models.quota.ChangeQuotaModel;
 import org.ovirt.engine.ui.uicommonweb.models.storage.LunModel;
 import org.ovirt.engine.ui.uicompat.ConstantsManager;
 import org.ovirt.engine.ui.uicompat.FrontendActionAsyncResult;
@@ -113,6 +118,28 @@
         privateUnPlugCommand = value;
     }
 
+    ISupportSystemTreeContext systemTreeContext;
+
+    public ISupportSystemTreeContext getSystemTreeContext() {
+        return systemTreeContext;
+    }
+
+    public void setSystemTreeContext(ISupportSystemTreeContext 
systemTreeContext) {
+        this.systemTreeContext = systemTreeContext;
+    }
+
+    private UICommand privateChangeQuotaCommand;
+
+    public UICommand getChangeQuotaCommand()
+    {
+        return privateChangeQuotaCommand;
+    }
+
+    private void setChangeQuotaCommand(UICommand value)
+    {
+        privateChangeQuotaCommand = value;
+    }
+
     private boolean privateIsDiskHotPlugSupported;
 
     public boolean getIsDiskHotPlugSupported()
@@ -161,6 +188,8 @@
         setPlugCommand(new UICommand("Plug", this)); //$NON-NLS-1$
         setUnPlugCommand(new UICommand("Unplug", this)); //$NON-NLS-1$
         setMoveCommand(new UICommand("Move", this)); //$NON-NLS-1$
+        setChangeQuotaCommand(new UICommand("changeQuota", this)); 
//$NON-NLS-1$
+        getChangeQuotaCommand().setIsAvailable(false);
 
         UpdateActionAvailability();
     }
@@ -307,6 +336,59 @@
         diskModel.StopProgress();
     }
 
+    private void changeQuota() {
+        ArrayList<DiskImage> disks = (ArrayList<DiskImage>) getSelectedItems();
+
+        if (disks == null || getWindow() != null)
+        {
+            return;
+        }
+
+        ChangeQuotaModel model = new ChangeQuotaModel();
+        setWindow(model);
+        
model.setTitle(ConstantsManager.getInstance().getConstants().assignQuotaForDisk());
+        model.setHashName("change_quota_disks"); //$NON-NLS-1$
+        model.StartProgress(null);
+        model.init(disks);
+
+        UICommand command = new UICommand("onChangeQuota", this); //$NON-NLS-1$
+        command.setTitle(ConstantsManager.getInstance().getConstants().ok());
+        command.setIsDefault(true);
+        model.getCommands().add(command);
+        command = new UICommand("Cancel", this); //$NON-NLS-1$
+        
command.setTitle(ConstantsManager.getInstance().getConstants().cancel());
+        command.setIsCancel(true);
+        model.getCommands().add(command);
+    }
+
+    private void onChangeQuota() {
+        ChangeQuotaModel model = (ChangeQuotaModel) getWindow();
+        ArrayList<VdcActionParametersBase> paramerterList = new 
ArrayList<VdcActionParametersBase>();
+
+        for (Object item : model.getItems())
+        {
+            ChangeQuotaItemModel itemModel = (ChangeQuotaItemModel) item;
+            DiskImage disk = (DiskImage) itemModel.getEntity();
+            VdcActionParametersBase parameters =
+                    new ChangeQuotaParameters(((Quota) 
itemModel.getQuota().getSelectedItem()).getId(),
+                            disk.getId(),
+                            disk.getstorage_ids().get(0),
+                            disk.getstorage_pool_id().getValue());
+            paramerterList.add(parameters);
+        }
+
+        model.StartProgress(null);
+
+        Frontend.RunMultipleAction(VdcActionType.ChangeQuotaForDisk, 
paramerterList,
+                new IFrontendMultipleActionAsyncCallback() {
+                    @Override
+                    public void Executed(FrontendMultipleActionAsyncResult 
result) {
+                        Cancel();
+                    }
+                },
+                this);
+    }
+
     private void Edit()
     {
         final Disk disk = (Disk) getSelectedItem();
@@ -383,7 +465,8 @@
                 {
                     StorageType storageType = storage.getstorage_type();
                     boolean isFileDomain =
-                            storageType == StorageType.NFS || storageType == 
StorageType.LOCALFS || storageType == StorageType.POSIXFS;
+                            storageType == StorageType.NFS || storageType == 
StorageType.LOCALFS
+                                    || storageType == StorageType.POSIXFS;
                     
diskModel.getWipeAfterDelete().setIsChangable(!isFileDomain);
                 }
 
@@ -767,6 +850,26 @@
         getPlugCommand().setIsExecutionAllowed(isPlugCommandAvailable(true));
 
         
getUnPlugCommand().setIsExecutionAllowed(isPlugCommandAvailable(false));
+
+        if (systemTreeContext != null
+                && systemTreeContext.getSystemTreeSelectedItem() != null
+                && systemTreeContext.getSystemTreeSelectedItem().getType() == 
SystemTreeItemType.DataCenter
+                &&
+                ((storage_pool) 
systemTreeContext.getSystemTreeSelectedItem().getEntity()).getQuotaEnforcementType()
 != QuotaEnforcementTypeEnum.DISABLED) {
+            ArrayList<Disk> disks = getSelectedItems() != null ? 
(ArrayList<Disk>) getSelectedItems() : null;
+            getChangeQuotaCommand().setIsAvailable(true);
+            getChangeQuotaCommand().setIsExecutionAllowed(true);
+            if (disks != null && !disks.isEmpty()) {
+                for (Disk diskItem : disks) {
+                    if (diskItem.getDiskStorageType() != 
DiskStorageType.IMAGE) {
+                        getChangeQuotaCommand().setIsExecutionAllowed(false);
+                        break;
+                    }
+                }
+            } else {
+                getChangeQuotaCommand().setIsExecutionAllowed(false);
+            }
+        }
     }
 
     public boolean isVmDown() {
@@ -878,6 +981,10 @@
         else if (command == getUnPlugCommand())
         {
             Plug(false);
+        } else if (command == getChangeQuotaCommand()) {
+            changeQuota();
+        } else if (command.getName().equals("onChangeQuota")) { //$NON-NLS-1$
+            onChangeQuota();
         }
     }
 
diff --git 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmListModel.java
 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmListModel.java
index d00af9e..71f9bc2 100644
--- 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmListModel.java
+++ 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmListModel.java
@@ -685,7 +685,9 @@
         ObservableCollection<EntityModel> list = new 
ObservableCollection<EntityModel>();
         list.add(new VmGeneralModel());
         list.add(new VmInterfaceListModel());
-        list.add(new VmDiskListModel());
+        VmDiskListModel diskListModel = new VmDiskListModel();
+        diskListModel.setSystemTreeContext(this);
+        list.add(diskListModel);
         list.add(new VmSnapshotListModel());
         list.add(new VmEventListModel());
         list.add(new VmAppListModel());
@@ -964,6 +966,7 @@
                 .vmsResideOnSeveralDCsMakeSureTheExportedVMResideOnSameDcMsg();
     }
 
+    @Override
     protected boolean entitiesSelectedOnDifferentDataCenters()
     {
         ArrayList<VM> vms = new ArrayList<VM>();
@@ -988,10 +991,12 @@
         return t.size() > 1;
     }
 
+    @Override
     protected String extractNameFromEntity(VM entity) {
         return entity.getvm_name();
     }
 
+    @Override
     protected boolean entititesEqualsNullSafe(VM e1, VM e2) {
         return e1.getId().equals(e2.getId());
     }
diff --git 
a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/ApplicationConstants.java
 
b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/ApplicationConstants.java
index 6072581..078075f 100644
--- 
a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/ApplicationConstants.java
+++ 
b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/ApplicationConstants.java
@@ -2170,9 +2170,6 @@
     @DefaultStringValue("Storage Quota")
     String quotaStorage();
 
-    @DefaultStringValue("Assign Quota")
-    String assignQuota();
-
     @DefaultStringValue("Extended")
     String extendedPanelLabel();
 
diff --git 
a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/gin/uicommon/TemplateModule.java
 
b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/gin/uicommon/TemplateModule.java
index a2b0ce7..6ff7adb 100644
--- 
a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/gin/uicommon/TemplateModule.java
+++ 
b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/gin/uicommon/TemplateModule.java
@@ -28,6 +28,7 @@
 import org.ovirt.engine.ui.uicommonweb.models.vms.DiskModel;
 import org.ovirt.engine.ui.webadmin.gin.ClientGinjector;
 import 
org.ovirt.engine.ui.webadmin.section.main.presenter.popup.PermissionsPopupPresenterWidget;
+import 
org.ovirt.engine.ui.webadmin.section.main.presenter.popup.quota.ChangeQuotaPopupPresenterWidget;
 import 
org.ovirt.engine.ui.webadmin.section.main.presenter.popup.storage.DisksAllocationPopupPresenterWidget;
 import 
org.ovirt.engine.ui.webadmin.section.main.presenter.popup.template.TemplateInterfacePopupPresenterWidget;
 import 
org.ovirt.engine.ui.webadmin.section.main.presenter.popup.template.TemplateNewPresenterWidget;
@@ -123,15 +124,19 @@
     @Provides
     @Singleton
     public SearchableDetailModelProvider<DiskModel, TemplateListModel, 
TemplateDiskListModel> getTemplateDiskListProvider(ClientGinjector ginjector,
-            final Provider<DisksAllocationPopupPresenterWidget> 
copyPopupProvider) {
+            final Provider<DisksAllocationPopupPresenterWidget> 
copyPopupProvider,
+            final Provider<ChangeQuotaPopupPresenterWidget> 
changeQutoaPopupProvider) {
         return new SearchableDetailTabModelProvider<DiskModel, 
TemplateListModel, TemplateDiskListModel>(ginjector,
                 TemplateListModel.class,
                 TemplateDiskListModel.class) {
             @Override
             public AbstractModelBoundPopupPresenterWidget<? extends Model, ?> 
getModelPopup(TemplateDiskListModel source,
-                    UICommand lastExecutedCommand, Model windowModel) {
+                    UICommand lastExecutedCommand,
+                    Model windowModel) {
                 if (lastExecutedCommand == getModel().getCopyCommand()) {
                     return copyPopupProvider.get();
+                } else if (lastExecutedCommand == 
getModel().getChangeQuotaCommand()) {
+                    return changeQutoaPopupProvider.get();
                 } else {
                     return super.getModelPopup(source, lastExecutedCommand, 
windowModel);
                 }
@@ -149,7 +154,8 @@
                 TemplateInterfaceListModel.class) {
             @Override
             public AbstractModelBoundPopupPresenterWidget<? extends Model, ?> 
getModelPopup(TemplateInterfaceListModel source,
-                    UICommand lastExecutedCommand, Model windowModel) {
+                    UICommand lastExecutedCommand,
+                    Model windowModel) {
                 if ((lastExecutedCommand == getModel().getNewCommand())
                         || (lastExecutedCommand == 
getModel().getEditCommand())) {
                     return popupProvider.get();
diff --git 
a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/gin/uicommon/VirtualMachineModule.java
 
b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/gin/uicommon/VirtualMachineModule.java
index 530aab8..deeee9f 100644
--- 
a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/gin/uicommon/VirtualMachineModule.java
+++ 
b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/gin/uicommon/VirtualMachineModule.java
@@ -35,6 +35,7 @@
 import 
org.ovirt.engine.ui.webadmin.section.main.presenter.popup.AssignTagsPopupPresenterWidget;
 import 
org.ovirt.engine.ui.webadmin.section.main.presenter.popup.PermissionsPopupPresenterWidget;
 import 
org.ovirt.engine.ui.webadmin.section.main.presenter.popup.guide.GuidePopupPresenterWidget;
+import 
org.ovirt.engine.ui.webadmin.section.main.presenter.popup.quota.ChangeQuotaPopupPresenterWidget;
 import 
org.ovirt.engine.ui.webadmin.section.main.presenter.popup.storage.DisksAllocationPopupPresenterWidget;
 import 
org.ovirt.engine.ui.webadmin.section.main.presenter.popup.vm.VmChangeCDPopupPresenterWidget;
 import 
org.ovirt.engine.ui.webadmin.section.main.presenter.popup.vm.VmClonePopupPresenterWidget;
@@ -185,7 +186,8 @@
     public SearchableDetailModelProvider<Disk, VmListModel, VmDiskListModel> 
getVmDiskListProvider(ClientGinjector ginjector,
             final Provider<VmDiskPopupPresenterWidget> popupProvider,
             final Provider<VmDiskRemovePopupPresenterWidget> 
removeConfirmPopupProvider,
-            final Provider<DisksAllocationPopupPresenterWidget> 
movePopupProvider) {
+            final Provider<DisksAllocationPopupPresenterWidget> 
movePopupProvider,
+            final Provider<ChangeQuotaPopupPresenterWidget> 
changeQutoaPopupProvider) {
         return new SearchableDetailTabModelProvider<Disk, VmListModel, 
VmDiskListModel>(ginjector,
                 VmListModel.class,
                 VmDiskListModel.class) {
@@ -199,6 +201,8 @@
                     return popupProvider.get();
                 } else if (lastExecutedCommand == getModel().getMoveCommand()) 
{
                     return movePopupProvider.get();
+                } else if (lastExecutedCommand == 
getModel().getChangeQuotaCommand()) {
+                    return changeQutoaPopupProvider.get();
                 } else {
                     return super.getModelPopup(source, lastExecutedCommand, 
windowModel);
                 }
diff --git 
a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/tab/template/SubTabTemplateDiskView.java
 
b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/tab/template/SubTabTemplateDiskView.java
index b6da4e6..75713a4 100644
--- 
a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/tab/template/SubTabTemplateDiskView.java
+++ 
b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/tab/template/SubTabTemplateDiskView.java
@@ -24,7 +24,10 @@
 
     @Inject
     public SubTabTemplateDiskView(final 
SearchableDetailModelProvider<DiskModel, TemplateListModel, 
TemplateDiskListModel> modelProvider,
-            EventBus eventBus, ApplicationConstants constants, 
ApplicationTemplates templates, ApplicationResources resources) {
+            EventBus eventBus,
+            ApplicationConstants constants,
+            ApplicationTemplates templates,
+            ApplicationResources resources) {
         super(modelProvider, constants, templates, resources);
 
         actionPanel.addActionButton(new 
UiCommandButtonDefinition<DiskModel>(eventBus, constants.copyDisk()) {
@@ -34,6 +37,13 @@
             }
         });
 
+        actionPanel.addActionButton(new 
UiCommandButtonDefinition<DiskModel>(eventBus, constants.assignQuota()) {
+            @Override
+            protected UICommand resolveCommand() {
+                return modelProvider.getModel().getChangeQuotaCommand();
+            }
+        });
+
         setIsActionTree(true);
     }
 


--
To view, visit http://gerrit.ovirt.org/7681
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ieb2d52f6caf15c1e7e4b65e75657c0f62438af4b
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Gilad Chaplik <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to