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

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

Removed unnecessary print 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
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 NoteLayer noteLayer = null;
93
94 //Check if collectionItem has a notelayer.
95 if(collectItem.getNoteLayer() != null){
96 noteLayer = collectItem.getNoteLayer();
97
98 }else{
99 //Create a new note layer.
100 noteLayer = new NoteLayer();
101 noteLayer.setAssociatedItem(collectItem);
102
103 //Create a new frame and set noteLayer's frame attribute.
104 int frameNumber = FrameIO.getLastNumber("notesmain") + 1;
105 HonoursFrameIO.generateFrame(frameNumber, "notesmain");
106 Frame layerFrame = FrameIO.LoadFrame("notesmain"+frameNumber);
107 noteLayer.setFrame(layerFrame);
108 noteLayer.setAssociatedItem(collectItem);
109
110 collectItem.setNoteLayer(noteLayer);
111
112 //now put collectItem back in collection list.
113 int itemIndex = CollectionItem.getPositionInCollection(collectItem, collect);
114 collect.getItems().remove(itemIndex);
115 collect.getItems().add(itemIndex, collectItem);
116
117 //put collection back in collection list.
118 int collectIndex = Collection.getCollectionPosition(collect);
119 Main._collections.remove(collectIndex);
120 Main._collections.add(collectIndex,collect);
121 }
122
123 //debugging
124 //System.err.println("*** link (in AddNewNote): " + noteLayer.getFrame().getName());
125
126 //Add new text item to noteLayer's frame in a free space - for now
127 //just add at position (200,200) and hope that any other note has been moved since.
128 Text noteText = noteLayer.getFrame().addText(200, 200, "@[Insert note here]", null);
129 noteText.setBackgroundColor(Color.LIGHT_GRAY);
130 noteText.setColor(Color.BLACK);
131 noteText.setBorderColor(Color.BLACK);
132 noteText.setThickness(1);
133 noteLayer.getFrame().setSaved();
134 FrameKeyboardActions.Refresh();
135
136 HonoursFrameIO.DISPLAY_NOTES = false;
137 Text displayText = (Text)Misc.getItemContainingData("OptionViewNotes",FrameIO.LoadFrame(Interfaces.NAVIGATION_OVERLAY_VIEW_NOTES_CLICKABLE));
138 displayText.setText("Hide Notes");
139
140
141
142 HonoursFrameIO.ToggleNotesDisplay(collectItem);
143 }
144
145
146 public static void ToggleNotesView(){
147 ToggleNotesView(DisplayIO.getCurrentFrame());
148 }
149
150
151 /**
152 * Toggle the display of notes for a collection item on and off.
153 * @param frame
154 */
155 public static void ToggleNotesView(Frame frame){
156 Collection collect = Collection.findCollection(frame);
157 if(collect != null){
158 CollectionItem cItem = CollectionItem.findCollectionItem(frame, collect);
159 if(cItem != null)
160 HonoursFrameIO.ToggleNotesDisplay(cItem);
161 }
162 }
163
164
165}
Note: See TracBrowser for help on using the repository browser.