Author: [EMAIL PROTECTED]
Date: Tue Oct  7 09:17:27 2008
New Revision: 3725

Added:
     
trunk/reference/code-museum/src/com/google/gwt/museum/client/defaultmuseum/Issue2855.java
    
(contents, props changed)
Modified:
     
trunk/reference/code-museum/src/com/google/gwt/museum/client/defaultmuseum/DefaultMuseum.java
     
trunk/reference/code-museum/src/com/google/gwt/museum/client/defaultmuseum/Issue1169.java
    trunk/user/src/com/google/gwt/user/client/ui/PopupPanel.java
    trunk/user/test/com/google/gwt/user/client/ui/PopupTest.java

Log:
Added getters/setters to PopupPanel for autoHide and modal variables.

Patch by: jlabanca
Review by: rjrjr
Issue: 2855



Modified:  
trunk/reference/code-museum/src/com/google/gwt/museum/client/defaultmuseum/DefaultMuseum.java
==============================================================================
---  
trunk/reference/code-museum/src/com/google/gwt/museum/client/defaultmuseum/DefaultMuseum.java
    
(original)
+++  
trunk/reference/code-museum/src/com/google/gwt/museum/client/defaultmuseum/DefaultMuseum.java
    
Tue Oct  7 09:17:27 2008
@@ -41,8 +41,8 @@
      addIssue(new Issue2392());
      addIssue(new Issue2443());
      addIssue(new Issue2553());
+    addIssue(new Issue2855());
      addIssue(new TreeVisuals());
      addIssue(new TestFireEvents());
-
    }
  }

Modified:  
trunk/reference/code-museum/src/com/google/gwt/museum/client/defaultmuseum/Issue1169.java
==============================================================================
---  
trunk/reference/code-museum/src/com/google/gwt/museum/client/defaultmuseum/Issue1169.java
        
(original)
+++  
trunk/reference/code-museum/src/com/google/gwt/museum/client/defaultmuseum/Issue1169.java
        
Tue Oct  7 09:17:27 2008
@@ -18,13 +18,12 @@
  import com.google.gwt.museum.client.common.AbstractIssue;
  import com.google.gwt.user.client.Command;
  import com.google.gwt.user.client.ui.MenuBar;
-import com.google.gwt.user.client.ui.PopupPanel;
  import com.google.gwt.user.client.ui.Widget;

  /**
- * The [EMAIL PROTECTED] PopupPanel} used to display sub menus in a [EMAIL 
PROTECTED] MenuBar}  
is not
- * accessible, nor is it under the [EMAIL PROTECTED] MenuBar MenuBar's} DOM  
structure, so
- * it cannot be uniquely styled.
+ * The [EMAIL PROTECTED] com.google.gwt.user.client.ui.PopupPanel} used to 
display sub
+ * menus in a [EMAIL PROTECTED] MenuBar} is not accessible, nor is it under the
+ * [EMAIL PROTECTED] MenuBar MenuBar's} DOM structure, so it cannot be 
uniquely  
styled.
   */
  public class Issue1169 extends AbstractIssue {
    /**

Added:  
trunk/reference/code-museum/src/com/google/gwt/museum/client/defaultmuseum/Issue2855.java
==============================================================================
--- (empty file)
+++  
trunk/reference/code-museum/src/com/google/gwt/museum/client/defaultmuseum/Issue2855.java
        
Tue Oct  7 09:17:27 2008
@@ -0,0 +1,114 @@
+/*
+ * Copyright 2008 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may  
not
+ * use this file except in compliance with the License. You may obtain a  
copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,  
WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations  
under
+ * the License.
+ */
+package com.google.gwt.museum.client.defaultmuseum;
+
+import com.google.gwt.museum.client.common.AbstractIssue;
+import com.google.gwt.user.client.Window;
+import com.google.gwt.user.client.ui.Button;
+import com.google.gwt.user.client.ui.ClickListener;
+import com.google.gwt.user.client.ui.PopupPanel;
+import com.google.gwt.user.client.ui.VerticalPanel;
+import com.google.gwt.user.client.ui.Widget;
+
+/**
+ * <h1>PopupPanel.setAutoHideEnabled() and setModel()</h1>
+ *
+ * <p>
+ * Verify that all states of the [EMAIL PROTECTED] PopupPanel} (combinations 
of modal  
and
+ * autoHide) work and can be change seemlessly.
+ * </p>
+ */
+public class Issue2855 extends AbstractIssue {
+
+  @Override
+  public Widget createIssue() {
+    // Create the popup panel
+    final PopupPanel popup = new PopupPanel();
+
+    // Add buttons to call getters and setters
+    Button toggleAutoHide = new Button("4. Toggle AutoHide",
+        new ClickListener() {
+          public void onClick(Widget sender) {
+            popup.setAutoHideEnabled(!popup.isAutoHideEnabled());
+          }
+        });
+    Button toggleModal = new Button("3. Toggle Modal", new ClickListener()  
{
+      public void onClick(Widget sender) {
+        popup.setModal(!popup.isModal());
+      }
+    });
+    Button isAutoHide = new Button("isAutoHide?", new ClickListener() {
+      public void onClick(Widget sender) {
+        Window.alert("AutoHide: " + popup.isAutoHideEnabled());
+      }
+    });
+    Button isModal = new Button("isModal?", new ClickListener() {
+      public void onClick(Widget sender) {
+        Window.alert("Modal: " + popup.isModal());
+      }
+    });
+    Button closeButton = new Button("Close", new ClickListener() {
+      public void onClick(Widget sender) {
+        popup.hide();
+      }
+    });
+    VerticalPanel vPanel = new VerticalPanel();
+    vPanel.add(toggleModal);
+    vPanel.add(toggleAutoHide);
+    vPanel.add(isModal);
+    vPanel.add(isAutoHide);
+    vPanel.add(closeButton);
+    popup.setWidget(vPanel);
+
+    // Add control buttons
+    Button showPopup = new Button("1. Show Popup", new ClickListener() {
+      public void onClick(Widget sender) {
+        popup.center();
+      }
+    });
+    Button clickable = new Button("2/4. Click Me", new ClickListener() {
+      public void onClick(Widget sender) {
+        Window.alert("You got me!");
+      }
+    });
+    VerticalPanel layout = new VerticalPanel();
+    layout.add(showPopup);
+    layout.add(clickable);
+    return layout;
+  }
+
+  @Override
+  public String getInstructions() {
+    String text = "Perform the following steps:<br>"
+        + "1. Show the popup<br>"
+        + "2. Click the 'Click Me' button and verify an alert box  
appears<br>"
+        + "3. Click the 'Toggle Modal' button<br>"
+        + "4. Click the 'Click Me' button and verify an alert box doesn't  
appear<br>"
+        + "5. Click the 'Toggle AutoHide' button<br>"
+        + "6. Click on the screen and verify that the popup closes";
+    return text;
+  }
+
+  @Override
+  public String getSummary() {
+    return "PopupPanel.setAutoHideEnabled() and setModel() tests";
+  }
+
+  @Override
+  public boolean hasCSS() {
+    return false;
+  }
+}

Modified: trunk/user/src/com/google/gwt/user/client/ui/PopupPanel.java
==============================================================================
--- trunk/user/src/com/google/gwt/user/client/ui/PopupPanel.java        
(original)
+++ trunk/user/src/com/google/gwt/user/client/ui/PopupPanel.java        Tue Oct 
 7  
09:17:27 2008
@@ -435,6 +435,26 @@
      return isAnimationEnabled;
    }

