Author: [EMAIL PROTECTED]
Date: Wed Nov 12 15:23:17 2008
New Revision: 4040
Added:
branches/1_6_clean_events/user/src/com/google/gwt/event/dom/client/PrivateMap.java
- copied, changed from r4025,
/branches/1_6_clean_events/user/src/com/google/gwt/core/client/impl/PrivateMap.java
Removed:
branches/1_6_clean_events/user/src/com/google/gwt/core/client/impl/PrivateMap.java
Modified:
branches/1_6_clean_events/user/src/com/google/gwt/event/dom/client/DomEvent.java
branches/1_6_clean_events/user/src/com/google/gwt/user/client/ui/RootPanel.java
Log:
Reverts use of PrivateMap in RootPanel. Moves PrivateMap to
com.google.gwt.event.dom.client (where its only remaining client lives),
and makes it package private. Also reverts use of WidgetCollection in
RootPanel. It's all about narrowing the scope, baby.
Modified:
branches/1_6_clean_events/user/src/com/google/gwt/event/dom/client/DomEvent.java
==============================================================================
---
branches/1_6_clean_events/user/src/com/google/gwt/event/dom/client/DomEvent.java
(original)
+++
branches/1_6_clean_events/user/src/com/google/gwt/event/dom/client/DomEvent.java
Wed Nov 12 15:23:17 2008
@@ -15,7 +15,6 @@
*/
package com.google.gwt.event.dom.client;
-import com.google.gwt.core.client.impl.PrivateMap;
import com.google.gwt.event.shared.EventHandler;
import com.google.gwt.event.shared.GwtEvent;
import com.google.gwt.event.shared.HandlerManager;
Copied:
branches/1_6_clean_events/user/src/com/google/gwt/event/dom/client/PrivateMap.java
(from r4025,
/branches/1_6_clean_events/user/src/com/google/gwt/core/client/impl/PrivateMap.java)
==============================================================================
---
/branches/1_6_clean_events/user/src/com/google/gwt/core/client/impl/PrivateMap.java
(original)
+++
branches/1_6_clean_events/user/src/com/google/gwt/event/dom/client/PrivateMap.java
Wed Nov 12 15:23:17 2008
@@ -13,8 +13,7 @@
* License for the specific language governing permissions and limitations
under
* the License.
*/
-
-package com.google.gwt.core.client.impl;
+package com.google.gwt.event.dom.client;
import com.google.gwt.core.client.GWT;
import com.google.gwt.core.client.JavaScriptObject;
@@ -22,11 +21,11 @@
import java.util.HashMap;
/**
- * Private map implementation used by gwt team.
+ * Lightweight map implementation. Package protected due to non-final API.
*
* @param <V> value type
*/
-public class PrivateMap<V> {
+class PrivateMap<V> {
/**
* Js version of our map.
Modified:
branches/1_6_clean_events/user/src/com/google/gwt/user/client/ui/RootPanel.java
==============================================================================
---
branches/1_6_clean_events/user/src/com/google/gwt/user/client/ui/RootPanel.java
(original)
+++
branches/1_6_clean_events/user/src/com/google/gwt/user/client/ui/RootPanel.java
Wed Nov 12 15:23:17 2008
@@ -15,7 +15,6 @@
*/
package com.google.gwt.user.client.ui;
-import com.google.gwt.core.client.impl.PrivateMap;
import com.google.gwt.dom.client.Document;
import com.google.gwt.event.logical.shared.CloseEvent;
import com.google.gwt.event.logical.shared.CloseHandler;
@@ -26,6 +25,11 @@
import com.google.gwt.user.client.Element;
import com.google.gwt.user.client.Window;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
/**
* The panel to which all other widgets must ultimately be added.
RootPanels are
* never created directly. Rather, they are accessed via [EMAIL PROTECTED]
RootPanel#get()}.
@@ -57,22 +61,21 @@
}
}
- private static PrivateMap<RootPanel> rootPanels = new
PrivateMap<RootPanel>();
- private static boolean hooked;
- private static WidgetCollection widgetsToDetach = new
WidgetCollection(null);
+ private static Map<String, RootPanel> rootPanels = new HashMap<String,
RootPanel>();
+ private static Set<Widget> widgetsToDetach = new HashSet<Widget>();
/**
* Marks a widget as detached and removes it from the detach list.
*
* If an element belonging to a widget originally passed to
- * [EMAIL PROTECTED] #detachOnWindowClose(Widget)} has been removed from the
document,
- * calling this method will cause it to be marked as detached
immediately.
- * Failure to do so will keep the widget from being garbage collected
until
- * the page is unloaded.
+ * [EMAIL PROTECTED] #detachOnWindowClose(Widget)} has been removed from the
document, calling
+ * this method will cause it to be marked as detached immediately.
Failure to
+ * do so will keep the widget from being garbage collected until the
page is
+ * unloaded.
*
* This method may only be called per widget, and only for widgets that
were
- * originally passed to [EMAIL PROTECTED] #detachOnWindowClose(Widget)}. Any
widget
in
- * the detach list, whose element is no longer in the document when the
page
+ * originally passed to [EMAIL PROTECTED] #detachOnWindowClose(Widget)}. Any
widget
in the
+ * detach list, whose element is no longer in the document when the page
* unloads, will cause an assertion error.
*
* @param widget the widget that no longer needs to be cleaned up when
the
@@ -86,7 +89,7 @@
+ "not currently in the detach list";
widget.onDetach();
- widgetsToDetach.add(widget);
+ widgetsToDetach.remove(widget);
}
/**
@@ -132,7 +135,7 @@
*/
public static RootPanel get(String id) {
// See if this RootPanel is already created.
- RootPanel rp = rootPanels.safeGet(id);
+ RootPanel rp = rootPanels.get(id);
if (rp != null) {
return rp;
}
@@ -148,8 +151,7 @@
// Note that the code in this if block only happens once -
// on the first RootPanel.get(String) or RootPanel.get()
// call.
- if (hooked == false) {
- hooked = true;
+ if (rootPanels.size() == 0) {
hookWindowClosing();
// If we're in a RTL locale, set the RTL directionality
@@ -169,7 +171,7 @@
rp = new RootPanel(elem);
}
- rootPanels.safePut(id, rp);
+ rootPanels.put(id, rp);
detachOnWindowClose(rp);
return rp;
}
--~--~---------~--~----~------------~-------~--~----~
http://groups.google.com/group/Google-Web-Toolkit-Contributors
-~----------~----~----~----~------~----~------~--~---