{
Object result = Boolean.FALSE;
if (args.length >= 2 && menu == null)
{
MainScreen screen = (MainScreen) SendMenuExtension.getBrowserField().getScreen();
int sendType = Integer.parseInt(args[0].toString());
boolean getAll = (args.length>=3) ? ((Boolean) args[2]).booleanValue() : false;
int ordering = (args.length>=4) ? Integer.parseInt(args[3].toString()) : 0;
int priority = (args.length>=5) ? Integer.parseInt(args[4].toString()) : 0;
try
{
JSONObject context = new JSONObject(args[1].toString());
SendCommand[] sendCommands = SendCommandRepository.getInstance().get(sendType,context,getAll);
if(sendCommands != null && sendCommands.length > 0)
{
if(args.length >= 6 && args[5] != null)
{
try
{
JSONObject filterArgs = new JSONObject(args[5].toString());
SendContextFilter filter = new SendContextFilter(filterArgs);
for (int i = 0; i < sendCommands.length; i++)
{
sendCommands[i].setSendCommandContextFilter(filter);
}
} catch (JSONException e) {
System.out.println(e.toString());
}
}
SendCommandMenu sendCommandmenu = new SendCommandMenu(sendCommands, 0, 0);
SendCommandMenuItem[] menuItems = sendCommandmenu.getSendCommandMenuItems();
menu = new SubMenu(menuItems,menuLabel,ordering,priority);
screen.addMenuItem(menu.getMenuItem());
result = Boolean.TRUE;
}
}
catch (JSONException e)
{