~ubuntu-branches/ubuntu/oneiric/tuxguitar/oneiric

« back to all changes in this revision

Viewing changes to src/org/herac/tuxguitar/gui/actions/ActionContainer.java

  • Committer: Bazaar Package Importer
  • Author(s): Philippe Coval
  • Date: 2008-06-19 00:30:30 UTC
  • mto: (5.1.2 sid)
  • mto: This revision was merged to the branch mainline in revision 3.
  • Revision ID: james.westby@ubuntu.com-20080619003030-h719szrhsngou7c6
Tags: upstream-1.0
ImportĀ upstreamĀ versionĀ 1.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * Created on 18-dic-2005
3
 
 *
4
 
 * TODO To change the template for this generated file go to
5
 
 * Window - Preferences - Java - Code Style - Code Templates
6
 
 */
7
 
package org.herac.tuxguitar.gui.actions;
8
 
 
9
 
import java.util.ArrayList;
10
 
import java.util.HashMap;
11
 
import java.util.Iterator;
12
 
import java.util.List;
13
 
import java.util.Map;
14
 
 
15
 
import org.eclipse.swt.events.TypedEvent;
16
 
import org.herac.tuxguitar.gui.actions.caret.GoDownAction;
17
 
import org.herac.tuxguitar.gui.actions.caret.GoLeftAction;
18
 
import org.herac.tuxguitar.gui.actions.caret.GoRightAction;
19
 
import org.herac.tuxguitar.gui.actions.caret.GoUpAction;
20
 
import org.herac.tuxguitar.gui.actions.composition.ChangeClefAction;
21
 
import org.herac.tuxguitar.gui.actions.composition.ChangeInfoAction;
22
 
import org.herac.tuxguitar.gui.actions.composition.ChangeKeySignatureAction;
23
 
import org.herac.tuxguitar.gui.actions.composition.ChangeTempoAction;
24
 
import org.herac.tuxguitar.gui.actions.composition.ChangeTimeSignatureAction;
25
 
import org.herac.tuxguitar.gui.actions.composition.ChangeTripletFeelAction;
26
 
import org.herac.tuxguitar.gui.actions.dispose.DisposeAction;
27
 
import org.herac.tuxguitar.gui.actions.duration.ChangeDottedDurationAction;
28
 
import org.herac.tuxguitar.gui.actions.duration.ChangeDoubleDottedDurationAction;
29
 
import org.herac.tuxguitar.gui.actions.duration.ChangeTupletoDurationAction;
30
 
import org.herac.tuxguitar.gui.actions.duration.DecrementDurationAction;
31
 
import org.herac.tuxguitar.gui.actions.duration.IncrementDurationAction;
32
 
import org.herac.tuxguitar.gui.actions.duration.SetEighthDurationAction;
33
 
import org.herac.tuxguitar.gui.actions.duration.SetHalfDurationAction;
34
 
import org.herac.tuxguitar.gui.actions.duration.SetQuarterDurationAction;
35
 
import org.herac.tuxguitar.gui.actions.duration.SetSixteenthDurationAction;
36
 
import org.herac.tuxguitar.gui.actions.duration.SetSixtyFourthDurationAction;
37
 
import org.herac.tuxguitar.gui.actions.duration.SetThirtySecondDurationAction;
38
 
import org.herac.tuxguitar.gui.actions.duration.SetWholeDurationAction;
39
 
import org.herac.tuxguitar.gui.actions.edit.RedoAction;
40
 
import org.herac.tuxguitar.gui.actions.edit.SetMouseModeEditionAction;
41
 
import org.herac.tuxguitar.gui.actions.edit.SetMouseModeSelectionAction;
42
 
import org.herac.tuxguitar.gui.actions.edit.SetNaturalKeyAction;
43
 
import org.herac.tuxguitar.gui.actions.edit.UndoAction;
44
 
import org.herac.tuxguitar.gui.actions.effects.ChangeAccentuatedNoteAction;
45
 
