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

« back to all changes in this revision

Viewing changes to TuxGuitar/src/org/herac/tuxguitar/gui/items/menu/BeatMenuItem.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 02-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.items.menu;
 
8
 
 
9
import org.eclipse.swt.SWT;
 
10
import org.eclipse.swt.widgets.Menu;
 
11
import org.eclipse.swt.widgets.MenuItem;
 
12
import org.eclipse.swt.widgets.Shell;
 
13
import org.herac.tuxguitar.gui.TuxGuitar;
 
14
import org.herac.tuxguitar.gui.actions.insert.InsertTextAction;
 
15
import org.herac.tuxguitar.gui.actions.note.ChangeTiedNoteAction;
 
16
import org.herac.tuxguitar.gui.actions.note.CleanBeatAction;
 
17
import org.herac.tuxguitar.gui.actions.note.DecrementNoteSemitoneAction;
 
18
import org.herac.tuxguitar.gui.actions.note.IncrementNoteSemitoneAction;
 
19
import org.herac.tuxguitar.gui.actions.note.ShiftNoteDownAction;
 
20
import org.herac.tuxguitar.gui.actions.note.ShiftNoteUpAction;
 
21
import org.herac.tuxguitar.gui.items.MenuItems;
 
22
import org.herac.tuxguitar.song.models.TGNote;
 
23
 
 
24
/**
 
25
 * @author julian
 
26
 *
 
27
 * TODO To change the template for this generated type comment go to
 
28
 * Window - Preferences - Java - Code Style - Code Templates
 
29
 */
 
