Exemplo n.º 1
0
    public ActionDefinition loadAction(String actionName) {
      index = 0;
      this.s = actionName.toCharArray();

      String name = readTillChar('(', '{');
      Action action = actions.get(name);

      if (action == null) return null;

      ActionDefinition result = new ActionDefinition(action);

      if (action instanceof ParameterizedAction) {
        skip('(');

        ParameterizedAction parametrizedAction = (ParameterizedAction) action;
        Map<String, ActionParameter<?>> actionParams = new HashMap<String, ActionParameter<?>>();
        for (ActionParameter<?> param : parametrizedAction.getActionParameters()) {
          actionParams.put(param.getName(), param);
        }

        while (index < s.length && s[index] != ')') {
          String paramName = readTillChar('=', '=');
          skip('=');
          String paramValue = readTillChar(',', ')');
          if (paramName.length() > 0) {
            ActionParameter<?> actionParam = actionParams.get(paramName);
            if (actionParam != null) {
              result.getParameters().put(paramName, actionParam.readFromString(paramValue));
            }
          }
          skip(',');
        }
        skip(')');
      }
      if (action instanceof AdaptableAction) {
        skip('{');

        while (index < s.length && s[index] != '}') {
          String paramName = readTillChar('=', '=');
          skip('=');
          String paramValue = readTillChar(',', '}');
          if ("icon".equals(paramName) && paramValue.length() > 0) {
            result.setIcon(paramValue);
          } else if ("name".equals(paramName) && paramValue.length() > 0) {
            result.setName(paramValue);
          }
          skip(',');
        }
        skip('}');
      }

      return result;
    }
Exemplo n.º 2
0
 @Override
 public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
   if (currentAction.getAction() instanceof AdaptableAction) {
     if (rowIndex == 0) {
       currentAction.setName((String) aValue);
       return;
     } else if (rowIndex == 1) {
       currentAction.setIcon((String) aValue);
       return;
     } else {
       rowIndex -= 2;
     }
   }
   ActionParameter<Object> param = getParam(rowIndex);
   currentAction.getParameters().put(param.getName(), param.readFromString((String) aValue));
 }