Omer Frenkel has uploaded a new change for review.

Change subject: user portal: add icon for vm with next_run configuration
......................................................................

user portal: add icon for vm with next_run configuration

Change-Id: Id20f0c08aed971c7801d06693c859abe4ad659b7
Signed-off-by: Omer Frenkel <ofren...@redhat.com>
---
A 
frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/table/column/DecoratedImageResouceCell.java
A 
frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/table/column/ImageWithDecorator.java
A 
frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/table/column/ImageWithDecoratorColumn.java
M 
frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/table/column/StyledImageResourceCell.java
A 
frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/table/column/TitlePanelCell.java
M 
frontend/webadmin/modules/userportal-gwtp/src/main/java/org/ovirt/engine/ui/userportal/ApplicationResources.java
M 
frontend/webadmin/modules/userportal-gwtp/src/main/java/org/ovirt/engine/ui/userportal/widget/table/column/VmStatusColumn.java
A 
frontend/webadmin/modules/userportal-gwtp/src/main/resources/org/ovirt/engine/ui/userportal/images/status/vm_delta.png
8 files changed, 212 insertions(+), 59 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/24/27824/1

diff --git 
a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/table/column/DecoratedImageResouceCell.java
 
b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/table/column/DecoratedImageResouceCell.java
new file mode 100644
index 0000000..665c7b4
--- /dev/null
+++ 
b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/table/column/DecoratedImageResouceCell.java
@@ -0,0 +1,47 @@
+package org.ovirt.engine.ui.common.widget.table.column;
+
+import com.google.gwt.core.client.GWT;
+import com.google.gwt.safehtml.client.SafeHtmlTemplates;
+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;
+
+public class DecoratedImageResouceCell extends 
TitlePanelCell<ImageWithDecorator> {
+
+    interface CellTemplate extends SafeHtmlTemplates {
+        @Template("<div style=\"position: relative; left: 0; top: 0;\"><span 
style=\"position: relative; left: 0px; top: 0px;\">{0}</span><span 
style=\"position: absolute; left: {2}px; top: {3}px;\">{1}</span></div>")
+        SafeHtml doubleImageContainer(SafeHtml imageHtml, SafeHtml 
decoratorHtml, int left, int top);
+    }
+
+    private static CellTemplate template;
+
+    public DecoratedImageResouceCell() {
+        super();
+
+        // Delay cell template creation until the first time it's needed
+        if (template == null) {
+            template = GWT.create(CellTemplate.class);
+        }
+    }
+
+    @Override
+    public void render(Context context, ImageWithDecorator value, 
SafeHtmlBuilder sb) {
+        if (value != null) {
+            SafeHtml mainImageHtml = SafeHtmlUtils.fromTrustedString("");
+            SafeHtml decorateImageHtml = SafeHtmlUtils.fromTrustedString("");
+            if (value.getImage() != null) {
+                mainImageHtml =
+                        
SafeHtmlUtils.fromTrustedString(AbstractImagePrototype.create(value.getImage()).getHTML());
+            }
+            if (value.getDecorator() != null) {
+                decorateImageHtml =
+                        
SafeHtmlUtils.fromTrustedString(AbstractImagePrototype.create(value.getDecorator()).getHTML());
+            }
+            sb.append(template.doubleImageContainer(mainImageHtml,
+                    decorateImageHtml,
+                    value.getDecoratorPositionLeft(),
+                    value.getDecoratorPositionTop()));
+        }
+    }
+}
diff --git 
a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/table/column/ImageWithDecorator.java
 
