Lior Vernia has uploaded a new change for review.

Change subject: webadmin: Implement validation in EntityModelCellTable
......................................................................

webadmin: Implement validation in EntityModelCellTable

Validation accepts a list of errors, and outlines invalid entries
(ones which have non-empty errors) with a red outline, as well as adds
the invalidity reason as tooltip.

Change-Id: I8cddd3a6dbfe3cd9b18b631f4da13865b367d096
Bug-Url: https://bugzilla.redhat.com/1048752
Signed-off-by: Lior Vernia <[email protected]>
---
M 
frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/editor/EntityModelCellTable.java
A 
frontend/webadmin/modules/gwt-common/src/main/resources/org/ovirt/engine/ui/common/css/CellTableValidation.css
2 files changed, 36 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/04/31504/1

diff --git 
a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/editor/EntityModelCellTable.java
 
b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/editor/EntityModelCellTable.java
index f11fb36..027e775 100644
--- 
a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/editor/EntityModelCellTable.java
+++ 
b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/editor/EntityModelCellTable.java
@@ -13,12 +13,16 @@
 import org.ovirt.engine.ui.common.widget.table.header.SelectAllCheckBoxHeader;
 import org.ovirt.engine.ui.uicommonweb.models.EntityModel;
 import org.ovirt.engine.ui.uicommonweb.models.ListModel;
+import org.ovirt.engine.ui.uicompat.external.StringUtils;
 
 import com.google.gwt.cell.client.Cell;
 import com.google.gwt.cell.client.CheckboxCell;
 import com.google.gwt.core.client.GWT;
 import com.google.gwt.dom.client.BrowserEvents;
+import com.google.gwt.dom.client.Element;
 import com.google.gwt.dom.client.Style.Unit;
+import com.google.gwt.resources.client.ClientBundle;
+import com.google.gwt.resources.client.CssResource;
 import com.google.gwt.safehtml.shared.SafeHtml;
 import com.google.gwt.safehtml.shared.SafeHtmlUtils;
 import com.google.gwt.user.cellview.client.Column;
@@ -41,17 +45,28 @@
  */
 public class EntityModelCellTable<M extends ListModel> extends 
ElementIdCellTable<EntityModel> implements IsEditorDriver<M> {
 
+    public interface CellTableValidation extends CssResource {
+        String invalidRow();
+    }
+
+    public interface CellTableResources extends ClientBundle {
+        @Source("org/ovirt/engine/ui/common/css/CellTableValidation.css")
+        CellTableValidation cellTableValidation();
+    }
+
     public static enum SelectionMode {
         NONE,
         SINGLE,
         MULTIPLE
     }
 
+    private static final CellTableResources cellTableResources = 
GWT.create(CellTableResources.class);
     private static final int DEFAULT_PAGESIZE = 1000;
     private static final int CHECK_COLUMN_WIDTH = 27;
 
     private static CommonApplicationConstants constants = 
GWT.create(CommonApplicationConstants.class);
 
+    private final CellTableValidation style;
     private final HasDataListModelEditorAdapter<M, EntityModel> editorAdapter;
 
     /**
@@ -170,6 +185,10 @@
             boolean hideCheckbox,
             boolean showSelectAllCheckbox) {
         super(DEFAULT_PAGESIZE, resources);
+
+        style = cellTableResources.cellTableValidation();
+        style.ensureInjected();
+
         this.editorAdapter = new HasDataListModelEditorAdapter<M, 
EntityModel>(this);
 
         // Configure table selection model
@@ -306,6 +325,20 @@
         return asEditor().flush();
     }
 
+    public void validate(List<String> errors) {
+        for (int i=0; i < getRowCount(); ++i) {
+            String error = errors.get(i);
+            Element element = getRowElement(i);
+            boolean valid = StringUtils.isEmpty(error);
+            element.setTitle(valid ? null : error);
+            if (!valid) {
+                element.addClassName(style.invalidRow());
+            } else {
+                element.removeClassName(style.invalidRow());
+            }
+        }
+    }
+
     @Override
     public HasEditorDriver<M> asEditor() {
         return editorAdapter;
diff --git 
a/frontend/webadmin/modules/gwt-common/src/main/resources/org/ovirt/engine/ui/common/css/CellTableValidation.css
 
b/frontend/webadmin/modules/gwt-common/src/main/resources/org/ovirt/engine/ui/common/css/CellTableValidation.css
new file mode 100644
index 0000000..ac85dc4
--- /dev/null
+++ 
b/frontend/webadmin/modules/gwt-common/src/main/resources/org/ovirt/engine/ui/common/css/CellTableValidation.css
@@ -0,0 +1,3 @@
+.invalidRow {
+       outline: thin solid red;
+}
\ No newline at end of file


-- 
To view, visit http://gerrit.ovirt.org/31504
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I8cddd3a6dbfe3cd9b18b631f4da13865b367d096
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: ovirt-engine-3.5
Gerrit-Owner: Lior Vernia <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to