Convert the command to the screen document type.
@param strCommand The command text.
@param The standard document type (MAINT/DISPLAY/SELECT/MENU/etc).
321777
public int commandToDocType(String strCommand)
    {
        if (UserInfo.VERBOSE_MAINT_SCREEN.equalsIgnoreCase(strCommand))
            return UserInfo.VERBOSE_MAINT_MODE;
        if (UserInfo.LOGIN_SCREEN.equalsIgnoreCase(strCommand))
            return UserInfo.LOGIN_SCREEN_MODE;
        if (UserInfo.ENTRY_SCREEN.equalsIgnoreCase(strCommand))
            return UserInfo.ENTRY_SCREEN_MODE;
        if (UserInfo.PREFERENCES_SCREEN.equalsIgnoreCase(strCommand))
            return UserInfo.PREFERENCES_SCREEN_MODE;
        if (UserInfo.PASSWORD_CHANGE_SCREEN.equalsIgnoreCase(strCommand))
            return UserInfo.PASSWORD_CHANGE_SCREEN_MODE;
        return super.commandToDocType(strCommand);
    }
788591
@Override
    protected void doHandle(CommandContext ctx) throws CommandFormatException {
        final ParsedCommandLine line = ctx.getParsedCommandLine();
        String result = line.getSubstitutedLine().trim().substring(line.getOperationName().length()).trim();
        if(ctx.isResolveParameterValues()) {
            result = CLIExpressionResolver.resolve(result);
        }
        // apply escape rules
        int i = result.indexOf('\\');
        if(i >= 0) {
            final StringBuilder buf = new StringBuilder(result.length() - 1);
            buf.append(result.substring(0, i));
            boolean escaped = true;
            while(++i < result.length()) {
                if(escaped) {
                    buf.append(result.charAt(i));
                    escaped = false;
                } else {
                    final char c = result.charAt(i);
                    if(c == '\\') {
                        escaped = true;
                    } else {
                        buf.append(c);
                    }
                }
            }
            result = buf.toString();
        }
        ctx.printLine(result);
    }
666008
public Object doRemoteCommand(String strCommand, Map<String, Object> properties)
    {
        if (SET_DEFAULT_COMMAND.equalsIgnoreCase(strCommand))
            if (properties != null)
                if (properties.get(DBConstants.SYSTEM_NAME) != null)
        {
            if (this.getTask() != null)
            if (this.getTask().getApplication() instanceof BaseApplication)
            if (((BaseApplication)this.getTask().getApplication()).getEnvironment() != null)
            {
                String systemName = properties.get(DBConstants.SYSTEM_NAME).toString();
                Environment env = ((BaseApplication)this.getTask().getApplication()).getEnvironment();
                properties.put(DBConstants.SYSTEM_NAME, "base");
                BaseApplication app = new MainApplication(env, properties, null);
                try {
                    Task task = new AutoTask(app, null, properties);
                    RecordOwner recordOwner = new BaseProcess(task, null, properties);
                    Menus menus = new Menus(recordOwner);
                    menus.setKeyArea(Menus.CODE_KEY);
                    menus.getField(Menus.CODE).setString(ResourceConstants.DEFAULT_RESOURCE);
                    if (menus.seek(null))
                        menus.edit();
                    else
                        menus.addNew();
                    menus.getField(Menus.CODE).setString(ResourceConstants.DEFAULT_RESOURCE);
                    ((PropertiesField)menus.getField(Menus.PARAMS)).setProperty(DBConstants.SYSTEM_NAME, systemName);
                    if (menus.getEditMode() == DBConstants.EDIT_ADD)
                        menus.add();
                    else
                        menus.set();
                } catch (DBException e) {
                    e.printStackTrace();
                } finally {
                    app.free();
                }
                env.getDefaultApplication().getSystemRecordOwner().setProperty(DBConstants.DEFAULT_SYSTEM_NAME, systemName);
                return Boolean.TRUE;    // Success
            }
        }
        return super.doRemoteCommand(strCommand, properties);
    }