b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/table/column/ImageWithDecorator.java
new file mode 100644
index 0000000..43f3a62f
--- /dev/null
+++ 
b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/table/column/ImageWithDecorator.java
@@ -0,0 +1,52 @@
+package org.ovirt.engine.ui.common.widget.table.column;
+
+import com.google.gwt.resources.client.ImageResource;
+
+public class ImageWithDecorator {
+    private ImageResource image;
+    private ImageResource decorator;
+    private int decoratorPositionLeft;
+    private int decoratorPositionTop;
+
+    public ImageWithDecorator(ImageResource image,
+            ImageResource decorator,
+            int decoratorPositionLeft,
+            int decoratorPositionTop) {
+        this.image = image;
+        this.decorator = decorator;
+        this.decoratorPositionLeft = decoratorPositionLeft;
+        this.decoratorPositionTop = decoratorPositionTop;
+    }
+
+    public ImageResource getImage() {
+        return image;
+    }
+
+    public void setImage(ImageResource image) {
+        this.image = image;
+    }
+
+    public ImageResource getDecorator() {
+        return decorator;
+    }
+
+    public void setDecorator(ImageResource decorator) {
+        this.decorator = decorator;
+    }
+
+    public int getDecoratorPositionLeft() {
+        return decoratorPositionLeft;
+    }
+
+    public void setDecoratorPositionLeft(int decoratorPositionLeft) {
+        this.decoratorPositionLeft = decoratorPositionLeft;
+    }
+
+    public int getDecoratorPositionTop() {
+        return decoratorPositionTop;
+    }
+
+    public void setDecoratorPositionTop(int decoratorPositionTop) {
+        this.decoratorPositionTop = decoratorPositionTop;
+    }
+}
diff --git 
a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/table/column/ImageWithDecoratorColumn.java
 
b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/table/column/ImageWithDecoratorColumn.java
new file mode 100644
index 0000000..c971f28
--- /dev/null
+++ 
b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/table/column/ImageWithDecoratorColumn.java
@@ -0,0 +1,25 @@
+package org.ovirt.engine.ui.common.widget.table.column;
+
+import com.google.gwt.user.cellview.client.Column;
+import org.ovirt.engine.ui.uicompat.EnumTranslator;
+
+public abstract class ImageWithDecoratorColumn <T> extends Column<T, 
ImageWithDecorator> {
+
+    public ImageWithDecoratorColumn() {
+        super(new DecoratedImageResouceCell());
+    }
+
+    @Override
+    public DecoratedImageResouceCell getCell() {
+        return (DecoratedImageResouceCell) super.getCell();
+    }
+
+    public void setTitle(String title) {
+        getCell().setTitle(title);
+    }
+
+    public void setEnumTitle(Enum<?> enumObj) {
+        setTitle(EnumTranslator.createAndTranslate(enumObj));
+    }
+
+}
diff --git 
a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/table/column/StyledImageResourceCell.java
 
b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/table/column/StyledImageResourceCell.java
index dbc5432..749b5a0 100644
--- 
a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/table/column/StyledImageResourceCell.java
+++ 
b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/table/column/StyledImageResourceCell.java
@@ -1,30 +1,19 @@
 package org.ovirt.engine.ui.common.widget.table.column;
 
-import java.util.HashSet;
-import java.util.Set;
-
-import org.ovirt.engine.ui.common.widget.ElementAwareDecoratedPopupPanel;
-
-import com.google.gwt.cell.client.ImageResourceCell;
-import com.google.gwt.cell.client.ValueUpdater;
 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.NativeEvent;
 import com.google.gwt.resources.client.ImageResource;
 import com.google.gwt.safehtml.client.SafeHtmlTemplates;
 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;
-import com.google.gwt.user.client.ui.Label;
 
 /**
  * ImageResourceCell that supports setting a style and displaying a tooltip in 
a
  * DecoratedPopupPanel.
  *
  */
