[26588] | 1 | package org.honours.actions;
|
---|
| 2 |
|
---|
| 3 | import java.awt.Color;
|
---|
| 4 | import java.util.List;
|
---|
| 5 |
|
---|
| 6 | import org.expeditee.actions.Navigation;
|
---|
| 7 | import org.expeditee.gui.DisplayIO;
|
---|
| 8 | import org.expeditee.gui.Frame;
|
---|
| 9 | import org.expeditee.gui.FrameIO;
|
---|
| 10 | import org.expeditee.gui.MessageBay;
|
---|
| 11 | import org.honours.agents.CollectionToGreenstone;
|
---|
| 12 | import org.honours.collection.*;
|
---|
| 13 |
|
---|
| 14 | public class CollectionNavigation {
|
---|
| 15 |
|
---|
| 16 | //TODO: Change these actions so that we
|
---|
| 17 | //account for content layers.
|
---|
| 18 | public static void Previous(Frame frame)
|
---|
| 19 | {
|
---|
| 20 | String frameSetName = frame.getFramesetName();
|
---|
| 21 | int frameNum= frame.getNumber();
|
---|
| 22 |
|
---|
| 23 | int lastInFrame = FrameIO.getLastNumber(frameSetName);
|
---|
| 24 | if(frameNum == 1){
|
---|
| 25 | Navigation.Goto(frameSetName+lastInFrame);
|
---|
| 26 | }else{
|
---|
| 27 | frameNum--;
|
---|
| 28 | Navigation.Goto(frameSetName + frameNum);
|
---|
| 29 |
|
---|
| 30 | }
|
---|
| 31 | }
|
---|
| 32 |
|
---|
| 33 | public static void PreviousItem(){
|
---|
| 34 | PreviousItem(DisplayIO.getCurrentFrame());
|
---|
| 35 | }
|
---|
| 36 |
|
---|
| 37 | public static void NextItem(){
|
---|
| 38 | NextItem(DisplayIO.getCurrentFrame());
|
---|
| 39 | }
|
---|
| 40 |
|
---|
| 41 | public static void NextItem(Frame frame){
|
---|
| 42 |
|
---|
| 43 | System.err.println("Reached Next Item....");
|
---|
| 44 | Collection collection = Collection.findCollection(frame);
|
---|
| 45 | System.err.println("Collection is: " + collection.getName());
|
---|
| 46 |
|
---|
| 47 | if(collection != null){
|
---|
| 48 | List<CollectionItem> lci = collection.getItems();
|
---|
| 49 | boolean hit = false;
|
---|
| 50 | int i = 0;
|
---|
| 51 | CollectionItem navigateTo = null;
|
---|
| 52 |
|
---|
| 53 | while(i < lci.size() && !hit){
|
---|
| 54 | CollectionItem ci = lci.get(i);
|
---|
| 55 |
|
---|
| 56 | /*if(ci.getFrame() == frame){
|
---|
| 57 |
|
---|
| 58 | if(i == lci.size()-1){
|
---|
| 59 | navigateTo = lci.get(0);
|
---|
| 60 | }else{
|
---|
| 61 | navigateTo = lci.get(i+1);
|
---|
| 62 | }
|
---|
| 63 | hit = true;
|
---|
| 64 | }*/
|
---|
| 65 | if(ci.getFrame().getName().equals(frame.getName())){
|
---|
| 66 |
|
---|
| 67 | if(i == lci.size() -1){
|
---|
| 68 | navigateTo = lci.get(0);
|
---|
| 69 | }else{
|
---|
| 70 | navigateTo = lci.get(i+1);
|
---|
| 71 | }
|
---|
| 72 | hit = true;
|
---|
| 73 | }
|
---|
| 74 | i++;
|
---|
| 75 | }
|
---|
| 76 |
|
---|
| 77 | if(hit){
|
---|
| 78 | Navigation.Goto(navigateTo.getFrame().getName());
|
---|
| 79 | }
|
---|
| 80 | }
|
---|
| 81 | }
|
---|
| 82 |
|
---|
| 83 |
|
---|
| 84 | /**
|
---|
| 85 | * Just like Previous() method above but
|
---|
| 86 | * we navigate to the previous CollectionItem (as
|
---|
| 87 | * opposed to the previous frame).
|
---|
| 88 | * @param frame
|
---|
| 89 | */
|
---|
| 90 | public static void PreviousItem(Frame frame){
|
---|
| 91 |
|
---|
| 92 | Collection collection = Collection.findCollection(frame);
|
---|
| 93 |
|
---|
| 94 | if(collection != null){
|
---|
| 95 |
|
---|
| 96 | List<CollectionItem> lci = collection.getItems();
|
---|
| 97 | boolean hit = false;
|
---|
| 98 | int i = 0;
|
---|
| 99 | CollectionItem navigateTo = null;
|
---|
| 100 |
|
---|
| 101 | while(i < lci.size() && !hit){
|
---|
| 102 |
|
---|
| 103 | CollectionItem ci = lci.get(i);
|
---|
| 104 |
|
---|
| 105 | if(ci.getFrame().getName().equals(frame.getName()))
|
---|
| 106 | {
|
---|
| 107 | if(i == 0)
|
---|
| 108 | navigateTo = lci.get(lci.size()-1);
|
---|
| 109 | else
|
---|
| 110 | navigateTo = lci.get(i-1);
|
---|
| 111 |
|
---|
| 112 | hit = true;
|
---|
| 113 | }
|
---|
| 114 |
|
---|
| 115 | i++;
|
---|
| 116 | }
|
---|
| 117 |
|
---|
| 118 | if(hit){
|
---|
| 119 | Navigation.Goto(navigateTo.getFrame().getName());
|
---|
| 120 | }
|
---|
| 121 |
|
---|
| 122 | }else{
|
---|
| 123 | MessageBay.errorMessage("ERROR: Collection can't be found");
|
---|
| 124 | return;
|
---|
| 125 | }
|
---|
| 126 | }
|
---|
| 127 |
|
---|
| 128 | /**
|
---|
| 129 | * Navigate to next frame visited in collection space.
|
---|
| 130 | * @param frame
|
---|
| 131 | */
|
---|
| 132 | public static void Next(Frame frame){
|
---|
| 133 |
|
---|
| 134 | String frameSetName = frame.getFramesetName();
|
---|
| 135 | int frameNum = frame.getNumber();
|
---|
| 136 |
|
---|
| 137 | int lastInFrame = FrameIO.getLastNumber(frameSetName);
|
---|
| 138 |
|
---|
| 139 | if(frameNum == lastInFrame){
|
---|
| 140 | Navigation.Goto(frameSetName+"1");
|
---|
| 141 | }else{
|
---|
| 142 | frameNum++;
|
---|
| 143 | Navigation.Goto(frameSetName+frameNum);
|
---|
| 144 | }
|
---|
| 145 | }
|
---|
| 146 |
|
---|
| 147 | public static void NextInCollection(){
|
---|
| 148 | Next(DisplayIO.getCurrentFrame());
|
---|
| 149 | }
|
---|
| 150 |
|
---|
| 151 | public static void PreviousInCollection(){
|
---|
| 152 | Previous(DisplayIO.getCurrentFrame());
|
---|
| 153 | }
|
---|
| 154 |
|
---|
| 155 | /* public static void GoToCollectionSpace(){
|
---|
| 156 | Frame currFrame = DisplayIO.getCurrentFrame();
|
---|
| 157 |
|
---|
| 158 | Collection matchingCollection = Collection.findCollection(currFrame);
|
---|
| 159 | CollectionSpace collectionSpace;
|
---|
| 160 |
|
---|
| 161 |
|
---|
| 162 | //Obtain the collection's collectionSpace.
|
---|
| 163 | if(matchingCollection != null){
|
---|
| 164 | collectionSpace = matchingCollection.getCollectionSpace();
|
---|
| 165 | if(collectionSpace != null){
|
---|
| 166 | Navigation.Goto(collectionSpace.getName());
|
---|
| 167 | return;
|
---|
| 168 | }
|
---|
| 169 | }else{
|
---|
| 170 | return;
|
---|
| 171 | }
|
---|
| 172 |
|
---|
| 173 | //Otherwise need to produce one.
|
---|
| 174 | MessageBay.displayMessage("Now generating new collection space...", Color.blue);
|
---|
| 175 | collectionSpace = new CollectionSpace(matchingCollection);
|
---|
| 176 |
|
---|
| 177 | //TODO:Run generate() method.
|
---|
| 178 | collectionSpace.generate();
|
---|
| 179 | }*/
|
---|
| 180 |
|
---|
| 181 |
|
---|
| 182 | public static void UpdateCollectionAction(){
|
---|
| 183 | org.honours.agents.UpdateCollection uc =
|
---|
| 184 | new org.honours.agents.UpdateCollection();
|
---|
| 185 | uc.process(DisplayIO.getCurrentFrame());
|
---|
| 186 | }
|
---|
| 187 |
|
---|
| 188 | public static void ExportToGreenstoneAction(){
|
---|
| 189 | CollectionToGreenstone ctg = new
|
---|
| 190 | CollectionToGreenstone();
|
---|
| 191 | ctg.process(DisplayIO.getCurrentFrame());
|
---|
| 192 |
|
---|
| 193 | }
|
---|
| 194 |
|
---|
| 195 | /**
|
---|
| 196 | * Used to navigate away from a layer
|
---|
| 197 | * back to the associated item.
|
---|
| 198 | */
|
---|
| 199 | /* public static void BackToItem(){
|
---|
| 200 | BackToItem(DisplayIO.getCurrentFrame());
|
---|
| 201 | }*/
|
---|
| 202 |
|
---|
| 203 | /**
|
---|
| 204 | * Used to navigate back to an item when
|
---|
| 205 | * we are currently viewing a layer of that item.
|
---|
| 206 | * @param frame
|
---|
| 207 | */
|
---|
| 208 | /* public static void BackToItem(Frame frame){
|
---|
| 209 |
|
---|
| 210 | ContentLayer thisLayer = null;
|
---|
| 211 | CollectionItem layerParent = null;
|
---|
| 212 |
|
---|
| 213 | Frame goTo = null;
|
---|
| 214 |
|
---|
| 215 | Collection findCollection = Collection.findCollection(frame.getFramesetName());
|
---|
| 216 |
|
---|
| 217 | if(findCollection != null)
|
---|
| 218 | thisLayer = ContentLayer.findItemLayer(frame,findCollection);
|
---|
| 219 |
|
---|
| 220 | if(thisLayer != null)
|
---|
| 221 | layerParent = thisLayer.getAssociatedItem();
|
---|
| 222 |
|
---|
| 223 | goTo = layerParent.getFrame();
|
---|
| 224 |
|
---|
| 225 | Navigation.Goto(goTo.getName());
|
---|
| 226 | }*/
|
---|
| 227 |
|
---|
| 228 | /////////////////
|
---|
| 229 |
|
---|
| 230 | /**
|
---|
| 231 | * Used to navigate to an image layer frame.
|
---|
| 232 | */
|
---|
| 233 | /* public static void NavigateToImageLayer(){
|
---|
| 234 | NavigateToImageLayer(DisplayIO.getCurrentFrame());
|
---|
| 235 | }*/
|
---|
| 236 |
|
---|
| 237 | /* public static void NavigateToImageLayer(Frame frame){
|
---|
| 238 |
|
---|
| 239 | CollectionItem cItem = null;
|
---|
| 240 | Frame goTo = null;
|
---|
| 241 | Collection findCollection = Collection.findCollection(frame);
|
---|
| 242 | LAYER_TYPE textType = LAYER_TYPE.IMAGE;
|
---|
| 243 |
|
---|
| 244 | if(findCollection != null)
|
---|
| 245 | cItem = CollectionItem.findCollectionItem(frame, findCollection);
|
---|
| 246 |
|
---|
| 247 | if(cItem != null){
|
---|
| 248 | //get layers
|
---|
| 249 | List<ContentLayer> layers = cItem.getLayers();
|
---|
| 250 |
|
---|
| 251 | if(layers.size() > 0)
|
---|
| 252 | for(ContentLayer cl : layers)
|
---|
| 253 | if(cl.getLayerType() == textType)
|
---|
| 254 | goTo = cl.getFrame();
|
---|
| 255 |
|
---|
| 256 | }
|
---|
| 257 |
|
---|
| 258 | if(goTo != null)
|
---|
| 259 | Navigation.Goto(goTo.getName());
|
---|
| 260 | }*/
|
---|
| 261 |
|
---|
| 262 | //////////////////////
|
---|
| 263 |
|
---|
| 264 | /**
|
---|
| 265 | * Used to navigate to a text layer item.
|
---|
| 266 | */
|
---|
| 267 | /* public static void NavigateToTextLayer(){
|
---|
| 268 | NavigateToTextLayer(DisplayIO.getCurrentFrame());
|
---|
| 269 | }*/
|
---|
| 270 |
|
---|
| 271 | /**
|
---|
| 272 | * TODO: REFACTOR this and NavigateToTextLayer() method.
|
---|
| 273 | * @param frame
|
---|
| 274 | */
|
---|
| 275 | /* public static void NavigateToTextLayer(Frame frame){
|
---|
| 276 | CollectionItem cItem = null;
|
---|
| 277 | Frame goTo = null;
|
---|
| 278 | LAYER_TYPE textType = LAYER_TYPE.TEXT;
|
---|
| 279 |
|
---|
| 280 | Collection findCollection = Collection.findCollection(frame);
|
---|
| 281 |
|
---|
| 282 | if(findCollection != null)
|
---|
| 283 | cItem = CollectionItem.findCollectionItem(frame, findCollection);
|
---|
| 284 |
|
---|
| 285 | if(cItem != null){
|
---|
| 286 | //get layers.
|
---|
| 287 | List<ContentLayer> layers = cItem.getLayers();
|
---|
| 288 |
|
---|
| 289 | if(layers.size() > 0){
|
---|
| 290 | for(ContentLayer cl : layers){
|
---|
| 291 |
|
---|
| 292 | if(cl.getLayerType() == textType)
|
---|
| 293 | goTo = cl.getFrame();
|
---|
| 294 | }
|
---|
| 295 | }
|
---|
| 296 | }
|
---|
| 297 |
|
---|
| 298 | if(goTo != null){
|
---|
| 299 | Navigation.Goto(goTo.getName());
|
---|
| 300 | }
|
---|
| 301 | }*/
|
---|
| 302 |
|
---|
| 303 |
|
---|
| 304 |
|
---|
| 305 | }
|
---|