[overlord-commits] Overlord SVN: r1060 - bpm-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client.

overlord-commits at lists.jboss.org overlord-commits at lists.jboss.org
Mon Jul 5 05:23:13 EDT 2010


Author: heiko.braun at jboss.com
Date: 2010-07-05 05:23:13 -0400 (Mon, 05 Jul 2010)
New Revision: 1060

Modified:
   bpm-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/LoginView.java
Log:
Improve login error handling

Modified: bpm-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/LoginView.java
===================================================================
--- bpm-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/LoginView.java	2010-07-05 08:20:24 UTC (rev 1059)
+++ bpm-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/LoginView.java	2010-07-05 09:23:13 UTC (rev 1060)
@@ -30,10 +30,12 @@
 import com.google.gwt.user.client.ui.*;
 import com.mvc4g.client.Controller;
 import com.mvc4g.client.ViewInterface;
+import org.gwt.mosaic.ui.client.Caption;
 import org.gwt.mosaic.ui.client.MessageBox;
-import org.gwt.mosaic.ui.client.WidgetWrapper;
 import org.gwt.mosaic.ui.client.WindowPanel;
-import org.gwt.mosaic.ui.client.layout.*;
+import org.gwt.mosaic.ui.client.layout.BoxLayout;
+import org.gwt.mosaic.ui.client.layout.BoxLayoutData;
+import org.gwt.mosaic.ui.client.layout.MosaicPanel;
 import org.jboss.bpm.console.client.util.ConsoleLog;
 import org.jboss.errai.bus.client.ErraiBus;
 import org.jboss.errai.bus.client.api.base.MessageBuilder;
@@ -59,6 +61,7 @@
 
   public final static String[] KNOWN_ROLES = {"administrator", "manager", "user"};
 
+  private HTML messagePanel = new HTML("Authentication required");
 
   public LoginView()
   {
@@ -67,7 +70,7 @@
 
   public void setController(Controller controller)
   {
-   
+
   }
 
   public void display()
@@ -197,10 +200,9 @@
 
                 public void onLoginFailed(Request request, Throwable t)
                 {
-                  // auth failed                  
-                  window.hide();
-                  //MessageBox.error("Login failed", t.getMessage());
-                  alert("Login failed", t.getMessage());
+                  usernameInput.setText("");
+                  passwordInput.setText("");
+                  messagePanel.setHTML("<div style='color:#CC0000;'>Authentication failed. Please try again:</div>");                  
                 }
               }
           );
@@ -228,58 +230,22 @@
     }
   }
 
