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.events.SelectionAdapter;
11
import org.eclipse.swt.events.SelectionEvent;
12
import org.eclipse.swt.widgets.ToolBar;
13
import org.eclipse.swt.widgets.ToolItem;
14
import org.herac.tuxguitar.gui.SystemImages;
15
import org.herac.tuxguitar.gui.TuxGuitar;
16
import org.herac.tuxguitar.gui.items.ToolItems;
20
* TODO To change the template for this generated type comment go to
21
* Window - Preferences - Java - Code Style - Code Templates
23
public class PlayerToolItems extends ToolItems{
24
public static final String NAME = "player.items";
26
private static final int STATUS_STOPED = 1;
27
private static final int STATUS_PAUSED = 2;
28
private static final int STATUS_RUNNING = 3;
30
private ToolBar toolBar;
31
private ToolItem first;
32
private ToolItem last;
33
private ToolItem previous;
34
private ToolItem next;
35
private ToolItem stop;
36
private ToolItem play;
39
public PlayerToolItems(){
43
public void showItems(ToolBar toolBar){
44
this.toolBar = toolBar;
46
this.first = new ToolItem(toolBar,SWT.PUSH);
47
this.first.setImage(SystemImages.TRANSPORT_ICON_FIRST_1);
48
this.first.addSelectionListener(new SelectionAdapter() {
49
public void widgetSelected(SelectionEvent e) {
50
TuxGuitar.instance().getTransport().gotoFirst(e);
54
this.previous = new ToolItem(toolBar,SWT.PUSH);
55
this.previous.setImage(SystemImages.TRANSPORT_ICON_PREVIOUS_1);
56
this.previous.addSelectionListener(new SelectionAdapter() {
57
public void widgetSelected(SelectionEvent e) {
58
TuxGuitar.instance().getTransport().gotoPrevious(e);
62
this.stop = new ToolItem(toolBar,SWT.PUSH);
63
this.stop.setImage(SystemImages.TRANSPORT_ICON_STOP_1);
64
this.stop.addSelectionListener(new SelectionAdapter() {
65
public void widgetSelected(SelectionEvent e) {
66
TuxGuitar.instance().getTransport().stop(e);
70
this.play = new ToolItem(toolBar,SWT.PUSH);
71
this.play.setImage(SystemImages.TRANSPORT_ICON_PLAY_1);
72
this.play.addSelectionListener(new SelectionAdapter() {
73
public void widgetSelected(SelectionEvent e) {
74
TuxGuitar.instance().getTransport().play(e);
78
this.next = new ToolItem(toolBar,SWT.PUSH);
79
this.next.setImage(SystemImages.TRANSPORT_ICON_NEXT_1);
80
this.next.addSelectionListener(new SelectionAdapter() {
81
public void widgetSelected(SelectionEvent e) {
82
TuxGuitar.instance().getTransport().gotoNext(e);
86
this.last = new ToolItem(toolBar,SWT.PUSH);
87
this.last.setImage(SystemImages.TRANSPORT_ICON_LAST_1);
88
this.last.addSelectionListener(new SelectionAdapter() {
89
public void widgetSelected(SelectionEvent e) {
90
TuxGuitar.instance().getTransport().gotoLast(e);
94
this.status = STATUS_STOPED;
95
this.loadProperties();
100
public void update(){
101
int lastStatus = this.status;
103
if(TuxGuitar.instance().getPlayer().isRunning()){
104
this.status = STATUS_RUNNING;
105
}else if(TuxGuitar.instance().getPlayer().isPaused()){
106
this.status = STATUS_PAUSED;
108
this.status = STATUS_STOPED;
111
if(lastStatus != this.status){
112
if(this.status == STATUS_RUNNING){
113
this.first.setImage(SystemImages.TRANSPORT_ICON_FIRST_2);
114
this.last.setImage(SystemImages.TRANSPORT_ICON_LAST_2);
115
this.previous.setImage(SystemImages.TRANSPORT_ICON_PREVIOUS_2);
116
this.next.setImage(SystemImages.TRANSPORT_ICON_NEXT_2);
117
this.stop.setImage(SystemImages.TRANSPORT_ICON_STOP_2);
118
this.play.setImage(SystemImages.TRANSPORT_ICON_PAUSE);
119
}else if(this.status == STATUS_PAUSED){
120
this.first.setImage(SystemImages.TRANSPORT_ICON_FIRST_2);
121
this.last.setImage(SystemImages.TRANSPORT_ICON_LAST_2);
122
this.previous.setImage(SystemImages.TRANSPORT_ICON_PREVIOUS_2);
123
this.next.setImage(SystemImages.TRANSPORT_ICON_NEXT_2);
124
this.stop.setImage(SystemImages.TRANSPORT_ICON_STOP_2);
125
this.play.setImage(SystemImages.TRANSPORT_ICON_PLAY_2);
127
}else if(this.status == STATUS_STOPED){
128
this.first.setImage(SystemImages.TRANSPORT_ICON_FIRST_1);
129
this.last.setImage(SystemImages.TRANSPORT_ICON_LAST_1);
130
this.previous.setImage(SystemImages.TRANSPORT_ICON_PREVIOUS_1);
131
this.next.setImage(SystemImages.TRANSPORT_ICON_NEXT_1);
132
this.stop.setImage(SystemImages.TRANSPORT_ICON_STOP_1);
133
this.play.setImage(SystemImages.TRANSPORT_ICON_PLAY_1);
139
public void loadProperties(){
140
this.play.setToolTipText(TuxGuitar.getProperty("player.start"));
141
this.stop.setToolTipText(TuxGuitar.getProperty("player.stop"));