Kanagaraj M has uploaded a new change for review.

Change subject: webadmin: Cluster Dialog - using RadioButton for services
......................................................................

webadmin: Cluster Dialog - using RadioButton for services

Cluster with Virt and Gluster will be allowed only if
the configuration property AllowGlusterWithVirtGlusterEnabled=true.

There is a validation already present to check the above condition
in the engine backend.

In the Cluster Dialog, the oVirt and Gluster check boxes will be
replaced by Radio Buttons if AllowGlusterWithVirtGlusterEnabled=false.

Change-Id: I94ae82c605c6fa47e846efc17a7870b6b3a8c9c6
Bug-Url: https://bugzilla.redhat.com/838461
Signed-off-by: Kanagaraj M <[email protected]>
---
M 
frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/dataprovider/AsyncDataProvider.java
M 
frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/clusters/ClusterListModel.java
M 
frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/clusters/ClusterModel.java
M 
frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/presenter/popup/cluster/ClusterPopupPresenterWidget.java
M 
frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/cluster/ClusterPopupView.java
M 
frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/cluster/ClusterPopupView.ui.xml
6 files changed, 180 insertions(+), 58 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/36/9836/1

diff --git 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/dataprovider/AsyncDataProvider.java
 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/dataprovider/AsyncDataProvider.java
index 28dfbc8..c2ace38 100644
--- 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/dataprovider/AsyncDataProvider.java
+++ 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/dataprovider/AsyncDataProvider.java
@@ -1379,6 +1379,20 @@
                 aQuery);
     }
 
