Greg Sheremeta has uploaded a new change for review.

Change subject: userportal, webadmin: cleanup ImageButtonCell
......................................................................

userportal, webadmin: cleanup ImageButtonCell

Deleted barely used AbstractImageButtonCell and replaced its
single use with ImageButtonCell.

Tweaked some variable names in ImageButtonCell.

Change-Id: I2f6555485b32e735244b0bd98962766049a18117
Signed-off-by: Greg Sheremeta <[email protected]>
---
D 
frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/table/cell/AbstractImageButtonCell.java
M 
frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/table/cell/ImageButtonCell.java
M 
frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/widget/footer/AlertsEventsFooterView.java
3 files changed, 12 insertions(+), 94 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/00/39100/1

diff --git 
a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/table/cell/AbstractImageButtonCell.java
 
b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/table/cell/AbstractImageButtonCell.java
deleted file mode 100644
index c2412ee..0000000
--- 
a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/table/cell/AbstractImageButtonCell.java
+++ /dev/null
@@ -1,82 +0,0 @@
-package org.ovirt.engine.ui.common.widget.table.cell;
-
-import java.util.HashSet;
-import java.util.Set;
-
-import org.ovirt.engine.ui.uicommonweb.UICommand;
-
-import com.google.gwt.cell.client.ValueUpdater;
-import com.google.gwt.dom.client.BrowserEvents;
-import com.google.gwt.dom.client.Element;
-import com.google.gwt.dom.client.EventTarget;
-import com.google.gwt.dom.client.NativeEvent;
-import com.google.gwt.resources.client.ImageResource;
-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.user.client.ui.AbstractImagePrototype;
-
-/**
- * Cell that renders ActionButtonDefinition-like image buttons.
- *
- * @param <C>
- *            The data type of the cell (the model)
- */
-public abstract class AbstractImageButtonCell<C> extends AbstractCell<C> {
-
-    private final SafeHtml imageHtml;
-
-    public AbstractImageButtonCell(ImageResource image) {
-        super();
-        this.imageHtml = 
SafeHtmlUtils.fromTrustedString(AbstractImagePrototype.create(image).getHTML());
-    }
-
-    @Override
-    public Set<String> getConsumedEvents() {
-        Set<String> set = new HashSet<>(super.getConsumedEvents());
-        set.add(BrowserEvents.CLICK);
-        return set;
-    }
-
-    @Override
-    public void onBrowserEvent(Context context, Element parent, C value, 
SafeHtml tooltipContent, NativeEvent event, ValueUpdater<C> valueUpdater) {
-        super.onBrowserEvent(context, parent, value, tooltipContent, event, 
valueUpdater);
-
-        EventTarget eventTarget = event.getEventTarget();
-        if (!Element.is(eventTarget)) {
-            return;
-        }
-
-        if (BrowserEvents.CLICK.equals(event.getType())) {
-            onClick(value);
-        }
-    }
-
-    @Override
-    public void render(Context context, C value, SafeHtmlBuilder sb, String 
id) {
-        sb.appendHtmlConstant("<span id=\"" //$NON-NLS-1$
-                + id
-                + "\" style=\"vertical-align: middle;\">"); //$NON-NLS-1$
-        sb.append(imageHtml);
-        sb.appendHtmlConstant("</span>"); //$NON-NLS-1$
-    }
-
-    /**
-     * Get the UICommand associated with the button.
-     * @param value
-     * @return
-     */
-    protected abstract UICommand resolveCommand(C value);
-
-    /**
-     * Execute the click command.
-     * @param value
-     */
-    protected void onClick(C value) {
-        UICommand command = resolveCommand(value);
-        if (command != null) {
-            command.execute();
-        }
-    }
-
-}
diff --git 
a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/table/cell/ImageButtonCell.java
 
