Arik Hadas has uploaded a new change for review. Change subject: userportal: refactor in UserPortalListModel & BootSequenceModel ......................................................................
userportal: refactor in UserPortalListModel & BootSequenceModel - extract the code that set the boot from network option for a given vm from UserPortalListModel#RunOnce to a new private method to make it a little bit shorter - extract the common code in BootSequenceModel#getHardDiskOption, BootSequenceModel#getNetworkOption, BootSequenceModel#getCdromOption to a new private method to reduce the code duplication Change-Id: I841bedf241e82f6f89e88a66d6cd4e4ea681102f Signed-off-by: Arik Hadas <[email protected]> --- M frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/userportal/UserPortalListModel.java M frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/BootSequenceModel.java 2 files changed, 21 insertions(+), 30 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/36/11736/1 diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/userportal/UserPortalListModel.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/userportal/UserPortalListModel.java index 752f98e..4b08d19 100644 --- a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/userportal/UserPortalListModel.java +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/userportal/UserPortalListModel.java @@ -783,6 +783,20 @@ .get(vm.getVdsGroupCompatibilityVersion())); // Boot sequence. + setIsBootFromNetworkAllowedForVm(vm); + setIsBootFromHardDiskAllowedForVm(vm); + + UICommand tempVar3 = new UICommand("OnRunOnce", this); //$NON-NLS-1$ + tempVar3.setTitle(ConstantsManager.getInstance().getConstants().ok()); + tempVar3.setIsDefault(true); + model.getCommands().add(tempVar3); + UICommand tempVar4 = new UICommand("Cancel", this); //$NON-NLS-1$ + tempVar4.setTitle(ConstantsManager.getInstance().getConstants().cancel()); + tempVar4.setIsCancel(true); + model.getCommands().add(tempVar4); + } + + private void setIsBootFromNetworkAllowedForVm(VM vm) { AsyncQuery _asyncQuery2 = new AsyncQuery(); _asyncQuery2.setModel(this); @@ -807,17 +821,6 @@ }; Frontend.RunQuery(VdcQueryType.GetVmInterfacesByVmId, new IdQueryParameters(vm.getId()), _asyncQuery2); - - setIsBootFromHardDiskAllowedForVm(vm); - - UICommand tempVar3 = new UICommand("OnRunOnce", this); //$NON-NLS-1$ - tempVar3.setTitle(ConstantsManager.getInstance().getConstants().ok()); - tempVar3.setIsDefault(true); - model.getCommands().add(tempVar3); - UICommand tempVar4 = new UICommand("Cancel", this); //$NON-NLS-1$ - tempVar4.setTitle(ConstantsManager.getInstance().getConstants().cancel()); - tempVar4.setIsCancel(true); - model.getCommands().add(tempVar4); } private void setIsBootFromHardDiskAllowedForVm(VM vm) { diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/BootSequenceModel.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/BootSequenceModel.java index 4174775..ef94ce8 100644 --- a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/BootSequenceModel.java +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/BootSequenceModel.java @@ -48,35 +48,23 @@ public EntityModel getHardDiskOption() { - for (EntityModel a : getItems()) - { - if ((BootSequence) a.getEntity() == BootSequence.C) - { - return a; - } - } - - throw new IndexOutOfBoundsException(); + return getBootSequenceOption(BootSequence.C); } public EntityModel getNetworkOption() { - for (EntityModel a : getItems()) - { - if ((BootSequence) a.getEntity() == BootSequence.N) - { - return a; - } - } - - throw new IndexOutOfBoundsException(); + return getBootSequenceOption(BootSequence.N); } public EntityModel getCdromOption() { + return getBootSequenceOption(BootSequence.D); + } + + private EntityModel getBootSequenceOption(BootSequence bootSequenceOption) { for (EntityModel a : getItems()) { - if ((BootSequence) a.getEntity() == BootSequence.D) + if ((BootSequence) a.getEntity() == bootSequenceOption) { return a; } -- To view, visit http://gerrit.ovirt.org/11736 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I841bedf241e82f6f89e88a66d6cd4e4ea681102f 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
