/*
 * DesktopMenuCallback.java
 *
 * Copyright (C) 2009-12 by RStudio, Inc.
 *
 * Unless you have received this program directly from RStudio pursuant
 * to the terms of a commercial license agreement with RStudio, then
 * this program is licensed to you under the terms of version 3 of the
 * GNU Affero General Public License. This program is distributed WITHOUT
 * ANY EXPRESS OR IMPLIED WARRANTY, INCLUDING THOSE OF NON-INFRINGEMENT,
 * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Please refer to the
 * AGPL (http://www.gnu.org/licenses/agpl-3.0.txt) for more details.
 *
 */
package org.rstudio.core.client.command.impl;

import org.rstudio.core.client.command.AppCommand;
import org.rstudio.core.client.command.MenuCallback;

public class DesktopMenuCallback implements MenuCallback
{
   public native final void beginMainMenu() /*-{
      $wnd.desktopMenuCallback.beginMainMenu();
   }-*/;

   public native final void beginMenu(String label) /*-{
      label = @org.rstudio.core.client.command.AppMenuItem::replaceMnemonics(Ljava/lang/String;Ljava/lang/String;)(label, "&");
      $wnd.desktopMenuCallback.beginMenu(label);
   }-*/;

   public void addCommand(String commandId, AppCommand command)
   {
      addCommand(commandId,
                 command.getMenuLabel(true),
                 command.getTooltip(),
                 command.getShortcutRaw(),
                 command.isCheckable());
   }

   private native void addCommand(String cmdId,
                                  String label,
                                  String tooltip,
                                  String shortcut,
                                  boolean isCheckable) /*-{
      $wnd.desktopMenuCallback.addCommand(cmdId, label, tooltip, shortcut, isCheckable);
   }-*/;

   public native final void addSeparator() /*-{
      $wnd.desktopMenuCallback.addSeparator();
   }-*/;

   public native final void endMenu() /*-{
      $wnd.desktopMenuCallback.endMenu();
   }-*/;

   public native final void endMainMenu() /*-{
      $wnd.desktopMenuCallback.endMainMenu();
   }-*/;
}

@@ -630,16 +630,59 @@
 .impl;%0A%0A
+import org.rstudio.core.client.StringUtil;%0A
 import o
@@ -1294,32 +1294,51 @@
                 
+StringUtil.notNull(
 command.getMenuL
@@ -1347,16 +1347,17 @@
 el(true)
+)
 ,%0A      
@@ -1359,32 +1359,51 @@
                 
+StringUtil.notNull(
 command.getToolt
@@ -1406,16 +1406,17 @@
 ooltip()
+)
 ,%0A      
@@ -1418,32 +1418,51 @@
                 
+StringUtil.notNull(
 command.getShort
@@ -1469,16 +1469,17 @@
 cutRaw()
+)
 ,%0A      

enforce non-null strings