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

« back to all changes in this revision

Viewing changes to TuxGuitar/src/org/herac/tuxguitar/gui/items/tool/CompositionToolItems.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.widgets.ToolBar;
 
11
import org.eclipse.swt.widgets.ToolItem;
 
12
import org.herac.tuxguitar.gui.TuxGuitar;
 
13
import org.herac.tuxguitar.gui.actions.composition.ChangeTempoAction;
 
14
import org.herac.tuxguitar.gui.actions.composition.ChangeTimeSignatureAction;
 
15
import org.herac.tuxguitar.gui.actions.insert.RepeatAlternativeAction;
 
16
import org.herac.tuxguitar.gui.actions.insert.RepeatCloseAction;
 
17
import org.herac.tuxguitar.gui.actions.insert.RepeatOpenAction;
 
18
import org.herac.tuxguitar.gui.items.ToolItems;
 
19
 
 
20
/**
 
21
 * @author julian
 
22
 *
 
23
 * TODO To change the template for this generated type comment go to
 
24
 * Window - Preferences - Java - Code Style - Code Templates
 
25
 */
 
26
public class CompositionToolItems extends ToolItems{
 
27
        public static final String NAME = "composition.items";
 
28
        
 
29
        private ToolItem tempo;
 
30
        private ToolItem timeSignature;
 
31
        private ToolItem repeatOpen;
 
32
        private ToolItem repeatClose;
 
33
        private ToolItem repeatAlternative;
 
34
        
 
35
        public CompositionToolItems(){
 
36
                super(NAME);
 
37
        }
 
38
        
 
39
        public void showItems(ToolBar toolBar){
 
40
                this.tempo = new ToolItem(toolBar, SWT.PUSH);
 
41
                this.tempo.addSelectionListener(TuxGuitar.instance().getAction(ChangeTempoAction.NAME));
 
42
                
 
43
                this.timeSignature = new ToolItem(toolBar, SWT.PUSH);
 
44
                this.timeSignature.addSelectionListener(TuxGuitar.instance().getAction(ChangeTimeSignatureAction.NAME));
 
45
                
 
46
                new ToolItem(toolBar, SWT.SEPARATOR);
 
47
                
 
48
                this.repeatOpen = new ToolItem(toolBar, SWT.PUSH);
 
49
                this.repeatOpen.addSelectionListener(TuxGuitar.instance().getAction(RepeatOpenAction.NAME));
 
50
                
 
51
                this.repeatClose = new ToolItem(toolBar, SWT.PUSH);
 
52
                this.repeatClose.addSelectionListener(TuxGuitar.instance().getAction(RepeatCloseAction.NAME));
 
53
                
 
54
                this.repeatAlternative = new ToolItem(toolBar, SWT.PUSH);
 
55
                this.repeatAlternative.addSelectionListener(TuxGuitar.instance().getAction(RepeatAlternativeAction.NAME));
 
56
                
 
57
                this.loadIcons();
 
58
                this.loadProperties();
 
59
        }
 
60
        
 
61
        public void loadProperties(){
 
62
                this.tempo.setToolTipText(TuxGuitar.getProperty("composition.tempo"));
 
63
                this.timeSignature.setToolTipText(TuxGuitar.getProperty("composition.timesignature"));
 
64
                this.repeatOpen.setToolTipText(TuxGuitar.getProperty("repeat.open"));
 
65
                this.repeatClose.setToolTipText(TuxGuitar.getProperty("repeat.close"));
 
66
                this.repeatAlternative.setToolTipText(TuxGuitar.getProperty("repeat.alternative"));
 
67
        }
 
68
        
 
69
        public void loadIcons(){
 
70
                this.tempo.setImage(TuxGuitar.instance().getIconManager().getCompositionTempo());
 
71
                this.timeSignature.setImage(TuxGuitar.instance().getIconManager().getCompositionTimeSignature());
 
72
                this.repeatOpen.setImage(TuxGuitar.instance().getIconManager().getCompositionRepeatOpen());
 
73
                this.repeatClose.setImage(TuxGuitar.instance().getIconManager().getCompositionRepeatClose());
 
74
                this.repeatAlternative.setImage(TuxGuitar.instance().getIconManager().getCompositionRepeatAlternative());
 
75
        }
 
76
        
 
77
        public void update(){
 
78
                boolean running = TuxGuitar.instance().getPlayer().isRunning();
 
79
                this.tempo.setEnabled( !running );
 
80
                this.timeSignature.setEnabled( !running );
 
81
                this.repeatOpen.setEnabled( !running );
 
82
                this.repeatClose.setEnabled( !running );
 
83
                this.repeatAlternative.setEnabled( !running );
 
84
        }
 
85
}