Kanagaraj M has uploaded a new change for review. Change subject: webadmin: disabling gluster swift action radioboxes ......................................................................
webadmin: disabling gluster swift action radioboxes Disabling the not-supported operation checkboxes in the manage gluster swift popup. Start radio will be disabled if the service is already running. Overridden the defaul RadioboxCell implementation to include the disabled state of radio button. Change-Id: I3127a217875526c250c1175d61efb317615e8c20 Bug-Url: https://bugzilla.redhat.com/974516 Signed-off-by: Kanagaraj M <[email protected]> --- M frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/cluster/ManageGlusterSwiftPopupView.java 1 file changed, 52 insertions(+), 20 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/41/16441/1 diff --git a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/cluster/ManageGlusterSwiftPopupView.java b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/cluster/ManageGlusterSwiftPopupView.java index 3516f4c..7facafe 100644 --- a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/cluster/ManageGlusterSwiftPopupView.java +++ b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/cluster/ManageGlusterSwiftPopupView.java @@ -30,7 +30,9 @@ import com.google.gwt.editor.client.SimpleBeanEditorDriver; import com.google.gwt.event.shared.EventBus; import com.google.gwt.resources.client.CssResource; +import com.google.gwt.safehtml.shared.SafeHtml; import com.google.gwt.safehtml.shared.SafeHtmlBuilder; +import com.google.gwt.safehtml.shared.SafeHtmlUtils; import com.google.gwt.uibinder.client.UiBinder; import com.google.gwt.uibinder.client.UiField; import com.google.gwt.user.cellview.client.Column; @@ -124,7 +126,7 @@ }, constants.serviceStatusGlusterSwift()); Column<EntityModel, Boolean> startSwiftColumn = - new Column<EntityModel, Boolean>(new RadioboxCell(false, true)) { + new Column<EntityModel, Boolean>(new SwiftActionRadioboxCell(false, true)) { @Override public Boolean getValue(EntityModel object) { GlusterSwiftServiceModel swiftServiceModel = (GlusterSwiftServiceModel) object; @@ -134,8 +136,8 @@ @Override public void render(Context context, EntityModel object, SafeHtmlBuilder sb) { GlusterSwiftServiceModel swiftServiceModel = (GlusterSwiftServiceModel) object; - if (swiftServiceModel.getStartSwift().getIsChangable()) { - super.render(context, object, sb); + if (getCell() instanceof SwiftActionRadioboxCell) { + ((SwiftActionRadioboxCell) getCell()).render(context, swiftServiceModel.getStartSwift(), sb); } } }; @@ -153,21 +155,22 @@ }); hostServicesTable.addEntityModelColumn(startSwiftColumn, constants.startGlusterSwift()); - Column<EntityModel, Boolean> stopSwiftColumn = new Column<EntityModel, Boolean>(new RadioboxCell(false, true)) { - @Override - public Boolean getValue(EntityModel object) { - GlusterSwiftServiceModel swiftServiceModel = (GlusterSwiftServiceModel) object; - return (Boolean) swiftServiceModel.getStopSwift().getEntity(); - } + Column<EntityModel, Boolean> stopSwiftColumn = + new Column<EntityModel, Boolean>(new SwiftActionRadioboxCell(false, true)) { + @Override + public Boolean getValue(EntityModel object) { + GlusterSwiftServiceModel swiftServiceModel = (GlusterSwiftServiceModel) object; + return (Boolean) swiftServiceModel.getStopSwift().getEntity(); + } - @Override - public void render(Context context, EntityModel object, SafeHtmlBuilder sb) { - GlusterSwiftServiceModel swiftServiceModel = (GlusterSwiftServiceModel) object; - if (swiftServiceModel.getStopSwift().getIsChangable()) { - super.render(context, object, sb); - } - } - }; + @Override + public void render(Context context, EntityModel object, SafeHtmlBuilder sb) { + GlusterSwiftServiceModel swiftServiceModel = (GlusterSwiftServiceModel) object; + if (getCell() instanceof SwiftActionRadioboxCell) { + ((SwiftActionRadioboxCell) getCell()).render(context, swiftServiceModel.getStartSwift(), sb); + } + } + }; stopSwiftColumn.setFieldUpdater(new FieldUpdater<EntityModel, Boolean>() { @Override public void update(int index, EntityModel object, Boolean value) { @@ -185,7 +188,7 @@ hostServicesTable.addEntityModelColumn(stopSwiftColumn, constants.stopGlusterSwift()); Column<EntityModel, Boolean> restartSwiftColumn = - new Column<EntityModel, Boolean>(new RadioboxCell(false, true)) { + new Column<EntityModel, Boolean>(new SwiftActionRadioboxCell(false, true)) { @Override public Boolean getValue(EntityModel object) { GlusterSwiftServiceModel swiftServiceModel = (GlusterSwiftServiceModel) object; @@ -195,8 +198,8 @@ @Override public void render(Context context, EntityModel object, SafeHtmlBuilder sb) { GlusterSwiftServiceModel swiftServiceModel = (GlusterSwiftServiceModel) object; - if (swiftServiceModel.getRestartSwift().getIsChangable()) { - super.render(context, object, sb); + if (getCell() instanceof SwiftActionRadioboxCell) { + ((SwiftActionRadioboxCell) getCell()).render(context, swiftServiceModel.getStartSwift(), sb); } } }; @@ -249,4 +252,33 @@ String swiftStatusWidget(); } + + private static class SwiftActionRadioboxCell extends RadioboxCell { + + /** + * An html string representation of an unchecked disabled input box. + */ + private static final SafeHtml INPUT_UNCHECKED_DISABLED = + SafeHtmlUtils.fromSafeConstant("<input type=\"radio\" tabindex=\"-1\" disabled/>"); //$NON-NLS-1$ + + public SwiftActionRadioboxCell(boolean dependsOnSelection, boolean handlesSelection) { + super(dependsOnSelection, handlesSelection); + } + + public void render(Context context, EntityModel model, SafeHtmlBuilder sb) { + Boolean value = (Boolean) model.getEntity(); + Object key = context.getKey(); + Boolean viewData = getViewData(key); + if (viewData != null && viewData.equals(value)) { + clearViewData(key); + viewData = null; + } + if (!model.getIsChangable()) { + sb.append(INPUT_UNCHECKED_DISABLED); + } + else { + super.render(context, value, sb); + } + } + } } -- To view, visit http://gerrit.ovirt.org/16441 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I3127a217875526c250c1175d61efb317615e8c20 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Kanagaraj M <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
