Vojtech Szocs has uploaded a new change for review.

Change subject: webadmin,userportal: Loading indicator for GWTP place transition
......................................................................

webadmin,userportal: Loading indicator for GWTP place transition

Added "Loading" indicator, represented as a small text box shown
in top center of the screen, to be shown when the application is
transitioning from one place to another.

The "Loading" indicator is meant to provide visual feedback that
the application is currently busy and any user interaction should
be currently avoided to avoid unexpected state switches.

Change-Id: I242f1f994af15bdc29d1d47b90b7792924abf19e
Signed-off-by: Vojtech Szocs <[email protected]>
---
M 
frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/CommonApplicationConstants.java
M 
frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/gin/BaseSystemModule.java
A 
frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/system/LockInteractionManager.java
3 files changed, 90 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/93/7493/1

diff --git 
a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/CommonApplicationConstants.java
 
b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/CommonApplicationConstants.java
index dad8f4e..a29fd9a 100644
--- 
a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/CommonApplicationConstants.java
+++ 
b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/CommonApplicationConstants.java
@@ -28,6 +28,9 @@
     @DefaultStringValue(" ")
     String space();
 
+    @DefaultStringValue("Loading...")
+    String loadingIndicator();
+
     // Widgets
 
     @DefaultStringValue("Next >>")
diff --git 
a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/gin/BaseSystemModule.java
 
b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/gin/BaseSystemModule.java
index c387841..d024737 100644
--- 
a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/gin/BaseSystemModule.java
+++ 
b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/gin/BaseSystemModule.java
@@ -10,6 +10,7 @@
 import org.ovirt.engine.ui.common.system.AsyncCallFailureHandler;
 import org.ovirt.engine.ui.common.system.ClientStorage;
 import org.ovirt.engine.ui.common.system.ErrorPopupManager;
+import org.ovirt.engine.ui.common.system.LockInteractionManager;
 import org.ovirt.engine.ui.common.uicommon.ClientAgentType;
 
 import com.google.gwt.event.shared.EventBus;
@@ -36,6 +37,7 @@
         bind(ClientAgentType.class).in(Singleton.class);
         bind(ClientStorage.class).in(Singleton.class);
         bind(ApplicationFocusManager.class).asEagerSingleton();
+        bind(LockInteractionManager.class).asEagerSingleton();
     }
 
     protected void bindResourceConfiguration(
diff --git 
a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/system/LockInteractionManager.java
 
b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/system/LockInteractionManager.java
new file mode 100644
index 0000000..95add5b
--- /dev/null
+++ 
b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/system/LockInteractionManager.java
@@ -0,0 +1,85 @@
+package org.ovirt.engine.ui.common.system;
+
+import org.ovirt.engine.ui.common.CommonApplicationConstants;
+
+import com.google.gwt.core.client.Scheduler;
+import com.google.gwt.core.client.Scheduler.ScheduledCommand;
+import com.google.gwt.dom.client.Document;
+import com.google.gwt.dom.client.Element;
+import com.google.gwt.dom.client.Style;
+import com.google.gwt.dom.client.Style.FontWeight;
+import com.google.gwt.dom.client.Style.Position;
+import com.google.gwt.dom.client.Style.Unit;
+import com.google.gwt.event.shared.EventBus;
+import com.google.inject.Inject;
+import com.gwtplatform.mvp.client.proxy.LockInteractionEvent;
+import com.gwtplatform.mvp.client.proxy.LockInteractionHandler;
+
+/**
+ * Handles GWTP {@link LockInteractionEvent} by displaying "Loading" indicator 
when the application is transitioning
+ * from one place to another.
+ * <p>
+ * The "Loading" indicator provides visual feedback that the application is 
currently busy and any user interaction
+ * should be currently avoided to avoid unexpected state switches.
+ */
+public class LockInteractionManager implements LockInteractionHandler {
+
+    private final CommonApplicationConstants constants;
+
+    // Loading indicator element
+    private Element loadingIndicator;
+
+    @Inject
+    public LockInteractionManager(EventBus eventBus, 
CommonApplicationConstants constants) {
+        this.constants = constants;
+        eventBus.addHandler(LockInteractionEvent.getType(), this);
+    }
+
+    @Override
+    public void onLockInteraction(LockInteractionEvent event) {
+        if (event.shouldLock()) {
+            showLoadingIndicator();
+        } else {
+            // Use deferred command because some other initialization might
+            // happen right after place transition, so we want to hide the
+            // loading indicator only after the browser event loop returns
+            Scheduler.get().scheduleDeferred(new ScheduledCommand() {
+                @Override
+                public void execute() {
+                    hideLoadingIndicator();
+                }
+            });
+        }
+    }
+
+    void showLoadingIndicator() {
+        ensureLoadingIndicator();
+        Document.get().getBody().appendChild(loadingIndicator);
+    }
+
+    void hideLoadingIndicator() {
+        ensureLoadingIndicator();
+        Document.get().getBody().removeChild(loadingIndicator);
+    }
+
+    void ensureLoadingIndicator() {
+        if (loadingIndicator == null) {
+            loadingIndicator = Document.get().createDivElement();
+            loadingIndicator.setInnerText(constants.loadingIndicator());
+
+            Style style = loadingIndicator.getStyle();
+            style.setPosition(Position.RELATIVE);
+            style.setTop(7, Unit.PX);
+            style.setWidth(90, Unit.PX);
+            style.setHeight(19, Unit.PX);
+            style.setProperty("lineHeight", 19, Unit.PX); //$NON-NLS-1$
+            style.setProperty("margin", "0 auto"); //$NON-NLS-1$ //$NON-NLS-2$
+            style.setZIndex(1);
+            style.setProperty("border", "1px solid black"); //$NON-NLS-1$ 
//$NON-NLS-2$
+            style.setBackgroundColor("yellow"); //$NON-NLS-1$
+            style.setFontWeight(FontWeight.BOLD);
+            style.setProperty("textAlign", "center"); //$NON-NLS-1$ 
//$NON-NLS-2$
+        }
+    }
+
+}


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

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

Reply via email to