948793
function renderCommand(command) {

    if (!panel.buttonDiv) {
      var formGroup = addEle(panel.panelForm, 'div', 'form-group');
      panel.buttonDiv = addEle(formGroup, 'div', indent ? 'col-sm-offset-3 col-sm-9' : 'col-sm-9');
    }
    var cmdTheme = command.theme || 'default';
    var button = addEle(panel.buttonDiv, 'button', 'btn btn-' + cmdTheme + ' btn-presentation', {type: 'button'});

    var icon = command.icon;
    if (icon) {
      if (left(icon, 2) == 'fa')
        icon = '<i class="fa ' + icon + '"></i>&nbsp;';
      else
        icon = '<span class="glyphicon ' + icon + '"></span>&nbsp;';
      button.innerHTML = icon + command.name;
    } else {
      button.innerHTML = command.name;
    }

    $(button).on('click', function (event) {
      event.preventDefault();
      bootstrapInterface.dispatch(new Request({type: 'Command', command: command}));
    });
    panel.listeners.push(button); // so we can avoid leakage on deleting panel
  }
151833
public int commandToDocType(String strCommand)
    {
        if (CLASS_DETAIL_SCREEN.equalsIgnoreCase(strCommand))
            return CLASS_DETAIL_MODE;
        if (RESOURCE_DETAIL_SCREEN.equalsIgnoreCase(strCommand))
            return RESOURCE_DETAIL_MODE;
        return super.commandToDocType(strCommand);
    }
1171939
public void printHelp(Command command) {
        if (command.getDescriptor().getUsage() != null) {
            printUsage(command.getDescriptor().getUsage());
        } else {
            printUsage(command);
        }
        int leftWidth = printOptions(command.getOptions());
        printArguments(command.getArgumentsList(), leftWidth);
    }
701514
private boolean processTemplateCommand(String cmdLine, int cmdTPosBegin, int cmdTPosEnd)
            throws MiniTemplator.TemplateSyntaxException {
        int p0 = skipBlanks(cmdLine, 0);
        if (p0 >= cmdLine.length()) {
            return false;
        }
        int p = skipNonBlanks(cmdLine, p0);
        String cmd = cmdLine.substring(p0, p);
        String parms = cmdLine.substring(p);
        /* select */
        if (cmd.equalsIgnoreCase("$beginBlock")) {
            processBeginBlockCmd(parms, cmdTPosBegin, cmdTPosEnd);
        } else if (cmd.equalsIgnoreCase("$endBlock")) {
            processEndBlockCmd(parms, cmdTPosBegin, cmdTPosEnd);
        } else if (cmd.equalsIgnoreCase("$include")) {
            processIncludeCmd(parms, cmdTPosBegin, cmdTPosEnd);
        } else if (cmd.equalsIgnoreCase("$if")) {
            processIfCmd(parms, cmdTPosBegin, cmdTPosEnd);
        } else if (cmd.equalsIgnoreCase("$elseIf")) {
            processElseIfCmd(parms, cmdTPosBegin, cmdTPosEnd);
        } else if (cmd.equalsIgnoreCase("$else")) {
            processElseCmd(parms, cmdTPosBegin, cmdTPosEnd);
        } else if (cmd.equalsIgnoreCase("$endIf")) {
            processEndIfCmd(parms, cmdTPosBegin, cmdTPosEnd);
        } else {
            if (cmd.startsWith("$") && !cmd.startsWith("${")) {
                throw new MiniTemplator.TemplateSyntaxException(
                        "Unknown command \"" + cmd + "\" in template at offset " + cmdTPosBegin + ".");
            } else {
                return false;
            }
        }
        return true;
    }
