1 | package org.honours.actions;
|
---|
2 |
|
---|
3 | import java.util.ArrayList;
|
---|
4 | import java.util.List;
|
---|
5 |
|
---|
6 | import org.expeditee.gui.*;
|
---|
7 | import org.expeditee.items.Dot;
|
---|
8 | import org.expeditee.items.Item;
|
---|
9 | import org.expeditee.items.ItemParentStateChangedEvent;
|
---|
10 | import org.expeditee.items.Line;
|
---|
11 | import org.expeditee.items.Picture;
|
---|
12 | import org.expeditee.items.Text;
|
---|
13 | import org.honours.collection.Collection;
|
---|
14 | import org.honours.collection.CollectionItem;
|
---|
15 | import org.honours.items.Data;
|
---|
16 |
|
---|
17 | /**
|
---|
18 | * When editing the display of the current frame in
|
---|
19 | * a collection set, change all the other frames so they
|
---|
20 | * look the same.
|
---|
21 | * @author Korii
|
---|
22 | */
|
---|
23 | public class ApplyDisplayToCollection {
|
---|
24 |
|
---|
25 | /*the manually changed frame which we compare
|
---|
26 | with all the other frames in the frameset.*/
|
---|
27 | private static Frame _comparisonFrame;
|
---|
28 | private static List<Item> _comparisonFrameItems; //items on the comparison frame.
|
---|
29 |
|
---|
30 | private static Collection _collection;
|
---|
31 |
|
---|
32 | /**
|
---|
33 | * Updates all frames based on the current frame being viewed.
|
---|
34 | */
|
---|
35 | public static void updateAllFrames(){
|
---|
36 | updateAllFrames(DisplayIO.getCurrentFrame());
|
---|
37 | }
|
---|
38 |
|
---|
39 | /**
|
---|
40 | * Updates all frames based on the passed frame.
|
---|
41 | * @param frame - the frame used to change the display of
|
---|
42 | * the other frames in the same frameset.
|
---|
43 | */
|
---|
44 | public static void updateAllFrames(Frame frame){
|
---|
45 |
|
---|
46 | if(frame == null){
|
---|
47 | MessageBay.errorMessage("ERROR: Can't update display. Item cannot be found.");
|
---|
48 | return;
|
---|
49 | }
|
---|
50 |
|
---|
51 | _comparisonFrame = frame;
|
---|
52 |
|
---|
53 | _comparisonFrameItems = _comparisonFrame.getItems();
|
---|
54 |
|
---|
55 | //Find matching collection.
|
---|
56 | _collection = Collection.findCollection(_comparisonFrame);
|
---|
57 |
|
---|
58 | for(CollectionItem ci : _collection.getItems()){
|
---|
59 | Frame currCiFrame = ci.getFrame();
|
---|
60 | if(currCiFrame == DisplayIO.getCurrentFrame())
|
---|
61 | continue;
|
---|
62 |
|
---|
63 | MessageBay.displayMessage("Updating display of: " + currCiFrame.getName());
|
---|
64 | changeItemDisplay(ci,currCiFrame);
|
---|
65 | }
|
---|
66 |
|
---|
67 | }
|
---|
68 |
|
---|
69 | /**
|
---|
70 | * Change the passed Collection Item's display.
|
---|
71 | * @param ci - the collection item, whose display we want to change.
|
---|
72 | * @param frame - the collection item's frame representation.
|
---|
73 | */
|
---|
74 | private static void changeItemDisplay(CollectionItem ci, Frame frame){
|
---|
75 |
|
---|
76 | List<Item> list = frame.getItems(true);
|
---|
77 | List<Item> saved = new ArrayList<Item>();
|
---|
78 | }
|
---|
79 |
|
---|
80 | }
|
---|