+    public static void GetAllowClusterWithVirtGlusterEnabled(AsyncQuery 
aQuery) {
+        aQuery.converterCallback = new IAsyncConverter() {
+            @Override
+            public Object Convert(Object source, AsyncQuery _asyncQuery)
+            {
+                return source != null ? source : Boolean.TRUE;
+            }
+        };
+        GetConfigFromCache(
+                new 
GetConfigurationValueParameters(ConfigurationValues.AllowClusterWithVirtGlusterEnabled,
+                        Config.DefaultConfigurationVersion),
+                aQuery);
+    }
+
     public static void GetCPUList(AsyncQuery aQuery, Version version) {
         aQuery.converterCallback = new IAsyncConverter() {
             @Override
diff --git 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/clusters/ClusterListModel.java
 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/clusters/ClusterListModel.java
index 05a71f7..adefb51 100644
--- 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/clusters/ClusterListModel.java
+++ 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/clusters/ClusterListModel.java
@@ -311,73 +311,76 @@
             return;
         }
 
-        ClusterModel model = new ClusterModel();
-        model.setEntity(cluster);
-        model.Init(true);
-        setWindow(model);
-        
model.setTitle(ConstantsManager.getInstance().getConstants().editClusterTitle());
-        model.setHashName("edit_cluster"); //$NON-NLS-1$
-        model.setOriginalName(cluster.getname());
-        model.getName().setEntity(cluster.getname());
-        model.getEnableOvirtService().setEntity(cluster.supportsVirtService());
-        model.getEnableOvirtService().setIsChangable(false);
-        
model.getEnableGlusterService().setEntity(cluster.supportsGlusterService());
-        model.getEnableGlusterService().setIsChangable(false);
+        final ClusterModel clusterModel = new ClusterModel();
+        clusterModel.setEntity(cluster);
+        clusterModel.Init(true);
+        setWindow(clusterModel);
+        
clusterModel.setTitle(ConstantsManager.getInstance().getConstants().editClusterTitle());
+        clusterModel.setHashName("edit_cluster"); //$NON-NLS-1$
+        clusterModel.setOriginalName(cluster.getname());
+        clusterModel.getName().setEntity(cluster.getname());
+        
clusterModel.getEnableOvirtService().setEntity(cluster.supportsVirtService());
+        clusterModel.getEnableOvirtService().setIsChangable(true);
+        
clusterModel.getEnableGlusterService().setEntity(cluster.supportsGlusterService());
+        clusterModel.getEnableGlusterService().setIsChangable(true);
 
-        AsyncQuery asyncQuery = new AsyncQuery();
-        asyncQuery.setModel(model);
-        asyncQuery.asyncCallback = new INewAsyncCallback() {
+        AsyncDataProvider.GetAllowClusterWithVirtGlusterEnabled(new 
AsyncQuery(this, new INewAsyncCallback() {
             @Override
-            public void OnSuccess(Object model1, Object result)
-            {
-                ClusterModel clusterModel = (ClusterModel) model1;
-                ArrayList<GlusterVolumeEntity> volumes =
-                        (ArrayList<GlusterVolumeEntity>) result;
-                if (volumes.size() > 0)
-                {
-                    
clusterModel.getEnableGlusterService().setIsChangable(false);
-                }
-                else
-                {
-                    
clusterModel.getEnableGlusterService().setIsChangable(true);
-                }
-            }
-        };
-        AsyncDataProvider.GetVolumeList(asyncQuery, cluster.getname());
+            public void OnSuccess(Object model, Object returnValue) {
+                final boolean isVirtGlusterAllowed = (Boolean) returnValue;
+                AsyncQuery asyncQuery = new AsyncQuery();
+                asyncQuery.setModel(clusterModel);
+                asyncQuery.asyncCallback = new INewAsyncCallback() {
+                    @Override
+                    public void OnSuccess(Object model1, Object result)
+                    {
+                        ArrayList<GlusterVolumeEntity> volumes = 
(ArrayList<GlusterVolumeEntity>) result;
+                        if (volumes.size() > 0)
+                        {
+                            
clusterModel.getEnableGlusterService().setIsChangable(false);
+                            if (!isVirtGlusterAllowed)
+                            {
+                                
clusterModel.getEnableOvirtService().setIsChangable(false);
+                            }
+                        }
+                    }
+                };
+                AsyncDataProvider.GetVolumeList(asyncQuery, cluster.getname());
 
-        AsyncQuery asyncQuery1 = new AsyncQuery();
-        asyncQuery1.setModel(model);
-        asyncQuery1.asyncCallback = new INewAsyncCallback() {
-            @Override
-            public void OnSuccess(Object model1, Object result)
-            {
-                ClusterModel clusterModel = (ClusterModel) model1;
-                ArrayList<VM> vmList = (ArrayList<VM>) result;
-                if (vmList.size() > 0)
-                {
-                    clusterModel.getEnableOvirtService().setIsChangable(false);
-                }
-                else
-                {
-                    clusterModel.getEnableOvirtService().setIsChangable(true);
-                }
+                AsyncQuery asyncQuery1 = new AsyncQuery();
+                asyncQuery1.setModel(clusterModel);
+                asyncQuery1.asyncCallback = new INewAsyncCallback() {
+                    @Override
+                    public void OnSuccess(Object model1, Object result)
+                    {
+                        ArrayList<VM> vmList = (ArrayList<VM>) result;
+                        if (vmList.size() > 0)
+                        {
+                            
clusterModel.getEnableOvirtService().setIsChangable(false);
+                            if (!isVirtGlusterAllowed)
+                            {
+                                
clusterModel.getEnableGlusterService().setIsChangable(false);
+                            }
+                        }
+                    }
+                };
+                AsyncDataProvider.GetVmListByClusterName(asyncQuery1, 
cluster.getname());
             }
-        };
-        AsyncDataProvider.GetVmListByClusterName(asyncQuery1, 
cluster.getname());
+        }));
 
         if (getSystemTreeSelectedItem() != null && 
getSystemTreeSelectedItem().getType() == SystemTreeItemType.Cluster) {
-            model.getName().setIsChangable(false);
-            model.getName().setInfo("Cannot edit Cluster's Name in tree 
context"); //$NON-NLS-1$
+            clusterModel.getName().setIsChangable(false);
+            clusterModel.getName().setInfo("Cannot edit Cluster's Name in tree 
context"); //$NON-NLS-1$
         }
 
         UICommand tempVar = new UICommand("OnSave", this); //$NON-NLS-1$
         tempVar.setTitle(ConstantsManager.getInstance().getConstants().ok());
         tempVar.setIsDefault(true);
-        model.getCommands().add(tempVar);
+        clusterModel.getCommands().add(tempVar);
         UICommand tempVar2 = new UICommand("Cancel", this); //$NON-NLS-1$
         
tempVar2.setTitle(ConstantsManager.getInstance().getConstants().cancel());
         tempVar2.setIsCancel(true);
-        model.getCommands().add(tempVar2);
+        clusterModel.getCommands().add(tempVar2);
     }
 
     public void remove()
diff --git 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/clusters/ClusterModel.java
 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/clusters/ClusterModel.java
index dc3a9c1..89ccaa9 100644
--- 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/clusters/ClusterModel.java
+++ 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/clusters/ClusterModel.java
@@ -191,6 +191,23 @@
         privateVersion = value;
     }
 
+    private boolean allowClusterWithVirtGlusterEnabled;
+
+    public boolean getAllowClusterWithVirtGlusterEnabled()
+    {
+        return allowClusterWithVirtGlusterEnabled;
+    }
+
+    public void setAllowClusterWithVirtGlusterEnabled(boolean value)
+    {
+        allowClusterWithVirtGlusterEnabled = value;
+        if (allowClusterWithVirtGlusterEnabled != value)
+        {
+            allowClusterWithVirtGlusterEnabled = value;
+            OnPropertyChanged(new 
PropertyChangedEventArgs("AllowClusterWithVirtGlusterEnabled")); //$NON-NLS-1$
+        }
+    }
+
     private EntityModel privateEnableOvirtService;
 
     public EntityModel getEnableOvirtService()
@@ -538,18 +555,39 @@
         setIsEdit(isEdit);
         setName(new EntityModel());
         setDescription(new EntityModel());
+        setAllowClusterWithVirtGlusterEnabled(true);
+        AsyncDataProvider.GetAllowClusterWithVirtGlusterEnabled(new 
AsyncQuery(this, new INewAsyncCallback() {
+            @Override
+            public void OnSuccess(Object model, Object returnValue) {
+                setAllowClusterWithVirtGlusterEnabled((Boolean) returnValue);
+            }
+        }));
+
         setEnableOvirtService(new EntityModel());
+        setEnableGlusterService(new EntityModel());
+
+        getEnableOvirtService().getEntityChangedEvent().addListener(new 
IEventListener() {
+            @Override
+            public void eventRaised(Event ev, Object sender, EventArgs args) {
+                if (!getAllowClusterWithVirtGlusterEnabled() && (Boolean) 
getEnableOvirtService().getEntity()) {
+                    getEnableGlusterService().setEntity(Boolean.FALSE);
+                }
+            }
+        });
         
getEnableOvirtService().setEntity(ApplicationModeHelper.isModeSupported(ApplicationMode.VirtOnly));
         
getEnableOvirtService().setIsAvailable(ApplicationModeHelper.getUiMode() != 
ApplicationMode.VirtOnly
                 && 
ApplicationModeHelper.isModeSupported(ApplicationMode.VirtOnly));
 
         initImportCluster(isEdit);
 
-        setEnableGlusterService(new EntityModel());
         getEnableGlusterService().getEntityChangedEvent().addListener(new 
IEventListener() {
 
             @Override
             public void eventRaised(Event ev, Object sender, EventArgs args) {
+                if (!getAllowClusterWithVirtGlusterEnabled() && (Boolean) 
getEnableGlusterService().getEntity()) {
+                    getEnableOvirtService().setEntity(Boolean.FALSE);
+                }
+
                 if (!isEdit
                         && getEnableGlusterService().getEntity() != null
                         && (Boolean) getEnableGlusterService().getEntity())
@@ -720,6 +758,12 @@
                 }
             }
         });
+
+        getIsImportGlusterConfiguration().setIsAvailable(false);
+        getGlusterHostAddress().setIsAvailable(false);
+        getGlusterHostFingerprint().setIsAvailable(false);
+        getGlusterHostPassword().setIsAvailable(false);
+
         getIsImportGlusterConfiguration().setEntity(false);
     }
 
@@ -943,7 +987,7 @@
                 }
                 else if (clusterModel.getIsEdit()) {
                     
clusterModel.getVersion().setSelectedItem(Linq.FirstOrDefault(versions,
-                            new Linq.VersionPredicate(((VDSGroup) 
clusterModel.getEntity()).getcompatibility_version())));
+                            new 
Linq.VersionPredicate(clusterModel.getEntity().getcompatibility_version())));
                 }
             }
         };
diff --git 
a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/presenter/popup/cluster/ClusterPopupPresenterWidget.java
 
b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/presenter/popup/cluster/ClusterPopupPresenterWidget.java
index a99f547..39e1f1e 100644
--- 
a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/presenter/popup/cluster/ClusterPopupPresenterWidget.java
+++ 
b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/presenter/popup/cluster/ClusterPopupPresenterWidget.java
@@ -1,5 +1,9 @@
 package org.ovirt.engine.ui.webadmin.section.main.presenter.popup.cluster;
 
+import org.ovirt.engine.core.compat.Event;
+import org.ovirt.engine.core.compat.EventArgs;
+import org.ovirt.engine.core.compat.IEventListener;
+import org.ovirt.engine.core.compat.PropertyChangedEventArgs;
 import 
org.ovirt.engine.ui.common.presenter.AbstractModelBoundPopupPresenterWidget;
 import org.ovirt.engine.ui.uicommonweb.models.clusters.ClusterModel;
 
