Roy Golan has uploaded a new change for review.

Change subject: UI: add info icon when updating numbe of CPUs
......................................................................

UI: add info icon when updating numbe of CPUs

Change-Id: Ieac0e757c54b002eeab8f9099e6e8d151eb43340
Signed-off-by: Roy Golan <[email protected]>
---
M 
frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/CommonApplicationMessages.java
M 
frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/uicommon/popup/AbstractVmPopupWidget.java
M 
frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/uicommon/popup/AbstractVmPopupWidget.ui.xml
M 
frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/ExistingVmModelBehavior.java
4 files changed, 54 insertions(+), 6 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/52/23252/1

diff --git 
a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/CommonApplicationMessages.java
 
b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/CommonApplicationMessages.java
index abde869..341a73b 100644
--- 
a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/CommonApplicationMessages.java
+++ 
b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/CommonApplicationMessages.java
@@ -144,4 +144,6 @@
     @DefaultMessage("{0} or {1}")
     String or(String a, String b);
 
+    @DefaultMessage("Some warning")
+    String hotPlugUnplugCpuWarning();
 }
diff --git 
a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/uicommon/popup/AbstractVmPopupWidget.java
 
b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/uicommon/popup/AbstractVmPopupWidget.java
index c1f7ca3..504e030 100644
--- 
a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/uicommon/popup/AbstractVmPopupWidget.java
+++ 
b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/uicommon/popup/AbstractVmPopupWidget.java
@@ -208,7 +208,10 @@
     @UiField(provided = true)
     @Path(value = "totalCPUCores.entity")
     @WithElementId("totalCPUCores")
-    public EntityModelTextBoxEditor<String> totalvCPUsEditor;
+    public StringEntityModelTextBoxOnlyEditor totalvCPUsEditor;
+
+    @UiField(provided = true)
+    InfoIcon totalVCpuInfoIcon;
 
     @UiField
     @Ignore
@@ -730,7 +733,7 @@
     private void initTextBoxEditors() {
         descriptionEditor = new StringEntityModelTextBoxEditor(new 
ModeSwitchingVisibilityRenderer());
         commentEditor = new StringEntityModelTextBoxEditor(new 
ModeSwitchingVisibilityRenderer());
-        totalvCPUsEditor = new StringEntityModelTextBoxEditor(new 
ModeSwitchingVisibilityRenderer());
+        totalvCPUsEditor = new StringEntityModelTextBoxOnlyEditor(new 
ModeSwitchingVisibilityRenderer());
         numOfVmsEditor = new IntegerEntityModelTextBoxEditor(new 
ModeSwitchingVisibilityRenderer());
         cpuPinning = new StringEntityModelTextBoxOnlyEditor(new 
ModeSwitchingVisibilityRenderer());
         cpuSharesAmountEditor = new IntegerEntityModelTextBoxOnlyEditor(new 
ModeSwitchingVisibilityRenderer());
@@ -774,6 +777,8 @@
             }
 
         });