952476
public void printUsage(Command command) {
        String commandName = command.getDescriptor().getName();
        StringBuilder sb = new StringBuilder(getSyntaxPrefix()).append(commandName).append(" ");

        // create a list for processed option groups
        Collection<OptionGroup> processedGroups = new ArrayList<>();

        Collection<Option> optList = command.getOptions().getAllOptions();
        if (optList.size() > 1 && getOptionComparator() != null) {
            List<Option> optList2 = new ArrayList<>(optList);
            optList2.sort(getOptionComparator());
            optList = optList2;
        }

        for (Iterator<Option> it = optList.iterator(); it.hasNext();) {
            // get the next Option
            Option option = it.next();
            // check if the option is part of an OptionGroup
            OptionGroup group = command.getOptions().getOptionGroup(option);
            if (group != null) {
                // if the group has not already been processed
                if (!processedGroups.contains(group)) {
                    // add the group to the processed list
                    processedGroups.add(group);
                    // add the usage clause
                    appendOptionGroup(sb, group);
                }
                // otherwise the option was displayed in the group
                // previously so ignore it.
            }
            // if the Option is not part of an OptionGroup
            else {
                appendOption(sb, option, option.isRequired());
            }
            if (it.hasNext()) {
                sb.append(" ");
            }
        }

        for (Arguments arguments : command.getArgumentsList()) {
            sb.append(" ");
            appendArguments(sb, arguments);
        }

        printWrapped(getSyntaxPrefix().length() + commandName.length() + 1, sb.toString());
    }
271012
public static void displayMessageBox( String strMsg, final int iType, boolean bWrapText )
  {
    final String strWrappedMsg = bWrapText ? wrapText( strMsg ) : strMsg;

    Runnable logMsgBox = new Runnable()
    {
      public void run()
      {
        JOptionPane.showMessageDialog( getWindow(), strWrappedMsg, "", iType );
      }
    };

    if( EventQueue.isDispatchThread() )
    {
      logMsgBox.run();
    }
    else
    {
      try
      {
        EventQueue.invokeAndWait( logMsgBox );
      }
      catch( Throwable t )
      {
        t.printStackTrace();
      }
    }
  }
881197
public void printHtmlType(PrintWriter out, String strTag, String strParams, String strData)
    {
        out.print(m_recDetail.getField(MenusModel.TYPE).toString());
    }
1083613
public static void printCommandInfo(Command command, PrintWriter pw) {
    String description =
        String.format("%s: %s", command.getCommandName(), command.getDescription());
    int width = 80;
    try {
      width = TerminalFactory.get().getWidth();
    } catch (Exception e) {
      // In case the terminal factory failed to decide terminal type, use default width
    }

    HELP_FORMATTER.printWrapped(pw, width, description);
    HELP_FORMATTER.printUsage(pw, width, command.getUsage());
    if (command.getOptions().getOptions().size() > 0) {
      HELP_FORMATTER.printOptions(pw, width, command.getOptions(), HELP_FORMATTER.getLeftPadding(),
          HELP_FORMATTER.getDescPadding());
    }
  }
1233458
@VisibleForTesting
    protected void setSttyMode(STTYMode mode) throws IOException {
        String[] cmd;
        if (mode == STTYMode.COOKED) {
            cmd = new String[]{"/bin/sh", "-c", "stty -raw echo </dev/tty"};
        } else {
            cmd = new String[]{"/bin/sh", "-c", "stty raw -echo </dev/tty"};
        }

        Process p = runtime.exec(cmd);

        try {
            p.waitFor();
        } catch (InterruptedException ie) {
            throw new IOException(ie.getMessage(), ie);
        }

        try (InputStreamReader in = new InputStreamReader(p.getErrorStream(), UTF_8);
             BufferedReader reader = new BufferedReader(in)) {
            String err = reader.readLine();
            if (err != null) {
                throw new IOException(err);
            }
        }
    }
109918
public boolean isCharCommand(final ICmdLineArg<?> argDef)
    {
        return argDef.getKeychar() != null && isCharCommand() && (charCommand() == argDef.getKeychar().charValue());
    }
110102
function Command(args) {
  if (false === (this instanceof Command)) throw new Error('new operator required');
  if (typeof args == 'function') { // shorthand for function command
    args = {type: 'Function', contents: args};
  }
  if (args instanceof Procedure) { // shorthand for Procedure command
    args = {type: 'Procedure', contents: args};
  }
  args = args || {};
  var i;
  var unusedProperties = getInvalidProperties(args,
    ['name', 'description', 'type', 'contents', 'scope', 'timeout', 'theme', 'icon', 'bucket', 'presentationMode','location','images']);
  var errorList = [];
  for (i = 0; i < unusedProperties.length; i++) errorList.push('invalid property: ' + unusedProperties[i]);
  if (errorList.length > 1) throw new Error('error creating Command: multiple errors');
  if (errorList.length) throw new Error('error creating Command: ' + errorList[0]);
  for (i in args) this[i] = args[i];
  this.name = this.name || "a command"; // name is optional
  if ('string' != typeof this.name) throw new Error('name must be string');
  if ('undefined' == typeof this.description) this.description = this.name + ' Command';
  if ('undefined' == typeof this.type) this.type = 'Stub';
  if (!contains(Command.getTypes(), this.type)) throw new Error('Invalid command type: ' + this.type);
  switch (this.type) {
    case 'Stub':
      break;
    case 'Menu':
      if (!(this.contents instanceof Array)) throw new Error('contents must be array of menu items');
      if (!this.contents.length) throw new Error('contents must be array of menu items');
      for (i in this.contents) {
        if (this.contents.hasOwnProperty(i))
          if (typeof this.contents[i] != 'string' && !(this.contents[i] instanceof Command))
            throw new Error('contents must be array of menu items');
      }
      break;
    case 'Presentation':
      if (!(this.contents instanceof Presentation)) throw new Error('contents must be a Presentation');
      this.presentationMode = this.presentationMode || 'View';
      if (!contains(Command.getPresentationModes(), this.presentationMode)) throw new Error('Invalid presentationMode: ' + this.presentationMode);
      //['View', 'Edit', 'List']
      break;
    case 'Function':
      if (typeof this.contents != 'function') throw new Error('contents must be a Function');
      break;
    case 'Procedure':
      if (!(this.contents instanceof Procedure)) throw new Error('contents must be a Procedure');
      break;
    default:
      throw new TypeError();
  }
  if ('undefined' != typeof this.scope)
    if (!((this.scope instanceof Model) || (this.scope instanceof List)))
      throw new Error('optional scope property must be Model or List');
  if ('undefined' != typeof this.timeout)
    if (typeof this.timeout != 'number') throw new Error('timeout must be a Number');
  if ('undefined' != typeof this.timeout)
    if (typeof this.timeout != 'number') throw new Error('timeout must be a Number');
  if ('undefined' != typeof this.theme) {
    if ('string' != typeof this.theme) throw new Error('invalid theme');
    if (!contains(['default', 'primary', 'success', 'info', 'warning', 'danger', 'link'], this.theme))
      throw new Error('invalid theme');
  }
  if ('undefined' != typeof this.icon) {
    if ('string' != typeof this.icon) throw new Error('invalid icon');
    if (!contains(['fa', 'glyphicon'], this.icon.split('-')[0]) || !this.icon.split('-')[1])
      throw new Error('invalid icon');
  }

  // Validations done
  this._eventListeners = [];
}
131336
public void printInputControl(PrintWriter out, String strFieldDesc, String strFieldName, String strSize, String strMaxSize, String strValue, String strControlType, String strFieldType)
    {
        if (!HtmlConstants.BUTTON.equalsIgnoreCase(strControlType))
        {
            strFieldName = DBParams.COMMAND;
            strControlType = HtmlConstants.SUBMIT;
        }
        String strButtonDesc = ((SButtonBox)this.getScreenField()).getButtonDesc();
        if ((strButtonDesc == null)
            && (((SButtonBox)this.getScreenField()).getImageButtonName() != null))
        {
            if (this.getScreenField().getParentScreen() instanceof GridScreen)
            { // These are command buttons such as "Form" or "Detail"
                GridScreen gridScreen = (GridScreen)this.getScreenField().getParentScreen();
                Record record = gridScreen.getMainRecord();
                String strRecordClass = record.getClass().getName();
                String strImage = DBConstants.FORM;
                if (((SButtonBox)this.getScreenField()).getImageButtonName() != null)
                    strImage = ((SButtonBox)this.getScreenField()).getImageButtonName();
                String strButtonCommand = ((SButtonBox)this.getScreenField()).getButtonCommand();
                if ((strButtonCommand == null) || (strButtonCommand.length() == 0))
                    strButtonCommand = ThinMenuConstants.FORM;
//x                String strCommand = "&" + DBParams.COMMAND + "=" + strButtonCommand;
//?                try {
//?                    out.println("<td align=\"center\" valign=\"center\"><a href=\"" + "?record=" + strRecordClass + strCommand + "&" + DBConstants.STRING_OBJECT_ID_HANDLE + "=" + URLEncoder.encode(strBookmark, DBConstants.URL_ENCODING) + "\"><IMG SRC=\"" + HtmlConstants.IMAGE_DIR + "buttons/" + strImage + ".gif\" width=\"16\" height=\"16\" alt=\"Open this record\"></a></td>");
//?                } catch (java.io.UnsupportedEncodingException ex) {
//?                    ex.printStackTrace();
//?                }
                if (strButtonDesc == null)
                    strButtonDesc = DBConstants.BLANK;
                strButtonCommand = strButtonCommand + "&amp;record=" + strRecordClass + "&amp;objectID=";
                out.println(" <xfm:trigger name=\"" + strImage + "\" ref=\"" + strFieldName + "\" command=\"" + strButtonCommand + "\">");
                out.println("   <xfm:hint>" + strFieldDesc + "</xfm:hint>");
                out.println("   <xfm:image>" + strImage + "</xfm:image>");
                out.println("   <xfm:caption>" + strButtonDesc + "</xfm:caption>");
                out.println(" </xfm:trigger>");
            }
            else
            {
                strButtonDesc = ((SButtonBox)this.getScreenField()).getImageButtonName();
                strControlType = "image";
                strFieldType = "image";
//?             ? = this.getScreenField()).getImageButtonName();
                super.printInputControl(out, strFieldDesc, strFieldName, strSize, strMaxSize, strValue, strControlType, strFieldType);
            }
        }
        else
        {
            strControlType = "submit";
            if (strButtonDesc == null)
            {
                strButtonDesc = ((SButtonBox)this.getScreenField()).getButtonCommand();
//?                strControlType = "trigger";
            }
            String strImage = "Form";
            if (((SButtonBox)this.getScreenField()).getImageButtonName() != null)
                strImage = ((SButtonBox)this.getScreenField()).getImageButtonName();
//?            else if (!strButtonDesc.equals(((SButtonBox)this.getScreenField()).getButtonCommand()))
//?                strControlType = "trigger";
            if (this.getScreenField().getConverter() == null)
                strFieldName = strButtonDesc;   // Since this isn't tied to a field, set this to the command name.
//x            out.println("<td><input type=\"" + strControlType + "\" name=\"" + strFieldName + "\" value=\"" + strButtonDesc + "\"/></td>");
            out.println(" <xfm:" + strControlType + " name=\"" + strButtonDesc + "\" ref=\"" + strFieldName + "\">");
            out.println("   <xfm:hint>" + strFieldDesc + "</xfm:hint>");
            out.println("   <xfm:image>" + strImage + "</xfm:image>");
            out.println("   <xfm:caption>" + strButtonDesc + "</xfm:caption>");
            out.println(" </xfm:" + strControlType + ">");
        }
    }
