コード例 #1
0
 @Override
 public void addFrameworkGuiEventListener(FrameworkGuiEventListener listener) {
   if (listener != null) {
     guiListeners.add(listener);
   } else {
     logger.log(Level.WARNING, "Can not add null as a GuiListener", TaskManager.getCurrentTick());
   }
 }
コード例 #2
0
  /**
   * Reads typed parameters from xml element and returns them in a Map where the key is the
   * parameter's String name and the value is the value of the parameter. Finds all tags named
   * "param". Those tags should have two attributes, name and type. Valid parameters types are
   * "int", "double", "boolean", and "string". If the value is not compatible with the specified
   * type then value will be null, except in the case of a Boolean with an incompatible value, in
   * which case the value will be False. If a parameter's value is not specified or empty then the
   * value will be null.
   *
   * @param moduleElement Dom {@link Element}
   * @return parameters indexed by name.
   */
  public static Map<String, Object> getTypedParams(Element moduleElement) {
    Map<String, Object> prop = new HashMap<String, Object>();
    List<Element> nl = getChildren(moduleElement, "param");
    if (nl != null) {
      for (Element param : nl) {
        String name = param.getAttribute("name");
        String type = param.getAttribute("type");
        String sValue = getValue(param);
        Object value = sValue;
        if (sValue != null) {

          if (type == null || "string".equalsIgnoreCase(type)) {
            value = sValue;
          } else if ("int".equalsIgnoreCase(type)) {
            try {
              value = Integer.parseInt(sValue);
            } catch (NumberFormatException e) {
              value = null;
              logger.log(Level.FINE, e.toString(), TaskManager.getCurrentTick());
            }
          } else if ("double".equalsIgnoreCase(type)) {
            try {
              value = Double.parseDouble(sValue);
            } catch (NumberFormatException e) {
              value = null;
              logger.log(Level.FINE, e.toString(), TaskManager.getCurrentTick());
            }
          } else if ("boolean".equalsIgnoreCase(type)) {
            value = Boolean.parseBoolean(sValue);
          }
        }
        prop.put(name, value);
      }
    }
    return prop;
  }
コード例 #3
0
 @Override
 protected void runThisFrameworkTask() {
   logger.log(Level.FINE, name, TaskManager.getCurrentTick());
   gw.triggerBroadcast(trigger);
   cancel();
 }