+
+        totalVCpuInfoIcon = new 
InfoIcon(applicationTemplates.italicText(messages.hotPlugUnplugCpuWarning()), 
resources);
     }
 
     /**
@@ -1063,7 +1068,6 @@
 
         // System tab
         memSizeEditor.setLabel(constants.memSizeVmPopup());
-        totalvCPUsEditor.setLabel(constants.numOfVCPUs());
         corePerSocketEditor.setLabel(constants.coresPerSocket());
         numOfSocketsEditor.setLabel(constants.numOfSockets());
     }
diff --git 
a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/uicommon/popup/AbstractVmPopupWidget.ui.xml
 
b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/uicommon/popup/AbstractVmPopupWidget.ui.xml
index c636bc9..fe9a20c 100644
--- 
a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/uicommon/popup/AbstractVmPopupWidget.ui.xml
+++ 
b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/uicommon/popup/AbstractVmPopupWidget.ui.xml
@@ -287,6 +287,13 @@
             width: 230px;
         }
 
+        .labelToCoupleCoupleWithInfoIcon {
+            float: right;
+            line-height: 30px;
+            padding: 0 5px;
+            width: 248px;
+        }
+
         .labelToCoupleCoupleLeft {
             float: left;
         }
@@ -301,6 +308,11 @@
 
         .cpuPinningTextBox {
             width: 202px;
+            padding-left: 5px;
+        }
+
+        .totalvcpusTextBox{
+            width: 230px;
             padding-left: 5px;
         }
 
@@ -407,7 +419,15 @@
                                        <g:FlowPanel>
                             <ge:EntityModelTextBoxEditor 
ui:field="memSizeEditor"/>
                             <ge:EntityModelTextBoxEditor 
ui:field="totalvCPUsEditor" />
-                                                       <g:FlowPanel 
addStyleNames="{style.sectionPanel}">
+                            <g:FlowPanel addStyleNames="{style.labelToCouple}">
+                                <g:Label text="{constants.numOfVCPUs}" 
addStyleNames="{style.labelToCoupleLabel}"/>
+                                <g:FlowPanel 
addStyleNames="{style.labelToCoupleCoupleWithInfoIcon}">
+                                    <d:InfoIcon ui:field="totalVCpuInfoIcon" 
addStyleNames="{style.labelToCoupleCoupleLeft}"/>
+                                    <ge:StringEntityModelTextBoxOnlyEditor 
ui:field="totalvCPUsEditor" addStyleNames="{style.labelToCoupleCoupleRight}" 
contentWidgetStyleName="${style.totalvcpusTextBox}"/>
+                                </g:FlowPanel>
+                            </g:FlowPanel>
+
+                        <g:FlowPanel addStyleNames="{style.sectionPanel}">
                                                                
<d:AdvancedParametersExpander ui:field="vcpusAdvancedParameterExpander"/>
                                                                <g:FlowPanel 
ui:field="vcpusAdvancedParameterExpanderContent" 
addStyleNames="{style.generalExpanderContent}">
                                                                        
<e:ListModelListBoxEditor ui:field="corePerSocketEditor" />
diff --git 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/ExistingVmModelBehavior.java
 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/ExistingVmModelBehavior.java
index b5c9849..d021d59 100644
--- 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/ExistingVmModelBehavior.java
+++ 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/ExistingVmModelBehavior.java
@@ -4,18 +4,23 @@
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.List;
+import java.util.Map;
 
 import org.ovirt.engine.core.common.businessentities.DisplayType;
 import org.ovirt.engine.core.common.businessentities.StoragePool;
 import org.ovirt.engine.core.common.businessentities.VDSGroup;
 import org.ovirt.engine.core.common.businessentities.VM;
+import org.ovirt.engine.core.common.businessentities.VMStatus;
 import org.ovirt.engine.core.common.businessentities.VmWatchdog;
 import 
org.ovirt.engine.core.common.businessentities.network.VmNetworkInterface;
+import org.ovirt.engine.core.common.queries.ConfigurationValues;
 import org.ovirt.engine.core.common.queries.IdQueryParameters;
 import org.ovirt.engine.core.common.queries.VdcQueryReturnValue;
 import org.ovirt.engine.core.common.queries.VdcQueryType;
 import org.ovirt.engine.core.compat.Guid;
 import org.ovirt.engine.core.compat.StringHelper;
+import org.ovirt.engine.core.compat.Version;
+import 
org.ovirt.engine.core.searchbackend.StringConditionRelationAutoCompleter;
 import org.ovirt.engine.ui.frontend.AsyncQuery;
 import org.ovirt.engine.ui.frontend.Frontend;
 import org.ovirt.engine.ui.frontend.INewAsyncCallback;
@@ -165,7 +170,7 @@
         getModel().getIsHighlyAvailable().setEntity(vm.isAutoStartup());
 
         
getModel().getTotalCPUCores().setEntity(Integer.toString(vm.getNumOfCpus()));
-        getModel().getTotalCPUCores().setIsChangable(!vm.isRunning());
+        getModel().getTotalCPUCores().setIsChangable(isHotPlugCpuSupported());
 
         getModel().getIsStateless().setEntity(vm.isStateless());
         getModel().getIsStateless().setIsAvailable(vm.getVmPoolId() == null);
@@ -179,7 +184,7 @@
         getModel().selectSsoMethod(vm.getSsoMethod());
 
         getModel().getNumOfSockets().setSelectedItem(vm.getNumOfSockets());
-        getModel().getNumOfSockets().setIsChangable(!vm.isRunning());
+        getModel().getNumOfSockets().setIsChangable(isHotPlugCpuSupported());
 
         getModel().getCoresPerSocket().setIsChangable(!vm.isRunning());
 
@@ -339,4 +344,21 @@
 
         updateCdImage();
     }
+
+    @Override
+    public void numOfSocketChanged() {
+        // changing the architecture is not allowed. the number of sockets is 
used as the num
+        // of virtual cpu to plug/unplug to the VM
+        Integer selectedItem = getModel().getNumOfSockets().getSelectedItem();
+        Integer selectedItem1 = 
getModel().getCoresPerSocket().getSelectedItem();
+        getModel().getTotalCPUCores().setEntity(Integer.toString(selectedItem 
* selectedItem1));
+    }
+
+    private boolean isHotPlugCpuSupported() {
+        Version clusterVersion = 
getModel().getSelectedCluster().getcompatibility_version();
+        return getVm().getStatus() == VMStatus.Up &&
+                ((Boolean) 
AsyncDataProvider.getConfigValuePreConverted(ConfigurationValues.HotPlugEnabled,
 clusterVersion.getValue())) &&
+                Boolean.parseBoolean(((Map<String, String>) 
AsyncDataProvider.getConfigValuePreConverted(ConfigurationValues.HotPlugCpuSupported,
+                        
clusterVersion.getValue())).get(getModel().getSelectedCluster().getArchitecture().name()));
+    }
 }


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

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

Reply via email to