Reviewers: rdayal,

Description:
Rolling back, breaks other projects.

*** Original change description ***

MenuItem should use ScheduledCommand instead of Command

Repost of 1698803
Thanks Patrick!


Please review this at http://gwt-code-reviews.appspot.com/1733803/

Affected files:
  M tools/api-checker/config/gwt24_25userApi.conf
  M user/src/com/google/gwt/user/client/ui/MenuBar.java
  M user/src/com/google/gwt/user/client/ui/MenuItem.java
  M user/src/com/google/gwt/user/client/ui/SuggestBox.java


Index: tools/api-checker/config/gwt24_25userApi.conf
===================================================================
--- tools/api-checker/config/gwt24_25userApi.conf       (revision 11016)
+++ tools/api-checker/config/gwt24_25userApi.conf       (working copy)
@@ -195,10 +195,3 @@
 # Adding final modifier to static fields Boolean.TRUE/FALSE
 java.lang.Boolean::FALSE FINAL_ADDED
 java.lang.Boolean::TRUE FINAL_ADDED
-
-# MenuItem is no longer using Command
-com.google.gwt.user.client.ui.MenuBar::addItem(Lcom/google/gwt/safehtml/shared/SafeHtml;Lcom/google/gwt/user/client/Command;) OVERRIDABLE_METHOD_ARGUMENT_TYPE_CHANGE -com.google.gwt.user.client.ui.MenuBar::addItem(Ljava/lang/String;Lcom/google/gwt/user/client/Command;) OVERRIDABLE_METHOD_ARGUMENT_TYPE_CHANGE -com.google.gwt.user.client.ui.MenuBar::addItem(Ljava/lang/String;ZLcom/google/gwt/user/client/Command;) OVERRIDABLE_METHOD_ARGUMENT_TYPE_CHANGE -com.google.gwt.user.client.ui.MenuItem::getCommand() OVERRIDABLE_METHOD_RETURN_TYPE_CHANGE -com.google.gwt.user.client.ui.MenuItem::setCommand(Lcom/google/gwt/user/client/Command;) OVERRIDABLE_METHOD_ARGUMENT_TYPE_CHANGE
Index: user/src/com/google/gwt/user/client/ui/MenuBar.java
===================================================================
--- user/src/com/google/gwt/user/client/ui/MenuBar.java (revision 11016)
+++ user/src/com/google/gwt/user/client/ui/MenuBar.java (working copy)
@@ -19,7 +19,6 @@
 import com.google.gwt.aria.client.Roles;
 import com.google.gwt.core.client.GWT;
 import com.google.gwt.core.client.Scheduler;
-import com.google.gwt.core.client.Scheduler.ScheduledCommand;
 import com.google.gwt.dom.client.EventTarget;
 import com.google.gwt.event.dom.client.BlurEvent;
 import com.google.gwt.event.dom.client.BlurHandler;
@@ -33,6 +32,7 @@
 import com.google.gwt.resources.client.ImageResource;
 import com.google.gwt.resources.client.ImageResource.ImageOptions;
 import com.google.gwt.safehtml.shared.SafeHtml;
+import com.google.gwt.user.client.Command;
 import com.google.gwt.user.client.DOM;
 import com.google.gwt.user.client.Element;
 import com.google.gwt.user.client.Event;
@@ -44,7 +44,7 @@

 /**
* 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.core.client.Scheduler.ScheduledCommand} or + * each of which can either fire a {@link com.google.gwt.user.client.Command} or
  * open a cascaded menu bar.
  *
  * <p>
@@ -285,7 +285,7 @@
    * @param cmd the command to be fired
    * @return the {@link MenuItem} object created
    */
