Example #1
0
  public static String getImageURL(int mode, AppW app) {

    //		String modeText = app.getKernel().getModeText(mode);
    //		// bugfix for Turkish locale added Locale.US
    //		String iconName = "mode_" +StringUtil.toLowerCase(modeText)
    //				+ "_32";
    //

    // macro
    if (mode >= EuclidianConstants.MACRO_MODE_ID_OFFSET) {
      int macroID = mode - EuclidianConstants.MACRO_MODE_ID_OFFSET;
      try {
        Macro macro = app.getKernel().getMacro(macroID);
        String iconName = macro.getIconFileName();
        if (iconName == null || iconName.length() == 0) {
          // default icon
          return safeURI(myIconResourceBundle.mode_tool_32());
        }
        // use image as icon
        Image img = new NoDragImage(app.getImageManager().getExternalImageSrc(iconName), 32);
        return img.getUrl();
      } catch (Exception e) {
        App.debug("macro does not exist: ID = " + macroID);
        return "";
      }
    }

    return safeURI(getImageURLNotMacro(mode));
  }
Example #2
0
  /*
   * Take a list of commands and return all possible syntaxes for these
   * commands
   */
  private List<String> getSyntaxes(List<String> commands) {
    if (commands == null) {
      return null;
    }
    ArrayList<String> syntaxes = new ArrayList<String>();
    for (String cmd : commands) {

      String cmdInt = app.getInternalCommand(cmd);
      Localization loc = app.getLocalization();
      String syntaxString;
      if (component.isForCAS()) {
        syntaxString = app.getLocalization().getCommandSyntaxCAS(cmdInt);
      } else {
        syntaxString =
            app.getExam() == null
                ? loc.getCommandSyntax(cmdInt)
                : app.getExam().getSyntax(cmdInt, loc, app.getSettings());
      }
      if (syntaxString != null) {
        if (syntaxString.endsWith(
            component.isForCAS() ? Localization.syntaxCAS : Localization.syntaxStr)) {

          // command not found, check for macros
          Macro macro = component.isForCAS() ? null : app.getKernel().getMacro(cmd);
          if (macro != null) {
            syntaxes.add(macro.toString());
          } else {
            // syntaxes.add(cmdInt + "[]");
            Log.debug("Can't find syntax for: " + cmd);
          }

          continue;
        }
        for (String syntax : syntaxString.split("\\n")) {
          syntaxes.add(syntax);
        }
      }
    }
    return syntaxes;
  }