Alexander Wels has posted comments on this change. Change subject: webadmin: Implement validation in EntityModelCellTable ......................................................................
Patch Set 1: (1 comment) http://gerrit.ovirt.org/#/c/31324/1/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/editor/EntityModelCellTable.java File frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/editor/EntityModelCellTable.java: Line 314: String error = errors.get(i); Line 315: Element element = getRowElement(i); Line 316: boolean valid = StringUtils.isEmpty(error); Line 317: element.setTitle(valid ? null : error); Line 318: element.getStyle().setOutlineStyle(valid ? OutlineStyle.NONE : OutlineStyle.SOLID); Instead of setting styles on the element like this I suggest you use css classes. For instance create a .css under src/main/resources/org/ovirt/engine/ui/common/css lets say 'Validation.css'. In the css file do something like this: .validationError { border: 1px solid red; } Then in EntityModelCellTable class define the resource and the associated style like this: public interface ValidationCss extends CssResource { String validationError(); } public interface EntityModelCellTableResources extends ClientBundle { @Source("org/ovirt/engine/ui/common/css/Validation.css") ValidationCss validationCss(); } private static final EntityModelCellTableResources ENTITY_MODEL_CELL_TABLE_RESOURCES = GWT.create(EntityModelCellTableResources.class); private final ValidationCss style; In the constructor: style = ENTITY_MODEL_CELL_TABLE_RESOURCES.validationCss(); style.ensureInjected(); And finally in validate you can now do the following: if (!valid) { element.addClassName(style.validationError()); } else { element.removeClassName(style.validationError()); } This is a lot of work, but this will make it much easier later to change the style in the .css file without having to alter code. It will also make it very easy to externalize the style class, so we can brand it at a later time. Line 319: element.getStyle().setOutlineColor("red"); //$NON-NLS-1$ Line 320: element.getStyle().setOutlineWidth(1, Unit.PX); Line 321: } Line 322: } -- To view, visit http://gerrit.ovirt.org/31324 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I8cddd3a6dbfe3cd9b18b631f4da13865b367d096 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Lior Vernia <[email protected]> Gerrit-Reviewer: Alexander Wels <[email protected]> Gerrit-Reviewer: Alona Kaplan <[email protected]> Gerrit-Reviewer: Lior Vernia <[email protected]> Gerrit-Reviewer: Vojtech Szocs <[email protected]> Gerrit-Reviewer: [email protected] Gerrit-Reviewer: oVirt Jenkins CI Server Gerrit-HasComments: Yes _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