@@ -9,6 +13,9 @@
 public class ClusterPopupPresenterWidget extends 
AbstractModelBoundPopupPresenterWidget<ClusterModel, 
ClusterPopupPresenterWidget.ViewDef> {
 
     public interface ViewDef extends 
AbstractModelBoundPopupPresenterWidget.ViewDef<ClusterModel> {
+
+        void allowClusterWithVirtGlusterEnabled(boolean value);
+
     }
 
     @Inject
@@ -16,4 +23,20 @@
         super(eventBus, view);
     }
 
+    @Override
+    public void init(final ClusterModel model) {
+        super.init(model);
+
+        model.getPropertyChangedEvent().addListener(new IEventListener() {
+
+            @Override
+            public void eventRaised(Event ev, Object sender, EventArgs args) {
+                String propName = ((PropertyChangedEventArgs) 
args).PropertyName;
+                if ("AllowClusterWithVirtGlusterEnabled".equals(propName)) { 
//$NON-NLS-1$
+                    
getView().allowClusterWithVirtGlusterEnabled(model.getAllowClusterWithVirtGlusterEnabled());
+                }
+            }
+        });
+    }
+
 }
diff --git 
a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/cluster/ClusterPopupView.java
 
b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/cluster/ClusterPopupView.java
index 3ca5adf..2950c02 100644
--- 
a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/cluster/ClusterPopupView.java
+++ 
b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/cluster/ClusterPopupView.java
@@ -35,6 +35,7 @@
 import com.google.gwt.uibinder.client.UiField;
 import com.google.gwt.user.client.ui.FlowPanel;
 import com.google.gwt.user.client.ui.Label;
+import com.google.gwt.user.client.ui.VerticalPanel;
 import com.google.inject.Inject;
 
 public class ClusterPopupView extends 
