示例#1
0
 @Override
 public Object getValueAt(int rowIndex, int columnIndex) {
   if (currentAction.getAction() instanceof AdaptableAction) {
     if (rowIndex < 2) {
       switch (columnIndex) {
         case 0:
           return rowIndex == 0 ? tr("Tooltip") : tr("Icon");
         case 1:
           return rowIndex == 0 ? currentAction.getName() : currentAction.getIcon();
         default:
           return null;
       }
     } else {
       rowIndex -= 2;
     }
   }
   ActionParameter<Object> param = getParam(rowIndex);
   switch (columnIndex) {
     case 0:
       return param.getName();
     case 1:
       return param.writeToString(currentAction.getParameters().get(param.getName()));
     default:
       return null;
   }
 }
示例#2
0
    @SuppressWarnings("unchecked")
    public String saveAction(ActionDefinition action) {
      result.setLength(0);

      String val = (String) action.getAction().getValue("toolbar");
      if (val == null) return null;
      escape(val);
      if (action.getAction() instanceof ParameterizedAction) {
        result.append('(');
        List<ActionParameter<?>> params =
            ((ParameterizedAction) action.getAction()).getActionParameters();
        for (int i = 0; i < params.size(); i++) {
          ActionParameter<Object> param = (ActionParameter<Object>) params.get(i);
          escape(param.getName());
          result.append('=');
          Object value = action.getParameters().get(param.getName());
          if (value != null) {
            escape(param.writeToString(value));
          }
          if (i < params.size() - 1) {
            result.append(',');
          } else {
            result.append(')');
          }
        }
      }
      if (action.getAction() instanceof AdaptableAction) {
        boolean first = true;
        String tmp = action.getName();
        if (tmp.length() != 0) {
          result.append(first ? "{" : ",");
          result.append("name=");
          escape(tmp);
          first = false;
        }
        tmp = action.getIcon();
        if (tmp.length() != 0) {
          result.append(first ? "{" : ",");
          result.append("icon=");
          escape(tmp);
          first = false;
        }
        if (!first) {
          result.append('}');
        }
      }

      return result.toString();
    }