source: other-projects/GlamED/trunk/src/org/honours/gui/Interfaces.java@ 26588

Last change on this file since 26588 was 26588, checked in by davidb, 11 years ago

Initial import of Korii's 520 project for managing digital cultural collections from Greenstone in Expeditee.

File size: 6.1 KB
Line 
1package org.honours.gui;
2
3import java.util.List;
4
5import org.expeditee.gui.*;
6import org.expeditee.items.Text;
7
8import org.honours.Main;
9import org.honours.collection.*;
10
11/**
12 * This class is used for displaying the
13 * various different overlays/interfaces available.
14 * @author Korii
15 */
16public class Interfaces {
17
18 //various frame names for the different interface overlays.
19 public static final String MAIN_INTERFACE_OVERLAY = "interface-overlays1";
20 public static final String NAVIGATION_OVERLAY = "interface-overlays2";
21 public static final String LAYERS_BACK_BTN_OVERLAY = "interface-overlays3";
22 public static final String TOGGLE_TOOLS_OVERLAY = "interface-overlays4";
23 //public static final String DISPLAY_LAYERS_OVERLAY = "interface-overlays5";
24 public static final String BLANK_TOOLBAR_OVERLAY = "interface-overlays6";
25 //public static final String BLANK_DISPLAY_LAYERS_OVERLAY = "interface-overlays7";
26
27 //TODO: Overlay for hiding notes.
28 public static final String BLANK_HIDE_NOTES_OVERLAY = "interface-overlays9";
29
30 public static final String BLANK_TOGGLER_OVERLAY = "interface-overlays10";
31
32 private static final String AO_TEXT3 = "@ao:3";
33 private static final String _aoText4 = "@ao:4";
34
35 //used to determine positioning of the various @ao:3/4 text items.
36 private static int _mainOverAoX = 3;
37 private static int _mainOverAoY = 10;
38
39 private static int _toolbarAoX = 1272;
40 private static int _toolbarAoY = 130;
41
42 private static int _toggleAoX = 1272;
43 private static int _toggleAoY = 94;
44
45 private static int _notesAoX = 1272;
46 private static int _notesAoY = 58;
47
48 private static String _overlayAnnotationData = "overlay-annotation";
49
50
51 /**
52 * This method sets up the main overlay on the profile
53 * frame.
54 * @param frame - frame to add the main overlay too.
55 */
56 public static void setUpMainOverlay(Frame frame){
57
58 List<Text> list = frame.getBodyTextItems(true);
59
60 boolean found = false;
61 int i = 0;
62
63 while(i < list.size() && !found){
64
65 Text text = list.get(i);
66
67 if(text.getText().equals(AO_TEXT3)){
68 if(text.hasLink()){
69 if(text.getLink().equals(MAIN_INTERFACE_OVERLAY)){
70 found = true;
71 }
72
73 }
74 }
75 i++;
76 }
77
78 if(!found){
79 Text t = frame.addText(_mainOverAoX,_mainOverAoY,AO_TEXT3,null);
80 t.setLink(MAIN_INTERFACE_OVERLAY);
81
82 frame.setSaved();
83 frame.setChanged(true);
84 }
85
86 FrameKeyboardActions.Refresh();
87 }
88
89
90 /**
91 * Set up overlay which displays toolbar for collection items.
92 * @param cItem - the collection item to add the toolbar to (or rather its represented frame).
93 */
94 public static void setUpToolbarOverlay(CollectionItem cItem) {
95
96 Frame ciFrame = cItem.getFrame();
97 List<Text> list = ciFrame.getBodyTextItems(true);
98
99 boolean found = false;
100 int i = 0;
101
102 while(i < list.size() && !found){
103
104 Text t = list.get(i);
105
106 if(t.getText().equals(AO_TEXT3)){
107
108 if(t.hasLink()){
109 if(t.getLink().equals(NAVIGATION_OVERLAY)){
110 found = true;
111 }
112 }
113 }
114
115 i++;
116 }
117
118 if(!found){
119
120 Text newText = ciFrame.addText(_toolbarAoX,_toolbarAoY,AO_TEXT3,null);
121 newText.setLink(NAVIGATION_OVERLAY);
122 }
123
124
125 }
126
127 /**
128 * Method to set up overlay which displays a "toggle toolbar" option/button.
129 * @param cItem - the collection item to add the toggle toolbar option to.
130 */
131 public static void setUpToggleToolbarOverlay(CollectionItem cItem) {
132 Frame ciFrame = cItem.getFrame();
133 List<Text> list = ciFrame.getBodyTextItems(true);
134
135 boolean found = false;
136 int i = 0;
137
138 while(i < list.size() && !found){
139
140 Text t = list.get(i);
141
142 if(t.getText().equals(AO_TEXT3)){
143
144 if(t.hasLink()){
145
146 if(t.getLink().equals(TOGGLE_TOOLS_OVERLAY)){
147 found = true;
148 }
149 }
150 }
151 i++;
152 }
153
154 if(!found){
155 Text newText = ciFrame.addText(_toggleAoX,_toggleAoY,AO_TEXT3,null);
156 newText.setLink(TOGGLE_TOOLS_OVERLAY);
157 }
158
159 }
160
161 /**
162 * Method to set up an overlay for displaying notes for
163 * the passed collection item.
164 * @param cItem - collection item to add notes to.
165 */
166 public static void setUpNotesOverlay(CollectionItem cItem) {
167
168 Frame ciFrame = cItem.getFrame();
169 List<Text> list = ciFrame.getBodyTextItems(true);
170
171 boolean found = false;
172 int i = 0;
173
174 while(i < list.size() && !found){
175
176 Text t = list.get(i);
177
178 if(t.getText().equals(_aoText4)){
179
180 if(t.hasLink()){
181
182 if(t.getLink().startsWith("notes")){
183 found = true;
184 }
185
186 }
187 }
188
189 i++;
190 }
191
192 if(!found){
193
194 //check for an overlay frame in notes frameset associated with this collection item.
195 NoteLayer getNoteLayer = cItem.getNoteLayer();
196 Frame getNotesOverlayFrame = null;
197
198 if(getNoteLayer == null){
199
200 //Create a new notelayer and frame
201 getNoteLayer = new NoteLayer();
202 getNoteLayer.setAssociatedItem(cItem);
203
204 //Create new frame.
205 int frameNumber = FrameIO.getLastNumber("notesmain") + 1;
206 HonoursFrameIO.generateFrame(frameNumber, "notesmain");
207 getNotesOverlayFrame = FrameIO.LoadFrame("notesmain"+frameNumber);
208 getNoteLayer.setFrame(FrameIO.LoadFrame(getNotesOverlayFrame.getName()));
209 cItem.setNoteLayer(getNoteLayer);
210
211 //Add collectionItem back into collection
212 //Add collection back into collections list
213 Collection matchingCollection = Collection.findCollection(cItem.getFrame());
214 int collectionIndex = Collection.getCollectionPosition(matchingCollection);
215 int collectionItemPosition = CollectionItem.getPositionInCollection(cItem, matchingCollection);
216
217 matchingCollection.getItems().remove(collectionItemPosition);
218 matchingCollection.getItems().add(collectionItemPosition,cItem);
219
220 Main._collections.remove(collectionIndex);
221 Main._collections.add(collectionIndex, matchingCollection);
222 }else{
223 getNotesOverlayFrame = getNoteLayer.getFrame();
224 }
225
226 Text newText = ciFrame.addText(_notesAoX,_notesAoY,_aoText4,null);
227 newText.setLink(getNotesOverlayFrame.getName());
228 }
229 }
230
231}
Note: See TracBrowser for help on using the repository browser.