Arik Hadas has uploaded a new change for review. Change subject: webadmin: allow changing name of VM attached to pool ......................................................................
webadmin: allow changing name of VM attached to pool This is a quick solution for a requirement to be able to manage the names of VMs which are attached to pools. We let the user open edit dialog for VM which is attached to pool, and in this dialog the only attribute the user can change is the VM's name (all other widgets are disabled). Change-Id: I139ca66f945657b4d2323d6669e595c77a8fad09 Bug-Url: https://bugzilla.redhat.com/867308 Signed-off-by: Arik Hadas <[email protected]> --- M frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/form/key_value/KeyValueWidget.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/vm/VmDesktopNewPopupWidget.java M frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/UnitVmModel.java M frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmListModel.java 5 files changed, 105 insertions(+), 7 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/93/10293/1 diff --git a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/form/key_value/KeyValueWidget.java b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/form/key_value/KeyValueWidget.java index ca2ed8c..3a37a27 100644 --- a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/form/key_value/KeyValueWidget.java +++ b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/form/key_value/KeyValueWidget.java @@ -34,6 +34,7 @@ VerticalPanel panel; private ArrayList<KeyValueLineWidget> widgetList = new ArrayList<KeyValueLineWidget>(); + private boolean enabled = true; KeyValueWidget() { initWidget(WidgetUiBinder.uiBinder.createAndBindUi(this)); @@ -64,6 +65,7 @@ widgetList.add(keyValueLineWidget); panel.add(keyValueLineWidget); keyValueLineWidget.edit(keyValueLineModel); + keyValueLineWidget.setEnabled(enabled); } } @@ -101,4 +103,10 @@ throw new NotImplementedException(); } + public void setEnabled(boolean value) { + enabled = value; + for (KeyValueLineWidget widget : widgetList) { + widget.setEnabled(enabled); + } + } } 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 3195c06..199bea5 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 @@ -427,7 +427,7 @@ @UiField @Ignore - KeyValueWidget customPropertiesSheetEditor; + protected KeyValueWidget customPropertiesSheetEditor; CommonApplicationConstants constants; diff --git a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/uicommon/popup/vm/VmDesktopNewPopupWidget.java b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/uicommon/popup/vm/VmDesktopNewPopupWidget.java index 8327aa3..4996e21 100644 --- a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/uicommon/popup/vm/VmDesktopNewPopupWidget.java +++ b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/uicommon/popup/vm/VmDesktopNewPopupWidget.java @@ -28,6 +28,9 @@ public void edit(UnitVmModel object) { super.edit(object); initTabAvailabilityListeners(object); + + if (object.isVmAttachedToPool()) + disableAllWidgetsExceptNameEditor(); } private void initTabAvailabilityListeners(final UnitVmModel vm) { @@ -41,4 +44,64 @@ expander.setVisible(true); } + private void disableAllWidgetsExceptNameEditor() { + // ==General Tab== + dataCenterEditor.setEnabled(false); + clusterEditor.setEnabled(false); + quotaEditor.setEnabled(false); + descriptionEditor.setEnabled(false); + + numOfVmsEditor.setEnabled(false); + prestartedVmsEditor.setEnabled(false); + editPrestartedVmsEditor.setEnabled(false); + + templateEditor.setEnabled(false); + memSizeEditor.setEnabled(false); + totalvCPUsEditor.setEnabled(false); + + corePerSocketEditor.setEnabled(false); + numOfSocketsEditor.setEnabled(false); + + oSTypeEditor.setEnabled(false); + isStatelessEditor.setEnabled(false); + isDeleteProtectedEditor.setEnabled(false); + + // ==Initial run Tab== + timeZoneEditor.setEnabled(false); + domainEditor.setEnabled(false); + + // ==Console Tab== + displayProtocolEditor.setEnabled(false); + usbSupportEditor.setEnabled(false); + numOfMonitorsEditor.setEnabled(false); + isSmartcardEnabledEditor.setEnabled(false); + allowConsoleReconnectEditor.setEnabled(false); + + // ==Host Tab== + isAutoAssignEditor.setEnabled(false); + specificHost.setEnabled(false); + defaultHostEditor.setEnabled(false); + runVMOnSpecificHostEditor.setEnabled(false); + dontMigrateVMEditor.setEnabled(false); + cpuPinning.setEnabled(false); + + // ==Resource Allocation Tab== + minAllocatedMemoryEditor.setEnabled(false); + provisioningEditor.setEnabled(false); + provisioningThinEditor.setEnabled(false); + provisioningCloneEditor.setEnabled(false); + disksAllocationView.setEnabled(false); + + // ==Boot Options Tab== + firstBootDeviceEditor.setEnabled(false); + secondBootDeviceEditor.setEnabled(false); + cdAttachedEditor.setEnabled(false); + cdImageEditor.setEnabled(false); + kernel_pathEditor.setEnabled(false); + initrd_pathEditor.setEnabled(false); + kernel_parametersEditor.setEnabled(false); + + // ==Custom Properties Tab== + customPropertiesSheetEditor.setEnabled(false); + } } diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/UnitVmModel.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/UnitVmModel.java index 4d0e763..03fa7aa 100644 --- a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/UnitVmModel.java +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/UnitVmModel.java @@ -68,6 +68,22 @@ privateIsNew = value; } + private boolean vmAttachedToPool; + + public boolean isVmAttachedToPool() { + return vmAttachedToPool; + } + + public void setVmAttachedToPool(boolean value) { + if (vmAttachedToPool != value) { + if (value) { + getNumOfSockets().setIsChangable(false); + getCoresPerSocket().setIsChangable(false); + } + vmAttachedToPool = value; + } + } + private VmType privateVmType = getVmType().values()[0]; public VmType getVmType() @@ -1029,10 +1045,22 @@ setTotalCPUCores(new EntityModel()); getTotalCPUCores().getEntityChangedEvent().addListener(this); - setNumOfSockets(new ListModel()); + setNumOfSockets(new ListModel() { + @Override + public void setIsChangable(boolean value) { + if (!isVmAttachedToPool()) + super.setIsChangable(value); + } + }); getNumOfSockets().getSelectedItemChangedEvent().addListener(this); - setCoresPerSocket(new ListModel()); + setCoresPerSocket(new ListModel() { + @Override + public void setIsChangable(boolean value) { + if (!isVmAttachedToPool()) + super.setIsChangable(value); + } + }); getCoresPerSocket().getSelectedItemChangedEvent().addListener(this); setRunVMOnSpecificHost(new EntityModel()); 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 b4462d0..617c3ac 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 @@ -844,6 +844,7 @@ UnitVmModel model = new UnitVmModel(new ExistingVmModelBehavior(vm)); model.setVmType(vm.getVmType()); + model.setVmAttachedToPool(vm.getVmPoolId() != null); setWindow(model); model.setTitle(ConstantsManager.getInstance() .getMessages() @@ -2628,7 +2629,7 @@ } /** - * Return true if and only if one elemnt is selected, and this element is not a part of any pool. + * Return true if and only if one element is selected. */ private boolean isEditCommandExecutionAllowed(List items) { if (items == null) { @@ -2637,9 +2638,7 @@ if (items.size() != 1) { return false; } - - VM selectedItem = (VM) items.get(0); - return selectedItem.getVmPoolId() == null; + return true; } @Override -- To view, visit http://gerrit.ovirt.org/10293 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I139ca66f945657b4d2323d6669e595c77a8fad09 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Arik Hadas <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
