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.tool;
9
import org.eclipse.swt.SWT;
10
import org.eclipse.swt.widgets.ToolBar;
11
import org.eclipse.swt.widgets.ToolItem;
12
import org.herac.tuxguitar.gui.TuxGuitar;
13
import org.herac.tuxguitar.gui.actions.note.ChangeVelocityAction;
14
import org.herac.tuxguitar.gui.editors.tab.Caret;
15
import org.herac.tuxguitar.gui.items.ToolItems;
16
import org.herac.tuxguitar.song.models.TGVelocities;
20
* TODO To change the template for this generated type comment go to
21
* Window - Preferences - Java - Code Style - Code Templates
23
public class DynamicToolItems extends ToolItems{
24
public static final String NAME = "dynamic.items";
26
private ToolBar toolBar;
28
private ToolItem pianoPianissimo;
29
private ToolItem pianissimo;
30
private ToolItem piano;
31
private ToolItem mezzoPiano;
32
private ToolItem mezzoForte;
33
private ToolItem forte;
34
private ToolItem fortissimo;
35
private ToolItem forteFortissimo;
38
public DynamicToolItems(){
42
public void showItems(ToolBar toolBar){
43
this.toolBar = toolBar;
45
this.pianoPianissimo = new ToolItem(this.toolBar, SWT.CHECK);
46
this.pianoPianissimo.setData(new Integer(TGVelocities.PIANO_PIANISSIMO));
47
this.pianoPianissimo.addSelectionListener(TuxGuitar.instance().getAction(ChangeVelocityAction.NAME));
50
this.pianissimo = new ToolItem(this.toolBar, SWT.CHECK);
51
this.pianissimo.setData(new Integer(TGVelocities.PIANISSIMO));
52
this.pianissimo.addSelectionListener(TuxGuitar.instance().getAction(ChangeVelocityAction.NAME));
55
this.piano = new ToolItem(this.toolBar, SWT.CHECK);
56
this.piano.setData(new Integer(TGVelocities.PIANO));
57
this.piano.addSelectionListener(TuxGuitar.instance().getAction(ChangeVelocityAction.NAME));
60
this.mezzoPiano = new ToolItem(this.toolBar, SWT.CHECK);
61
this.mezzoPiano.setData(new Integer(TGVelocities.MEZZO_PIANO));
62
this.mezzoPiano.addSelectionListener(TuxGuitar.instance().getAction(ChangeVelocityAction.NAME));
65
this.mezzoForte = new ToolItem(this.toolBar, SWT.CHECK);
66
this.mezzoForte.setData(new Integer(TGVelocities.MEZZO_FORTE));
67
this.mezzoForte.addSelectionListener(TuxGuitar.instance().getAction(ChangeVelocityAction.NAME));
70
this.forte = new ToolItem(this.toolBar, SWT.CHECK);
71
this.forte.setData(new Integer(TGVelocities.FORTE));
72
this.forte.addSelectionListener(TuxGuitar.instance().getAction(ChangeVelocityAction.NAME));
75
this.fortissimo = new ToolItem(this.toolBar, SWT.CHECK);
76
this.fortissimo.setData(new Integer(TGVelocities.FORTISSIMO));
77
this.fortissimo.addSelectionListener(TuxGuitar.instance().getAction(ChangeVelocityAction.NAME));
80
this.forteFortissimo = new ToolItem(this.toolBar, SWT.CHECK);
81
this.forteFortissimo.setData(new Integer(TGVelocities.FORTE_FORTISSIMO));
82
this.forteFortissimo.addSelectionListener(TuxGuitar.instance().getAction(ChangeVelocityAction.NAME));
85
this.loadProperties();
89
Caret caret = TuxGuitar.instance().getTablatureEditor().getTablature().getCaret();
90
int velocity = ((caret.getSelectedNote() != null)?caret.getSelectedNote().getVelocity():caret.getVelocity());
91
boolean running = TuxGuitar.instance().getPlayer().isRunning();
92
this.pianoPianissimo.setSelection(velocity == TGVelocities.PIANO_PIANISSIMO);
93
this.pianoPianissimo.setEnabled( !running );
94
this.pianissimo.setSelection(velocity == TGVelocities.PIANISSIMO);
95
this.pianissimo.setEnabled( !running );
96
this.piano.setSelection(velocity == TGVelocities.PIANO);
97
this.piano.setEnabled( !running );
98
this.mezzoPiano.setSelection(velocity == TGVelocities.MEZZO_PIANO);
99
this.mezzoPiano.setEnabled( !running );
100
this.mezzoForte.setSelection(velocity == TGVelocities.MEZZO_FORTE);
101
this.mezzoForte.setEnabled( !running );
102
this.forte.setSelection(velocity == TGVelocities.FORTE);
103
this.forte.setEnabled( !running );
104
this.fortissimo.setSelection(velocity == TGVelocities.FORTISSIMO);
105
this.fortissimo.setEnabled( !running );
106
this.forteFortissimo.setSelection(velocity == TGVelocities.FORTE_FORTISSIMO);
107
this.forteFortissimo.setEnabled( !running );
110
public void loadProperties(){
111
this.pianoPianissimo.setToolTipText(TuxGuitar.getProperty("dynamic.piano-pianissimo"));
112
this.pianissimo.setToolTipText(TuxGuitar.getProperty("dynamic.pianissimo"));
113
this.piano.setToolTipText(TuxGuitar.getProperty("dynamic.piano"));
114
this.mezzoPiano.setToolTipText(TuxGuitar.getProperty("dynamic.mezzo-piano"));
115
this.mezzoForte.setToolTipText(TuxGuitar.getProperty("dynamic.mezzo-forte"));
116
this.forte.setToolTipText(TuxGuitar.getProperty("dynamic.forte"));
117
this.fortissimo.setToolTipText(TuxGuitar.getProperty("dynamic.fortissimo"));
118
this.forteFortissimo.setToolTipText(TuxGuitar.getProperty("dynamic.forte-fortissimo"));
121
public void loadIcons(){
122
this.pianoPianissimo.setImage(TuxGuitar.instance().getIconManager().getDynamicPPP());
123
this.pianissimo.setImage(TuxGuitar.instance().getIconManager().getDynamicPP());
124
this.piano.setImage(TuxGuitar.instance().getIconManager().getDynamicP());
125
this.mezzoPiano.setImage(TuxGuitar.instance().getIconManager().getDynamicMP());
126
this.mezzoForte.setImage(TuxGuitar.instance().getIconManager().getDynamicMF());
127
this.forte.setImage(TuxGuitar.instance().getIconManager().getDynamicF());
128
this.fortissimo.setImage(TuxGuitar.instance().getIconManager().getDynamicFF());
129
this.forteFortissimo.setImage(TuxGuitar.instance().getIconManager().getDynamicFFF());