@Override public void actionPerformed(ActionEvent e) { Collection<String> t = new LinkedList<String>(getToolString()); ActionParser parser = new ActionParser(null); // get text definition of current action String res = parser.saveAction(act); // remove the button from toolbar preferences t.remove(res); Main.pref.putCollection("toolbar", t); Main.toolbar.refreshToolbarControl(); }
public ReflectionPostAction( String name, ActionParser parser, Object o, Method m, Class<?>... clazzes) { this.name = name; this.o = o; this.m = m; this.deprecated = m.isAnnotationPresent(Deprecated.class); Class<?>[] ps = m.getParameterTypes(); Annotation[][] as = m.getParameterAnnotations(); items = new Param[ps.length]; for (int i = 0; i < ps.length; i++) { Annotation a = null; for (int j = 0; j < as[i].length; j++) { if (as[i][j].annotationType().equals(Parameter.class)) a = as[i][j]; } if (a != null) { Parameter v = (Parameter) a; String pname = v.value(); Converter<?> converter = parser.getConverter(ps[i]); if (converter == null) throw new NullPointerException("for " + m + " parameter " + i); items[i] = new RequestParameter(pname, converter); } else { for (int j = 0; j < clazzes.length; j++) if (ps[i].equals(clazzes[j])) items[i] = new StaticParameter(j); if (ps[i].equals(HttpServletRequest.class)) items[i] = new ServletRequestParameter(); } if (items[i] == null) throw new NullPointerException("for " + m + " parameter " + i); } }
@Override public boolean ok() { Collection<String> t = new LinkedList<String>(); ActionParser parser = new ActionParser(null); for (int i = 0; i < selected.size(); ++i) { ActionDefinition action = (ActionDefinition) selected.get(i); if (action.isSeparator()) { t.add("|"); } else { String res = parser.saveAction(action); if (res != null) { t.add(res); } } } if (t.isEmpty()) { t = Collections.singletonList(EMPTY_TOOLBAR_MARKER); } Main.pref.putCollection("toolbar", t); Main.toolbar.refreshToolbarControl(); return false; }
private Collection<ActionDefinition> getDefinedActions() { loadActions(); Map<String, Action> allActions = new HashMap<String, Action>(regactions); allActions.putAll(actions); ActionParser actionParser = new ActionParser(allActions); Collection<ActionDefinition> result = new ArrayList<ActionDefinition>(); for (String s : getToolString()) { if (s.equals("|")) { result.add(ActionDefinition.getSeparator()); } else { ActionDefinition a = actionParser.loadAction(s); if (a != null) { result.add(a); } else { System.out.println("Could not load tool definition " + s); } } } return result; }