]> source.dussan.org Git - vaadin-framework.git/commitdiff
fixing multiple stacking order issues (#1118, #1113, #1162, #1107)
authorMatti Tahvonen <matti.tahvonen@itmill.com>
Fri, 16 Nov 2007 08:10:22 +0000 (08:10 +0000)
committerMatti Tahvonen <matti.tahvonen@itmill.com>
Fri, 16 Nov 2007 08:10:22 +0000 (08:10 +0000)
svn changeset:2831/svn branch:trunk

src/com/itmill/toolkit/terminal/gwt/client/ErrorMessage.java
src/com/itmill/toolkit/terminal/gwt/client/ui/ContextMenu.java
src/com/itmill/toolkit/terminal/gwt/client/ui/IButton.java
src/com/itmill/toolkit/terminal/gwt/client/ui/IFilterSelect.java
src/com/itmill/toolkit/terminal/gwt/client/ui/IPopupCalendar.java
src/com/itmill/toolkit/terminal/gwt/client/ui/IScrollTable.java
src/com/itmill/toolkit/terminal/gwt/client/ui/MenuBar.java
src/com/itmill/toolkit/terminal/gwt/client/ui/Notification.java
src/com/itmill/toolkit/terminal/gwt/public/default/table/table.css

index 57ba0b254a9100d796f0fc0de275fb840a60cc98..9df6900397cab71efa1f5bcdd75cf2aef9a72eb0 100644 (file)
@@ -6,61 +6,60 @@ import com.google.gwt.user.client.DOM;
 import com.google.gwt.user.client.Element;
 import com.google.gwt.user.client.ui.FlowPanel;
 import com.google.gwt.user.client.ui.HTML;
-import com.google.gwt.user.client.ui.PopupPanel;
+import com.itmill.toolkit.terminal.gwt.client.ui.ToolkitOverlay;
 
 public class ErrorMessage extends FlowPanel {
-       public static final String CLASSNAME = "i-error";
+    public static final String CLASSNAME = "i-error";
 
-       public ErrorMessage() {
-               super();
-               setStyleName(CLASSNAME);
-       }
+    public ErrorMessage() {
+        super();
+        setStyleName(CLASSNAME);
+    }
 
-       public void updateFromUIDL(UIDL uidl) {
-               clear();
-               for (Iterator it = uidl.getChildIterator(); it.hasNext();) {
-                       Object child = it.next();
-                       if (child instanceof String) {
-                               String errorMessage = (String) child;
-                               add(new HTML(errorMessage));
-                       } else if (child instanceof UIDL.XML) {
-                               UIDL.XML xml = (UIDL.XML) child;
-                               add(new HTML(xml.getXMLAsString()));
-                       } else {
-                               ErrorMessage childError = new ErrorMessage();
-                               add(childError);
-                               childError.updateFromUIDL((UIDL) child);
-                       }
-               }
-       }
-       
-       /**
-        * Shows this error message next to given element.
-        * 
-        * @param indicatorElement
-        */
-       public void showAt(Element indicatorElement) {
-               PopupPanel errorContainer = (PopupPanel) this.getParent();
-               if (errorContainer == null) {
-                       errorContainer = new PopupPanel();
-                       errorContainer.setWidget(this);
-               }
-               errorContainer.setPopupPosition(DOM
-                               .getAbsoluteLeft(indicatorElement)
-                               + 2
-                               * DOM.getElementPropertyInt(indicatorElement,
-                                               "offsetHeight"), DOM
-                               .getAbsoluteTop(indicatorElement)
-                               + 2
-                               * DOM.getElementPropertyInt(indicatorElement,
-                                               "offsetHeight"));
-               errorContainer.show();
-               
-       }
+    public void updateFromUIDL(UIDL uidl) {
+        clear();
+        for (Iterator it = uidl.getChildIterator(); it.hasNext();) {
+            Object child = it.next();
+            if (child instanceof String) {
+                String errorMessage = (String) child;
+                add(new HTML(errorMessage));
+            } else if (child instanceof UIDL.XML) {
+                UIDL.XML xml = (UIDL.XML) child;
+                add(new HTML(xml.getXMLAsString()));
+            } else {
+                ErrorMessage childError = new ErrorMessage();
+                add(childError);
+                childError.updateFromUIDL((UIDL) child);
+            }
+        }
+    }
 
-       public void hide() {
-               PopupPanel errorContainer = (PopupPanel) this.getParent();
-               if(errorContainer != null)
-                       errorContainer.hide();
-       }
+    /**
+     * Shows this error message next to given element.
+     * 
+     * @param indicatorElement
+     */
+    public void showAt(Element indicatorElement) {
+        ToolkitOverlay errorContainer = (ToolkitOverlay) getParent();
+        if (errorContainer == null) {
+            errorContainer = new ToolkitOverlay();
+            errorContainer.setWidget(this);
+        }
+        errorContainer.setPopupPosition(DOM.getAbsoluteLeft(indicatorElement)
+                + 2
+                * DOM.getElementPropertyInt(indicatorElement, "offsetHeight"),
+                DOM.getAbsoluteTop(indicatorElement)
+                        + 2
+                        * DOM.getElementPropertyInt(indicatorElement,
+                                "offsetHeight"));
+        errorContainer.show();
+
+    }
+
+    public void hide() {
+        ToolkitOverlay errorContainer = (ToolkitOverlay) getParent();
+        if (errorContainer != null) {
+            errorContainer.hide();
+        }
+    }
 }
index f488e9441b25c5273ca51f9c29daa8d0a8575659..000c6a095f6b84db0745018b237d4efa8dcbf30e 100644 (file)
@@ -5,93 +5,95 @@ import com.google.gwt.user.client.ui.MenuBar;
 import com.google.gwt.user.client.ui.MenuItem;
 import com.google.gwt.user.client.ui.PopupPanel;
 
-public class ContextMenu extends PopupPanel {
+public class ContextMenu extends ToolkitOverlay {
 
-       private ActionOwner actionOwner;
+    private ActionOwner actionOwner;
 
-       private CMenuBar menu = new CMenuBar();
+    private CMenuBar menu = new CMenuBar();
 
-       private int left;
+    private int left;
 
-       private int top;
+    private int top;
 
-       /**
-        * This method should be used only by Client object as only one per client
-        * should exists. Request an instance via client.getContextMenu();
-        
-        * @param cli
-        *            to be set as an owner of menu
-        */
-       public ContextMenu() {
-               super(true);
-               setWidget(menu);
-               setStyleName("i-contextmenu");
-       }
+    /**
+     * This method should be used only by Client object as only one per client
+     * should exists. Request an instance via client.getContextMenu();
+     * 
+     * @param cli
+     *                to be set as an owner of menu
+     */
+    public ContextMenu() {
+        super(true);
+        setWidget(menu);
+        setStyleName("i-contextmenu");
+    }
 
-       /**
-        * Sets the element from which to build menu
-        
-        * @param ao
-        */
-       public void setActionOwner(ActionOwner ao) {
-               this.actionOwner = ao;
-       }
+    /**
+     * Sets the element from which to build menu
+     * 
+     * @param ao
+     */
+    public void setActionOwner(ActionOwner ao) {
+        actionOwner = ao;
+    }
 
-       /**
-        * Shows context menu at given location.
-        
-        * @param left
-        * @param top
-        */
-       public void showAt(int left, int top) {
-               this.left = left;
-               this.top = top;
-               menu.clearItems();
-               Action[] actions = actionOwner.getActions();
-               for (int i = 0; i < actions.length; i++) {
-                       Action a = actions[i];
-                       menu.addItem(new MenuItem(a.getHTML(), true, a));
-               }
+    /**
+     * Shows context menu at given location.
+     * 
+     * @param left
+     * @param top
+     */
+    public void showAt(int left, int top) {
+        this.left = left;
+        this.top = top;
+        menu.clearItems();
+        Action[] actions = actionOwner.getActions();
+        for (int i = 0; i < actions.length; i++) {
+            Action a = actions[i];
+            menu.addItem(new MenuItem(a.getHTML(), true, a));
+        }
 
-               this.setPopupPositionAndShow(new PositionCallback() {
-                       public void setPosition(int offsetWidth, int offsetHeight) {
-                               // mac FF gets bad width due GWT popups overflow hacks,
-                               // re-determine width
-                               offsetWidth = menu.getOffsetWidth();
-                               int left = ContextMenu.this.left;
-                               int top = ContextMenu.this.top;
-                               if (offsetWidth + left > Window.getClientWidth()) {
-                                       left = left - offsetWidth;
-                                       if (left < 0)
-                                               left = 0;
-                               }
-                               if (offsetHeight + top > Window.getClientHeight()) {
-                                       top = top - offsetHeight;
-                                       if (top < 0)
-                                               top = 0;
-                               }
-                               setPopupPosition(left, top);
-                       }
-               });
-       }
+        setPopupPositionAndShow(new PositionCallback() {
+            public void setPosition(int offsetWidth, int offsetHeight) {
+                // mac FF gets bad width due GWT popups overflow hacks,
+                // re-determine width
+                offsetWidth = menu.getOffsetWidth();
+                int left = ContextMenu.this.left;
+                int top = ContextMenu.this.top;
+                if (offsetWidth + left > Window.getClientWidth()) {
+                    left = left - offsetWidth;
+                    if (left < 0) {
+                        left = 0;
+                    }
+                }
+                if (offsetHeight + top > Window.getClientHeight()) {
+                    top = top - offsetHeight;
+                    if (top < 0) {
+                        top = 0;
+                    }
+                }
+                setPopupPosition(left, top);
+            }
+        });
+    }
 
-       public void showAt(ActionOwner ao, int left, int top) {
-               setActionOwner(ao);
-               showAt(left, top);
-       }
+    public void showAt(ActionOwner ao, int left, int top) {
+        setActionOwner(ao);
+        showAt(left, top);
+    }
 
-       /**
-        * Extend standard Gwt MenuBar to set proper settings and to override
-        * onPopupClosed method so that PopupPanel gets closed.
-        */
-       class CMenuBar extends MenuBar {
-               public CMenuBar() {
-                       super(true);
-               }
+    /**
+     * Extend standard Gwt MenuBar to set proper settings and to override
+     * onPopupClosed method so that PopupPanel gets closed.
+     */
+    class CMenuBar extends MenuBar {
+        public CMenuBar() {
+            super(true);
+        }
 
-               public void onPopupClosed(PopupPanel sender, boolean autoClosed) {
-                       super.onPopupClosed(sender, autoClosed);
-                       ContextMenu.this.hide();
-               }
-       }
+        public void onPopupClosed(PopupPanel sender, boolean autoClosed) {
+            super.onPopupClosed(sender, autoClosed);
+            ContextMenu.this.hide();
+        }
+    }
 }
index 2a32e558c487c1ece4daf0082f0bb7aa2085c8c1..2aeb31a03d8914df5eebb0c6967eb288ab26b21e 100644 (file)
@@ -3,10 +3,9 @@ package com.itmill.toolkit.terminal.gwt.client.ui;
 import com.google.gwt.user.client.DOM;
 import com.google.gwt.user.client.Element;
 import com.google.gwt.user.client.Event;
+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.Widget;
-import com.google.gwt.user.client.ui.Button;
 import com.itmill.toolkit.terminal.gwt.client.ApplicationConnection;
 import com.itmill.toolkit.terminal.gwt.client.ErrorMessage;
 import com.itmill.toolkit.terminal.gwt.client.Paintable;
@@ -14,116 +13,119 @@ import com.itmill.toolkit.terminal.gwt.client.UIDL;
 
 public class IButton extends Button implements Paintable {
 
-       public static final String CLASSNAME = "i-button";
-
-       String id;
-
-       ApplicationConnection client;
-
-       private Element errorIndicatorElement;
-
-       private ErrorMessage errorMessage;
-
-       private PopupPanel errorContainer;
-
-       public IButton() {
-               setStyleName(CLASSNAME);
-               addClickListener(new ClickListener() {
-                       public void onClick(Widget sender) {
-                               if (id == null || client == null)
-                                       return;
-                               /*
-                                * TODO isolata workaround. Safari don't always seem to fire
-                                * onblur previously focused component before button is clicked.
-                                */
-                               IButton.this.setFocus(true);
-                               client.updateVariable(id, "state", true, true);
-                       }
-               });
-       }
-
-       public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
-
-               // Ensure correct implementation,
-               // but don't let container manage caption etc.
-               if (client.updateComponent(this, uidl, false))
-                       return;
-
-               // Save details
-               this.client = client;
-               id = uidl.getId();
-
-               // Set text
-               setText(uidl.getStringAttribute("caption"));
-
-               if (uidl.hasAttribute("error")) {
-                       UIDL errorUidl = uidl.getErrors();
-                       if (errorIndicatorElement == null) {
-                               errorIndicatorElement = DOM.createDiv();
-                               DOM.setElementProperty(errorIndicatorElement, "className",
-                                               "i-errorindicator");
-                               DOM.sinkEvents(errorIndicatorElement, Event.MOUSEEVENTS);
-                       }
-                       DOM.insertChild(getElement(), errorIndicatorElement, 0);
-                       if (errorMessage == null)
-                               errorMessage = new ErrorMessage();
-                       errorMessage.updateFromUIDL(errorUidl);
-
-               } else if (errorIndicatorElement != null) {
-                       DOM.setStyleAttribute(errorIndicatorElement, "display", "none");
-               }
-
-               if (uidl.hasAttribute("description")) {
-                       setTitle(uidl.getStringAttribute("description"));
-               }
-
-       }
-
-       public void onBrowserEvent(Event event) {
-               Element target = DOM.eventGetTarget(event);
-               if (errorIndicatorElement != null
-                               && DOM.compare(target, errorIndicatorElement)) {
-                       switch (DOM.eventGetType(event)) {
-                       case Event.ONMOUSEOVER:
-                               showErrorMessage();
-                               break;
-                       case Event.ONMOUSEOUT:
-                               hideErrorMessage();
-                               break;
-                       case Event.ONCLICK:
-                               ApplicationConnection.getConsole().log(
-                                               DOM.getInnerHTML(errorMessage.getElement()));
-                               return;
-                       default:
-                               break;
-                       }
-               }
-               super.onBrowserEvent(event);
-       }
-
-       private void hideErrorMessage() {
-               if (errorContainer != null) {
-                       errorContainer.hide();
-               }
-       }
-
-       private void showErrorMessage() {
-               if (errorMessage != null) {
-                       if (errorContainer == null) {
-                               errorContainer = new PopupPanel();
-                               errorContainer.setWidget(errorMessage);
-                       }
-                       errorContainer.setPopupPosition(DOM
-                                       .getAbsoluteLeft(errorIndicatorElement)
-                                       + 2
-                                       * DOM.getElementPropertyInt(errorIndicatorElement,
-                                                       "offsetHeight"), DOM
-                                       .getAbsoluteTop(errorIndicatorElement)
-                                       + 2
-                                       * DOM.getElementPropertyInt(errorIndicatorElement,
-                                                       "offsetHeight"));
-                       errorContainer.show();
-               }
-       }
+    public static final String CLASSNAME = "i-button";
+
+    String id;
+
+    ApplicationConnection client;
+
+    private Element errorIndicatorElement;
+
+    private ErrorMessage errorMessage;
+
+    private ToolkitOverlay errorContainer;
+
+    public IButton() {
+        setStyleName(CLASSNAME);
+        addClickListener(new ClickListener() {
+            public void onClick(Widget sender) {
+                if (id == null || client == null) {
+                    return;
+                }
+                /*
+                 * TODO isolata workaround. Safari don't always seem to fire
+                 * onblur previously focused component before button is clicked.
+                 */
+                IButton.this.setFocus(true);
+                client.updateVariable(id, "state", true, true);
+            }
+        });
+    }
+
+    public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
+
+        // Ensure correct implementation,
+        // but don't let container manage caption etc.
+        if (client.updateComponent(this, uidl, false)) {
+            return;
+        }
+
+        // Save details
+        this.client = client;
+        id = uidl.getId();
+
+        // Set text
+        setText(uidl.getStringAttribute("caption"));
+
+        if (uidl.hasAttribute("error")) {
+            UIDL errorUidl = uidl.getErrors();
+            if (errorIndicatorElement == null) {
+                errorIndicatorElement = DOM.createDiv();
+                DOM.setElementProperty(errorIndicatorElement, "className",
+                        "i-errorindicator");
+                DOM.sinkEvents(errorIndicatorElement, Event.MOUSEEVENTS);
+            }
+            DOM.insertChild(getElement(), errorIndicatorElement, 0);
+            if (errorMessage == null) {
+                errorMessage = new ErrorMessage();
+            }
+            errorMessage.updateFromUIDL(errorUidl);
+
+        } else if (errorIndicatorElement != null) {
+            DOM.setStyleAttribute(errorIndicatorElement, "display", "none");
+        }
+
+        if (uidl.hasAttribute("description")) {
+            setTitle(uidl.getStringAttribute("description"));
+        }
+
+    }
+
+    public void onBrowserEvent(Event event) {
+        Element target = DOM.eventGetTarget(event);
+        if (errorIndicatorElement != null
+                && DOM.compare(target, errorIndicatorElement)) {
+            switch (DOM.eventGetType(event)) {
+            case Event.ONMOUSEOVER:
+                showErrorMessage();
+                break;
+            case Event.ONMOUSEOUT:
+                hideErrorMessage();
+                break;
+            case Event.ONCLICK:
+                ApplicationConnection.getConsole().log(
+                        DOM.getInnerHTML(errorMessage.getElement()));
+                return;
+            default:
+                break;
+            }
+        }
+        super.onBrowserEvent(event);
+    }
+
+    private void hideErrorMessage() {
+        if (errorContainer != null) {
+            errorContainer.hide();
+        }
+    }
+
+    private void showErrorMessage() {
+        if (errorMessage != null) {
+            if (errorContainer == null) {
+                errorContainer = new ToolkitOverlay();
+                errorContainer.setWidget(errorMessage);
+            }
+            errorContainer.setPopupPosition(DOM
+                    .getAbsoluteLeft(errorIndicatorElement)
+                    + 2
+                    * DOM.getElementPropertyInt(errorIndicatorElement,
+                            "offsetHeight"), DOM
+                    .getAbsoluteTop(errorIndicatorElement)
+                    + 2
+                    * DOM.getElementPropertyInt(errorIndicatorElement,
+                            "offsetHeight"));
+            errorContainer.show();
+        }
+    }
 
 }