import org.herac.tuxguitar.gui.actions.effects.ChangeBendNoteAction;
46
 
import org.herac.tuxguitar.gui.actions.effects.ChangeDeadNoteAction;
47
 
import org.herac.tuxguitar.gui.actions.effects.ChangeFadeInAction;
48
 
import org.herac.tuxguitar.gui.actions.effects.ChangeGhostNoteAction;
49
 
import org.herac.tuxguitar.gui.actions.effects.ChangeGraceNoteAction;
50
 
import org.herac.tuxguitar.gui.actions.effects.ChangeHammerNoteAction;
51
 
import org.herac.tuxguitar.gui.actions.effects.ChangeHarmonicNoteAction;
52
 
import org.herac.tuxguitar.gui.actions.effects.ChangeHeavyAccentuatedNoteAction;
53
 
import org.herac.tuxguitar.gui.actions.effects.ChangePalmMuteAction;
54
 
import org.herac.tuxguitar.gui.actions.effects.ChangePoppingAction;
55
 
import org.herac.tuxguitar.gui.actions.effects.ChangeSlappingAction;
56
 
import org.herac.tuxguitar.gui.actions.effects.ChangeSlideNoteAction;
57
 
import org.herac.tuxguitar.gui.actions.effects.ChangeStaccatoAction;
58
 
import org.herac.tuxguitar.gui.actions.effects.ChangeTappingAction;
59
 
import org.herac.tuxguitar.gui.actions.effects.ChangeTremoloBarAction;
60
 
import org.herac.tuxguitar.gui.actions.effects.ChangeTremoloPickingAction;
61
 
import org.herac.tuxguitar.gui.actions.effects.ChangeTrillNoteAction;
62
 
import org.herac.tuxguitar.gui.actions.effects.ChangeVibratoNoteAction;
63
 
import org.herac.tuxguitar.gui.actions.file.ExportASCIIAction;
64
 
import org.herac.tuxguitar.gui.actions.file.ExportMidiAction;
65
 
import org.herac.tuxguitar.gui.actions.file.ExportPDFAction;
66
 
import org.herac.tuxguitar.gui.actions.file.ImportMidiAction;
67
 
import org.herac.tuxguitar.gui.actions.file.NewFileAction;
68
 
import org.herac.tuxguitar.gui.actions.file.OpenFileAction;
69
 
import org.herac.tuxguitar.gui.actions.file.PrintAction;
70
 
import org.herac.tuxguitar.gui.actions.file.PrintPreviewAction;
71
 
import org.herac.tuxguitar.gui.actions.file.SaveAsFileAction;
72
 
import org.herac.tuxguitar.gui.actions.file.SaveFileAction;
73
 
import org.herac.tuxguitar.gui.actions.help.ShowAboutDialogAction;
74
 
import org.herac.tuxguitar.gui.actions.insert.CloseRepeatAction;
75
 
import org.herac.tuxguitar.gui.actions.insert.InsertChordAction;
76
 
import org.herac.tuxguitar.gui.actions.insert.OpenRepeatAction;
77
 
import org.herac.tuxguitar.gui.actions.layout.SetLinearLayoutAction;
78
 
import org.herac.tuxguitar.gui.actions.layout.SetMultitrackViewAction;
79
 
import org.herac.tuxguitar.gui.actions.layout.SetPageLayoutAction;
80
 
import org.herac.tuxguitar.gui.actions.layout.SetScoreEnabledAction;
81
 
import org.herac.tuxguitar.gui.actions.marker.AddMarkerAction;
82
 
import org.herac.tuxguitar.gui.actions.marker.GoFirstMarkerAction;
83
 
import org.herac.tuxguitar.gui.actions.marker.GoLastMarkerAction;
84
 
import org.herac.tuxguitar.gui.actions.marker.GoNextMarkerAction;
85
 
