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

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

Removed method for toggling the display of the "View/Hide Toolbar" option - this is now automatically done when the user enters Audience Mode.

File size: 4.4 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 public static void AddNewNote(){
47
48 AddNewNote(DisplayIO.getCurrentFrame());
49 Actions.PerformActionCatchErrors(DisplayIO.getCurrentFrame(), null, "Format");
50 }
51
52 public static void AddNewNote(Frame frame){
53 Collection collect = Collection.findCollection(frame);
54
55 if(collect != null){
56 CollectionItem cItem = CollectionItem.findCollectionItem(frame, collect);
57 if(cItem != null)
58 AddNewNote(cItem,collect);
59 }
60 }
61
62 /**
63 * Add a new note about a collection item which will be displayed
64 * on the item's frame.
65 * @param collectItem
66 * @param collect
67 */
68 public static void AddNewNote(CollectionItem collectItem, Collection collect){
69
70 NoteLayer noteLayer = null;
71
72 //Check if collectionItem has a notelayer.
73 if(collectItem.getNoteLayer() != null){
74 noteLayer = collectItem.getNoteLayer();
75
76 }else{
77 //Create a new note layer.
78 noteLayer = new NoteLayer();
79 noteLayer.setAssociatedItem(collectItem);
80
81 //Create a new frame and set noteLayer's frame attribute.
82 int frameNumber = FrameIO.getLastNumber("notesmain") + 1;
83 HonoursFrameIO.generateFrame(frameNumber, "notesmain");
84 Frame layerFrame = FrameIO.LoadFrame("notesmain"+frameNumber);
85 noteLayer.setFrame(layerFrame);
86 noteLayer.setAssociatedItem(collectItem);
87
88 collectItem.setNoteLayer(noteLayer);
89
90 //now put collectItem back in collection list.
91 int itemIndex = CollectionItem.getPositionInCollection(collectItem, collect);
92 collect.getItems().remove(itemIndex);
93 collect.getItems().add(itemIndex, collectItem);
94
95 //put collection back in collection list.
96 int collectIndex = Collection.getCollectionPosition(collect);
97 Main._collections.remove(collectIndex);
98 Main._collections.add(collectIndex,collect);
99 }
100
101 //debugging
102 //System.err.println("*** link (in AddNewNote): " + noteLayer.getFrame().getName());
103
104 //Add new text item to noteLayer's frame in a free space - for now
105 //just add at position (200,200) and hope that any other note has been moved since.
106 Text noteText = noteLayer.getFrame().addText(200, 200, "@[Insert note here]", null);
107 noteText.setBackgroundColor(Color.LIGHT_GRAY);
108 noteText.setColor(Color.BLACK);
109 noteText.setBorderColor(Color.BLACK);
110 noteText.setThickness(1);
111 noteLayer.getFrame().setSaved();
112 FrameKeyboardActions.Refresh();
113
114 HonoursFrameIO.DISPLAY_NOTES = false;
115 Text displayText = (Text)Misc.getItemContainingData("OptionViewNotes",FrameIO.LoadFrame(Interfaces.NAVIGATION_OVERLAY_VIEW_NOTES_CLICKABLE));
116 displayText.setText("Hide Notes");
117
118 Text overlayLink = (Text)Misc.getItemContainingData(Interfaces.OVERLAY_TOOLBAR_DATA, DisplayIO.getCurrentFrame());
119
120 if(!overlayLink.getLink().equals(Interfaces.NAVIGATION_OVERLAY_VIEW_NOTES_CLICKABLE))
121 overlayLink.setLink(Interfaces.NAVIGATION_OVERLAY_VIEW_NOTES_CLICKABLE);
122
123 HonoursFrameIO.ToggleNotesDisplay(collectItem);
124 }
125
126
127 public static void ToggleNotesView(){
128 ToggleNotesView(DisplayIO.getCurrentFrame());
129 }
130
131
132 /**
133 * Toggle the display of notes for a collection item on and off.
134 * @param frame
135 */
136 public static void ToggleNotesView(Frame frame){
137 Collection collect = Collection.findCollection(frame);
138 if(collect != null){
139 CollectionItem cItem = CollectionItem.findCollectionItem(frame, collect);
140 if(cItem != null)
141 HonoursFrameIO.ToggleNotesDisplay(cItem);
142 }
143 }
144
145
146}
Note: See TracBrowser for help on using the repository browser.