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

« back to all changes in this revision

Viewing changes to src/org/herac/tuxguitar/gui/items/tool/PlayerToolItems.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.tool;
8
 
 
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;
17
 
/**
18
 
 * @author julian
19
 
 *
20
 
 * TODO To change the template for this generated type comment go to
21
 
 * Window - Preferences - Java - Code Style - Code Templates
22
 
 */
23
 
public class PlayerToolItems  extends ToolItems{
24
 
    public static final String NAME = "player.items";
25
 
    
26
 
        private static final int STATUS_STOPED = 1;
27
 
        private static final int STATUS_PAUSED = 2;
28
 
        private static final int STATUS_RUNNING = 3;    
29
 
        
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;  
37
 
        private int status;
38
 
        
39
 
    public PlayerToolItems(){
40
 
        super(NAME);
41
 
    }
42
 
   
43
 
    public void showItems(ToolBar toolBar){
44
 
        this.toolBar = toolBar;     
45
 
        
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);
51
 
                        }               
52
 
                });
53
 
                
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);
59
 
                        }               
60
 
                });     
61
 
        
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);
67
 
                        }               
68
 
                });                             
69
 
                
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);
75
 
                        }               
76
 
                });             
77
 
        
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);
83
 
                        }               
84
 
                });
85
 
                
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);
91
 
                        }               
92
 
                });        
93
 
        
94
 
                this.status = STATUS_STOPED;
95
 
        this.loadProperties();
96
 
    }
97
 
 
98
 
    
99
 
    
100
 
    public void update(){
101
 
        int lastStatus = this.status;
102
 
        
103
 
        if(TuxGuitar.instance().getPlayer().isRunning()){
104
 
                this.status = STATUS_RUNNING;                                   
105
 
                }else if(TuxGuitar.instance().getPlayer().isPaused()){
106
 
                        this.status = STATUS_PAUSED;
107
 
                }else{
108
 
                        this.status = STATUS_STOPED;
109
 
        }               
110
 
        
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); 
126
 
                                
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);
134
 
                        }       
135
 
                }       
136
 
                
137
 
    }
138
 
    
139
 
    public void loadProperties(){
140
 
        this.play.setToolTipText(TuxGuitar.getProperty("player.start"));
141
 
        this.stop.setToolTipText(TuxGuitar.getProperty("player.stop"));  
142
 
    }        
143
 
}
144