source: trunk/org/expeditee/actions/NavigationActions.java@ 4

Last change on this file since 4 was 4, checked in by davidb, 16 years ago

Starting source code to Expeditee

File size: 6.2 KB
Line 
1package org.expeditee.actions;
2
3import java.util.List;
4
5import org.expeditee.gui.DisplayIO;
6import org.expeditee.gui.Frame;
7import org.expeditee.gui.FrameGraphics;
8import org.expeditee.gui.FrameIO;
9import org.expeditee.gui.FrameUtils;
10import org.expeditee.items.Item;
11
12/**
13 * Provides the Navigation related KMS action procedures
14 *
15 * @author jdm18
16 *
17 */
18public class NavigationActions {
19
20 public static void setLastNavigationItem(Item i) {
21 _LastItemUsed = i;
22 if (i.getParent() != null) {
23 _Parent = i.getParent().getFrameName();
24 }
25 }
26
27 private static void Default() {
28 System.out.println("Not Implemented");
29 }
30
31 /**
32 * Performs a back operation from the current Frame. If the back-stack is
33 * empty, then nothing happens.
34 */
35 public static void Back() {
36 DisplayIO.Back();
37 }
38
39 public static void ClearBack(Item i) {
40 Default();
41 }
42
43 public static void DeleteBack() {
44 Default();
45 }
46
47 public static void GetBack(String topFrame, int x, int y) {
48 Default();
49 }
50
51 public static void GetBackList() {
52 Default();
53 }
54
55 /**
56 * Displays the user's home frame
57 */
58 public static void GotoHome() {
59 FrameUtils.DisplayHomeFrame();
60 }
61
62 /**
63 * Displays the user's profile frame (if there is one)
64 */
65 public static void GotoProfile() {
66 FrameUtils.DisplayProfileFrame();
67 }
68
69 /**
70 * Loads the Frame with the given FrameName and displays it
71 *
72 * @param frameName
73 * The name of the Frame to load
74 */
75 public static void Goto(String frameName) {
76 FrameUtils.DisplayFrame(frameName);
77 }
78
79 /**
80 * Loads the Frame in the current frameset with the given number and
81 * displays it
82 *
83 * @param value
84 * The number of the Frame to load
85 */
86 public static void Goto(Integer value) {
87 FrameUtils.DisplayFrame(value.toString());
88 }
89
90 /**
91 * Loads the Frame linked to by the Item that has this action, if there is
92 * one
93 *
94 * @param source
95 * The Item that has a link to the Frame to load and display
96 */
97 public static void GotoLink(Item source) {
98 FrameUtils.DisplayFrame(source.getLink());
99 }
100
101 /**
102 * Turns TwinFrames off if it is on, otherwise does nothing
103 */
104 public static void Large() {
105 if (DisplayIO.isTwinFramesOn())
106 DisplayIO.ToggleTwinFrames();
107 }
108
109 /**
110 * Navigates to the Frame with the next highest frame number in the current
111 * frameset. If the current frame is the last frame in the frameset, nothing
112 * happens.
113 */
114 public static void NextFrame() {
115 Frame next = FrameIO.LoadNext();
116 FrameUtils.DisplayFrame(next, true);
117 }
118
119 /**
120 * Navigates to the last frame in the frameset.
121 *
122 */
123 public static void LastFrame() {
124 Frame last = FrameIO.LoadLast();
125 FrameUtils.DisplayFrame(last, true);
126 }
127
128
129 public static void Next() {
130 NextFrame();
131 }
132
133 public static void Previous() {
134 PreviousFrame();
135 }
136
137 public static void PreviousFrame() {
138 Frame prev = FrameIO.LoadPrevious();
139 FrameUtils.DisplayFrame(prev, true);
140 }
141
142 private static String _Parent = null;
143
144 private static Item _LastItemUsed = null;
145
146 public static void NextChild(Frame source) {
147 String back = DisplayIO.peekFromBack(); // ByRob: "peekFromBack" is not
148 // an informative term, better to refer to back up stack
149 // if there is no parent frame (i.e. the user is on the home frame) //
150 // ByRob: this should say "for example, the user ...."
151 if (back == null) { // No frame was on the Backup stack
152 FrameGraphics.DisplayMessage("No Parent Frame Found.");
153 _LastItemUsed = null; // ByRob: what is reason for setting
154 // this to null, who is going to use
155 // it????
156 _Parent = null; // ByRob: what is reason for setting this to
157 // null, who is going to use it
158 return;
159 }
160
161 /*
162 * if(_Parent == null || !back.equals(_Parent.getFrameName())){ _Parent =
163 * FrameIO.LoadFrame(back); _LastItemUsed = null; }
164 */
165
166 if (_Parent == null || !back.equals(_Parent)) { // ByRob: what the heck
167 // is the code doing?
168 // What is it setting
169 // up???????
170 _Parent = back;
171 _LastItemUsed = null;
172 }
173
174 Frame parent = FrameIO.LoadFrame(_Parent); // at this point we have
175 // a parent frame (but
176 // does LoadFrame access
177 // backup stack?
178
179 // find the next item to visit // ByRob: We should NOT be trying to
180 // remember state!!! at time of Next, getNameOfCurrentFrame!!!!
181 // Actually, no. It could be situation that there is more than one item
182 // on frame linked to CurrentFr
183
184 List<Item> items = parent.getItems(); // getItems method gets us the
185 // FirstItem on the frame
186 int parentItemLinkedToSource = 0; // ByMike: Will be set to the
187 // index of the item on the parent which follows the item linked to the
188 // child frame we are currently viewing.
189
190 // ByMike: if 'Next' has been clicked previously get the index of the
191 // item FOLLOWING the ParentItem linked to the source
192 if (_LastItemUsed != null) {
193 parentItemLinkedToSource = items.indexOf(_LastItemUsed);
194 }
195
196 // ByMike: If the 'Next' child is being sought for the 1st time...
197
198 String sourceName = source.getFrameName().toLowerCase();
199
200 // ByMike: Find the first occurence of a ParentItem linked to the source
201 while (parentItemLinkedToSource < items.size()
202 && (items.get(parentItemLinkedToSource).getLink() == null || !items
203 .get(parentItemLinkedToSource).getLink().toLowerCase()
204 .equals(sourceName))) {
205 parentItemLinkedToSource++; // ByRob: this increments to the next
206 // item
207 }
208
209 // Find the next ParentItem linked to the next frame to be displayed
210 for (int i = parentItemLinkedToSource + 1; i < items.size(); i++) {
211 if (items.get(i).isLinkValid()
212 && !items.get(i).isAnnotation()
213 && !items.get(i).getLink().toLowerCase().equals(
214 source.getFrameName().toLowerCase())) {
215 _LastItemUsed = items.get(i);
216 FrameUtils.DisplayFrame(_LastItemUsed.getLink(), false);
217 return;
218 } // ByRob: end of if
219
220 } // ByRob: End of For
221
222 FrameGraphics.DisplayMessage("No more child frames found.");
223 }
224
225 public static void OtherWindow() {
226 Default();
227 }
228
229 /**
230 * Turns TwinFrames on if it is off, otherwise does nothing
231 *
232 */
233 // ByRob: Rob doesn't like notion of turning TwinFrames on and off,
234 // better to say more explicitly/directly what the mode is!!!!
235 public static void Small() {
236 if (!DisplayIO.isTwinFramesOn())
237 DisplayIO.ToggleTwinFrames();
238 }
239}
Note: See TracBrowser for help on using the repository browser.