import org.herac.tuxguitar.gui.actions.marker.GoPreviousMarkerAction;
86
 
import org.herac.tuxguitar.gui.actions.marker.ListMarkersAction;
87
 
import org.herac.tuxguitar.gui.actions.measure.AddMeasureAction;
88
 
import org.herac.tuxguitar.gui.actions.measure.CleanMeasureAction;
89
 
import org.herac.tuxguitar.gui.actions.measure.CopyMeasureAction;
90
 
import org.herac.tuxguitar.gui.actions.measure.GoFirstMeasureAction;
91
 
import org.herac.tuxguitar.gui.actions.measure.GoLastMeasureAction;
92
 
import org.herac.tuxguitar.gui.actions.measure.GoNextMeasureAction;
93
 
import org.herac.tuxguitar.gui.actions.measure.GoPreviousMeasureAction;
94
 
import org.herac.tuxguitar.gui.actions.measure.PasteMeasureAction;
95
 
import org.herac.tuxguitar.gui.actions.measure.RemoveMeasureAction;
96
 
import org.herac.tuxguitar.gui.actions.note.ChangeNoteAction;
97
 
import org.herac.tuxguitar.gui.actions.note.ChangeTiedNoteAction;
98
 
import org.herac.tuxguitar.gui.actions.note.ChangeVelocityAction;
99
 
import org.herac.tuxguitar.gui.actions.note.CleanBeatAction;
100
 
import org.herac.tuxguitar.gui.actions.note.DecrementNoteSemitoneAction;
101
 
import org.herac.tuxguitar.gui.actions.note.IncrementNoteSemitoneAction;
102
 
import org.herac.tuxguitar.gui.actions.note.InsertNoteAction;
103
 
import org.herac.tuxguitar.gui.actions.note.RemoveNoteAction;
104
 
import org.herac.tuxguitar.gui.actions.note.ShiftNoteDownAction;
105
 
import org.herac.tuxguitar.gui.actions.note.ShiftNoteUpAction;
106
 
import org.herac.tuxguitar.gui.actions.player.PlaySongAction;
107
 
import org.herac.tuxguitar.gui.actions.player.StopSongAction;
108
 
import org.herac.tuxguitar.gui.actions.settings.ConfigureKeyBindingsAction;
109
 
import org.herac.tuxguitar.gui.actions.settings.EditConfigAction;
110
 
import org.herac.tuxguitar.gui.actions.tools.SelectScaleAction;
111
 
import org.herac.tuxguitar.gui.actions.track.AddTrackAction;
112
 
import org.herac.tuxguitar.gui.actions.track.ChangeTrackPropertiesAction;
113
 
import org.herac.tuxguitar.gui.actions.track.CloneTrackAction;
114
 
import org.herac.tuxguitar.gui.actions.track.EditLyricsAction;
115
 
import org.herac.tuxguitar.gui.actions.track.GoFirstTrackAction;
116
 
import org.herac.tuxguitar.gui.actions.track.GoLastTrackAction;
117
 
import org.herac.tuxguitar.gui.actions.track.GoNextTrackAction;
118
 
import org.herac.tuxguitar.gui.actions.track.GoPreviousTrackAction;
119
 
import org.herac.tuxguitar.gui.actions.track.GoToTrackAction;
120
 
import org.herac.tuxguitar.gui.actions.track.MoveTrackDownAction;
121
 
import org.herac.tuxguitar.gui.actions.track.MoveTrackUpAction;
122
 
import org.herac.tuxguitar.gui.actions.track.RemoveTrackAction;
123
 
import org.herac.tuxguitar.gui.actions.view.ShowFretBoardAction;
124
 
import org.herac.tuxguitar.gui.actions.view.ShowMixerAction;
125
 
import org.herac.tuxguitar.gui.actions.view.ShowPianoAction;
126
 
import org.herac.tuxguitar.gui.actions.view.ShowTransportAction;
127
 