+  /**
+   * Returns <code>true</code> if the popup should be automatically hidden  
when
+   * the user clicks outside of it.
+   *
+   * @return true if autoHide is enabled, false if disabled
+   */
+  public boolean isAutoHideEnabled() {
+    return autoHide;
+  }
+
+  /**
+   * Returns <code>true</code> if keyboard or mouse events that do not  
target
+   * the PopupPanel or its children should be ignored.
+   *
+   * @return true if popup is modal, false if not
+   */
+  public boolean isModal() {
+    return modal;
+  }
+
    public boolean onEventPreview(Event event) {
      Element target = DOM.eventGetTarget(event);

@@ -542,6 +562,16 @@
    }

    /**
+   * Enable or disable the autoHide feature. When enabled, the popup will  
be
+   * automatically hidden when the user clicks outside of it.
+   *
+   * @param autoHide true to enable autoHide, false to disable
+   */
+  public void setAutoHideEnabled(boolean autoHide) {
+    this.autoHide = autoHide;
+  }
+
+  /**
     * Sets the height of the panel's child widget. If the panel's child  
widget
     * has not been set, the height passed in will be cached and used to set  
the
     * height immediately after the child widget is set.
@@ -563,6 +593,16 @@
      if (height.length() == 0) {
        desiredHeight = null;
      }
+  }
+
+  /**
+   * When the popup is modal, keyboard or mouse events that do not target  
the
+   * PopupPanel or its children will be ignored.
+   *
+   * @param modal true to make the popup modal
+   */
+  public void setModal(boolean modal) {
+    this.modal = modal;
    }

    /**

Modified: trunk/user/test/com/google/gwt/user/client/ui/PopupTest.java
==============================================================================
--- trunk/user/test/com/google/gwt/user/client/ui/PopupTest.java        
(original)
+++ trunk/user/test/com/google/gwt/user/client/ui/PopupTest.java        Tue Oct 
 7  
09:17:27 2008
@@ -50,6 +50,18 @@
      assertFalse(popup.isAnimationEnabled());
      popup.setAnimationEnabled(true);
      assertTrue(popup.isAnimationEnabled());
+
+    // Modal
+    popup.setModal(true);
+    assertTrue(popup.isModal());
+    popup.setModal(false);
+    assertFalse(popup.isModal());
+
+    // AutoHide enabled
+    popup.setAutoHideEnabled(true);
+    assertTrue(popup.isAutoHideEnabled());
+    popup.setAutoHideEnabled(false);
+    assertFalse(popup.isAutoHideEnabled());
    }

    /**

--~--~---------~--~----~------------~-------~--~----~
http://groups.google.com/group/Google-Web-Toolkit-Contributors
-~----------~----~----~----~------~----~------~--~---

Reply via email to