2
* Created on 02-dic-2005
4
* TODO To change the template for this generated file go to
5
* Window - Preferences - Java - Code Style - Code Templates
7
package org.herac.tuxguitar.gui.items.menu;
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;
27
* TODO To change the template for this generated type comment go to
28
* Window - Preferences - Java - Code Style - Code Templates
30
public class BeatMenuItem implements MenuItems{
32
private MenuItem noteMenuItem;
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;
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);
51
public void showItems(){
53
this.tiedNote = new MenuItem(this.menu, SWT.PUSH);
54
this.tiedNote.addSelectionListener(TuxGuitar.instance().getAction(ChangeTiedNoteAction.NAME));
57
this.cleanBeat = new MenuItem(this.menu, SWT.PUSH);
58
this.cleanBeat.addSelectionListener(TuxGuitar.instance().getAction(CleanBeatAction.NAME));
61
this.durationMenuItem = new DurationMenuItem(this.menu.getShell(),this.menu,SWT.CASCADE);
62
this.durationMenuItem.showItems();
65
this.chordMenuItem = new ChordMenuItem(this.menu.getShell(),this.menu,SWT.CASCADE);
66
this.chordMenuItem.showItems();
69
this.effectMenuItem = new NoteEffectsMenuItem(this.menu.getShell(),this.menu,SWT.CASCADE);
70
this.effectMenuItem.showItems();
73
this.dynamicMenuItem = new DynamicMenuItem(this.menu.getShell(),this.menu,SWT.CASCADE);
74
this.dynamicMenuItem.showItems();
77
new MenuItem(this.menu, SWT.SEPARATOR);
79
this.insertText = new MenuItem(this.menu, SWT.PUSH);
80
this.insertText.addSelectionListener(TuxGuitar.instance().getAction(InsertTextAction.NAME));
83
new MenuItem(this.menu, SWT.SEPARATOR);
86
this.semitoneUp = new MenuItem(this.menu, SWT.PUSH);
87
this.semitoneUp.addSelectionListener(TuxGuitar.instance().getAction(IncrementNoteSemitoneAction.NAME));
90
this.semitoneDown = new MenuItem(this.menu, SWT.PUSH);
91
this.semitoneDown.addSelectionListener(TuxGuitar.instance().getAction(DecrementNoteSemitoneAction.NAME));
94
new MenuItem(this.menu, SWT.SEPARATOR);
97
this.shiftUp = new MenuItem(this.menu, SWT.PUSH);
98
this.shiftUp.addSelectionListener(TuxGuitar.instance().getAction(ShiftNoteUpAction.NAME));
101
this.shiftDown = new MenuItem(this.menu, SWT.PUSH);
102
this.shiftDown.addSelectionListener(TuxGuitar.instance().getAction(ShiftNoteDownAction.NAME));
104
this.noteMenuItem.setMenu(this.menu);
107
this.loadProperties();
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();
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();
141
public void loadIcons(){
142
this.tiedNote.setImage(TuxGuitar.instance().getIconManager().getNoteTied());