-public class StyledImageResourceCell extends ImageResourceCell implements 
HasStyleClass {
+public class StyledImageResourceCell extends TitlePanelCell<ImageResource> 
implements HasStyleClass {
 
     interface CellTemplate extends SafeHtmlTemplates {
         @Template("<div style=\"{0}\" class=\"{1}\">{2}</div>")
@@ -33,13 +22,8 @@
 
     private String style = "line-height: 100%; text-align: center; 
vertical-align: middle;"; //$NON-NLS-1$
     private String styleClass = ""; //$NON-NLS-1$
-    private String title = ""; //$NON-NLS-1$
 
     private static CellTemplate template;
-
-    private ElementAwareDecoratedPopupPanel titlePanel = new 
ElementAwareDecoratedPopupPanel();
-
-    private Set<String> consumedEvents;
 
     public StyledImageResourceCell() {
         super();
@@ -48,15 +32,6 @@
         if (template == null) {
             template = GWT.create(CellTemplate.class);
         }
-
-        consumedEvents = new HashSet<String>();
-        consumedEvents.add("mouseover"); //$NON-NLS-1$
-        consumedEvents.add("mouseout"); //$NON-NLS-1$
-    }
-
-    @Override
-    public Set<String> getConsumedEvents() {
-        return consumedEvents;
     }
 
     @Override
@@ -76,35 +51,4 @@
     public void setStyleClass(String styleClass) {
         this.styleClass = styleClass == null ? "" : styleClass; //$NON-NLS-1$
     }
-
-    /**
-     * Set the text for the tooltip that will show when this cell is hovered 
over.
-     * @param title
-     */
-    public void setTitle(String title) {
-        this.title = title != null ? title : ""; //$NON-NLS-1$
-    }
-
-    @Override
-    public void onBrowserEvent(Context context, Element parent, ImageResource 
value,
-            NativeEvent event, ValueUpdater<ImageResource> valueUpdater) {
-        String eventType = event.getType();
-        handleTitlePanel(eventType, parent);
-    }
-
-    private void handleTitlePanel(String eventType, Element parent) {
-        if (title.isEmpty()) {
-            // no need to show/hide title
-            return;
-        }
-
-        titlePanel.setWidget(new Label(title));
-        if (BrowserEvents.MOUSEOVER.equals(eventType)) {
-            titlePanel.showRelativeTo(parent);
-        }
-        else if (BrowserEvents.MOUSEOUT.equals(eventType)) {
-            titlePanel.hide();
-        }
-    }
-
 }
diff --git 
a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/table/column/TitlePanelCell.java
 
b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/table/column/TitlePanelCell.java
new file mode 100644
index 0000000..700c17c
--- /dev/null
+++ 
b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/table/column/TitlePanelCell.java
@@ -0,0 +1,63 @@
+package org.ovirt.engine.ui.common.widget.table.column;
+
+import com.google.gwt.cell.client.AbstractCell;
+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.NativeEvent;
+import com.google.gwt.user.client.ui.Label;
+import org.ovirt.engine.ui.common.widget.ElementAwareDecoratedPopupPanel;
+
+import java.util.HashSet;
+import java.util.Set;
+
+public abstract class TitlePanelCell<T> extends AbstractCell<T> {
+
+    private String title = ""; //$NON-NLS-1$
+    private ElementAwareDecoratedPopupPanel titlePanel = new 
ElementAwareDecoratedPopupPanel();
+
+    private Set<String> consumedEvents;
+
+    @Override
+    public Set<String> getConsumedEvents() {
+        return consumedEvents;
+    }
+
+    public TitlePanelCell() {
+        super();
+
+        consumedEvents = new HashSet<String>();
+        consumedEvents.add("mouseover"); //$NON-NLS-1$
+        consumedEvents.add("mouseout"); //$NON-NLS-1$
+    }
+
+    /**
+     * Set the text for the tooltip that will show when this cell is hovered 
over.
+     *
+     * @param title
+     */
+    public void setTitle(String title) {
+        this.title = title != null ? title : ""; //$NON-NLS-1$
+    }
+
+    @Override
+    public void onBrowserEvent(Context context, Element parent, T value, 
NativeEvent event, ValueUpdater<T> valueUpdater) {
+        String eventType = event.getType();
+        handleTitlePanel(eventType, parent);
+    }
+
+    private void handleTitlePanel(String eventType, Element parent) {
+        if (title.isEmpty()) {
+            // no need to show/hide title
+            return;
+        }
+
+        titlePanel.setWidget(new Label(title));
+        if (BrowserEvents.MOUSEOVER.equals(eventType)) {
+            titlePanel.showRelativeTo(parent);
+        }
+        else if (BrowserEvents.MOUSEOUT.equals(eventType)) {
+            titlePanel.hide();
+        }
+    }
+}
diff --git 
a/frontend/webadmin/modules/userportal-gwtp/src/main/java/org/ovirt/engine/ui/userportal/ApplicationResources.java
 
b/frontend/webadmin/modules/userportal-gwtp/src/main/java/org/ovirt/engine/ui/userportal/ApplicationResources.java
index fb254b9..1c96c0e 100644
--- 
a/frontend/webadmin/modules/userportal-gwtp/src/main/java/org/ovirt/engine/ui/userportal/ApplicationResources.java
+++ 
b/frontend/webadmin/modules/userportal-gwtp/src/main/java/org/ovirt/engine/ui/userportal/ApplicationResources.java
@@ -103,6 +103,9 @@
     @Source("images/status/vm_run_runonce.png")
     ImageResource runOnceUpImage();
 
+    @Source("images/status/vm_delta.png")
+    ImageResource vmDelta();
+
     @Source("css/SideTabExtendedVmStyle.css")
     SideTabExtendedVmStyle sideTabExtendedVmStyle();
 
diff --git 
a/frontend/webadmin/modules/userportal-gwtp/src/main/java/org/ovirt/engine/ui/userportal/widget/table/column/VmStatusColumn.java
 
b/frontend/webadmin/modules/userportal-gwtp/src/main/java/org/ovirt/engine/ui/userportal/widget/table/column/VmStatusColumn.java
index 9bd6711..c922999 100644
--- 
a/frontend/webadmin/modules/userportal-gwtp/src/main/java/org/ovirt/engine/ui/userportal/widget/table/column/VmStatusColumn.java
+++ 
b/frontend/webadmin/modules/userportal-gwtp/src/main/java/org/ovirt/engine/ui/userportal/widget/table/column/VmStatusColumn.java
@@ -1,14 +1,33 @@
 package org.ovirt.engine.ui.userportal.widget.table.column;
 
 import org.ovirt.engine.core.common.businessentities.VM;
+import org.ovirt.engine.ui.common.widget.table.column.ImageWithDecorator;
+import org.ovirt.engine.ui.common.widget.table.column.ImageWithDecoratorColumn;
 import org.ovirt.engine.ui.uicommonweb.models.userportal.UserPortalItemModel;
 
 import com.google.gwt.resources.client.ImageResource;
+import org.ovirt.engine.ui.userportal.ApplicationResources;
+import org.ovirt.engine.ui.userportal.gin.ClientGinjectorProvider;
 
-public class VmStatusColumn extends 
UserPortalImageResourceColumn<UserPortalItemModel> {
+public class VmStatusColumn extends 
ImageWithDecoratorColumn<UserPortalItemModel> {
+    private final int DECORATOR_POSITION_LEFT = 16;
+    private final int DECORATOR_POSITION_TOP = -9;
+
+    protected ApplicationResources getApplicationResources() {
+        return ClientGinjectorProvider.getApplicationResources();
+    }
 
     @Override
-    public ImageResource getValue(UserPortalItemModel item) {
+    public ImageWithDecorator getValue(UserPortalItemModel item) {
+        VM vm = item.getVM();
+        ImageResource changesImage = null;
+        if (vm != null && vm.isNextRunConfigurationExists()) {
+            changesImage = getApplicationResources().vmDelta();
+        }
+        return new ImageWithDecorator(getMainImage(item), changesImage, 
DECORATOR_POSITION_LEFT, DECORATOR_POSITION_TOP);
+    }
+
+    private ImageResource getMainImage(UserPortalItemModel item) {
         switch (item.getStatus()) {
         case Up:
             VM vm = item.getVM();
diff --git 
a/frontend/webadmin/modules/userportal-gwtp/src/main/resources/org/ovirt/engine/ui/userportal/images/status/vm_delta.png
 
b/frontend/webadmin/modules/userportal-gwtp/src/main/resources/org/ovirt/engine/ui/userportal/images/status/vm_delta.png
new file mode 100644
index 0000000..45d9610
--- /dev/null
+++ 
b/frontend/webadmin/modules/userportal-gwtp/src/main/resources/org/ovirt/engine/ui/userportal/images/status/vm_delta.png
Binary files differ


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Id20f0c08aed971c7801d06693c859abe4ad659b7
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Omer Frenkel <ofren...@redhat.com>
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to