01: package org.osbl.client.item;
02:
03: import org.osbl.item.AbstractItemCollector;
04: import org.osbl.client.action.ActionRegistry;
05: import org.osbl.client.action.AuthorizedAction;
06:
07: import javax.swing.*;
08: import java.util.*;
09:
10: public class ActionAuthorizationCollector extends AbstractItemCollector {
11: List<String> items;
12:
13: public ActionAuthorizationCollector() {
14: }
15:
16: public Collection<String> getItems() {
17: if (items == null) {
18: Collection<Action> actions = ActionRegistry.getActions();
19: items = new ArrayList<String>(actions.size());
20:
21: for (Action action : actions) {
22: String permission = (String) action
23: .getValue(AuthorizedAction.PERMISSION_KEY);
24: if (permission == null)
25: permission = action
26: .getValue(Action.ACTION_COMMAND_KEY)
27: + "[x]";
28: items.add(permission);
29: }
30: }
31: return items;
32: }
33:
34: public void refresh() {
35: items = null;
36: }
37:
38: public int hashCode() {
39: return getClass().hashCode();
40: }
41:
42: public boolean equals(Object obj) {
43: return obj != null && getClass().equals(obj.getClass());
44: }
45: }
|