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

« back to all changes in this revision

Viewing changes to TuxGuitar/src/org/herac/tuxguitar/gui/items/menu/CompositionMenuItem.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.composition.ChangeClefAction;
 
15
import org.herac.tuxguitar.gui.actions.composition.ChangeInfoAction;
 
16
import org.herac.tuxguitar.gui.actions.composition.ChangeKeySignatureAction;
 
17
import org.herac.tuxguitar.gui.actions.composition.ChangeTempoAction;
 
18
import org.herac.tuxguitar.gui.actions.composition.ChangeTimeSignatureAction;
 
19
import org.herac.tuxguitar.gui.actions.composition.ChangeTripletFeelAction;
 
20
import org.herac.tuxguitar.gui.actions.insert.RepeatAlternativeAction;
 
21
import org.herac.tuxguitar.gui.actions.insert.RepeatCloseAction;
 
22
import org.herac.tuxguitar.gui.actions.insert.RepeatOpenAction;
 
23
import org.herac.tuxguitar.gui.items.MenuItems;
 
24
 
 
25
/**
 
26
 * @author julian
 
27
 *
 
28
 * TODO To change the template for this generated type comment go to
 
29
 * Window - Preferences - Java - Code Style - Code Templates
 
30
 */
 
31
public class CompositionMenuItem implements MenuItems{
 
32
        private MenuItem compositionMenuItem;
 
33
        private Menu menu;
 
34
        private MenuItem timeSignature;
 
35
        private MenuItem tempo;
 
36
        private MenuItem clef;
 
37
        private MenuItem keySignature;
 
38
        private MenuItem repeatOpen;
 
39
        private MenuItem repeatClose;
 
40
        private MenuItem repeatAlternative;
 
41
        private MenuItem tripletFeel;
 
42
        
 
43
        private MenuItem properties;
 
44
        
 
45
        public CompositionMenuItem(Shell shell,Menu parent, int style) {
 
46
                this.compositionMenuItem = new MenuItem(parent, style);
 
47
                this.menu = new Menu(shell, SWT.DROP_DOWN);
 
48
        }
 
49
        
 
50
        public void showItems(){
 
51
                //--TIME SIGNATURE--
 
52
                this.timeSignature = new MenuItem(this.menu, SWT.PUSH);
 
53
                this.timeSignature.addSelectionListener(TuxGuitar.instance().getAction(ChangeTimeSignatureAction.NAME));
 
54
                //--TEMPO--
 
55
                this.tempo = new MenuItem(this.menu, SWT.PUSH);
 
56
                this.tempo.addSelectionListener(TuxGuitar.instance().getAction(ChangeTempoAction.NAME));
 
57
                //--CLEF--
 
58
                this.clef = new MenuItem(this.menu, SWT.PUSH);
 
59
                this.clef.addSelectionListener(TuxGuitar.instance().getAction(ChangeClefAction.NAME));
 
60
                //--KEY SIGNATURE--
 
61
                this.keySignature = new MenuItem(this.menu, SWT.PUSH);
 
62
                this.keySignature.addSelectionListener(TuxGuitar.instance().getAction(ChangeKeySignatureAction.NAME));
 
63
                //--TRIPLET FEEL--
 
64
                this.tripletFeel = new MenuItem(this.menu, SWT.PUSH);
 
65
                this.tripletFeel.addSelectionListener(TuxGuitar.instance().getAction(ChangeTripletFeelAction.NAME));
 
66
                //--SEPARATOR--
 
67
                new MenuItem(this.menu, SWT.SEPARATOR);
 
68
                //--REPEAT OPEN--
 
69
                this.repeatOpen = new MenuItem(this.menu, SWT.PUSH);
 
70
                this.repeatOpen.addSelectionListener(TuxGuitar.instance().getAction(RepeatOpenAction.NAME));
 
71
                //--REPEAT CLOSE--
 
72
                this.repeatClose = new MenuItem(this.menu, SWT.PUSH);
 
73
                this.repeatClose.addSelectionListener(TuxGuitar.instance().getAction(RepeatCloseAction.NAME));
 
74
                //--REPEAT ALTERNATIVE--
 
75
                this.repeatAlternative = new MenuItem(this.menu, SWT.PUSH);
 
76
                this.repeatAlternative.addSelectionListener(TuxGuitar.instance().getAction(RepeatAlternativeAction.NAME));
 
77
                
 
78
                //--SEPARATOR--
 
79
                new MenuItem(this.menu, SWT.SEPARATOR);
 
80
                //--INFO--
 
81
                this.properties = new MenuItem(this.menu, SWT.PUSH);
 
82
                this.properties.addSelectionListener(TuxGuitar.instance().getAction(ChangeInfoAction.NAME));
 
83
                
 
84
                this.compositionMenuItem.setMenu(this.menu);
 
85
                
 
86
                this.loadIcons();
 
87
                this.loadProperties();
 
88
        }
 
89
        
 
90
        public void update(){
 
91
                boolean running = TuxGuitar.instance().getPlayer().isRunning();
 
92
                this.timeSignature.setEnabled(!running);
 
93
                this.tempo.setEnabled(!running);
 
94
                this.clef.setEnabled(!running);
 
95
                this.keySignature.setEnabled(!running);
 
96
                this.tripletFeel.setEnabled(!running);
 
97
                this.repeatOpen.setEnabled(!running);
 
98
                this.repeatClose.setEnabled(!running);
 
99
                this.repeatAlternative.setEnabled(!running);
 
100
        }
 
101
        
 
102
        public void loadProperties(){
 
103
                this.compositionMenuItem.setText(TuxGuitar.getProperty("composition"));
 
104
                this.timeSignature.setText(TuxGuitar.getProperty("composition.timesignature"));
 
105
                this.tempo.setText(TuxGuitar.getProperty("composition.tempo"));
 
106
                this.clef.setText(TuxGuitar.getProperty("composition.clef"));
 
107
                this.keySignature.setText(TuxGuitar.getProperty("composition.keysignature"));
 
108
                this.tripletFeel.setText(TuxGuitar.getProperty("composition.tripletfeel"));
 
109
                this.repeatOpen.setText(TuxGuitar.getProperty("repeat.open"));
 
110
                this.repeatClose.setText(TuxGuitar.getProperty("repeat.close"));
 
111
                this.repeatAlternative.setText(TuxGuitar.getProperty("repeat.alternative"));
 
112
                this.properties.setText(TuxGuitar.getProperty("composition.properties"));
 
113
        }
 
114
        
 
115
        public void loadIcons() {
 
116
                this.timeSignature.setImage(TuxGuitar.instance().getIconManager().getCompositionTimeSignature());
 
117
                this.tempo.setImage(TuxGuitar.instance().getIconManager().getCompositionTempo());
 
118
                this.repeatOpen.setImage(TuxGuitar.instance().getIconManager().getCompositionRepeatOpen());
 
119
                this.repeatClose.setImage(TuxGuitar.instance().getIconManager().getCompositionRepeatClose());
 
120
                this.repeatAlternative.setImage(TuxGuitar.instance().getIconManager().getCompositionRepeatAlternative());
 
121
                this.properties.setImage(TuxGuitar.instance().getIconManager().getSongProperties());
 
122
        }
 
123
}