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

« back to all changes in this revision

Viewing changes to TuxGuitar/src/org/herac/tuxguitar/gui/system/keybindings/KeyBindingReserveds.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
package org.herac.tuxguitar.gui.system.keybindings;
 
2
 
 
3
import org.herac.tuxguitar.gui.TuxGuitar;
 
4
import org.herac.tuxguitar.gui.actions.Action;
 
5
import org.herac.tuxguitar.gui.actions.caret.GoDownAction;
 
6
import org.herac.tuxguitar.gui.actions.caret.GoLeftAction;
 
7
import org.herac.tuxguitar.gui.actions.caret.GoRightAction;
 
8
import org.herac.tuxguitar.gui.actions.caret.GoUpAction;
 
9
import org.herac.tuxguitar.gui.actions.duration.DecrementDurationAction;
 
10
import org.herac.tuxguitar.gui.actions.duration.IncrementDurationAction;
 
11
import org.herac.tuxguitar.gui.actions.note.ChangeNoteAction;
 
12
import org.herac.tuxguitar.gui.actions.note.InsertNoteAction;
 
13
import org.herac.tuxguitar.gui.actions.note.RemoveNoteAction;
 
14
 
 
15
public class KeyBindingReserveds {
 
16
        
 
17
        private static KeyBindingAction[] reserveds = new KeyBindingAction[]{
 
18
                new KeyBindingAction(ChangeNoteAction.NAME,new KeyBinding(KeyBindingConstants.NUMBER_0,0)),
 
19
                new KeyBindingAction(ChangeNoteAction.NAME,new KeyBinding(KeyBindingConstants.NUMBER_1,0)),
 
20
                new KeyBindingAction(ChangeNoteAction.NAME,new KeyBinding(KeyBindingConstants.NUMBER_2,0)),
 
21
                new KeyBindingAction(ChangeNoteAction.NAME,new KeyBinding(KeyBindingConstants.NUMBER_3,0)),
 
22
                new KeyBindingAction(ChangeNoteAction.NAME,new KeyBinding(KeyBindingConstants.NUMBER_4,0)),
 
23
                new KeyBindingAction(ChangeNoteAction.NAME,new KeyBinding(KeyBindingConstants.NUMBER_5,0)),
 
24
                new KeyBindingAction(ChangeNoteAction.NAME,new KeyBinding(KeyBindingConstants.NUMBER_6,0)),
 
25
                new KeyBindingAction(ChangeNoteAction.NAME,new KeyBinding(KeyBindingConstants.NUMBER_7,0)),
 
26
                new KeyBindingAction(ChangeNoteAction.NAME,new KeyBinding(KeyBindingConstants.NUMBER_8,0)),
 
27
                new KeyBindingAction(ChangeNoteAction.NAME,new KeyBinding(KeyBindingConstants.NUMBER_9,0)),
 
28
                new KeyBindingAction(ChangeNoteAction.NAME,new KeyBinding(KeyBindingConstants.KEYPAD_0,0)),
 
29
                new KeyBindingAction(ChangeNoteAction.NAME,new KeyBinding(KeyBindingConstants.KEYPAD_1,0)),
 
30
                new KeyBindingAction(ChangeNoteAction.NAME,new KeyBinding(KeyBindingConstants.KEYPAD_2,0)),
 
31
                new KeyBindingAction(ChangeNoteAction.NAME,new KeyBinding(KeyBindingConstants.KEYPAD_3,0)),
 
32
                new KeyBindingAction(ChangeNoteAction.NAME,new KeyBinding(KeyBindingConstants.KEYPAD_4,0)),
 
33
                new KeyBindingAction(ChangeNoteAction.NAME,new KeyBinding(KeyBindingConstants.KEYPAD_5,0)),
 
34
                new KeyBindingAction(ChangeNoteAction.NAME,new KeyBinding(KeyBindingConstants.KEYPAD_6,0)),
 
35
                new KeyBindingAction(ChangeNoteAction.NAME,new KeyBinding(KeyBindingConstants.KEYPAD_7,0)),
 
36
                new KeyBindingAction(ChangeNoteAction.NAME,new KeyBinding(KeyBindingConstants.KEYPAD_8,0)),
 
37
                new KeyBindingAction(ChangeNoteAction.NAME,new KeyBinding(KeyBindingConstants.KEYPAD_9,0)),
 
38
                new KeyBindingAction(RemoveNoteAction.NAME,new KeyBinding(KeyBindingConstants.BACKSPACE,0)),
 
39
                new KeyBindingAction(RemoveNoteAction.NAME,new KeyBinding(KeyBindingConstants.DELETE,0)),
 
40
                new KeyBindingAction(InsertNoteAction.NAME,new KeyBinding(KeyBindingConstants.INSERT,0)),
 
41
                new KeyBindingAction(IncrementDurationAction.NAME,new KeyBinding(16777259,0)),
 
42
                new KeyBindingAction(DecrementDurationAction.NAME,new KeyBinding(16777261,0)),
 
43
                new KeyBindingAction(GoUpAction.NAME,new KeyBinding(KeyBindingConstants.UP,0)),
 
44
                new KeyBindingAction(GoDownAction.NAME,new KeyBinding(KeyBindingConstants.DOWN,0)),
 
45
                new KeyBindingAction(GoLeftAction.NAME,new KeyBinding(KeyBindingConstants.LEFT,0)),
 
46
                new KeyBindingAction(GoRightAction.NAME,new KeyBinding(KeyBindingConstants.RIGHT,0)),
 
47
        };
 
48
        
 
49
        public static boolean isReserved(KeyBinding kb){
 
50
                for(int i = 0;i < reserveds.length;i++){
 
51
                        if(kb.isSameAs(reserveds[i].getKeyBinding())){
 
52
                                return true;
 
53
                        }
 
54
                }
 
55
                return false;
 
56
        }
 
57
        
 
58
        public static Action getActionForKeyBinding(KeyBinding kb){
 
59
                for(int i = 0;i < reserveds.length;i++){
 
60
                        if(kb.isSameAs(reserveds[i].getKeyBinding())){
 
61
                                return TuxGuitar.instance().getAction(reserveds[i].getAction());
 
62
                        }
 
63
                }
 
64
                return null;
 
65
        }
 
66
        
 
67
        public static KeyBinding getKeyBindingForAction(String action){
 
68
                for(int i = 0;i < reserveds.length;i++){
 
69
                        if(action.equals(reserveds[i].getAction())){
 
70
                                return reserveds[i].getKeyBinding();
 
71
                        }
 
72
                }
 
73
                return null;
 
74
        }
 
75
}