1284214
@Override
    public void actionPerformed(ActionEvent e) {
        String cmd = e.getActionCommand();
        if (cmd.equals("Cut")) {
            // textArea.cut();
        } else if (cmd.equals("Copy")) {
            textArea.copy();
        } else if (cmd.equals("Paste")) {
            // textArea.paste();
        }
    }
338791
function execCommand(editor, command, value, useCSS, button) {

    // Restore the current ie selection
    restoreRange(editor);

    // Set the styling method
    if (!ie) {
      if (useCSS === undefined || useCSS === null)
        useCSS = editor.options.useCSS;
      editor.doc.execCommand("styleWithCSS", 0, useCSS.toString());
    }

    // Execute the command and check for error
    var success = true, description;
    if (ie && command.toLowerCase() == "inserthtml")
      getRange(editor).pasteHTML(value);
    else {
      try { success = editor.doc.execCommand(command, 0, value || null); }
      catch (err) { description = err.description; success = false; }
      if (!success) {
        if ("cutcopypaste".indexOf(command) > -1)
          showMessage(editor, "For security reasons, your browser does not support the " +
            command + " command. Try using the keyboard shortcut or context menu instead.",
            button);
        else
          showMessage(editor,
            (description ? description : "Error executing the " + command + " command."),
            button);
      }
    }

    // Enable the buttons
    refreshButtons(editor);
    return success;

  }