swtmenubar

16:53:26.812 INFO  jd.cli.Main - Decompiling swtmenubar.jar
package com.android.menubar;

public abstract interface IMenuBarCallback
{
  public abstract void onAboutMenuSelected();
  
  public abstract void onPreferencesMenuSelected();
  
  public abstract void printError(String paramString, Object... paramVarArgs);
}

/* Location:
 * Qualified Name:     com.android.menubar.IMenuBarCallback
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.android.menubar;

public enum IMenuBarEnhancer$MenuBarMode
{
  MAC_OS,  GENERIC;
  
  private IMenuBarEnhancer$MenuBarMode() {}
}

/* Location:
 * Qualified Name:     com.android.menubar.IMenuBarEnhancer.MenuBarMode
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.android.menubar;

import org.eclipse.swt.widgets.Display;

public abstract interface IMenuBarEnhancer
{
  public abstract MenuBarMode getMenuBarMode();
  
  public abstract void setupMenu(String paramString, Display paramDisplay, IMenuBarCallback paramIMenuBarCallback);
  
  public static enum MenuBarMode
  {
    MAC_OS,  GENERIC;
    
    private MenuBarMode() {}
  }
}

/* Location:
 * Qualified Name:     com.android.menubar.IMenuBarEnhancer
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.android.menubar;

import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.widgets.MenuItem;

class MenuBarEnhancer$1$1
  extends SelectionAdapter
{
  MenuBarEnhancer$1$1(MenuBarEnhancer.1 param1, MenuItem paramMenuItem, IMenuBarCallback paramIMenuBarCallback) {}
  
  public void widgetSelected(SelectionEvent e)
  {
    try
    {
      val$pref.setEnabled(false);
      val$callbacks.onPreferencesMenuSelected();
      super.widgetSelected(e);
    }
    finally
    {
      val$pref.setEnabled(true);
    }
  }
}

/* Location:
 * Qualified Name:     com.android.menubar.MenuBarEnhancer.1.1
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.android.menubar;

import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.widgets.MenuItem;

class MenuBarEnhancer$1$2
  extends SelectionAdapter
{
  MenuBarEnhancer$1$2(MenuBarEnhancer.1 param1, MenuItem paramMenuItem, IMenuBarCallback paramIMenuBarCallback) {}
  
  public void widgetSelected(SelectionEvent e)
  {
    try
    {
      val$about.setEnabled(false);
      val$callbacks.onAboutMenuSelected();
      super.widgetSelected(e);
    }
    finally
    {
      val$about.setEnabled(true);
    }
  }
}

/* Location:
 * Qualified Name:     com.android.menubar.MenuBarEnhancer.1.2
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.android.menubar;

import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.MenuItem;

final class MenuBarEnhancer$1
  implements IMenuBarEnhancer
{
  MenuBarEnhancer$1(Menu paramMenu) {}
  
  public IMenuBarEnhancer.MenuBarMode getMenuBarMode()
  {
    return IMenuBarEnhancer.MenuBarMode.GENERIC;
  }
  
  public void setupMenu(String appName, Display display, final IMenuBarCallback callbacks)
  {
    if (val$swtMenu.getItemCount() > 0) {
      new MenuItem(val$swtMenu, 2);
    }
    final MenuItem pref = new MenuItem(val$swtMenu, 0);
    pref.setText("&Options...");
    
    final MenuItem about = new MenuItem(val$swtMenu, 0);
    about.setText("&About...");
    
    pref.addSelectionListener(new SelectionAdapter()
    {
      public void widgetSelected(SelectionEvent e)
      {
        try
        {
          pref.setEnabled(false);
          callbacks.onPreferencesMenuSelected();
          super.widgetSelected(e);
        }
        finally
        {
          pref.setEnabled(true);
        }
      }
    });
    about.addSelectionListener(new SelectionAdapter()
    {
      public void widgetSelected(SelectionEvent e)
      {
        try
        {
          about.setEnabled(false);
          callbacks.onAboutMenuSelected();
          super.widgetSelected(e);
        }
        finally
        {
          about.setEnabled(true);
        }
      }
    });
  }
}

/* Location:
 * Qualified Name:     com.android.menubar.MenuBarEnhancer.1
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.android.menubar;

import java.io.PrintStream;
import org.eclipse.jface.action.IAction;

final class MenuBarEnhancer$2
  implements IMenuBarCallback
{
  MenuBarEnhancer$2(IAction paramIAction1, IAction paramIAction2) {}
  
  public void printError(String format, Object... args)
  {
    System.err.println(String.format(format, args));
  }
  
  public void onPreferencesMenuSelected()
  {
    if (val$preferencesAction != null) {
      val$preferencesAction.run();
    }
  }
  
  public void onAboutMenuSelected()
  {
    if (val$aboutAction != null) {
      val$aboutAction.run();
    }
  }
}

/* Location:
 * Qualified Name:     com.android.menubar.MenuBarEnhancer.2
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.android.menubar;

import org.eclipse.jface.action.IAction;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.Separator;
import org.eclipse.swt.widgets.Display;

final class MenuBarEnhancer$3
  implements IMenuBarEnhancer
{
  MenuBarEnhancer$3(IMenuManager paramIMenuManager, IAction paramIAction1, IAction paramIAction2, IAction paramIAction3) {}
  
  public IMenuBarEnhancer.MenuBarMode getMenuBarMode()
  {
    return IMenuBarEnhancer.MenuBarMode.GENERIC;
  }
  
  public void setupMenu(String appName, Display display, IMenuBarCallback callbacks)
  {
    if (!val$menuManager.isEmpty()) {
      val$menuManager.add(new Separator());
    }
    if (val$aboutAction != null) {
      val$menuManager.add(val$aboutAction);
    }
    if (val$preferencesAction != null) {
      val$menuManager.add(val$preferencesAction);
    }
    if (val$quitAction != null)
    {
      if ((val$aboutAction != null) || (val$preferencesAction != null)) {
        val$menuManager.add(new Separator());
      }
      val$menuManager.add(val$quitAction);
    }
  }
}

/* Location:
 * Qualified Name:     com.android.menubar.MenuBarEnhancer.3
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.android.menubar;

import java.io.PrintStream;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.Separator;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.MenuItem;

public final class MenuBarEnhancer
{
  public static IMenuBarEnhancer setupMenu(String appName, Menu swtMenu, IMenuBarCallback callbacks)
  {
    IMenuBarEnhancer enhancer = getEnhancer(callbacks, swtMenu.getDisplay());
    if (enhancer == null) {
      enhancer = getGenericEnhancer(swtMenu);
    }
    try
    {
      enhancer.setupMenu(appName, swtMenu.getDisplay(), callbacks);
    }
    catch (Exception e)
    {
      if (enhancer.getMenuBarMode() != IMenuBarEnhancer.MenuBarMode.GENERIC)
      {
        enhancer = getGenericEnhancer(swtMenu);
        try
        {
          enhancer.setupMenu(appName, swtMenu.getDisplay(), callbacks);
        }
        catch (Exception e2)
        {
          callbacks.printError("SWTMenuBar failed: %s", new Object[] { e2.toString() });
          return null;
        }
      }
    }
    return enhancer;
  }
  
  private static IMenuBarEnhancer getGenericEnhancer(Menu swtMenu)
  {
    IMenuBarEnhancer enhancer = new IMenuBarEnhancer()
    {
      public IMenuBarEnhancer.MenuBarMode getMenuBarMode()
      {
        return IMenuBarEnhancer.MenuBarMode.GENERIC;
      }
      
      public void setupMenu(String appName, Display display, final IMenuBarCallback callbacks)
      {
        if (val$swtMenu.getItemCount() > 0) {
          new MenuItem(val$swtMenu, 2);
        }
        final MenuItem pref = new MenuItem(val$swtMenu, 0);
        pref.setText("&Options...");
        
        final MenuItem about = new MenuItem(val$swtMenu, 0);
        about.setText("&About...");
        
        pref.addSelectionListener(new SelectionAdapter()
        {
          public void widgetSelected(SelectionEvent e)
          {
            try
            {
              pref.setEnabled(false);
              callbacks.onPreferencesMenuSelected();
              super.widgetSelected(e);
            }
            finally
            {
              pref.setEnabled(true);
            }
          }
        });
        about.addSelectionListener(new SelectionAdapter()
        {
          public void widgetSelected(SelectionEvent e)
          {
            try
            {
              about.setEnabled(false);
              callbacks.onAboutMenuSelected();
              super.widgetSelected(e);
            }
            finally
            {
              about.setEnabled(true);
            }
          }
        });
      }
    };
    return enhancer;
  }
  
  public static IMenuBarEnhancer setupMenuManager(String appName, Display display, IMenuManager menuManager, final IAction aboutAction, final IAction preferencesAction, final IAction quitAction)
  {
    IMenuBarCallback callbacks = new IMenuBarCallback()
    {
      public void printError(String format, Object... args)
      {
        System.err.println(String.format(format, args));
      }
      
      public void onPreferencesMenuSelected()
      {
        if (val$preferencesAction != null) {
          val$preferencesAction.run();
        }
      }
      
      public void onAboutMenuSelected()
      {
        if (aboutAction != null) {
          aboutAction.run();
        }
      }
    };
    IMenuBarEnhancer enhancer = getEnhancer(callbacks, display);
    if (enhancer == null) {
      enhancer = new IMenuBarEnhancer()
      {
        public IMenuBarEnhancer.MenuBarMode getMenuBarMode()
        {
          return IMenuBarEnhancer.MenuBarMode.GENERIC;
        }
        
        public void setupMenu(String appName, Display display, IMenuBarCallback callbacks)
        {
          if (!val$menuManager.isEmpty()) {
            val$menuManager.add(new Separator());
          }
          if (aboutAction != null) {
            val$menuManager.add(aboutAction);
          }
          if (preferencesAction != null) {
            val$menuManager.add(preferencesAction);
          }
          if (quitAction != null)
          {
            if ((aboutAction != null) || (preferencesAction != null)) {
              val$menuManager.add(new Separator());
            }
            val$menuManager.add(quitAction);
          }
        }
      };
    }
    enhancer.setupMenu(appName, display, callbacks);
    return enhancer;
  }
  
  private static IMenuBarEnhancer getEnhancer(IMenuBarCallback callbacks, Display display)
  {
    IMenuBarEnhancer enhancer = null;
    String p = SWT.getPlatform();
    String className = null;
    if ("cocoa".equals(p))
    {
      className = "com.android.menubar.internal.MenuBarEnhancerCocoa";
      if ((SWT.getVersion() >= 3700) && (MenuBarEnhancer37.isSupported(display))) {
        className = MenuBarEnhancer37.class.getName();
      }
    }
    if (System.getenv("DEBUG_SWTMENUBAR") != null) {
      callbacks.printError("DEBUG SwtMenuBar: SWT=%1$s, class=%2$s", new Object[] { p, className });
    }
    if (className != null) {
      try
      {
        Class<?> clazz = Class.forName(className);
        enhancer = (IMenuBarEnhancer)clazz.newInstance();
      }
      catch (Exception e)
      {
        callbacks.printError("Failed to instantiate %1$s: %2$s", new Object[] { className, e.toString() });
      }
    }
    return enhancer;
  }
}

/* Location:
 * Qualified Name:     com.android.menubar.MenuBarEnhancer
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.android.menubar;

class MenuBarEnhancer37$1
  implements Runnable
{
  MenuBarEnhancer37$1(MenuBarEnhancer37 paramMenuBarEnhancer37) {}
  
  public void run() {}
}

/* Location:
 * Qualified Name:     com.android.menubar.MenuBarEnhancer37.1
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.android.menubar;

import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;

class MenuBarEnhancer37$2
  extends SelectionAdapter
{
  MenuBarEnhancer37$2(MenuBarEnhancer37 paramMenuBarEnhancer37, IMenuBarCallback paramIMenuBarCallback) {}
  
  public void widgetSelected(SelectionEvent event)
  {
    val$callbacks.onPreferencesMenuSelected();
  }
}

/* Location:
 * Qualified Name:     com.android.menubar.MenuBarEnhancer37.2
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.android.menubar;

import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;

class MenuBarEnhancer37$3
  extends SelectionAdapter
{
  MenuBarEnhancer37$3(MenuBarEnhancer37 paramMenuBarEnhancer37, IMenuBarCallback paramIMenuBarCallback) {}
  
  public void widgetSelected(SelectionEvent event)
  {
    val$callbacks.onAboutMenuSelected();
  }
}

/* Location:
 * Qualified Name:     com.android.menubar.MenuBarEnhancer37.3
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.android.menubar;

import java.lang.reflect.Method;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.MenuItem;

public class MenuBarEnhancer37
  implements IMenuBarEnhancer
{
  private static final int kAboutMenuItem = -1;
  private static final int kPreferencesMenuItem = -2;
  private static final int kQuitMenuItem = -6;
  
  public IMenuBarEnhancer.MenuBarMode getMenuBarMode()
  {
    return IMenuBarEnhancer.MenuBarMode.MAC_OS;
  }
  
  public void setupMenu(String appName, Display display, IMenuBarCallback callbacks)
  {
    try
    {
      initialize(display, appName, callbacks);
    }
    catch (Exception e)
    {
      throw new IllegalStateException(e);
    }
    display.disposeExec(new Runnable()
    {
      public void run() {}
    });
  }
  
  public static boolean isSupported(Display display)
  {
    try
    {
      Object sysMenu = call0(display, "getSystemMenu");
      if ((sysMenu instanceof Menu)) {
        return (findMenuById((Menu)sysMenu, -2) != null) && (findMenuById((Menu)sysMenu, -1) != null);
      }
    }
    catch (Exception ignore) {}
    return false;
  }
  
  private void initialize(Display display, String appName, final IMenuBarCallback callbacks)
    throws Exception
  {
    Object sysMenu = call0(display, "getSystemMenu");
    if ((sysMenu instanceof Menu))
    {
      MenuItem menu = findMenuById((Menu)sysMenu, -2);
      if (menu != null) {
        menu.addSelectionListener(new SelectionAdapter()
        {
          public void widgetSelected(SelectionEvent event)
          {
            callbacks.onPreferencesMenuSelected();
          }
        });
      }
      menu = findMenuById((Menu)sysMenu, -1);
      if (menu != null)
      {
        menu.addSelectionListener(new SelectionAdapter()
        {
          public void widgetSelected(SelectionEvent event)
          {
            callbacks.onAboutMenuSelected();
          }
        });
        menu.setText("About " + appName);
      }
      menu = findMenuById((Menu)sysMenu, -6);
      if (menu != null) {
        menu.setText("Quit " + appName);
      }
    }
  }
  
  private static Object call0(Object obj, String method)
  {
    try
    {
      Method m = obj.getClass().getMethod(method, (Class[])null);
      if (m != null) {
        return m.invoke(obj, (Object[])null);
      }
    }
    catch (Exception ignore) {}
    return null;
  }
  
  private static MenuItem findMenuById(Menu menu, int id)
  {
    MenuItem[] items = menu.getItems();
    for (int i = items.length - 1; i >= 0; i--)
    {
      MenuItem item = items[i];
      Object menuId = call0(item, "getID");
      if (((menuId instanceof Integer)) && 
        (((Integer)menuId).intValue() == id)) {
        return item;
      }
    }
    return null;
  }
}

/* Location:
 * Qualified Name:     com.android.menubar.MenuBarEnhancer37
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.android.menubar.internal;

class MenuBarEnhancerCocoa$1
  implements Runnable
{
  MenuBarEnhancerCocoa$1(MenuBarEnhancerCocoa paramMenuBarEnhancerCocoa) {}
  
  public void run()
  {
    MenuBarEnhancerCocoa.access$000(this$0, MenuBarEnhancerCocoa.mProc3Args, "dispose");
  }
}

/* Location:
 * Qualified Name:     com.android.menubar.internal.MenuBarEnhancerCocoa.1
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.android.menubar.internal;

import com.android.menubar.IMenuBarCallback;

class MenuBarEnhancerCocoa$ActionProctarget
{
  private final IMenuBarCallback mCallbacks;
  
  public MenuBarEnhancerCocoa$ActionProctarget(IMenuBarCallback callbacks)
  {
    mCallbacks = callbacks;
  }
  
  public int actionProc(int id, int sel, int arg0)
  {
    return (int)actionProc(id, sel, arg0);
  }
  
  public long actionProc(long id, long sel, long arg0)
  {
    if (sel == MenuBarEnhancerCocoa.mSelAboutMenuItemSelected) {
      mCallbacks.onAboutMenuSelected();
    } else if (sel == MenuBarEnhancerCocoa.mSelPreferencesMenuItemSelected) {
      mCallbacks.onPreferencesMenuSelected();
    }
    return 0L;
  }
}

/* Location:
 * Qualified Name:     com.android.menubar.internal.MenuBarEnhancerCocoa.ActionProctarget
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.android.menubar.internal;

import com.android.menubar.IMenuBarCallback;
import com.android.menubar.IMenuBarEnhancer;
import com.android.menubar.IMenuBarEnhancer.MenuBarMode;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import org.eclipse.swt.SWT;
import org.eclipse.swt.internal.C;
import org.eclipse.swt.internal.Callback;
import org.eclipse.swt.widgets.Display;

public class MenuBarEnhancerCocoa
  implements IMenuBarEnhancer
{
  private static final long kAboutMenuItem = 0L;
  private static final long kPreferencesMenuItem = 2L;
  private static final long kQuitMenuItem = 10L;
  static long mSelPreferencesMenuItemSelected;
  static long mSelAboutMenuItemSelected;
  static Callback mProc3Args;
  private String mAppName;
  
  private static class ActionProctarget
  {
    private final IMenuBarCallback mCallbacks;
    
    public ActionProctarget(IMenuBarCallback callbacks)
    {
      mCallbacks = callbacks;
    }
    
    public int actionProc(int id, int sel, int arg0)
    {
      return (int)actionProc(id, sel, arg0);
    }
    
    public long actionProc(long id, long sel, long arg0)
    {
      if (sel == MenuBarEnhancerCocoa.mSelAboutMenuItemSelected) {
        mCallbacks.onAboutMenuSelected();
      } else if (sel == MenuBarEnhancerCocoa.mSelPreferencesMenuItemSelected) {
        mCallbacks.onPreferencesMenuSelected();
      }
      return 0L;
    }
  }
  
  public IMenuBarEnhancer.MenuBarMode getMenuBarMode()
  {
    return IMenuBarEnhancer.MenuBarMode.MAC_OS;
  }
  
  public void setupMenu(String appName, Display display, IMenuBarCallback callbacks)
  {
    mAppName = appName;
    
    ActionProctarget target = new ActionProctarget(callbacks);
    try
    {
      initialize(target);
    }
    catch (Exception e)
    {
      throw new IllegalStateException(e);
    }
    display.disposeExec(new Runnable()
    {
      public void run()
      {
        MenuBarEnhancerCocoa.this.invoke(MenuBarEnhancerCocoa.mProc3Args, "dispose");
      }
    });
  }
  
  private void initialize(Object callbackObject)
    throws Exception
  {
    Class<?> osCls = classForName("org.eclipse.swt.internal.cocoa.OS");
    if (mSelAboutMenuItemSelected == 0L)
    {
      mSelPreferencesMenuItemSelected = registerName(osCls, "preferencesMenuItemSelected:");
      mSelAboutMenuItemSelected = registerName(osCls, "aboutMenuItemSelected:");
    }
    mProc3Args = new Callback(callbackObject, "actionProc", 3);
    Method getAddress = Callback.class.getMethod("getAddress", new Class[0]);
    Object object = getAddress.invoke(mProc3Args, (Object[])null);
    long proc3 = convertToLong(object);
    if (proc3 == 0L) {
      SWT.error(3);
    }
    Class<?> nsMenuCls = classForName("org.eclipse.swt.internal.cocoa.NSMenu");
    Class<?> nsMenuitemCls = classForName("org.eclipse.swt.internal.cocoa.NSMenuItem");
    Class<?> nsStringCls = classForName("org.eclipse.swt.internal.cocoa.NSString");
    Class<?> nsApplicationCls = classForName("org.eclipse.swt.internal.cocoa.NSApplication");
    
    object = invoke(osCls, "objc_lookUpClass", new Object[] { "SWTApplicationDelegate" });
    
    long cls = convertToLong(object);
    
    invoke(osCls, "class_addMethod", new Object[] { wrapPointer(cls), wrapPointer(mSelPreferencesMenuItemSelected), wrapPointer(proc3), "@:@" });
    
    invoke(osCls, "class_addMethod", new Object[] { wrapPointer(cls), wrapPointer(mSelAboutMenuItemSelected), wrapPointer(proc3), "@:@" });
    
    Object sharedApplication = invoke(nsApplicationCls, "sharedApplication");
    Object mainMenu = invoke(sharedApplication, "mainMenu");
    Object mainMenuItem = invoke(nsMenuCls, mainMenu, "itemAtIndex", new Object[] { wrapPointer(0L) });
    
    Object appMenu = invoke(mainMenuItem, "submenu");
    
    Object aboutMenuItem = invoke(nsMenuCls, appMenu, "itemAtIndex", new Object[] { wrapPointer(0L) });
    if (mAppName != null)
    {
      Object nsStr = invoke(nsStringCls, "stringWith", new Object[] { "About " + mAppName });
      
      invoke(nsMenuitemCls, aboutMenuItem, "setTitle", new Object[] { nsStr });
    }
    if (mAppName != null)
    {
      Object quitMenuItem = invoke(nsMenuCls, appMenu, "itemAtIndex", new Object[] { wrapPointer(10L) });
      
      Object nsStr = invoke(nsStringCls, "stringWith", new Object[] { "Quit " + mAppName });
      
      invoke(nsMenuitemCls, quitMenuItem, "setTitle", new Object[] { nsStr });
    }
    Object prefMenuItem = invoke(nsMenuCls, appMenu, "itemAtIndex", new Object[] { wrapPointer(2L) });
    
    invoke(nsMenuitemCls, prefMenuItem, "setEnabled", new Object[] { Boolean.valueOf(true) });
    
    invoke(nsMenuitemCls, prefMenuItem, "setAction", new Object[] { wrapPointer(mSelPreferencesMenuItemSelected) });
    
    invoke(nsMenuitemCls, aboutMenuItem, "setAction", new Object[] { wrapPointer(mSelAboutMenuItemSelected) });
  }
  
  private long registerName(Class<?> osCls, String name)
    throws IllegalArgumentException, SecurityException, IllegalAccessException, InvocationTargetException, NoSuchMethodException
  {
    Object object = invoke(osCls, "sel_registerName", new Object[] { name });
    
    return convertToLong(object);
  }
  
  private long convertToLong(Object object)
  {
    if ((object instanceof Integer))
    {
      Integer i = (Integer)object;
      return i.longValue();
    }
    if ((object instanceof Long))
    {
      Long l = (Long)object;
      return l.longValue();
    }
    return 0L;
  }
  
  private static Object wrapPointer(long value)
  {
    Class<?> PTR_CLASS = C.PTR_SIZEOF == 8 ? Long.TYPE : Integer.TYPE;
    if (PTR_CLASS == Long.TYPE) {
      return new Long(value);
    }
    return new Integer((int)value);
  }
  
  private static Object invoke(Class<?> clazz, String methodName, Object[] args)
  {
    return invoke(clazz, null, methodName, args);
  }
  
  private static Object invoke(Class<?> clazz, Object target, String methodName, Object[] args)
  {
    try
    {
      Class<?>[] signature = new Class[args.length];
      for (int i = 0; i < args.length; i++)
      {
        Class<?> thisClass = args[i].getClass();
        if (thisClass == Integer.class) {
          signature[i] = Integer.TYPE;
        } else if (thisClass == Long.class) {
          signature[i] = Long.TYPE;
        } else if (thisClass == Byte.class) {
          signature[i] = Byte.TYPE;
        } else if (thisClass == Boolean.class) {
          signature[i] = Boolean.TYPE;
        } else {
          signature[i] = thisClass;
        }
      }
      Method method = clazz.getMethod(methodName, signature);
      return method.invoke(target, args);
    }
    catch (Exception e)
    {
      throw new IllegalStateException(e);
    }
  }
  
  private Class<?> classForName(String classname)
  {
    try
    {
      return Class.forName(classname);
    }
    catch (ClassNotFoundException e)
    {
      throw new IllegalStateException(e);
    }
  }
  
  private Object invoke(Class<?> cls, String methodName)
  {
    return invoke(cls, methodName, (Class[])null, (Object[])null);
  }
  
  private Object invoke(Class<?> cls, String methodName, Class<?>[] paramTypes, Object... arguments)
  {
    try
    {
      Method m = cls.getDeclaredMethod(methodName, paramTypes);
      return m.invoke(null, arguments);
    }
    catch (Exception e)
    {
      throw new IllegalStateException(e);
    }
  }
  
  private Object invoke(Object obj, String methodName)
  {
    return invoke(obj, methodName, (Class[])null, (Object[])null);
  }
  
  private Object invoke(Object obj, String methodName, Class<?>[] paramTypes, Object... arguments)
  {
    try
    {
      Method m = obj.getClass().getDeclaredMethod(methodName, paramTypes);
      return m.invoke(obj, arguments);
    }
    catch (Exception e)
    {
      throw new IllegalStateException(e);
    }
  }
}

/* Location:
 * Qualified Name:     com.android.menubar.internal.MenuBarEnhancerCocoa
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
1

Further reading...

For more information on Java 1.5 Tiger, you may find Java 1.5 Tiger, A developer's Notebook by D. Flanagan and B. McLaughlin from O'Reilly of interest.

New!JAR listings


Copyright 2006-2017. Infinite Loop Ltd