AbstractModelBoundPopupView<ClusterModel> implements 
ClusterPopupPresenterWidget.ViewDef {
@@ -87,6 +88,10 @@
     ListModelListBoxEditor<Object> versionEditor;
 
     @UiField
+    @Ignore
+    VerticalPanel servicesCheckboxPanel;
+
+    @UiField
     @Path(value = "enableOvirtService.entity")
     @WithElementId("enableOvirtService")
     EntityModelCheckBoxEditor enableOvirtServiceEditor;
@@ -95,6 +100,20 @@
     @Path(value = "enableGlusterService.entity")
     @WithElementId("enableGlusterService")
     EntityModelCheckBoxEditor enableGlusterServiceEditor;
+
+    @UiField
+    @Ignore
+    VerticalPanel servicesRadioPanel;
+
+    @UiField(provided = true)
+    @Path(value = "enableOvirtService.entity")
+    @WithElementId("enableOvirtServiceOption")
+    EntityModelRadioButtonEditor enableOvirtServiceOptionEditor;
+
+    @UiField(provided = true)
+    @Path(value = "enableGlusterService.entity")
+    @WithElementId("enableGlusterServiceOption")
+    EntityModelRadioButtonEditor enableGlusterServiceOptionEditor;
 
     @UiField(provided = true)
     @Path(value = "isImportGlusterConfiguration.entity")
@@ -217,6 +236,8 @@
         versionEditor.setLabel(constants.clusterPopupVersionLabel());
         
enableOvirtServiceEditor.setLabel(constants.clusterEnableOvirtServiceLabel());
         
enableGlusterServiceEditor.setLabel(constants.clusterEnableGlusterServiceLabel());
+        
enableOvirtServiceOptionEditor.setLabel(constants.clusterEnableOvirtServiceLabel());
+        
enableGlusterServiceOptionEditor.setLabel(constants.clusterEnableGlusterServiceLabel());
 
         
importGlusterConfigurationEditor.setLabel(constants.clusterImportGlusterConfigurationLabel());
         
importGlusterExplanationLabel.setText(constants.clusterImportGlusterConfigurationExplanationLabel());
@@ -242,6 +263,9 @@
     }
 
     private void initRadioButtonEditors() {
+        enableOvirtServiceOptionEditor = new 
EntityModelRadioButtonEditor("service"); //$NON-NLS-1$
+        enableGlusterServiceOptionEditor = new 
EntityModelRadioButtonEditor("service"); //$NON-NLS-1$
+
         optimizationNoneEditor = new EntityModelRadioButtonEditor("1"); 
//$NON-NLS-1$
         optimizationForServerEditor = new EntityModelRadioButtonEditor("1"); 
//$NON-NLS-1$
         optimizationForDesktopEditor = new EntityModelRadioButtonEditor("1"); 
//$NON-NLS-1$
@@ -302,6 +326,9 @@
     public void edit(final ClusterModel object) {
         Driver.driver.edit(object);
 
+        
servicesCheckboxPanel.setVisible(object.getAllowClusterWithVirtGlusterEnabled());
+        
servicesRadioPanel.setVisible(!object.getAllowClusterWithVirtGlusterEnabled());
+
         
object.getOptimizationForServer().getEntityChangedEvent().addListener(new 
IEventListener() {
 
             @Override
@@ -357,6 +384,12 @@
         return Driver.driver.flush();
     }
 
+    @Override
+    public void allowClusterWithVirtGlusterEnabled(boolean value) {
+        servicesCheckboxPanel.setVisible(value);
+        servicesRadioPanel.setVisible(!value);
+    }
+
     interface WidgetStyle extends CssResource {
         String label();
 
@@ -364,5 +397,4 @@
 
         String editorContentWidget();
     }
-
 }
diff --git 
a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/cluster/ClusterPopupView.ui.xml
 
b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/cluster/ClusterPopupView.ui.xml
index 9c47ba8..465e159 100644
--- 
a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/cluster/ClusterPopupView.ui.xml
+++ 
b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/cluster/ClusterPopupView.ui.xml
@@ -68,8 +68,14 @@
                                                                
<e:EntityModelTextBoxEditor ui:field="descriptionEditor" />
                                                                
<e:ListModelListBoxEditor ui:field="cPUEditor" />
                                                                
<e:ListModelListBoxEditor ui:field="versionEditor" />
-                                                               
<e:EntityModelCheckBoxEditor ui:field="enableOvirtServiceEditor" />
-                                                               
<e:EntityModelCheckBoxEditor ui:field="enableGlusterServiceEditor" />
+                                                               
<g:VerticalPanel ui:field="servicesCheckboxPanel">
+                                                                       
<e:EntityModelCheckBoxEditor ui:field="enableOvirtServiceEditor" />
+                                                                       
<e:EntityModelCheckBoxEditor ui:field="enableGlusterServiceEditor" />
+                                                               
</g:VerticalPanel>
+                                                               
<g:VerticalPanel ui:field="servicesRadioPanel">
+                                                                       
<e:EntityModelRadioButtonEditor ui:field="enableOvirtServiceOptionEditor" />
+                                                                       
<e:EntityModelRadioButtonEditor ui:field="enableGlusterServiceOptionEditor" />
+                                                               
</g:VerticalPanel>
                                                                
<e:EntityModelCheckBoxEditor ui:field="importGlusterConfigurationEditor"/>
                                                                <g:Label 
ui:field="importGlusterExplanationLabel" 
addStyleNames="{style.explanationLabel}"/>
                                                                
<e:EntityModelTextBoxEditor ui:field="glusterHostAddressEditor" />


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

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

Reply via email to