import org.herac.tuxguitar.gui.editors.TablatureEditor;
128
 
 
129
 
/**
130
 
 * @author julian
131
 
 *
132
 
 * TODO To change the template for this generated type comment go to
133
 
 * Window - Preferences - Java - Code Style - Code Templates
134
 
 */
135
 
public class ActionContainer {
136
 
    private Map actions;    
137
 
    private TablatureEditor tablatureEditor;
138
 
    private TypedEvent lastEvent;
139
 
    
140
 
    public ActionContainer(TablatureEditor tablatureEditor){
141
 
        this.tablatureEditor = tablatureEditor;
142
 
        this.actions = new HashMap();        
143
 
    }
144
 
    
145
 
    public void initActions(){                
146
 
        //file actions
147
 
        addAction(new NewFileAction(this.tablatureEditor));
148
 
        addAction(new OpenFileAction(this.tablatureEditor));
149
 
        addAction(new SaveFileAction(this.tablatureEditor));
150
 
        addAction(new SaveAsFileAction(this.tablatureEditor));
151
 
        addAction(new ImportMidiAction(this.tablatureEditor));
152
 
        addAction(new ExportMidiAction(this.tablatureEditor));
153
 
        addAction(new ExportPDFAction(this.tablatureEditor));
154
 
        addAction(new ExportASCIIAction(this.tablatureEditor));
155
 
        addAction(new PrintAction(this.tablatureEditor));
156
 
        addAction(new PrintPreviewAction(this.tablatureEditor));
157
 
        
158
 
        //edit actions
159
 
        addAction(new UndoAction(this.tablatureEditor));
160
 
        addAction(new RedoAction(this.tablatureEditor));
161
 
        addAction(new SetMouseModeSelectionAction(this.tablatureEditor));
162
 
        addAction(new SetMouseModeEditionAction(this.tablatureEditor));
163
 
        addAction(new SetNaturalKeyAction(this.tablatureEditor));
164
 
        
165
 
        //layout actions
166
 
        addAction(new SetPageLayoutAction(this.tablatureEditor));
167
 
        addAction(new SetLinearLayoutAction(this.tablatureEditor));
168
 
        addAction(new SetMultitrackViewAction(this.tablatureEditor));
169
 
        addAction(new SetScoreEnabledAction(this.tablatureEditor));
170
 
        
171
 
        //view actions
172
 
        addAction(new ShowFretBoardAction(this.tablatureEditor));
173
 
        addAction(new ShowPianoAction(this.tablatureEditor));
174
 
        addAction(new ShowMixerAction(this.tablatureEditor));
175
 
        addAction(new ShowTransportAction(this.tablatureEditor));
176
 
        
177
 
        //composition actions
178
 
        addAction(new ChangeTimeSignatureAction(this.tablatureEditor));
179
 
        addAction(new ChangeTempoAction(this.tablatureEditor));
180
 
        addAction(new ChangeClefAction(this.tablatureEditor));
181
 
        addAction(new ChangeKeySignatureAction(this.tablatureEditor));
182
 
        addAction(new ChangeTripletFeelAction(this.tablatureEditor));
183
 
        addAction(new ChangeInfoAction(this.tablatureEditor));
184
 
        
185
 
        //track actions
186
 
        addAction(new AddTrackAction(this.tablatureEditor));
187
 
        addAction(new RemoveTrackAction(this.tablatureEditor));
188
 
        addAction(new CloneTrackAction(this.tablatureEditor));
189
 
        addAction(new GoFirstTrackAction(this.tablatureEditor));
190
 
        addAction(new GoLastTrackAction(this.tablatureEditor));
191
 
        addAction(new GoNextTrackAction(this.tablatureEditor));
192
 
        addAction(new GoToTrackAction(this.tablatureEditor));
193
 
        addAction(new GoPreviousTrackAction(this.tablatureEditor));
194
 
        addAction(new MoveTrackUpAction(this.tablatureEditor));
195
 
        addAction(new MoveTrackDownAction(this.tablatureEditor));
196
 
        addAction(new EditLyricsAction((this.tablatureEditor)));
197
 
        addAction(new ChangeTrackPropertiesAction((this.tablatureEditor)));
198
 
        
199
 
        //measure actions
200
 
        addAction(new AddMeasureAction(this.tablatureEditor));
201
 
        addAction(new RemoveMeasureAction(this.tablatureEditor));
202
 
        addAction(new CopyMeasureAction(this.tablatureEditor));
203
 
        addAction(new PasteMeasureAction(this.tablatureEditor));
204
 
        addAction(new GoFirstMeasureAction(this.tablatureEditor));
205
 
        addAction(new GoLastMeasureAction(this.tablatureEditor));
206
 
        addAction(new GoNextMeasureAction(this.tablatureEditor));
207
 
        addAction(new GoPreviousMeasureAction(this.tablatureEditor));
208
 
        addAction(new CleanMeasureAction(this.tablatureEditor));
209
 
        
210
 
        //note actions
211
 
        addAction(new ChangeNoteAction(this.tablatureEditor));        
212
 
        addAction(new InsertNoteAction(this.tablatureEditor));
213
 
        addAction(new RemoveNoteAction(this.tablatureEditor));
214
 
        addAction(new CleanBeatAction(this.tablatureEditor));
215
 
        addAction(new ChangeTiedNoteAction(this.tablatureEditor));        
216
 
        addAction(new ChangeVelocityAction(this.tablatureEditor));        
217
 
        addAction(new ShiftNoteUpAction(this.tablatureEditor));
218
 
        addAction(new ShiftNoteDownAction(this.tablatureEditor));
219
 
        addAction(new IncrementNoteSemitoneAction(this.tablatureEditor));
220
 
        addAction(new DecrementNoteSemitoneAction(this.tablatureEditor));
221
 
        
222
 
        //duration actions
223
 
        addAction(new SetWholeDurationAction(this.tablatureEditor));
224
 
        addAction(new SetHalfDurationAction(this.tablatureEditor));
225
 
        addAction(new SetQuarterDurationAction(this.tablatureEditor));
226
 
        addAction(new SetEighthDurationAction(this.tablatureEditor));
227
 
        addAction(new SetSixteenthDurationAction(this.tablatureEditor));
228
 
        addAction(new SetThirtySecondDurationAction(this.tablatureEditor));
229
 
        addAction(new SetSixtyFourthDurationAction(this.tablatureEditor));
230
 
        addAction(new ChangeDottedDurationAction(this.tablatureEditor));
231
 
        addAction(new ChangeDoubleDottedDurationAction(this.tablatureEditor));
232
 
        addAction(new ChangeTupletoDurationAction(this.tablatureEditor));
233
 
        addAction(new IncrementDurationAction(this.tablatureEditor));
234
 
        addAction(new DecrementDurationAction(this.tablatureEditor));
235
 
        
236
 
        //insert actions
237
 
        addAction(new OpenRepeatAction(this.tablatureEditor));
238
 
        addAction(new CloseRepeatAction(this.tablatureEditor));         
239
 
        addAction(new InsertChordAction(this.tablatureEditor));
240
 
        
241
 
        //note effects action
242
 
        addAction(new ChangeVibratoNoteAction(this.tablatureEditor));     
243
 
        addAction(new ChangeBendNoteAction(this.tablatureEditor));
244
 
        addAction(new ChangeDeadNoteAction(this.tablatureEditor));
245
 
        addAction(new ChangeSlideNoteAction(this.tablatureEditor));
246
 
        addAction(new ChangeHammerNoteAction(this.tablatureEditor));
247
 
        addAction(new ChangeGhostNoteAction(this.tablatureEditor));
248
 
        addAction(new ChangeAccentuatedNoteAction(this.tablatureEditor));
249
 
        addAction(new ChangeHeavyAccentuatedNoteAction(this.tablatureEditor));
250
 
        addAction(new ChangeHarmonicNoteAction(this.tablatureEditor));
251
 
        addAction(new ChangeGraceNoteAction(this.tablatureEditor));
252
 
        addAction(new ChangeTrillNoteAction(this.tablatureEditor));
253
 
        addAction(new ChangeTremoloPickingAction(this.tablatureEditor));
254
 
        addAction(new ChangePalmMuteAction(this.tablatureEditor));        
255
 
        addAction(new ChangeStaccatoAction(this.tablatureEditor));
256
 
        addAction(new ChangeTappingAction(this.tablatureEditor));
257
 
        addAction(new ChangeSlappingAction(this.tablatureEditor));
258
 
        addAction(new ChangePoppingAction(this.tablatureEditor));
259
 
        addAction(new ChangeTremoloBarAction(this.tablatureEditor));
260
 
        addAction(new ChangeFadeInAction(this.tablatureEditor));
261
 
        
262
 
        //marker actions
263
 
        addAction(new AddMarkerAction(this.tablatureEditor));
264
 
        addAction(new ListMarkersAction(this.tablatureEditor));
265
 
        addAction(new GoPreviousMarkerAction(this.tablatureEditor));
266
 
        addAction(new GoNextMarkerAction(this.tablatureEditor));
267
 
        addAction(new GoFirstMarkerAction(this.tablatureEditor));        
268
 
        addAction(new GoLastMarkerAction(this.tablatureEditor));
269
 
        
270
 
        //player actions
271
 
        addAction(new PlaySongAction(this.tablatureEditor));
272
 
        addAction(new StopSongAction(this.tablatureEditor));        
273
 
        
274
 
        //language actions
275
 
        //addAction(new ChangeLanguageAction(this.tablatureEditor)); 
276
 
 
277
 
        //setting actions
278
 
        addAction(new EditConfigAction(this.tablatureEditor)); 
279
 
        addAction(new ConfigureKeyBindingsAction(this.tablatureEditor)); 
280
 
        
281
 
        //caret actions
282
 
        addAction(new GoRightAction(this.tablatureEditor));
283
 
        addAction(new GoLeftAction(this.tablatureEditor));
284
 
        addAction(new GoUpAction(this.tablatureEditor));
285
 
        addAction(new GoDownAction(this.tablatureEditor));        
286
 
        
287
 
        //help actions
288
 
        addAction(new ShowAboutDialogAction(this.tablatureEditor));
289
 
        
290
 
        //mouse actions
291
 
        //addAction(new SelectComponentAction(this.tablatureEditor));
292
 
        
293
 
        //tools
294
 
        addAction(new SelectScaleAction(this.tablatureEditor));
295
 
        
296
 
        //dispose
297
 
        addAction(new DisposeAction(this.tablatureEditor));
298
 
    }
299
 
    
300
 
    
301
 
    private void addAction(Action action){
302
 
        this.actions.put(action.getName(),action);
303
 
    }
304
 
 
305
 
    public Action getAction(String name){
306
 
        return (Action)this.actions.get(name);
307
 
    }    
308
 
    
309
 
    public List getAvailableKeyBindingActions(){
310
 
        List availableKeyBindingActions = new ArrayList();
311
 
        Iterator it = this.actions.keySet().iterator();
312
 
        while(it.hasNext()){
313
 
                String actionName = (String)it.next();
314
 
                if(getAction(actionName).isEditableKeyBinding()){
315
 
                        availableKeyBindingActions.add(actionName);
316
 
                }
317
 
        }        
318
 
        return availableKeyBindingActions;
319
 
    }  
320
 
    
321
 
    public TypedEvent getLastEvent() {
322
 
        return lastEvent;
323
 
    }
324
 
    
325
 
    public void setLastEvent(TypedEvent lastEvent) {
326
 
        this.lastEvent = lastEvent;
327
 
    }
328
 
}