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

« back to all changes in this revision

Viewing changes to src/org/herac/tuxguitar/gui/items/menu/NoteMenuItem.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.SystemImages;
14
 
import org.herac.tuxguitar.gui.TuxGuitar;
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.editors.TablatureEditor;
22
 
import org.herac.tuxguitar.gui.items.MenuItems;
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 NoteMenuItem implements MenuItems{
31
 
    private TablatureEditor tablatureEditor;
32
 
    private MenuItem noteMenuItem;
33
 
    private Menu menu;    
34
 
    private MenuItem tiedNote;
35
 
    private MenuItem cleanBeat;
36
 
    private MenuItem shiftUp;
37
 
    private MenuItem shiftDown;
38
 
    private MenuItem semitoneUp;
39
 
    private MenuItem semitoneDown;    
40
 
    private DurationMenuItem durationMenuItem;
41
 
    private ChordMenuItem chordMenuItem;
42
 
    private NoteEffectsMenuItem effectMenuItem;
43
 
    private DynamicMenuItem dynamicMenuItem;
44
 
    
45
 
    public NoteMenuItem(Shell shell,Menu parent, int style,TablatureEditor tablatureEditor) {
46
 
        this.noteMenuItem = new MenuItem(parent, style);
47
 
        this.tablatureEditor = tablatureEditor;
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.setImage(SystemImages.TIED_NOTE_IMAGE);
55
 
        this.tiedNote.addSelectionListener(TuxGuitar.instance().getAction(ChangeTiedNoteAction.NAME));
56
 
        
57
 
        //--Tied Note
58
 
        this.cleanBeat = new MenuItem(this.menu, SWT.PUSH);
59
 
        this.cleanBeat.addSelectionListener(TuxGuitar.instance().getAction(CleanBeatAction.NAME));        
60
 
        
61
 
        //--Duration--
62
 
        this.durationMenuItem = new DurationMenuItem(menu.getShell(),menu,SWT.CASCADE,tablatureEditor);
63
 
        this.durationMenuItem.showItems();
64
 
        
65
 
        //--Chord--
66
 
        this.chordMenuItem = new ChordMenuItem(menu.getShell(),menu,SWT.CASCADE,tablatureEditor);
67
 
        this.chordMenuItem.showItems();
68
 
 
69
 
        //--Effects--
70
 
        this.effectMenuItem = new NoteEffectsMenuItem(menu.getShell(),menu,SWT.CASCADE,tablatureEditor);
71
 
        this.effectMenuItem.showItems();        
72
 
        
73
 
        //--Dynamic--
74
 
        this.dynamicMenuItem = new DynamicMenuItem(menu.getShell(),menu,SWT.CASCADE,tablatureEditor);
75
 
        this.dynamicMenuItem.showItems();       
76
 
        
77
 
        //--SEPARATOR--
78
 
        new MenuItem(this.menu, SWT.SEPARATOR);
79
 
        
80
 
        //--Semitone Up
81
 
        this.semitoneUp = new MenuItem(this.menu, SWT.PUSH);
82
 
        this.semitoneUp.addSelectionListener(TuxGuitar.instance().getAction(IncrementNoteSemitoneAction.NAME));         
83
 
                
84
 
        //--Semitone Down
85
 
        this.semitoneDown = new MenuItem(this.menu, SWT.PUSH);
86
 
        this.semitoneDown.addSelectionListener(TuxGuitar.instance().getAction(DecrementNoteSemitoneAction.NAME));          
87
 
 
88
 
        //--SEPARATOR--
89
 
        new MenuItem(this.menu, SWT.SEPARATOR);
90
 
        
91
 
        //--Shift Up
92
 
        this.shiftUp = new MenuItem(this.menu, SWT.PUSH);
93
 
        this.shiftUp.addSelectionListener(TuxGuitar.instance().getAction(ShiftNoteUpAction.NAME));         
94
 
                
95
 
        //--Shift Down
96
 
        this.shiftDown = new MenuItem(this.menu, SWT.PUSH);
97
 
        this.shiftDown.addSelectionListener(TuxGuitar.instance().getAction(ShiftNoteDownAction.NAME));              
98
 
        
99
 
        this.noteMenuItem.setMenu(menu);        
100
 
        this.loadProperties();
101
 
    }    
102
 
    
103
 
    public void update(){
104
 
        this.durationMenuItem.update();
105
 
        this.chordMenuItem.update();
106
 
        this.effectMenuItem.update();
107
 
        this.dynamicMenuItem.update();
108
 
    }
109
 
    
110
 
    public void loadProperties(){
111
 
        this.noteMenuItem.setText(TuxGuitar.getProperty("note"));
112
 
        this.tiedNote.setText(TuxGuitar.getProperty("note.tiednote"));
113
 
        this.cleanBeat.setText(TuxGuitar.getProperty("note.clean-beat"));        
114
 
        this.semitoneUp.setText(TuxGuitar.getProperty("note.semitone-up"));
115
 
        this.semitoneDown.setText(TuxGuitar.getProperty("note.semitone-down"));                
116
 
        this.shiftUp.setText(TuxGuitar.getProperty("note.shift-up"));
117
 
        this.shiftDown.setText(TuxGuitar.getProperty("note.shift-down"));
118
 
        this.durationMenuItem.loadProperties();
119
 
        this.chordMenuItem.loadProperties();
120
 
        this.effectMenuItem.loadProperties();
121
 
        this.dynamicMenuItem.loadProperties();
122
 
    }    
123
 
}