Vojtech Szocs has posted comments on this change. Change subject: frontend: change VM status icons ......................................................................
Patch Set 7: Looks good to me, but someone else must approve (6 inline comments) .................................................... File frontend/webadmin/modules/userportal-gwtp/src/main/java/org/ovirt/engine/ui/userportal/widget/table/column/VmStatusColumn.java Line 15: if (vm == null) { Line 16: return getApplicationResources().vmStatusRunning(); Line 17: } Line 18: Line 19: if (vm.isRunOnce()) { Minor thing: ternary operator might be an option here to reduce code complexity, for example: if (vm == null) { return getApplicationResources().vmStatusRunning(); } else { return vm.isRunOnce() ? getApplicationResources().runOnceUpImage() : getApplicationResources().vmStatusRunning(); } Line 20: return getApplicationResources().runOnceUpImage(); Line 21: } else { Line 22: return getApplicationResources().vmStatusRunning(); Line 23: } .................................................... File frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/widget/table/column/VmStatusCell.java Line 36: String tooltip; Line 37: Line 38: switch (status) { Line 39: case Up: Line 40: if (vm.isRunOnce()) { Minor thing: ternary operator might be an option here to reduce code complexity, for example: tooltip = vm.isRunOnce() ? constants.runOnce() : constants.up(); Line 41: tooltip = constants.runOnce(); Line 42: statusImage = resources.runOnceUpImage(); Line 43: } else { Line 44: tooltip = constants.up(); .................................................... File frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/widget/table/column/VmTypeColumn.java Line 13: * Image column that corresponds to XAML {@code VmTypeTemplate}. Line 14: */ Line 15: public class VmTypeColumn extends WebAdminImageResourceColumn<VM> { Line 16: Line 17: private Map<VmTypeConfig, Pair<ImageResource, String>> configToIcon; Minor thing: consider using final Line 18: Line 19: private static final CommonApplicationConstants constants = ClientGinjectorProvider.instance().getApplicationConstants(); Line 20: Line 21: public VmTypeColumn() { Line 34: Line 35: @Override Line 36: public ImageResource getValue(VM vm) { Line 37: if (vm.getVmPoolId() == null) { Line 38: VmTypeConfig config = new VmTypeConfig(vm.isStateless(), vm.getVmType()); See my suggestion below, key lookup could be realized more simply, for example: VmTypeConfig config = VmTypeConfig.for(vm.getVmType(), vm.isStateless()); ... setTitle(config.getTooltip()); return config.getImageResource(); Line 39: Line 40: if (configToIcon.containsKey(config)) { Line 41: Pair<ImageResource, String> value = configToIcon.get(config); Line 42: setTitle(value.getSecond()); Line 41: Pair<ImageResource, String> value = configToIcon.get(config); Line 42: setTitle(value.getSecond()); Line 43: return value.getFirst(); Line 44: } else { Line 45: return getApplicationResources().manyDesktopsImage(); See my suggestion below, "ManyDesktops" should be represented as default (fallback) option in VmTypeConfig enum. Line 46: } Line 47: } else { Line 48: return getApplicationResources().manyDesktopsImage(); Line 49: } Line 48: return getApplicationResources().manyDesktopsImage(); Line 49: } Line 50: } Line 51: Line 52: class VmTypeConfig { Suggestion: use Java enum to enumerate different VM config vectors: public enum VmTypeConfig { DESKTOP_STATELESS(VmType.Desktop, true) { @Override public ImageResource getImageResource(ApplicationResources resources) { return resources.desktopStateless(); } @Override public String getTooltip(ApplicationConstants constants) { return constants.statelessDesktop(); } }, ... VmTypeConfig(VmType vmType, boolean stateless) { ... } public abstract ImageResource getImageResource(ApplicationResources resources); public abstract String getTooltip(ApplicationConstants constants); public static VmTypeConfig from(VmType vmType, boolean stateless) { // iterate over VmTypeConfig.values() and if not found, fall back to "ManyDesktops" } } This way, you can get rid of "configToIcon" hash map entirely, reducing code complexity. Line 53: Line 54: private boolean stateless; Line 55: Line 56: private VmType vmType; -- To view, visit http://gerrit.ovirt.org/16374 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I82b16f63527158d4cd44b0b39aed5010d61c2115 Gerrit-PatchSet: 7 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Tomas Jelinek <tjeli...@redhat.com> Gerrit-Reviewer: Tomas Jelinek <tjeli...@redhat.com> Gerrit-Reviewer: Vojtech Szocs <vsz...@redhat.com> Gerrit-Reviewer: oVirt Jenkins CI Server _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches