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.SystemImages;
16
import org.herac.tuxguitar.gui.TuxGuitar;
17
import org.herac.tuxguitar.gui.editors.TablatureEditor;
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 PlayMenuItem implements MenuItems{
27
private static final int STATUS_STOPED = 1;
28
private static final int STATUS_PAUSED = 2;
29
private static final int STATUS_RUNNING = 3;
31
private TablatureEditor tablatureEditor;
33
private MenuItem playMenuItem;
35
private MenuItem play;
36
private MenuItem stop;
39
public PlayMenuItem(Shell shell,Menu parent, int style,TablatureEditor tablatureEditor) {
40
this.playMenuItem = new MenuItem(parent, style);
41
this.tablatureEditor = tablatureEditor;
43
this.menu = new Menu(shell, SWT.DROP_DOWN);
47
public void showItems(){
48
this.play = new MenuItem(this.menu,SWT.PUSH);
49
this.play.setImage(SystemImages.TRANSPORT_ICON_PLAY_1);
50
this.play.addSelectionListener(new SelectionAdapter() {
51
public void widgetSelected(SelectionEvent e) {
52
TuxGuitar.instance().getTransport().play(e);
56
this.stop = new MenuItem(this.menu, SWT.PUSH);
57
this.stop.setImage(SystemImages.TRANSPORT_ICON_STOP_1);
58
this.stop.addSelectionListener(new SelectionAdapter() {
59
public void widgetSelected(SelectionEvent e) {
60
TuxGuitar.instance().getTransport().stop(e);
64
this.status = STATUS_STOPED;
65
this.playMenuItem.setMenu(menu);
66
this.loadProperties();
70
int lastStatus = this.status;
72
if(TuxGuitar.instance().getPlayer().isRunning()){
73
this.status = STATUS_RUNNING;
74
}else if(TuxGuitar.instance().getPlayer().isPaused()){
75
this.status = STATUS_PAUSED;
77
this.status = STATUS_STOPED;
80
if(lastStatus != this.status){
81
if(this.status == STATUS_RUNNING){
82
this.stop.setImage(SystemImages.TRANSPORT_ICON_STOP_2);
83
this.play.setImage(SystemImages.TRANSPORT_ICON_PAUSE);
84
}else if(this.status == STATUS_PAUSED){
85
this.stop.setImage(SystemImages.TRANSPORT_ICON_STOP_2);
86
this.play.setImage(SystemImages.TRANSPORT_ICON_PLAY_2);
87
}else if(this.status == STATUS_STOPED){
88
this.stop.setImage(SystemImages.TRANSPORT_ICON_STOP_1);
89
this.play.setImage(SystemImages.TRANSPORT_ICON_PLAY_1);
94
public void loadProperties(){
95
this.playMenuItem.setText(TuxGuitar.getProperty("player"));
96
this.play.setText(TuxGuitar.getProperty("player.start"));
97
this.stop.setText(TuxGuitar.getProperty("player.stop"));