-  private void alert(String caption, String message) {
-      final MessageBox alert = new MessageBox(MessageBox.MessageBoxType.ALERT, caption) {
-        @Override
-        public void onClose(boolean result) {
-          hide();
-          window.show();
-        }
-      };
-      alert.setAnimationEnabled(false);
-      int preferredWidth = Window.getClientWidth();
-      preferredWidth = Math.max(preferredWidth / 3, 256);
-      alert.setWidth(preferredWidth + "px");
-
-      final Button buttonOK = new Button("OK");
-      buttonOK.addClickHandler(new ClickHandler() {
-        public void onClick(ClickEvent event) {
-          alert.hide();
-          window.show();
-        }
-      });
-      alert.getButtonPanel().add(buttonOK);
-
-      alert.setWidget(new WidgetWrapper(new HTML(message),
-          HasAlignment.ALIGN_LEFT, HasAlignment.ALIGN_TOP));
-      alert.showModal();
-
-      if (alert.getOffsetWidth() < preferredWidth) {
-        alert.setWidth(preferredWidth + "px");
-        alert.center();
-      }
-
-      DeferredCommand.addCommand(new Command() {
-        public void execute() {
-          buttonOK.setFocus(true);
-        }
-      });
-    }
-
   /**
    * The 'layout' window panel.
    */
   private void createLayoutWindowPanel() {
 
-    window = new WindowPanel(config.getProfileName(), false);   
+    window = new WindowPanel(config.getProfileName(), false);
+    Widget closeBtn = window.getHeader().getWidget(0, Caption.CaptionRegion.RIGHT);
+    closeBtn.setVisible(false);    
     window.setAnimationEnabled(false);
 
 
     MosaicPanel panel = new MosaicPanel();
     panel.addStyleName("bpm-login");
-    
+
     createLayoutContent(panel);
-    window.setWidget(panel);    
+    window.setWidget(panel);
   }
 
   /**
@@ -287,18 +253,18 @@
    */
   private void createLayoutContent(MosaicPanel layoutPanel) {
 
-    layoutPanel.setLayout(new BorderLayout());
-    layoutPanel.setPadding(5);
+    layoutPanel.setLayout(new BoxLayout(BoxLayout.Orientation.VERTICAL));
+    layoutPanel.setPadding(10);
 
 
     Widget form = createForm();
 
-    final Button submit = new Button("Submit");
+    final Button submit = new Button("Login");
     submit.addClickHandler(new ClickHandler()
     {
 
       public void onClick(ClickEvent clickEvent)
-      {        
+      {
         engageLogin();
       }
     });
@@ -307,15 +273,70 @@
     HTML html = new HTML("Version: " + Version.VERSION);
     html.setStyleName("bpm-login-info");
 
-    MosaicPanel southContainer = new MosaicPanel(new BoxLayout(BoxLayout.Orientation.VERTICAL));
-    southContainer.add(submit, new BoxLayoutData(BoxLayoutData.FillStyle.HORIZONTAL));
-    southContainer.add(html);
+    MosaicPanel btnPanel = new MosaicPanel(new BoxLayout());
+    btnPanel.add(html, new BoxLayoutData(BoxLayoutData.FillStyle.HORIZONTAL));
+    btnPanel.add(submit);
 
-    layoutPanel.add(form, new BorderLayoutData(BorderLayout.Region.CENTER));
-    layoutPanel.add(southContainer, new BorderLayoutData(BorderLayout.Region.SOUTH));
+    layoutPanel.add(messagePanel, new BoxLayoutData(BoxLayoutData.FillStyle.HORIZONTAL));
+    layoutPanel.add(form, new BoxLayoutData(BoxLayoutData.FillStyle.BOTH));
+    layoutPanel.add(btnPanel, new BoxLayoutData(BoxLayoutData.FillStyle.HORIZONTAL));
 
   }
 
+  private Widget createForm()
+  {
+    MosaicPanel panel = new MosaicPanel(new BoxLayout(BoxLayout.Orientation.VERTICAL));
+    panel.setPadding(0);
+
+    MosaicPanel box1 = new MosaicPanel(new BoxLayout());
+    box1.setPadding(0);
+    MosaicPanel box2 = new MosaicPanel(new BoxLayout());
+    box2.setPadding(0);
+
+    usernameInput = new TextBox();
+    passwordInput = new PasswordTextBox();
+
+
+    BoxLayoutData bld1 = new BoxLayoutData(BoxLayoutData.FillStyle.HORIZONTAL);
+    bld1.setPreferredWidth("70px");
+
+    box1.add( new Label("Username:"), bld1);
+    box1.add(usernameInput);
+
+    box2.add(new Label("Password:"), bld1);
+    box2.add(passwordInput);
+
+    passwordInput.addKeyboardListener(
+        new KeyboardListener()
+        {
+
+          public void onKeyDown(Widget widget, char c, int i)
+          {
+          }
+
+          public void onKeyPress(Widget widget, char c, int i)
+          {
+          }
+
+          public void onKeyUp(Widget widget, char c, int i)
+          {
+            if(c == KeyboardListener.KEY_ENTER)
+            {
+              engageLogin();
+            }
+          }
+        }
+    );
+
+    panel.add(box1);
+    panel.add(box2);
+    return panel;
+  }
+
+
+  //  -----------------------------------
+
+  
   private void engageLogin()
   {
     requestProtectedResource();
@@ -365,45 +386,4 @@
     return passwordInput.getText();
   }
 
-  private Widget createForm()
-  {
-    MosaicPanel p = new MosaicPanel(new BoxLayout(BoxLayout.Orientation.VERTICAL));
-
-    usernameInput = new TextBox();
-    passwordInput = new PasswordTextBox();
-
-    Grid grid = new Grid(2,2);
-    grid.setWidget(0,0, new Label("Username:"));
-    grid.setWidget(0,1, usernameInput);
-
-    grid.setWidget(1,0, new Label("Password:"));
-    grid.setWidget(1,1, passwordInput);
-
-    p.add(grid);
-
-    passwordInput.addKeyboardListener(
-        new KeyboardListener()
-        {
-
-          public void onKeyDown(Widget widget, char c, int i)
-          {
-          }
-
-          public void onKeyPress(Widget widget, char c, int i)
-          {
-          }
-
-          public void onKeyUp(Widget widget, char c, int i)
-          {
-            if(c == KeyboardListener.KEY_ENTER)
-            {
-              engageLogin();
-            }
-          }
-        }
-    );
-
-    return p;
-  }
-
 }



More information about the overlord-commits mailing list