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.events.SelectionAdapter;
11
import org.eclipse.swt.events.SelectionEvent;
12
import org.eclipse.swt.widgets.Menu;
13
import org.eclipse.swt.widgets.MenuItem;
14
import org.eclipse.swt.widgets.Shell;
15
import org.herac.tuxguitar.gui.TuxGuitar;
16
import org.herac.tuxguitar.gui.actions.transport.TransportMetronomeAction;
17
import org.herac.tuxguitar.gui.actions.transport.TransportModeAction;
18
import org.herac.tuxguitar.gui.items.MenuItems;
23
* TODO To change the template for this generated type comment go to
24
* Window - Preferences - Java - Code Style - Code Templates
26
public class TransportMenuItem implements MenuItems{
27
private static final int STATUS_STOPPED = 1;
28
private static final int STATUS_PAUSED = 2;
29
private static final int STATUS_RUNNING = 3;
31
private MenuItem transportMenuItem;
33
private MenuItem play;
34
private MenuItem stop;
35
private MenuItem mode;
36
private MenuItem metronome;
40
public TransportMenuItem(Shell shell,Menu parent, int style) {
41
this.transportMenuItem = new MenuItem(parent, style);
42
this.menu = new Menu(shell, SWT.DROP_DOWN);
45
public void showItems(){
46
this.play = new MenuItem(this.menu,SWT.PUSH);
47
this.play.addSelectionListener(new SelectionAdapter() {
48
public void widgetSelected(SelectionEvent e) {
49
TuxGuitar.instance().getTransport().play(e);
53
this.stop = new MenuItem(this.menu, SWT.PUSH);
54
this.stop.addSelectionListener(new SelectionAdapter() {
55
public void widgetSelected(SelectionEvent e) {
56
TuxGuitar.instance().getTransport().stop(e);
61
new MenuItem(this.menu, SWT.SEPARATOR);
63
this.metronome = new MenuItem(this.menu, SWT.CHECK);
64
this.metronome.addSelectionListener(TuxGuitar.instance().getAction(TransportMetronomeAction.NAME));
66
this.mode = new MenuItem(this.menu, SWT.PUSH);
67
this.mode.addSelectionListener(TuxGuitar.instance().getAction(TransportModeAction.NAME));
69
this.transportMenuItem.setMenu(this.menu);
71
this.status = STATUS_STOPPED;
73
this.loadProperties();
77
this.metronome.setSelection(TuxGuitar.instance().getPlayer().isMetronomeEnabled());
78
this.loadIcons(false);
81
public void loadProperties(){
82
this.transportMenuItem.setText(TuxGuitar.getProperty("transport"));
83
this.play.setText(TuxGuitar.getProperty("transport.start"));
84
this.stop.setText(TuxGuitar.getProperty("transport.stop"));
85
this.mode.setText(TuxGuitar.getProperty("transport.mode"));
86
this.metronome.setText(TuxGuitar.getProperty("transport.metronome"));
89
public void loadIcons(){
91
this.mode.setImage(TuxGuitar.instance().getIconManager().getTransportMode());
92
this.metronome.setImage(TuxGuitar.instance().getIconManager().getTransportMetronome());
95
public void loadIcons(boolean force){
96
int lastStatus = this.status;
98
if(TuxGuitar.instance().getPlayer().isRunning()){
99
this.status = STATUS_RUNNING;
100
}else if(TuxGuitar.instance().getPlayer().isPaused()){
101
this.status = STATUS_PAUSED;
103
this.status = STATUS_STOPPED;
106
if(force || lastStatus != this.status){
107
if(this.status == STATUS_RUNNING){
108
this.stop.setImage(TuxGuitar.instance().getIconManager().getTransportIconStop2());
109
this.play.setImage(TuxGuitar.instance().getIconManager().getTransportIconPause());
110
}else if(this.status == STATUS_PAUSED){
111
this.stop.setImage(TuxGuitar.instance().getIconManager().getTransportIconStop2());
112
this.play.setImage(TuxGuitar.instance().getIconManager().getTransportIconPlay2());
113
}else if(this.status == STATUS_STOPPED){
114
this.stop.setImage(TuxGuitar.instance().getIconManager().getTransportIconStop1());
115
this.play.setImage(TuxGuitar.instance().getIconManager().getTransportIconPlay1());