source: other-projects/GlamED/trunk/src/org/honours/actions/MiscActions.java@ 26702

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

removing some unnecessary lines of code, mainly debug statements.

File size: 4.6 KB
Line 
1package org.honours.actions;
2
3import java.awt.Color;
4
5import org.expeditee.actions.Actions;
6import org.expeditee.actions.Misc;
7import org.expeditee.gui.DisplayIO;
8import org.expeditee.gui.Frame;
9import org.expeditee.gui.FrameIO;
10import org.expeditee.gui.FrameKeyboardActions;
11import org.expeditee.gui.MessageBay;
12import org.expeditee.items.Text;
13import org.honours.Main;
14import org.honours.collection.Collection;
15import org.honours.collection.CollectionItem;
16import org.honours.collection.NoteLayer;
17import org.honours.gui.HonoursFrameIO;
18import org.honours.gui.Interfaces;
19
20public class MiscActions {
21
22 /**
23 * Copy items on a frame which
24 * can be pasted on another frame.
25 */
26 public static void CopyFrame(){
27 HonoursFrameIO.CopyFrame();
28 }
29
30 /**
31 * Paste a copied frame on to
32 * the current frame being displayed.
33 */
34 public static void PasteFrame(){
35 HonoursFrameIO.PasteFrame();
36 }
37
38 /**
39 * Toggle toolbar on and off.
40 */
41 public static void ToggleToolbar(){
42
43 HonoursFrameIO.ToggleToolbar();
44 }
45
46 /**
47 * Toggle display of toggle toolbar on and off.
48 */
49 public static void ToggleToggler(){
50 HonoursFrameIO.toggleToggler();
51 }
52
53 /**
54 * Toggle display of layers on and off.
55 */
56/* public static void ToggleDisplayLayers(){
57 HonoursFrameIO.ToggleLayersDisplay();
58
59 if(HonoursFrameIO.DISPLAY_LAYERS)
60 MessageBay.displayMessage("Display of layers on");
61 else
62 MessageBay.displayMessage("Display of layers off");
63 }*/
64
65
66 ///////////
67
68 public static void AddNewNote(){
69 System.err.println("REACHED");
70 AddNewNote(DisplayIO.getCurrentFrame());
71 Actions.PerformActionCatchErrors(DisplayIO.getCurrentFrame(), null, "Format");
72 }
73
74 public static void AddNewNote(Frame frame){
75 Collection collect = Collection.findCollection(frame);
76
77 if(collect != null){
78 CollectionItem cItem = CollectionItem.findCollectionItem(frame, collect);
79 if(cItem != null)
80 AddNewNote(cItem,collect);
81 }
82 }
83
84 /**
85 * Add a new note about a collection item which will be displayed
86 * on the item's frame.
87 * @param collectItem
88 * @param collect
89 */
90 public static void AddNewNote(CollectionItem collectItem, Collection collect){
91
92 System.err.println("Adding new note...");
93 NoteLayer noteLayer = null;
94
95 //Check if collectionItem has a notelayer.
96 if(collectItem.getNoteLayer() != null){
97 noteLayer = collectItem.getNoteLayer();
98
99 }else{
100 //Create a new note layer.
101 noteLayer = new NoteLayer();
102 noteLayer.setAssociatedItem(collectItem);
103
104 //Create a new frame and set noteLayer's frame attribute.
105 int frameNumber = FrameIO.getLastNumber("notesmain") + 1;
106 HonoursFrameIO.generateFrame(frameNumber, "notesmain");
107 Frame layerFrame = FrameIO.LoadFrame("notesmain"+frameNumber);
108 noteLayer.setFrame(layerFrame);
109 noteLayer.setAssociatedItem(collectItem);
110
111 collectItem.setNoteLayer(noteLayer);
112
113 //now put collectItem back in collection list.
114 int itemIndex = CollectionItem.getPositionInCollection(collectItem, collect);
115 collect.getItems().remove(itemIndex);
116 collect.getItems().add(itemIndex, collectItem);
117
118 //put collection back in collection list.
119 int collectIndex = Collection.getCollectionPosition(collect);
120 Main._collections.remove(collectIndex);
121 Main._collections.add(collectIndex,collect);
122 }
123
124 //debugging
125 System.err.println("*** link (in AddNewNote): " + noteLayer.getFrame().getName());
126
127 //Add new text item to noteLayer's frame in a free space - for now
128 //just add at position (200,200) and hope that any other note has been moved since.
129 Text noteText = noteLayer.getFrame().addText(200, 200, "@[Insert note here]", null);
130 noteText.setBackgroundColor(Color.LIGHT_GRAY);
131 noteText.setColor(Color.BLACK);
132 noteText.setBorderColor(Color.BLACK);
133 noteText.setThickness(1);
134 noteLayer.getFrame().setSaved();
135 FrameKeyboardActions.Refresh();
136
137 HonoursFrameIO.DISPLAY_NOTES = false;
138 Text displayText = (Text)Misc.getItemContainingData("OptionViewNotes",FrameIO.LoadFrame(Interfaces.NAVIGATION_OVERLAY));
139 displayText.setText("Hide Notes");
140
141 HonoursFrameIO.ToggleNotesDisplay(collectItem);
142 }
143
144
145 public static void ToggleNotesView(){
146 ToggleNotesView(DisplayIO.getCurrentFrame());
147 }
148
149
150 /**
151 * Toggle the display of notes for a collection item on and off.
152 * @param frame
153 */
154 public static void ToggleNotesView(Frame frame){
155 Collection collect = Collection.findCollection(frame);
156 if(collect != null){
157 CollectionItem cItem = CollectionItem.findCollectionItem(frame, collect);
158 if(cItem != null)
159 HonoursFrameIO.ToggleNotesDisplay(cItem);
160 }
161 }
162
163
164}
Note: See TracBrowser for help on using the repository browser.