source: trunk/src/org/expeditee/actions/Help.java@ 660

Last change on this file since 660 was 306, checked in by ra33, 16 years ago

Added some HELP actions
More mail stuff... and networking stuff
Can now save frames and send messages to peers
Also version control prevent versions from being lost

File size: 2.2 KB
Line 
1package org.expeditee.actions;
2
3import java.util.Collection;
4import java.util.Collections;
5import java.util.Comparator;
6import java.util.LinkedList;
7import java.util.List;
8
9import org.expeditee.gui.DisplayIO;
10import org.expeditee.gui.Frame;
11import org.expeditee.gui.FrameMouseActions;
12import org.expeditee.items.Item;
13import org.expeditee.items.Text;
14
15public class Help {
16 /**
17 * Return a list of actions. TODO show the params they take. TODO link the
18 * actions to their help pages.
19 *
20 * @return
21 */
22 public static Collection<Item> getActions(String start, String end) {
23 return getItemList(Actions.getActions(), start, end);
24
25 }
26
27 public static Collection<Item> getActions(String start) {
28 return getItemList(Actions.getActions(), start, null);
29
30 }
31
32 public static Collection<Item> getActions() {
33 return getItemList(Actions.getActions(), null, null);
34
35 }
36
37 public static Collection<Item> getAgents(String start, String end) {
38 return getItemList(Actions.getAgents(), start, end);
39
40 }
41
42 public static Collection<Item> getAgents(String start) {
43 return getItemList(Actions.getAgents(), start, null);
44
45 }
46
47 public static Collection<Item> getAgents() {
48 return getItemList(Actions.getAgents(), null, null);
49 }
50
51 private static Collection<Item> getItemList(List<String> stringList,
52 String start, String end) {
53 Collection<Item> actions = new LinkedList<Item>();
54
55 Collections.sort(stringList, new Comparator<String>() {
56 public int compare(String a, String b) {
57 return String.CASE_INSENSITIVE_ORDER.compare(a, b);
58 }
59 });
60
61 Frame current = DisplayIO.getCurrentFrame();
62 float x = FrameMouseActions.MouseX;
63 float y = FrameMouseActions.MouseY;
64
65 // Do case sensitive comparison
66 if (start != null)
67 start = start.toLowerCase();
68 if (end != null)
69 end = end.toLowerCase();
70
71 for (String s : stringList) {
72 String lower = s.toLowerCase();
73 if (start != null) {
74 if (end != null) {
75 if (lower.compareToIgnoreCase(start) < 0)
76 continue;
77 if (lower.compareToIgnoreCase(end) > 0)
78 break;
79 } else if (!lower.matches(start) && !lower.startsWith(start)) {
80 continue;
81 }
82 }
83
84 Text t = current.createNewText(s);
85 t.setWidth(1000);
86 t.setPosition(x, y);
87 y += t.getBoundsHeight();
88 actions.add(t);
89 }
90
91 return actions;
92 }
93}
Note: See TracBrowser for help on using the repository browser.