-  public MenuItem addItem(SafeHtml html, ScheduledCommand cmd) {
+  public MenuItem addItem(SafeHtml html, Command cmd) {
     return addItem(new MenuItem(html, cmd));
   }

@@ -298,7 +298,7 @@
    * @param cmd the command to be fired
    * @return the {@link MenuItem} object created
    */
- public MenuItem addItem(String text, boolean asHTML, ScheduledCommand cmd) {
+  public MenuItem addItem(String text, boolean asHTML, Command cmd) {
     return addItem(new MenuItem(text, asHTML, cmd));
   }

@@ -335,7 +335,7 @@
    * @param cmd the command to be fired
    * @return the {@link MenuItem} object created
    */
-  public MenuItem addItem(String text, ScheduledCommand cmd) {
+  public MenuItem addItem(String text, Command cmd) {
     return addItem(new MenuItem(text, cmd));
   }

@@ -893,7 +893,7 @@

// Fire the item's command. The command must be fired in the same event
       // loop or popup blockers will prevent popups from opening.
-      final ScheduledCommand cmd = item.getCommand();
+      final Command cmd = item.getCommand();
       Scheduler.get().scheduleFinally(new Scheduler.ScheduledCommand() {
         @Override
         public void execute() {
Index: user/src/com/google/gwt/user/client/ui/MenuItem.java
===================================================================
--- user/src/com/google/gwt/user/client/ui/MenuItem.java        (revision 11016)
+++ user/src/com/google/gwt/user/client/ui/MenuItem.java        (working copy)
@@ -16,15 +16,15 @@
 package com.google.gwt.user.client.ui;

 import com.google.gwt.aria.client.Roles;
-import com.google.gwt.core.client.Scheduler.ScheduledCommand;
 import com.google.gwt.safehtml.client.HasSafeHtml;
 import com.google.gwt.safehtml.shared.SafeHtml;
+import com.google.gwt.user.client.Command;
 import com.google.gwt.user.client.DOM;

 /**
  * An entry in a
* {@link com.google.gwt.user.client.ui.MenuBar}. Menu items can either fire a - * {@link com.google.gwt.core.client.Scheduler.ScheduledCommand} when they are clicked, or open a + * {@link com.google.gwt.user.client.Command} when they are clicked, or open a
  * cascading sub-menu.
  *
  * Each menu item is assigned a unique DOM id in order to support ARIA. See
@@ -35,7 +35,7 @@
private static final String DEPENDENT_STYLENAME_SELECTED_ITEM = "selected"; private static final String DEPENDENT_STYLENAME_DISABLED_ITEM = "disabled";

-  private ScheduledCommand command;
+  private Command command;
   private MenuBar parentMenu, subMenu;
   private boolean enabled = true;

@@ -54,7 +54,7 @@
    * @param html the item's text
    * @param cmd the command to be fired when it is selected
    */
-  public MenuItem(SafeHtml html, ScheduledCommand cmd) {
+  public MenuItem(SafeHtml html, Command cmd) {
     this(html.asString(), true, cmd);
   }

@@ -75,7 +75,7 @@
    * @param asHTML <code>true</code> to treat the specified text as html
    * @param cmd the command to be fired when it is selected
    */
-  public MenuItem(String text, boolean asHTML, ScheduledCommand cmd) {
+  public MenuItem(String text, boolean asHTML, Command cmd) {
     this(text, asHTML);
     setCommand(cmd);
   }
@@ -98,7 +98,7 @@
    * @param text the item's text
    * @param cmd the command to be fired when it is selected
    */
-  public MenuItem(String text, ScheduledCommand cmd) {
+  public MenuItem(String text, Command cmd) {
     this(text, false);
     setCommand(cmd);
   }
@@ -135,7 +135,7 @@
    *
    * @return this item's command, or <code>null</code> if none exists
    */
-  public ScheduledCommand getCommand() {
+  public Command getCommand() {
     return command;
   }

@@ -177,7 +177,7 @@
    *
    * @param cmd the command to be associated with this item
    */
-  public void setCommand(ScheduledCommand cmd) {
+  public void setCommand(Command cmd) {
     command = cmd;
   }

@@ -255,4 +255,4 @@
   void setParentMenu(MenuBar parentMenu) {
     this.parentMenu = parentMenu;
   }
-}
\ No newline at end of file
+}
Index: user/src/com/google/gwt/user/client/ui/SuggestBox.java
===================================================================
--- user/src/com/google/gwt/user/client/ui/SuggestBox.java      (revision 11016)
+++ user/src/com/google/gwt/user/client/ui/SuggestBox.java      (working copy)
@@ -15,7 +15,6 @@
  */
 package com.google.gwt.user.client.ui;

-import com.google.gwt.core.client.Scheduler.ScheduledCommand;
 import com.google.gwt.dom.client.Document;
 import com.google.gwt.dom.client.Element;
 import com.google.gwt.editor.client.IsEditor;
@@ -36,6 +35,7 @@
 import com.google.gwt.event.logical.shared.ValueChangeEvent;
 import com.google.gwt.event.logical.shared.ValueChangeHandler;
 import com.google.gwt.event.shared.HandlerRegistration;
+import com.google.gwt.user.client.Command;
 import com.google.gwt.user.client.DOM;
 import com.google.gwt.user.client.ui.PopupPanel.AnimationType;
 import com.google.gwt.user.client.ui.SuggestOracle.Callback;
@@ -496,7 +496,7 @@
       for (final Suggestion curSuggestion : suggestions) {
         final SuggestionMenuItem menuItem = new SuggestionMenuItem(
             curSuggestion, isDisplayStringHTML);
-        menuItem.setCommand(new ScheduledCommand() {
+        menuItem.setCommand(new Command() {
           public void execute() {
             callback.onSuggestionSelected(curSuggestion);
           }


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

Reply via email to