index 5444614242eaf31f01e8e1b8e84767969246f8ea..2f4fa64e7232a03f8bcac577fa3604371a412aa0 100644 (file)
@@ -81,7 +81,7 @@ public class IFilterSelect extends Composite implements Paintable,
      * @author mattitahvonen
      * 
      */
-    public class SuggestionPopup extends PopupPanel implements
+    public class SuggestionPopup extends ToolkitOverlay implements
             PositionCallback, PopupListener {
         private static final int EXTRASPACE = 8;
 
@@ -654,25 +654,25 @@ public class IFilterSelect extends Composite implements Paintable,
      * Calculate minumum width for FilterSelect textarea
      */
     private native int minWidth(String captions) /*-{
-                       if(!captions || captions.length <= 0)
-                               return 0;
-                       captions = captions.split("|");
-                       var d = $wnd.document.createElement("div");
-                       var html = "";
-                       for(var i=0; i < captions.length; i++) {
-                               html += "<div>" + captions[i] + "</div>";
-                               // TODO apply same CSS classname as in suggestionmenu
-                       }
-                       d.style.position = "absolute";
-                       d.style.top = "0";
-                       d.style.left = "0";
-                       d.style.visibility = "hidden";
-                       d.innerHTML = html;
-                       $wnd.document.body.appendChild(d);
-                       var w = d.offsetWidth;
-                       $wnd.document.body.removeChild(d);
-                       return w;
-                   }-*/;
+                       if(!captions || captions.length <= 0)
+                               return 0;
+                       captions = captions.split("|");
+                       var d = $wnd.document.createElement("div");
+                       var html = "";
+                       for(var i=0; i < captions.length; i++) {
+                               html += "<div>" + captions[i] + "</div>";
+                               // TODO apply same CSS classname as in suggestionmenu
+                       }
+                       d.style.position = "absolute";
+                       d.style.top = "0";
+                       d.style.left = "0";
+                       d.style.visibility = "hidden";
+                       d.innerHTML = html;
+                       $wnd.document.body.appendChild(d);
+                       var w = d.offsetWidth;
+                       $wnd.document.body.removeChild(d);
+                       return w;
+                      }-*/;
 
     public void onFocus(Widget sender) {
         // NOP
index 9e9a27e2b4fc8df72123c2c0e747ead72e9d8cac..0242234c0df749274b02b27415242bf969bdd443 100644 (file)
@@ -10,61 +10,65 @@ import com.itmill.toolkit.terminal.gwt.client.Paintable;
 import com.itmill.toolkit.terminal.gwt.client.UIDL;\r
 \r
 public class IPopupCalendar extends ITextualDate implements Paintable,\r
-               ClickListener, PopupListener {\r
+        ClickListener, PopupListener {\r
 \r
-       private IButton calendarToggle;\r
+    private IButton calendarToggle;\r
 \r
-       private CalendarPanel calendar;\r
+    private CalendarPanel calendar;\r
 \r
-       private PopupPanel popup;\r
+    private ToolkitOverlay popup;\r
 \r
-       public IPopupCalendar() {\r
-               super();\r
+    public IPopupCalendar() {\r
+        super();\r
 \r
-               calendarToggle = new IButton();\r
-               calendarToggle.setText("...");\r
-               calendarToggle.addClickListener(this);\r
-               add(calendarToggle);\r
+        calendarToggle = new IButton();\r
+        calendarToggle.setText("...");\r
+        calendarToggle.addClickListener(this);\r
+        add(calendarToggle);\r
 \r
-               calendar = new CalendarPanel(this);\r
-               popup = new PopupPanel(true);\r
-               popup.setStyleName(IDateField.CLASSNAME + "-popup");\r
-               popup.setWidget(calendar);\r
-               popup.addPopupListener(this);\r
-       }\r
+        calendar = new CalendarPanel(this);\r
+        popup = new ToolkitOverlay(true);\r
+        popup.setStyleName(IDateField.CLASSNAME + "-popup");\r
+        popup.setWidget(calendar);\r
+        popup.addPopupListener(this);\r
+    }\r
 \r
-       public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {\r
-               super.updateFromUIDL(uidl, client);\r
-               if (date != null)\r
-                       calendar.updateCalendar();\r
-               calendarToggle.setEnabled(enabled);\r
-       }\r
+    public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {\r
+        super.updateFromUIDL(uidl, client);\r
+        if (date != null) {\r
+            calendar.updateCalendar();\r
+        }\r
+        calendarToggle.setEnabled(enabled);\r
+    }\r
 \r
-       public void onClick(Widget sender) {\r
-               if (sender == calendarToggle) {\r
-                       calendar.updateCalendar();\r
-                       popup.show();\r
-                       // clear previous values\r
-                       popup.setWidth("");\r
-                       popup.setHeight("");\r
-                       int w = calendar.getOffsetWidth();\r
-                       int h = calendar.getOffsetHeight();\r
-                       int t = calendarToggle.getAbsoluteTop();\r
-                       int l = calendarToggle.getAbsoluteLeft();\r
-                       if (l + w > Window.getClientWidth())\r
-                               l = Window.getClientWidth() - w;\r
-                       if (t + h > Window.getClientHeight())\r
-                               t = Window.getClientHeight() - h\r
-                                               - calendarToggle.getOffsetHeight() - 2;\r
-                       popup.setPopupPosition(l, t + calendarToggle.getOffsetHeight() + 2);\r
-                       popup.setWidth(w + "px");\r
-                       popup.setHeight(h + "px");\r
-               }\r
-       }\r
+    public void onClick(Widget sender) {\r
+        if (sender == calendarToggle) {\r
+            calendar.updateCalendar();\r
+            popup.show();\r
+            // clear previous values\r
+            popup.setWidth("");\r
+            popup.setHeight("");\r
+            int w = calendar.getOffsetWidth();\r
+            int h = calendar.getOffsetHeight();\r
+            int t = calendarToggle.getAbsoluteTop();\r
+            int l = calendarToggle.getAbsoluteLeft();\r
+            if (l + w > Window.getClientWidth()) {\r
+                l = Window.getClientWidth() - w;\r
+            }\r
+            if (t + h > Window.getClientHeight()) {\r
+                t = Window.getClientHeight() - h\r
+                        - calendarToggle.getOffsetHeight() - 2;\r
+            }\r
+            popup.setPopupPosition(l, t + calendarToggle.getOffsetHeight() + 2);\r
+            popup.setWidth(w + "px");\r
+            popup.setHeight(h + "px");\r
+        }\r
+    }\r
 \r
-       public void onPopupClosed(PopupPanel sender, boolean autoClosed) {\r
-               if (sender == popup)\r
-                       buildDate();\r
-       }\r
+    public void onPopupClosed(PopupPanel sender, boolean autoClosed) {\r
+        if (sender == popup) {\r
+            buildDate();\r
+        }\r
+    }\r
 \r
 }\r
index 5ff0e3e5c160b4efd047321155eee7cf42aab44d..a189e817261eeb0c4a29907e1fa6603462f6cb54 100644 (file)
@@ -921,8 +921,6 @@ public class IScrollTable extends Composite implements Table, ScrollListener,
             DOM.setInnerHTML(floatingCopyOfHeaderCell, DOM.getInnerHTML(td));
             floatingCopyOfHeaderCell = DOM
                     .getChild(floatingCopyOfHeaderCell, 1);
-            // TODO isolate non-standard css attribute (filter)
-            // TODO move styles to css file
             DOM.setElementProperty(floatingCopyOfHeaderCell, "className",
                     CLASSNAME + "-header-drag");
             updateFloatingCopysPosition(DOM.getAbsoluteLeft(td), DOM
index 47dddb68faeaaee54ded324e6e2314f312e1d66e..4d524b1237e9f5e2a14f780977caa9e6c57d6188 100644 (file)
@@ -17,6 +17,9 @@ package com.itmill.toolkit.terminal.gwt.client.ui;
  */
 
 //COPIED HERE DUE package privates in GWT
+import java.util.ArrayList;
+import java.util.List;
+
 import com.google.gwt.user.client.Command;
 import com.google.gwt.user.client.DOM;
 import com.google.gwt.user.client.DeferredCommand;
@@ -26,9 +29,6 @@ import com.google.gwt.user.client.ui.PopupListener;
 import com.google.gwt.user.client.ui.PopupPanel;
 import com.google.gwt.user.client.ui.Widget;
 
-import java.util.ArrayList;
-import java.util.List;
-
 /**
  * A standard menu bar widget. A menu bar can contain any number of menu items,
  * each of which can either fire a {@link com.google.gwt.user.client.Command} or
@@ -52,455 +52,455 @@ import java.util.List;
  */
 public class MenuBar extends Widget implements PopupListener {
 
-       private Element body;
-       private ArrayList items = new ArrayList();
-       private MenuBar parentMenu;
-       private PopupPanel popup;
-       private MenuItem selectedItem;
-       private MenuBar shownChildMenu;
-       private boolean vertical, autoOpen;
-
-       /**
-        * Creates an empty horizontal menu bar.
-        */
-       public MenuBar() {
-               this(false);
-       }
-
-       /**
-        * Creates an empty menu bar.
-        
-        * @param vertical
-        *            <code>true</code> to orient the menu bar vertically
-        */
-       public MenuBar(boolean vertical) {
-               super();
-
-               Element table = DOM.createTable();
-               body = DOM.createTBody();
-               DOM.appendChild(table, body);
-
-               if (!vertical) {
-                       Element tr = DOM.createTR();
-                       DOM.appendChild(body, tr);
-               }
-
-               this.vertical = vertical;
-
-               Element outer = DOM.createDiv();
-               DOM.appendChild(outer, table);
-               setElement(outer);
-
-               sinkEvents(Event.ONCLICK | Event.ONMOUSEOVER | Event.ONMOUSEOUT);
-               setStyleName("gwt-MenuBar");
-       }
-
-       /**
-        * Adds a menu item to the bar.
-        
-        * @param item
-        *            the item to be added
-        */
-       public void addItem(MenuItem item) {
-               Element tr;
-               if (vertical) {
-                       tr = DOM.createTR();
-                       DOM.appendChild(body, tr);
-               } else {
-                       tr = DOM.getChild(body, 0);
-               }
-
-               DOM.appendChild(tr, item.getElement());
-
-               item.setParentMenu(this);
-               item.setSelectionStyle(false);
-               items.add(item);
-       }
-
-       /**
-        * Adds a menu item to the bar, that will fire the given command when it is
-        * selected.
-        
-        * @param text
-        *            the item's text
-        * @param asHTML
-        *            <code>true</code> to treat the specified text as html
-        * @param cmd
-        *            the command to be fired
-        * @return the {@link MenuItem} object created
-        */
-       public MenuItem addItem(String text, boolean asHTML, Command cmd) {
-               MenuItem item = new MenuItem(text, asHTML, cmd);
-               addItem(item);
-               return item;
-       }
-
-       /**
-        * Adds a menu item to the bar, that will open the specified menu when it is
-        * selected.
-        
-        * @param text
-        *            the item's text
-        * @param asHTML
-        *            <code>true</code> to treat the specified text as html
-        * @param popup
-        *            the menu to be cascaded from it
-        * @return the {@link MenuItem} object created
-        */
-       public MenuItem addItem(String text, boolean asHTML, MenuBar popup) {
-               MenuItem item = new MenuItem(text, asHTML, popup);
-               addItem(item);
-               return item;
-       }
-
-       /**
-        * Adds a menu item to the bar, that will fire the given command when it is
-        * selected.
-        
-        * @param text
-        *            the item's text
-        * @param cmd
-        *            the command to be fired
-        * @return the {@link MenuItem} object created
-        */
-       public MenuItem addItem(String text, Command cmd) {
-               MenuItem item = new MenuItem(text, cmd);
-               addItem(item);
-               return item;
-       }
-
-       /**
-        * Adds a menu item to the bar, that will open the specified menu when it is
-        * selected.
-        
-        * @param text
-        *            the item's text
-        * @param popup
-        *            the menu to be cascaded from it
-        * @return the {@link MenuItem} object created
-        */
-       public MenuItem addItem(String text, MenuBar popup) {
-               MenuItem item = new MenuItem(text, popup);
-               addItem(item);
-               return item;
-       }
-
-       /**
-        * Removes all menu items from this menu bar.
-        */
-       public void clearItems() {
-               Element container = getItemContainerElement();
-               while (DOM.getChildCount(container) > 0) {
-                       DOM.removeChild(container, DOM.getChild(container, 0));
-               }
-               items.clear();
-       }
-
-       /**
-        * Gets whether this menu bar's child menus will open when the mouse is
-        * moved over it.
-        
-        * @return <code>true</code> if child menus will auto-open
-        */
-       public boolean getAutoOpen() {
-               return autoOpen;
-       }
-
-       public void onBrowserEvent(Event event) {
-               super.onBrowserEvent(event);
-
-               MenuItem item = findItem(DOM.eventGetTarget(event));
-               switch (DOM.eventGetType(event)) {
-               case Event.ONCLICK: {
-                       // Fire an item's command when the user clicks on it.
-                       if (item != null) {
-                               doItemAction(item, true);
-                       }
-                       break;
-               }
-
-               case Event.ONMOUSEOVER: {
-                       if (item != null) {
-                               itemOver(item);
-                       }
-                       break;
-               }
-
-               case Event.ONMOUSEOUT: {
-                       if (item != null) {
-                               itemOver(null);
-                       }
-                       break;
-               }
-               }
-       }
-
-       public void onPopupClosed(PopupPanel sender, boolean autoClosed) {
-               // If the menu popup was auto-closed, close all of its parents as well.
-               if (autoClosed) {
-                       closeAllParents();
-               }
-
-               // When the menu popup closes, remember that no item is
-               // currently showing a popup menu.
-               onHide();
-               shownChildMenu = null;
-               popup = null;
-       }
-
-       /**
-        * Removes the specified menu item from the bar.
-        
-        * @param item
-        *            the item to be removed
-        */
-       public void removeItem(MenuItem item) {
-               int idx = items.indexOf(item);
-               if (idx == -1) {
-                       return;
-               }
-
-               Element container = getItemContainerElement();
-               DOM.removeChild(container, DOM.getChild(container, idx));
-               items.remove(idx);
-       }
-
-       /**
-        * Sets whether this menu bar's child menus will open when the mouse is
-        * moved over it.
-        
-        * @param autoOpen
-        *            <code>true</code> to cause child menus to auto-open
-        */
-       public void setAutoOpen(boolean autoOpen) {
-               this.autoOpen = autoOpen;
-       }
-
-       /**
-        * Returns a list containing the <code>MenuItem</code> objects in the menu
-        * bar. If there are no items in the menu bar, then an empty
-        * <code>List</code> object will be returned.
-        
-        * @return a list containing the <code>MenuItem</code> objects in the menu
-        *         bar
-        */
-       protected List getItems() {
-               return this.items;
-       }
-
-       /**
-        * Returns the <code>MenuItem</code> that is currently selected
-        * (highlighted) by the user. If none of the items in the menu are currently
-        * selected, then <code>null</code> will be returned.
-        
-        * @return the <code>MenuItem</code> that is currently selected, or
-        *         <code>null</code> if no items are currently selected
-        */
-       protected MenuItem getSelectedItem() {
-               return this.selectedItem;
-       }
-
-       protected void onDetach() {
-               // When the menu is detached, make sure to close all of its children.
-               if (popup != null) {
-                       popup.hide();
-               }
-
-               super.onDetach();
-       }
-
-       /*
-        * Closes all parent menu popups.
-        */
-       void closeAllParents() {
-               MenuBar curMenu = this;
-               while (curMenu != null) {
-                       curMenu.close();
-
-                       if ((curMenu.parentMenu == null) && (curMenu.selectedItem != null)) {
-                               curMenu.selectedItem.setSelectionStyle(false);
-                               curMenu.selectedItem = null;
-                       }
-
-                       curMenu = curMenu.parentMenu;
-               }
-       }
-
-       /*
-        * Performs the action associated with the given menu item. If the item has
-        * a popup associated with it, the popup will be shown. If it has a command
-        * associated with it, and 'fireCommand' is true, then the command will be
-        * fired. Popups associated with other items will be hidden.
-        
-        * @param item the item whose popup is to be shown. @param fireCommand
-        * <code>true</code> if the item's command should be fired, <code>false</code>
-        * otherwise.
-        */
-       void doItemAction(final MenuItem item, boolean fireCommand) {
-               // If the given item is already showing its menu, we're done.
-               if ((shownChildMenu != null) && (item.getSubMenu() == shownChildMenu)) {
-                       return;
-               }
-
-               // If another item is showing its menu, then hide it.
-               if (shownChildMenu != null) {
-                       shownChildMenu.onHide();
-                       popup.hide();
-               }
-
-               // If the item has no popup, optionally fire its command.
-               if (item.getSubMenu() == null) {
-                       if (fireCommand) {
-                               // Close this menu and all of its parents.
-                               closeAllParents();
-
-                               // Fire the item's command.
-                               Command cmd = item.getCommand();
-                               if (cmd != null) {
-                                       DeferredCommand.addCommand(cmd);
-                               }
-                       }
-                       return;
-               }
-
-               // Ensure that the item is selected.
-               selectItem(item);
-
-               // Create a new popup for this item, and position it next to
-               // the item (below if this is a horizontal menu bar, to the
-               // right if it's a vertical bar).
-               popup = new PopupPanel(true) {
-                       {
-                               setWidget(item.getSubMenu());
-                               item.getSubMenu().onShow();
-                       }
-
-                       public boolean onEventPreview(Event event) {
-                               // Hook the popup panel's event preview. We use this to keep it
-                               // from
-                               // auto-hiding when the parent menu is clicked.
-                               switch (DOM.eventGetType(event)) {
-                               case Event.ONCLICK:
-                                       // If the event target is part of the parent menu, suppress
-                                       // the
-                                       // event altogether.
-                                       Element target = DOM.eventGetTarget(event);
-                                       Element parentMenuElement = item.getParentMenu()
-                                                       .getElement();
-                                       if (DOM.isOrHasChild(parentMenuElement, target)) {
-                                               return false;
-                                       }
-                                       break;
-                               }
-
-                               return super.onEventPreview(event);
-                       }
-               };
-               popup.addPopupListener(this);
-
-               if (vertical) {
-                       popup.setPopupPosition(item.getAbsoluteLeft()
-                                       + item.getOffsetWidth(), item.getAbsoluteTop());
-               } else {
-                       popup.setPopupPosition(item.getAbsoluteLeft(), item
-                                       .getAbsoluteTop()
-                                       + item.getOffsetHeight());
-               }
-
-               shownChildMenu = item.getSubMenu();
-               item.getSubMenu().parentMenu = this;
-
-               // Show the popup, ensuring that the menubar's event preview remains on
-               // top
-               // of the popup's.
-               popup.show();
-       }
-
-       void itemOver(MenuItem item) {
-               if (item == null) {
-                       // Don't clear selection if the currently selected item's menu is
-                       // showing.
-                       if ((selectedItem != null)
-                                       && (shownChildMenu == selectedItem.getSubMenu())) {
-                               return;
-                       }
-               }
-
-               // Style the item selected when the mouse enters.
-               selectItem(item);
-
-               // If child menus are being shown, or this menu is itself
-               // a child menu, automatically show an item's child menu
-               // when the mouse enters.
-               if (item != null) {
-                       if ((shownChildMenu != null) || (parentMenu != null) || autoOpen) {
-                               doItemAction(item, false);
-                       }
-               }
-       }
-
-       void selectItem(MenuItem item) {
-               if (item == selectedItem) {
-                       return;
-               }
-
-               if (selectedItem != null) {
-                       selectedItem.setSelectionStyle(false);
-               }
-
-               if (item != null) {
-                       item.setSelectionStyle(true);
-               }
-
-               selectedItem = item;
-       }
-
-       /**
-        * Closes this menu (if it is a popup).
-        */
-       private void close() {
-               if (parentMenu != null) {
-                       parentMenu.popup.hide();
-               }
-       }
-
-       private MenuItem findItem(Element hItem) {
-               for (int i = 0; i < items.size(); ++i) {
-                       MenuItem item = (MenuItem) items.get(i);
-                       if (DOM.isOrHasChild(item.getElement(), hItem)) {
-                               return item;
-                       }
-               }
-
-               return null;
-       }
-
-       private Element getItemContainerElement() {
-               if (vertical) {
-                       return body;
-               } else {
-                       return DOM.getChild(body, 0);
-               }
-       }
-
-       /*
-        * This method is called when a menu bar is hidden, so that it can hide any
-        * child popups that are currently being shown.
-        */
-       private void onHide() {
-               if (shownChildMenu != null) {
-                       shownChildMenu.onHide();
-                       popup.hide();
-               }
-       }
-
-       /*
-        * This method is called when a menu bar is shown.
-        */
-       private void onShow() {
-               // Select the first item when a menu is shown.
-               if (items.size() > 0) {
-                       selectItem((MenuItem) items.get(0));
-               }
-       }
+    private Element body;
+    private ArrayList items = new ArrayList();
+    private MenuBar parentMenu;
+    private PopupPanel popup;
+    private MenuItem selectedItem;
+    private MenuBar shownChildMenu;
+    private boolean vertical, autoOpen;
+
+    /**
+     * Creates an empty horizontal menu bar.
+     */
+    public MenuBar() {
+        this(false);
+    }
+
+    /**
+     * Creates an empty menu bar.
+     * 
+     * @param vertical
+     *                <code>true</code> to orient the menu bar vertically
+     */
+    public MenuBar(boolean vertical) {
+        super();
+
+        Element table = DOM.createTable();
+        body = DOM.createTBody();
+        DOM.appendChild(table, body);
+
+        if (!vertical) {
+            Element tr = DOM.createTR();
+            DOM.appendChild(body, tr);
+        }
+
+        this.vertical = vertical;
+
+        Element outer = DOM.createDiv();
+        DOM.appendChild(outer, table);
+        setElement(outer);
+
+        sinkEvents(Event.ONCLICK | Event.ONMOUSEOVER | Event.ONMOUSEOUT);
+        setStyleName("gwt-MenuBar");
+    }
+
+    /**
+     * Adds a menu item to the bar.
+     * 
+     * @param item
+     *                the item to be added
+     */
+    public void addItem(MenuItem item) {
+        Element tr;
+        if (vertical) {
+            tr = DOM.createTR();
+            DOM.appendChild(body, tr);
+        } else {
+            tr = DOM.getChild(body, 0);
+        }
+
+        DOM.appendChild(tr, item.getElement());
+
+        item.setParentMenu(this);
+        item.setSelectionStyle(false);
+        items.add(item);
+    }
+
+    /**
+     * Adds a menu item to the bar, that will fire the given command when it is
+     * selected.
+     * 
+     * @param text
+     *                the item's text
+     * @param asHTML
+     *                <code>true</code> to treat the specified text as html
+     * @param cmd
+     *                the command to be fired
+     * @return the {@link MenuItem} object created
+     */
+    public MenuItem addItem(String text, boolean asHTML, Command cmd) {
+        MenuItem item = new MenuItem(text, asHTML, cmd);
+        addItem(item);
+        return item;
+    }
+
+    /**
+     * Adds a menu item to the bar, that will open the specified menu when it is
+     * selected.
+     * 
+     * @param text
+     *                the item's text
+     * @param asHTML
+     *                <code>true</code> to treat the specified text as html
+     * @param popup
+     *                the menu to be cascaded from it
+     * @return the {@link MenuItem} object created
+     */
+    public MenuItem addItem(String text, boolean asHTML, MenuBar popup) {
+        MenuItem item = new MenuItem(text, asHTML, popup);
+        addItem(item);
+        return item;
+    }
+
+    /**
+     * Adds a menu item to the bar, that will fire the given command when it is
+     * selected.
+     * 
+     * @param text
+     *                the item's text
+     * @param cmd
+     *                the command to be fired
+     * @return the {@link MenuItem} object created
+     */
+    public MenuItem addItem(String text, Command cmd) {
+        MenuItem item = new MenuItem(text, cmd);
+        addItem(item);
+        return item;
+    }
+
+    /**
+     * Adds a menu item to the bar, that will open the specified menu when it is
+     * selected.
+     * 
+     * @param text
+     *                the item's text
+     * @param popup
+     *                the menu to be cascaded from it
+     * @return the {@link MenuItem} object created
+     */
+    public MenuItem addItem(String text, MenuBar popup) {
+        MenuItem item = new MenuItem(text, popup);
+        addItem(item);
+        return item;
+    }
+
+    /**
+     * Removes all menu items from this menu bar.
+     */
+    public void clearItems() {
+        Element container = getItemContainerElement();
+        while (DOM.getChildCount(container) > 0) {
+            DOM.removeChild(container, DOM.getChild(container, 0));
+        }
+        items.clear();
+    }
+
+    /**
+     * Gets whether this menu bar's child menus will open when the mouse is
+     * moved over it.
+     * 
+     * @return <code>true</code> if child menus will auto-open
+     */
+    public boolean getAutoOpen() {
+        return autoOpen;
+    }
+
+    public void onBrowserEvent(Event event) {
+        super.onBrowserEvent(event);
+
+        MenuItem item = findItem(DOM.eventGetTarget(event));
+        switch (DOM.eventGetType(event)) {
+        case Event.ONCLICK: {
+            // Fire an item's command when the user clicks on it.
+            if (item != null) {
+                doItemAction(item, true);
+            }
+            break;
+        }
+
+        case Event.ONMOUSEOVER: {
+            if (item != null) {
+                itemOver(item);
+            }
+            break;
+        }
+
+        case Event.ONMOUSEOUT: {
+            if (item != null) {
+                itemOver(null);
+            }
+            break;
+        }
+        }
+    }
+
+    public void onPopupClosed(PopupPanel sender, boolean autoClosed) {
+        // If the menu popup was auto-closed, close all of its parents as well.
+        if (autoClosed) {
+            closeAllParents();
+        }
+
+        // When the menu popup closes, remember that no item is
+        // currently showing a popup menu.
+        onHide();
+        shownChildMenu = null;
+        popup = null;
+    }
+
+    /**
+     * Removes the specified menu item from the bar.
+     * 
+     * @param item
+     *                the item to be removed
+     */
+    public void removeItem(MenuItem item) {
+        int idx = items.indexOf(item);
+        if (idx == -1) {
+            return;
+        }
+
+        Element container = getItemContainerElement();
+        DOM.removeChild(container, DOM.getChild(container, idx));
+        items.remove(idx);
+    }
+
+    /**
+     * Sets whether this menu bar's child menus will open when the mouse is
+     * moved over it.
+     * 
+     * @param autoOpen
+     *                <code>true</code> to cause child menus to auto-open
+     */
+    public void setAutoOpen(boolean autoOpen) {
+        this.autoOpen = autoOpen;
+    }
+
+    /**
+     * Returns a list containing the <code>MenuItem</code> objects in the menu
+     * bar. If there are no items in the menu bar, then an empty
+     * <code>List</code> object will be returned.
+     * 
+     * @return a list containing the <code>MenuItem</code> objects in the menu
+     *         bar
+     */
+    protected List getItems() {
+        return items;
+    }
+
+    /**
+     * Returns the <code>MenuItem</code> that is currently selected
+     * (highlighted) by the user. If none of the items in the menu are currently
+     * selected, then <code>null</code> will be returned.
+     * 
+     * @return the <code>MenuItem</code> that is currently selected, or
+     *         <code>null</code> if no items are currently selected
+     */
+    protected MenuItem getSelectedItem() {
+        return selectedItem;
+    }
+
+    protected void onDetach() {
+        // When the menu is detached, make sure to close all of its children.
+        if (popup != null) {
+            popup.hide();
+        }
+
+        super.onDetach();
+    }
+
+    /*
+     * Closes all parent menu popups.
+     */
+    void closeAllParents() {
+        MenuBar curMenu = this;
+        while (curMenu != null) {
+            curMenu.close();
+
+            if ((curMenu.parentMenu == null) && (curMenu.selectedItem != null)) {
+                curMenu.selectedItem.setSelectionStyle(false);
+                curMenu.selectedItem = null;
+            }
+
+            curMenu = curMenu.parentMenu;
+        }
+    }
+
+    /*
+     * Performs the action associated with the given menu item. If the item has
+     * a popup associated with it, the popup will be shown. If it has a command
+     * associated with it, and 'fireCommand' is true, then the command will be
+     * fired. Popups associated with other items will be hidden.
+     * 
+     * @param item the item whose popup is to be shown. @param fireCommand
+     * <code>true</code> if the item's command should be fired, <code>false</code>
+     * otherwise.
+     */
+    void doItemAction(final MenuItem item, boolean fireCommand) {
+        // If the given item is already showing its menu, we're done.
+        if ((shownChildMenu != null) && (item.getSubMenu() == shownChildMenu)) {
+            return;
+        }
+
+        // If another item is showing its menu, then hide it.
+        if (shownChildMenu != null) {
+            shownChildMenu.onHide();
+            popup.hide();
+        }
+
+        // If the item has no popup, optionally fire its command.
+        if (item.getSubMenu() == null) {
+            if (fireCommand) {
+                // Close this menu and all of its parents.
+                closeAllParents();
+
+                // Fire the item's command.
+                Command cmd = item.getCommand();
+                if (cmd != null) {
+                    DeferredCommand.addCommand(cmd);
+                }
+            }
+            return;
+        }
+
+        // Ensure that the item is selected.
+        selectItem(item);
+
+        // Create a new popup for this item, and position it next to
+        // the item (below if this is a horizontal menu bar, to the
+        // right if it's a vertical bar).
+        popup = new ToolkitOverlay(true) {
+            {
+                setWidget(item.getSubMenu());
+                item.getSubMenu().onShow();
+            }
+
+            public boolean onEventPreview(Event event) {
+                // Hook the popup panel's event preview. We use this to keep it
+                // from
+                // auto-hiding when the parent menu is clicked.
+                switch (DOM.eventGetType(event)) {
+                case Event.ONCLICK:
+                    // If the event target is part of the parent menu, suppress
+                    // the
+                    // event altogether.
+                    Element target = DOM.eventGetTarget(event);
+                    Element parentMenuElement = item.getParentMenu()
+                            .getElement();
+                    if (DOM.isOrHasChild(parentMenuElement, target)) {
+                        return false;
+                    }
+                    break;
+                }
+
+                return super.onEventPreview(event);
+            }
+        };
+        popup.addPopupListener(this);
+
+        if (vertical) {
+            popup.setPopupPosition(item.getAbsoluteLeft()
+                    + item.getOffsetWidth(), item.getAbsoluteTop());
+        } else {
+            popup.setPopupPosition(item.getAbsoluteLeft(), item
+                    .getAbsoluteTop()
+                    + item.getOffsetHeight());
+        }
+
+        shownChildMenu = item.getSubMenu();
+        item.getSubMenu().parentMenu = this;
+
+        // Show the popup, ensuring that the menubar's event preview remains on
+        // top
+        // of the popup's.
+        popup.show();
+    }
+
+    void itemOver(MenuItem item) {
+        if (item == null) {
+            // Don't clear selection if the currently selected item's menu is
+            // showing.
+            if ((selectedItem != null)
+                    && (shownChildMenu == selectedItem.getSubMenu())) {
+                return;
+            }
+        }
+
+        // Style the item selected when the mouse enters.
+        selectItem(item);
+
+        // If child menus are being shown, or this menu is itself
+        // a child menu, automatically show an item's child menu
+        // when the mouse enters.
+        if (item != null) {
+            if ((shownChildMenu != null) || (parentMenu != null) || autoOpen) {
+                doItemAction(item, false);
+            }
+        }
+    }
+
+    void selectItem(MenuItem item) {
+        if (item == selectedItem) {
+            return;
+        }
+
+        if (selectedItem != null) {
+            selectedItem.setSelectionStyle(false);
+        }
+
+        if (item != null) {
+            item.setSelectionStyle(true);
+        }
+
+        selectedItem = item;
+    }
+
+    /**
+     * Closes this menu (if it is a popup).
+     */
+    private void close() {
+        if (parentMenu != null) {
+            parentMenu.popup.hide();
+        }
+    }
+
+    private MenuItem findItem(Element hItem) {
+        for (int i = 0; i < items.size(); ++i) {
+            MenuItem item = (MenuItem) items.get(i);
+            if (DOM.isOrHasChild(item.getElement(), hItem)) {
+                return item;
+            }
+        }
+
+        return null;
+    }
+
+    private Element getItemContainerElement() {
+        if (vertical) {
+            return body;
+        } else {
+            return DOM.getChild(body, 0);
+        }
+    }
+
+    /*
+     * This method is called when a menu bar is hidden, so that it can hide any
+     * child popups that are currently being shown.
+     */
+    private void onHide() {
+        if (shownChildMenu != null) {
+            shownChildMenu.onHide();
+            popup.hide();
+        }
+    }
+
+    /*
+     * This method is called when a menu bar is shown.
+     */
+    private void onShow() {
+        // Select the first item when a menu is shown.
+        if (items.size() > 0) {
+            selectItem((MenuItem) items.get(0));
+        }
+    }
 }
index cd4740007e2e8a051d9fdcec2ee61ebac6198a4d..130ac370ee3749dd6f652159b8696226f0b8e3f8 100644 (file)
@@ -6,224 +6,223 @@ import com.google.gwt.user.client.Event;
 import com.google.gwt.user.client.EventPreview;\r
 import com.google.gwt.user.client.Timer;\r
 import com.google.gwt.user.client.ui.HTML;\r
-import com.google.gwt.user.client.ui.PopupPanel;\r
 import com.google.gwt.user.client.ui.Widget;\r
 \r
-public class Notification extends PopupPanel {\r
-\r
-       public static final int CENTERED = 1;\r
-       public static final int CENTERED_TOP = 2;\r
-       public static final int CENTERED_BOTTOM = 3;\r
-       public static final int TOP_LEFT = 4;\r
-       public static final int TOP_RIGHT = 5;\r
-       public static final int BOTTOM_LEFT = 6;\r
-       public static final int BOTTOM_RIGHT = 7;\r
-\r
-       public static final int DELAY_FOREVER = -1;\r
-       public static final int DELAY_NONE = 0;\r
-\r
-       private static final String STYLENAME = "i-Notification";\r
-       private static final int mouseMoveThreshold = 7;\r
-       private static final int Z_INDEX_BASE = 20000;\r
-\r
-       private int startOpacity = 90;\r
-       private int fadeMsec = 400;\r
-       private int delayMsec = 1000;\r
-\r
-       private Timer fader;\r
-       private Timer delay;\r
-       private EventPreview eventPreview;\r
-\r
-       private String temporaryStyle;\r
-\r
-       public Notification() {\r
-               setStylePrimaryName(STYLENAME);\r
-               sinkEvents(Event.ONCLICK);\r
-               DOM.setStyleAttribute(getElement(), "zIndex", "" + Z_INDEX_BASE);\r
-       }\r
-\r
-       public Notification(int delayMsec) {\r
-               this();\r
-               this.delayMsec = delayMsec;\r
-       }\r
-\r
-       public Notification(int delayMsec, int fadeMsec, int startOpacity) {\r
-               this(delayMsec);\r
-               this.fadeMsec = fadeMsec;\r
-               this.startOpacity = startOpacity;\r
-       }\r
-\r
-       public void startDelay() {\r
-               DOM.removeEventPreview(eventPreview);\r
-               if (delayMsec > 0) {\r
-                       delay = new Timer() {\r
-                               public void run() {\r
-                                       fade();\r
-                               }\r
-                       };\r
-                       delay.scheduleRepeating(delayMsec);\r
-               } else if (delayMsec == 0) {\r
-                       fade();\r
-               }\r
-       }\r
-\r
-       public void show() {\r
-               show(CENTERED);\r
-       }\r
-\r
-       public void show(String style) {\r
-               show(CENTERED, style);\r
-       }\r
-\r
-       public void show(int position) {\r
-               show(position, null);\r
-       }\r
-\r
-       public void show(Widget widget, int position, String style) {\r
-               setWidget(widget);\r
-               show(position, style);\r
-       }\r
-\r
-       public void show(String html, int position, String style) {\r
-               setWidget(new HTML(html));\r
-               show(position, style);\r
-       }\r
-\r
-       public void show(int position, String style) {\r
-               hide();\r
-               setOpacity(getElement(), startOpacity);\r
-               if (style != null) {\r
-                       this.temporaryStyle = style;\r
-                       addStyleName(style);\r
-               }\r
-               super.show();\r
-               setPosition(position);\r
-\r
-               if (eventPreview == null) {\r
-                       eventPreview = new EventPreview() {\r
-                               int x = -1;\r
-                               int y = -1;\r
-\r
-                               public boolean onEventPreview(Event event) {\r
-                                       switch (DOM.eventGetType(event)) {\r
-                                       case Event.ONMOUSEMOVE:\r
-                                               if (x < 0) {\r
-                                                       x = DOM.eventGetClientX(event);\r
-                                                       y = DOM.eventGetClientY(event);\r
-                                               } else if (Math.abs(DOM.eventGetClientX(event) - x) > mouseMoveThreshold\r
-                                                               || Math.abs(DOM.eventGetClientY(event) - y) > mouseMoveThreshold) {\r
-                                                       startDelay();\r
-                                               }\r
-                                               break;\r
-                                       case Event.KEYEVENTS:\r
-                                       case Event.ONCLICK:\r
-                                       case Event.ONDBLCLICK:\r
-                                       case Event.ONSCROLL:\r
-                                       default:\r
-                                               startDelay();\r
-                                       }\r
-                                       return true;\r
-                               }\r
-                       };\r
-               }\r
-\r
-               DOM.addEventPreview(eventPreview);\r
-       }\r
-\r
-       public void hide() {\r
-               DOM.removeEventPreview(eventPreview);\r
-               cancelDelay();\r
-               cancelFade();\r
-               if (this.temporaryStyle != null) {\r
-                       removeStyleName(this.temporaryStyle);\r
-                       this.temporaryStyle = null;\r
-               }\r
-               super.hide();\r
-       }\r
-\r
-       public void fade() {\r
-               cancelDelay();\r
-               fader = new Timer() {\r
-                       int opacity = startOpacity;\r
-\r
-                       public void run() {\r
-                               opacity -= 5;\r
-                               setOpacity(getElement(), opacity);\r
-                               if (opacity <= 0) {\r
-                                       cancel();\r
-                                       hide();\r
-                               }\r
-                       }\r
-               };\r
-               int msec = fadeMsec / (startOpacity / 5);\r
-               fader.scheduleRepeating(msec);\r
-       }\r
-\r
-       public void setPosition(int position) {\r
-               Element el = getElement();\r
-               DOM.setStyleAttribute(el, "top", null);\r
-               DOM.setStyleAttribute(el, "left", null);\r
-               DOM.setStyleAttribute(el, "bottom", null);\r
-               DOM.setStyleAttribute(el, "right", null);\r
-               switch (position) {\r
-               case TOP_LEFT:\r
-                       DOM.setStyleAttribute(el, "top", "0px");\r
-                       DOM.setStyleAttribute(el, "left", "0px");\r
-                       break;\r
-               case TOP_RIGHT:\r
-                       DOM.setStyleAttribute(el, "top", "0px");\r
-                       DOM.setStyleAttribute(el, "right", "0px");\r
-                       break;\r
-               case BOTTOM_RIGHT:\r
-                       DOM.setStyleAttribute(el, "position", "absolute");\r
-                       DOM.setStyleAttribute(el, "bottom", "0px");\r
-                       DOM.setStyleAttribute(el, "right", "0px");\r
-                       break;\r
-               case BOTTOM_LEFT:\r
-                       DOM.setStyleAttribute(el, "bottom", "0px");\r
-                       DOM.setStyleAttribute(el, "left", "0px");\r
-                       break;\r
-               case CENTERED_TOP:\r
-                       center();\r
-                       DOM.setStyleAttribute(el, "top", "0px");\r
-                       break;\r
-               case CENTERED_BOTTOM:\r
-                       center();\r
-                       DOM.setStyleAttribute(el, "top", null);\r
-                       DOM.setStyleAttribute(el, "bottom", "0px");\r
-                       break;\r
-               default:\r
-               case CENTERED:\r
-                       center();\r
-                       break;\r
-               }\r
-       }\r
-\r
-       private void cancelFade() {\r
-               if (fader != null) {\r
-                       fader.cancel();\r
-                       fader = null;\r
-               }\r
-       }\r
-\r
-       private void cancelDelay() {\r
-               if (delay != null) {\r
-                       delay.cancel();\r
-                       delay = null;\r
-               }\r
-       }\r
-\r
-       private void setOpacity(Element el, int opacity) {\r
-               DOM.setStyleAttribute(el, "opacity", "" + (opacity / 100.0));\r
-               DOM.setStyleAttribute(el, "filter", "Alpha(opacity=" + opacity + ")");\r
-\r
-       }\r
-\r
-       public void onBrowserEvent(Event event) {\r
-               DOM.removeEventPreview(eventPreview);\r
-               if (fader == null) {\r
-                       fade();\r
-               }\r
-       }\r
+public class Notification extends ToolkitOverlay {\r
+\r
+    public static final int CENTERED = 1;\r
+    public static final int CENTERED_TOP = 2;\r
+    public static final int CENTERED_BOTTOM = 3;\r
+    public static final int TOP_LEFT = 4;\r
+    public static final int TOP_RIGHT = 5;\r
+    public static final int BOTTOM_LEFT = 6;\r
+    public static final int BOTTOM_RIGHT = 7;\r
+\r
+    public static final int DELAY_FOREVER = -1;\r
+    public static final int DELAY_NONE = 0;\r
+\r
+    private static final String STYLENAME = "i-Notification";\r
+    private static final int mouseMoveThreshold = 7;\r
+    private static final int Z_INDEX_BASE = 20000;\r
+\r
+    private int startOpacity = 90;\r
+    private int fadeMsec = 400;\r
+    private int delayMsec = 1000;\r
+\r
+    private Timer fader;\r
+    private Timer delay;\r
+    private EventPreview eventPreview;\r
+\r
+    private String temporaryStyle;\r
+\r
+    public Notification() {\r
+        setStylePrimaryName(STYLENAME);\r
+        sinkEvents(Event.ONCLICK);\r
+        DOM.setStyleAttribute(getElement(), "zIndex", "" + Z_INDEX_BASE);\r
+    }\r
+\r
+    public Notification(int delayMsec) {\r
+        this();\r
+        this.delayMsec = delayMsec;\r
+    }\r
+\r
+    public Notification(int delayMsec, int fadeMsec, int startOpacity) {\r
+        this(delayMsec);\r
+        this.fadeMsec = fadeMsec;\r
+        this.startOpacity = startOpacity;\r
+    }\r
+\r
+    public void startDelay() {\r
+        DOM.removeEventPreview(eventPreview);\r
+        if (delayMsec > 0) {\r
+            delay = new Timer() {\r
+                public void run() {\r
+                    fade();\r
+                }\r
+            };\r
+            delay.scheduleRepeating(delayMsec);\r
+        } else if (delayMsec == 0) {\r
+            fade();\r
+        }\r
+    }\r
+\r
+    public void show() {\r
+        show(CENTERED);\r
+    }\r
+\r
+    public void show(String style) {\r
+        show(CENTERED, style);\r
+    }\r
+\r
+    public void show(int position) {\r
+        show(position, null);\r
+    }\r
+\r
+    public void show(Widget widget, int position, String style) {\r
+        setWidget(widget);\r
+        show(position, style);\r
+    }\r
+\r
+    public void show(String html, int position, String style) {\r
+        setWidget(new HTML(html));\r
+        show(position, style);\r
+    }\r
+\r
+    public void show(int position, String style) {\r
+        hide();\r
+        setOpacity(getElement(), startOpacity);\r
+        if (style != null) {\r
+            temporaryStyle = style;\r
+            addStyleName(style);\r
+        }\r
+        super.show();\r
+        setPosition(position);\r
+\r
+        if (eventPreview == null) {\r
+            eventPreview = new EventPreview() {\r
+                int x = -1;\r
+                int y = -1;\r
+\r
+                public boolean onEventPreview(Event event) {\r
+                    switch (DOM.eventGetType(event)) {\r
+                    case Event.ONMOUSEMOVE:\r
+                        if (x < 0) {\r
+                            x = DOM.eventGetClientX(event);\r
+                            y = DOM.eventGetClientY(event);\r
+                        } else if (Math.abs(DOM.eventGetClientX(event) - x) > mouseMoveThreshold\r
+                                || Math.abs(DOM.eventGetClientY(event) - y) > mouseMoveThreshold) {\r
+                            startDelay();\r
+                        }\r
+                        break;\r
+                    case Event.KEYEVENTS:\r
+                    case Event.ONCLICK:\r
+                    case Event.ONDBLCLICK:\r
+                    case Event.ONSCROLL:\r
+                    default:\r
+                        startDelay();\r
+                    }\r
+                    return true;\r
+                }\r
+            };\r
+        }\r
+\r
+        DOM.addEventPreview(eventPreview);\r
+    }\r
+\r
+    public void hide() {\r
+        DOM.removeEventPreview(eventPreview);\r
+        cancelDelay();\r
+        cancelFade();\r
+        if (temporaryStyle != null) {\r
+            removeStyleName(temporaryStyle);\r
+            temporaryStyle = null;\r
+        }\r
+        super.hide();\r
+    }\r
+\r
+    public void fade() {\r
+        cancelDelay();\r
+        fader = new Timer() {\r
+            int opacity = startOpacity;\r
+\r
+            public void run() {\r
+                opacity -= 5;\r
+                setOpacity(getElement(), opacity);\r
+                if (opacity <= 0) {\r
+                    cancel();\r
+                    hide();\r
+                }\r
+            }\r
+        };\r
+        int msec = fadeMsec / (startOpacity / 5);\r
+        fader.scheduleRepeating(msec);\r
+    }\r
+\r
+    public void setPosition(int position) {\r
+        Element el = getElement();\r
+        DOM.setStyleAttribute(el, "top", null);\r
+        DOM.setStyleAttribute(el, "left", null);\r
+        DOM.setStyleAttribute(el, "bottom", null);\r
+        DOM.setStyleAttribute(el, "right", null);\r
+        switch (position) {\r
+        case TOP_LEFT:\r
+            DOM.setStyleAttribute(el, "top", "0px");\r
+            DOM.setStyleAttribute(el, "left", "0px");\r
+            break;\r
+        case TOP_RIGHT:\r
+            DOM.setStyleAttribute(el, "top", "0px");\r
+            DOM.setStyleAttribute(el, "right", "0px");\r
+            break;\r
+        case BOTTOM_RIGHT:\r
+            DOM.setStyleAttribute(el, "position", "absolute");\r
+            DOM.setStyleAttribute(el, "bottom", "0px");\r
+            DOM.setStyleAttribute(el, "right", "0px");\r
+            break;\r
+        case BOTTOM_LEFT:\r
+            DOM.setStyleAttribute(el, "bottom", "0px");\r
+            DOM.setStyleAttribute(el, "left", "0px");\r
+            break;\r
+        case CENTERED_TOP:\r
+            center();\r
+            DOM.setStyleAttribute(el, "top", "0px");\r
+            break;\r
+        case CENTERED_BOTTOM:\r
+            center();\r
+            DOM.setStyleAttribute(el, "top", null);\r
+            DOM.setStyleAttribute(el, "bottom", "0px");\r
+            break;\r
+        default:\r
+        case CENTERED:\r
+            center();\r
+            break;\r
+        }\r
+    }\r
+\r
+    private void cancelFade() {\r
+        if (fader != null) {\r
+            fader.cancel();\r
+            fader = null;\r
+        }\r
+    }\r
+\r
+    private void cancelDelay() {\r
+        if (delay != null) {\r
+            delay.cancel();\r
+            delay = null;\r
+        }\r
+    }\r
+\r
+    private void setOpacity(Element el, int opacity) {\r
+        DOM.setStyleAttribute(el, "opacity", "" + (opacity / 100.0));\r
+        DOM.setStyleAttribute(el, "filter", "Alpha(opacity=" + opacity + ")");\r
+\r
+    }\r
+\r
+    public void onBrowserEvent(Event event) {\r
+        DOM.removeEventPreview(eventPreview);\r
+        if (fader == null) {\r
+            fade();\r
+        }\r
+    }\r
 \r
 }\r
index bd06ccb01093eea4a1c1c24a5e8e36a9104b9daa..6ff2bd4e1d3a2dc396c727ec069e321268d06b40 100644 (file)
        opacity: 0.5;
        filter: alpha(opacity=50);
        margin-top: 20px;
+       z-index: 20000;
 }
 
 .i-table-scrollposition {