30
public class BeatMenuItem implements MenuItems{
 
31
        
 
32
        private MenuItem noteMenuItem;
 
33
        private Menu menu;
 
34
        private MenuItem tiedNote;
 
35
        private MenuItem cleanBeat;
 
36
        private MenuItem insertText;
 
37
        private MenuItem shiftUp;
 
38
        private MenuItem shiftDown;
 
39
        private MenuItem semitoneUp;
 
40
        private MenuItem semitoneDown;
 
41
        private DurationMenuItem durationMenuItem;
 
42
        private ChordMenuItem chordMenuItem;
 
43
        private NoteEffectsMenuItem effectMenuItem;
 
44
        private DynamicMenuItem dynamicMenuItem;
 
45
        
 
46
        public BeatMenuItem(Shell shell,Menu parent, int style) {
 
47
                this.noteMenuItem = new MenuItem(parent, style);
 
48
                this.menu = new Menu(shell, SWT.DROP_DOWN);
 
49
        }
 
50
        
 
51
        public void showItems(){
 
52
                //--Tied Note
 
53
                this.tiedNote = new MenuItem(this.menu, SWT.PUSH);
 
54
                this.tiedNote.addSelectionListener(TuxGuitar.instance().getAction(ChangeTiedNoteAction.NAME));
 
55
                
 
56
                //--Tied Note
 
57
                this.cleanBeat = new MenuItem(this.menu, SWT.PUSH);
 
58
                this.cleanBeat.addSelectionListener(TuxGuitar.instance().getAction(CleanBeatAction.NAME));
 
59
                
 
60
                //--Duration--
 
61
                this.durationMenuItem = new DurationMenuItem(this.menu.getShell(),this.menu,SWT.CASCADE);
 
62
                this.durationMenuItem.showItems();
 
63
                
 
64
                //--Chord--
 
65
                this.chordMenuItem = new ChordMenuItem(this.menu.getShell(),this.menu,SWT.CASCADE);
 
66
                this.chordMenuItem.showItems();
 
67
                
 
68
                //--Effects--
 
69
                this.effectMenuItem = new NoteEffectsMenuItem(this.menu.getShell(),this.menu,SWT.CASCADE);
 
70
                this.effectMenuItem.showItems();
 
71
                
 
72
                //--Dynamic--
 
73
                this.dynamicMenuItem = new DynamicMenuItem(this.menu.getShell(),this.menu,SWT.CASCADE);
 
74
                this.dynamicMenuItem.showItems();
 
75
                
 
76
                //--SEPARATOR--
 
77
                new MenuItem(this.menu, SWT.SEPARATOR);
 
78
                
 
79
                this.insertText = new MenuItem(this.menu, SWT.PUSH);
 
80
                this.insertText.addSelectionListener(TuxGuitar.instance().getAction(InsertTextAction.NAME));
 
81
                
 
82
                //--SEPARATOR--
 
83
                new MenuItem(this.menu, SWT.SEPARATOR);
 
84
                
 
85
                //--Semitone Up
 
86
                this.semitoneUp = new MenuItem(this.menu, SWT.PUSH);
 
87
                this.semitoneUp.addSelectionListener(TuxGuitar.instance().getAction(IncrementNoteSemitoneAction.NAME));
 
88
                
 
89
                //--Semitone Down
 
90
                this.semitoneDown = new MenuItem(this.menu, SWT.PUSH);
 
91
                this.semitoneDown.addSelectionListener(TuxGuitar.instance().getAction(DecrementNoteSemitoneAction.NAME));
 
92
                
 
93
                //--SEPARATOR--
 
94
                new MenuItem(this.menu, SWT.SEPARATOR);
 
95
                
 
96
                //--Shift Up
 
97
                this.shiftUp = new MenuItem(this.menu, SWT.PUSH);
 
98
                this.shiftUp.addSelectionListener(TuxGuitar.instance().getAction(ShiftNoteUpAction.NAME));
 
99
                
 
100
                //--Shift Down
 
101
                this.shiftDown = new MenuItem(this.menu, SWT.PUSH);
 
102
                this.shiftDown.addSelectionListener(TuxGuitar.instance().getAction(ShiftNoteDownAction.NAME));
 
103
                
 
104
                this.noteMenuItem.setMenu(this.menu);
 
105
                
 
106
                this.loadIcons();
 
107
                this.loadProperties();
 
108
        }
 
109
        
 
110
        public void update(){
 
111
                TGNote note = TuxGuitar.instance().getTablatureEditor().getTablature().getCaret().getSelectedNote();
 
112
                boolean running = TuxGuitar.instance().getPlayer().isRunning();
 
113
                this.tiedNote.setEnabled(!running);
 
114
                this.cleanBeat.setEnabled(!running);
 
115
                this.semitoneUp.setEnabled(!running && note != null);
 
116
                this.semitoneDown.setEnabled(!running && note != null);
 
117
                this.shiftUp.setEnabled(!running && note != null);
 
118
                this.shiftDown.setEnabled(!running && note != null);
 
119
                this.insertText.setEnabled(!running);
 
120
                this.durationMenuItem.update();
 
121
                this.chordMenuItem.update();
 
122
                this.effectMenuItem.update();
 
123
                this.dynamicMenuItem.update();
 
124
        }
 
125
        
 
126
        public void loadProperties(){
 
127
                this.noteMenuItem.setText(TuxGuitar.getProperty("beat"));
 
128
                this.cleanBeat.setText(TuxGuitar.getProperty("beat.clean"));
 
129
                this.tiedNote.setText(TuxGuitar.getProperty("note.tiednote"));
 
130
                this.semitoneUp.setText(TuxGuitar.getProperty("note.semitone-up"));
 
131
                this.semitoneDown.setText(TuxGuitar.getProperty("note.semitone-down"));
 
132
                this.shiftUp.setText(TuxGuitar.getProperty("note.shift-up"));
 
133
                this.shiftDown.setText(TuxGuitar.getProperty("note.shift-down"));
 
134
                this.insertText.setText(TuxGuitar.getProperty("text.insert"));
 
135
                this.durationMenuItem.loadProperties();
 
136
                this.chordMenuItem.loadProperties();
 
137
                this.effectMenuItem.loadProperties();
 
138
                this.dynamicMenuItem.loadProperties();
 
139
        }
 
140
        
 
141
        public void loadIcons(){
 
142
                this.tiedNote.setImage(TuxGuitar.instance().getIconManager().getNoteTied());
 
143
        }
 
144
}