b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/table/cell/ImageButtonCell.java
index d8c79ff..ec4657a 100644
--- 
a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/table/cell/ImageButtonCell.java
+++ 
b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/table/cell/ImageButtonCell.java
@@ -29,24 +29,24 @@
 
     interface CellTemplate extends SafeHtmlTemplates {
         @Template("<span id=\"{0}\" class=\"{1}\">{2}</span>")
-        SafeHtml span(String id, String styleClass, SafeHtml html);
+        SafeHtml span(String id, String classNames, SafeHtml html);
     }
 
     private static CellTemplate template = GWT.create(CellTemplate.class);
 
     private final SafeHtml enabledHtml;
-    private final String enabledCss;
+    private final String enabledClassNames;
 
     private final SafeHtml disabledHtml;
-    private final String disabledCss;
+    private final String disabledClassNames;
 
-    public ImageButtonCell(ImageResource enabledImage, String enabledCss,
-            ImageResource disabledImage, String disabledCss) {
+    public ImageButtonCell(ImageResource enabledImage, String 
enabledClassNames,
+            ImageResource disabledImage, String disabledClassNames) {
         super();
         this.enabledHtml = 
SafeHtmlUtils.fromTrustedString(AbstractImagePrototype.create(enabledImage).getHTML());
-        this.enabledCss = enabledCss;
+        this.enabledClassNames = enabledClassNames;
         this.disabledHtml = 
SafeHtmlUtils.fromTrustedString(AbstractImagePrototype.create(disabledImage).getHTML());
-        this.disabledCss = disabledCss;
+        this.disabledClassNames = disabledClassNames;
     }
 
     /**
@@ -76,7 +76,7 @@
 
     @Override
     public void render(Context context, T value, SafeHtmlBuilder sb, String 
id) {
-        String css = isEnabled(value) ? enabledCss : disabledCss;
+        String css = isEnabled(value) ? enabledClassNames : disabledClassNames;
         SafeHtml html = isEnabled(value) ? enabledHtml : disabledHtml;
 
         sb.append(template.span(id, css, html));
diff --git 
a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/widget/footer/AlertsEventsFooterView.java
 
b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/widget/footer/AlertsEventsFooterView.java
index d86c07f..67c3489 100644
--- 
a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/widget/footer/AlertsEventsFooterView.java
+++ 
b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/widget/footer/AlertsEventsFooterView.java
@@ -10,10 +10,10 @@
 import org.ovirt.engine.ui.common.uicommon.model.SearchableTabModelProvider;
 import org.ovirt.engine.ui.common.widget.action.CommandLocation;
 import org.ovirt.engine.ui.common.widget.table.SimpleActionTable;
-import org.ovirt.engine.ui.common.widget.table.cell.AbstractImageButtonCell;
+import org.ovirt.engine.ui.common.widget.table.cell.ImageButtonCell;
+import org.ovirt.engine.ui.common.widget.table.column.AbstractColumn;
 import 
org.ovirt.engine.ui.common.widget.table.column.AbstractFullDateTimeColumn;
 import 
org.ovirt.engine.ui.common.widget.table.column.AbstractImageResourceColumn;
-import org.ovirt.engine.ui.common.widget.table.column.AbstractColumn;
 import org.ovirt.engine.ui.common.widget.table.column.AbstractTextColumn;
 import org.ovirt.engine.ui.common.widget.table.column.AuditLogSeverityColumn;
 import org.ovirt.engine.ui.uicommonweb.UICommand;
@@ -508,12 +508,12 @@
         }
     }
 
-    class DismissAuditLogImageButtonCell extends 
AbstractImageButtonCell<AuditLog> {
+    class DismissAuditLogImageButtonCell extends ImageButtonCell<AuditLog> {
 
         AlertModelProvider alertModelProvider;
 
         public DismissAuditLogImageButtonCell(AlertModelProvider 
alertModelProvider) {
-            super(resources.dialogIconClose());
+            super(resources.dialogIconClose(), "", 
resources.dialogIconClose(), ""); //$NON-NLS-1$ //$NON-NLS-2$
             this.alertModelProvider = alertModelProvider;
         }
 


-- 
To view, visit https://gerrit.ovirt.org/39100
To unsubscribe, visit https://gerrit.ovirt.org/settings

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

Reply via email to