[Engine-devel] Got some troubles when I want to modify oVirt GUI

Itamar Heim iheim at redhat.com
Tue Mar 12 13:30:57 UTC 2013


On 03/12/2013 12:57 PM, Vojtech Szocs wrote:
> Hi,
>
> first of all, did you consider submitting this as RFE in oVirt bugzilla? Maybe it could be useful to have it in oVirt. (Implementing this via UI plugin would be far too complicated, as UI code is tightly coupled with UiCommon code in case of VM dialog.)>

my understanding this is a full blown feature, not a plugin.

Wei D - please note UI is to help the user to not make mistakes, but 
validations must also happen at engine side to cover rest api, etc.


> Regarding UI code changes, the general idea is to implement business logic in UiCommon models (VmListModel, UnitVmModel, etc.) and have UI code bind to these models. It would be best if you just send a patch (diff) instead of specific files, it's really hard to see what changes you made, but based on the files you sent, here are my comments:
>
> * Changes in UnitVmModel look good, you basically added two new fields [privateRunVMOnSpecificHost, privateRunVMOnTrustedHost], hooked up their *_EntityChanged methods, and implemented logic for handling field value changes in these methods
>
> * Changes in VmListModel look good, you used newly added UnitVmModel fields in onSave [I assume setTrustedHostFlag/setDedicatedVmForVds are new fields for VM entity?], note - you might also want to update UpdateActionAvailability disable migrating VM when RunVMOnTrustedHost=true, etc.
>
> * AbstractVmPopupWidget already has specificHost radio button & drop-down on Host dialog tab, and I assume you want to reuse the drop-down (host list) for trustedHost, so just add new radio button there:
>
>    AbstractVmPopupWidget.ui.xml line 331
>
>    <g:HorizontalPanel verticalAlignment='ALIGN_MIDDLE'>
>      <g:RadioButton name="specificOrTrustedHostGroup" ui:field="specificHost" addStyleNames="{style.radioButtonSpecificHost}" />
>      <g:RadioButton name="specificOrTrustedHostGroup" ui:field="trustedHost" addStyleNames="{style.radioButtonSpecificHost}" />
>      <g:Label ui:field="specificHostLabel" text="{constants.specificVmPopup}" />
>      <e:ListModelListBoxEditor ui:field="defaultHostEditor" />
>    </g:HorizontalPanel>
>
> * In AbstractVmPopupWidget you to bind newly added RadioButton:
>
>    @UiField(provided = true)
>    @Ignore
>    @WithElementId("trustedHost")
>    public RadioButton trustedHost;
>
>    You create trustedHost widget in constructor, and in initTabAvailabilityListeners you just add trustedHost.addValueChangeHandler(...) to have logic when trustedHost gets selected.
>
> Regards,
> Vojtech
>
>
> ----- Original Message -----
> From: "Wei D Chen" <wei.d.chen at intel.com>
> To: engine-devel at ovirt.org
> Sent: Tuesday, March 12, 2013 9:48:34 AM
> Subject: [Engine-devel] Got some troubles when I want to modify oVirt GUI
>
> Hi,
>     In order to add new feature to Ovirt, that is user can choose virtual machine whether on trusted machine or not when it runs up, we modified the relative files.
> Our goal is when the user click the trusted button, Run/Migration options are disabled. But unfortunately, we haven’t succeeded in graphic interface.
> I modified these files, I can’t see Host Tab, can you give me some help? Maybe we need modify more files. We did the following efforts:
> (1) add a trusted radio button.
> (2) Modify AbstractVmPopupWidget.ui.xml
> <g:HorizontalPanel verticalAlignment='ALIGN_MIDDLE'>
>       <g:RadioButton ui:field="runVMOnTrustedHost"/>
>       <e:EntityModelRadioButtonEditor width="150px" ui:field="runVMOnTrustedHostEditor"
>                    addStyleNames="{style.radioButton}" />
> </g:HorizontalPanel>
> (3) Modify AbstractVmPopupWidget.java
> @UiField(provided = true)
> @Path(value = "runVMOnTrustedHost.entity")
>      @WithElementId("runVMOnTrustedHost")
> public EntityModelRadioButtonEditor runVMOnTrustedHostEditor;
>
> initListeners method:
> object.getIsAutoAssign().getPropertyChangedEvent().addListener(new IEventListener() {
>              @Override
>              public void eventRaised(Event ev, Object sender, EventArgs args) {
>                  boolean isAutoAssign = (Boolean) object.getIsAutoAssign().getEntity();
>                  boolean runVMOnTrustedHost = (Boolean) object.getRunVMOnTrustedHost().getEntity();
>                  defaultHostEditor.setEnabled(!isAutoAssign && !runVMOnTrustedHost);
>                  //defaultHostEditor.setEnabled(!isAutoAssign);
>                  // only this is not bind to the model, so needs to listen to the change explicitly
>                 specificHost.setValue(!isAutoAssign && !runVMOnTrustedHost);
>                 //specificHost.setValue(!isAutoAssign);
>              }
>          });
> isAutoAssignEditor.addDomHandler(new ClickHandler() {
>              @Override
>              public void onClick(ClickEvent event) {
>                  defaultHostEditor.setEnabled(false);
>              }
>          }, ClickEvent.getType());
>          vm.getIsAutoAssign().getEntityChangedEvent().addListener(new IEventListener() {
>              @Override
>              public void eventRaised(Event ev, Object sender, EventArgs args) {
>                  if (!isAutoAssignEditor.asRadioButton().getValue() && !runVMOnTrustedHostEditor.asRadioButton().getValue())
>                  {
>                      specificHost.setValue(true, true);
>                  }
>              }
>          });
>          runVMOnTrustedHostEditor.addDomHandler(new ClickHandler() {
>              @Override
>              public void onClick(ClickEvent event) {
>                  defaultHostEditor.setEnabled(false);
>              }
>          }, ClickEvent.getType());
>          vm.getRunVMOnTrustedHost().getEntityChangedEvent().addListener(new IEventListener() {
>              @Override
>              public void eventRaised(Event ev, Object sender, EventArgs args) {
>                  if (!runVMOnTrustedHostEditor.asRadioButton().getValue() && !isAutoAssignEditor.asRadioButton().getValue())
>                  {
>                      specificHost.setValue(true, true);
>                  }
>              }
>          });
> (4) Modify UnitVmModel.java
>    private void RunVMOnTrustedHost_EntityChanged(Object sender, EventArgs args)
>     {
>          if ((Boolean) getRunVMOnTrustedHost().getEntity() == true)
>          {
>              clearAndDisable(getRunVMOnSpecificHost());
>              clearAndDisable(getHostCpu());
>          }
>          else
>          {
>              getRunVMOnSpecificHost().setIsChangable(true);
>          }
>          behavior.updateCpuPinningVisibility();
>   }
>
>
> _______________________________________________
> Engine-devel mailing list
> Engine-devel at ovirt.org
> http://lists.ovirt.org/mailman/listinfo/engine-devel
> _______________________________________________
> Engine-devel mailing list
> Engine-devel at ovirt.org
> http://lists.ovirt.org/mailman/listinfo/engine-devel
>




More information about the Engine-devel mailing list