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

« back to all changes in this revision

Viewing changes to src/org/herac/tuxguitar/gui/items/menu/DurationMenuItem.java

  • Committer: Bazaar Package Importer
  • Author(s): Philippe Coval
  • Date: 2007-02-04 01:41:23 UTC
  • Revision ID: james.westby@ubuntu.com-20070204014123-9pv7okph0iaiqkvw
Tags: upstream-0.9.1
ImportĀ upstreamĀ versionĀ 0.9.1

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.menu;
 
8
 
 
9
import org.eclipse.swt.SWT;
 
10
import org.eclipse.swt.widgets.Menu;
 
11
import org.eclipse.swt.widgets.MenuItem;
 
12
import org.eclipse.swt.widgets.Shell;
 
13
import org.herac.tuxguitar.gui.SystemImages;
 
14
import org.herac.tuxguitar.gui.TuxGuitar;
 
15
import org.herac.tuxguitar.gui.actions.duration.ChangeDottedDurationAction;
 
16
import org.herac.tuxguitar.gui.actions.duration.ChangeDoubleDottedDurationAction;
 
17
import org.herac.tuxguitar.gui.actions.duration.ChangeTupletoDurationAction;
 
18
import org.herac.tuxguitar.gui.actions.duration.SetEighthDurationAction;
 
19
import org.herac.tuxguitar.gui.actions.duration.SetHalfDurationAction;
 
20
import org.herac.tuxguitar.gui.actions.duration.SetQuarterDurationAction;
 
21
import org.herac.tuxguitar.gui.actions.duration.SetSixteenthDurationAction;
 
22
import org.herac.tuxguitar.gui.actions.duration.SetSixtyFourthDurationAction;
 
23
import org.herac.tuxguitar.gui.actions.duration.SetThirtySecondDurationAction;
 
24
import org.herac.tuxguitar.gui.actions.duration.SetWholeDurationAction;
 
25
import org.herac.tuxguitar.gui.editors.TablatureEditor;
 
26
import org.herac.tuxguitar.gui.items.MenuItems;
 
27
import org.herac.tuxguitar.song.models.Duration;
 
28
/**
 
29
 * @author julian
 
30
 *
 
31
 * TODO To change the template for this generated type comment go to
 
32
 * Window - Preferences - Java - Code Style - Code Templates
 
33
 */
 
34
public class DurationMenuItem  implements MenuItems{
 
35
    private TablatureEditor tablatureEditor;
 
36
    private Shell shell;
 
37
    private MenuItem durationMenuItem;
 
38
    private Menu menu; 
 
39
    private MenuItem whole;
 
40
    private MenuItem half;
 
41
    private MenuItem quarter;
 
42
    private MenuItem eighth;
 
43
    private MenuItem sixteenth;
 
44
    private MenuItem thirtySecond;
 
45
    private MenuItem sixtyFourth;
 
46
    private MenuItem dotted;
 
47
    private MenuItem doubleDotted;
 
48
    private MenuItem tupleto;
 
49
    
 
50
    public DurationMenuItem(Shell shell,Menu parent, int style,TablatureEditor tablatureEditor) {
 
51
        this.durationMenuItem = new MenuItem(parent, style);
 
52
        this.tablatureEditor = tablatureEditor;
 
53
        this.shell = shell;
 
54
        this.menu = new Menu(shell, SWT.DROP_DOWN);
 
55
    }
 
56
 
 
57
    
 
58
    public void showItems(){  
 
59
        //--whole--
 
60
        this.whole = new MenuItem(this.menu, SWT.PUSH);
 
61
        this.whole.setImage(SystemImages.getDuration(Duration.WHOLE));
 
62
        this.whole.addSelectionListener(TuxGuitar.instance().getAction(SetWholeDurationAction.NAME));
 
63
        //--half--
 
64
        this.half = new MenuItem(this.menu, SWT.PUSH);
 
65
        this.half.setImage(SystemImages.getDuration(Duration.HALF));
 
66
        this.half.addSelectionListener(TuxGuitar.instance().getAction(SetHalfDurationAction.NAME));
 
67
        //--quarter--
 
68
        this.quarter = new MenuItem(this.menu, SWT.PUSH);
 
69
        this.quarter.setImage(SystemImages.getDuration(Duration.QUARTER));
 
70
        this.quarter.addSelectionListener(TuxGuitar.instance().getAction(SetQuarterDurationAction.NAME));
 
71
        //--Eighth--
 
72
        this.eighth = new MenuItem(this.menu, SWT.PUSH);
 
73
        this.eighth.setImage(SystemImages.getDuration(Duration.EIGHTH));
 
74
        this.eighth.addSelectionListener(TuxGuitar.instance().getAction(SetEighthDurationAction.NAME));
 
75
        //--sixteenth--
 
76
        this.sixteenth = new MenuItem(this.menu, SWT.PUSH);
 
77
        this.sixteenth.setImage(SystemImages.getDuration(Duration.SIXTEENTH));
 
78
        this.sixteenth.addSelectionListener(TuxGuitar.instance().getAction(SetSixteenthDurationAction.NAME));
 
79
        //--thirtySecond--
 
80
        this.thirtySecond = new MenuItem(this.menu, SWT.PUSH);
 
81
        this.thirtySecond.setImage(SystemImages.getDuration(Duration.THIRTY_SECOND));
 
82
        this.thirtySecond.addSelectionListener(TuxGuitar.instance().getAction(SetThirtySecondDurationAction.NAME));       
 
83
        //--sixtyFourth--
 
84
        this.sixtyFourth = new MenuItem(this.menu, SWT.PUSH);
 
85
        this.sixtyFourth.setImage(SystemImages.getDuration(Duration.SIXTY_FOURTH));
 
86
        this.sixtyFourth.addSelectionListener(TuxGuitar.instance().getAction(SetSixtyFourthDurationAction.NAME));
 
87
                                
 
88
        //--SEPARATOR--
 
89
        new MenuItem(this.menu, SWT.SEPARATOR);        
 
90
        
 
91
        //--dotted---
 
92
        this.dotted = new MenuItem(this.menu, SWT.PUSH);
 
93
        this.dotted.setImage(SystemImages.DOTTED_IMAGE);
 
94
        this.dotted.addSelectionListener(TuxGuitar.instance().getAction(ChangeDottedDurationAction.NAME));        
 
95
        
 
96
        this.doubleDotted = new MenuItem(this.menu, SWT.PUSH);
 
97
        this.doubleDotted.setImage(SystemImages.DOUBLE_DOTTED_IMAGE);
 
98
        this.doubleDotted.addSelectionListener(TuxGuitar.instance().getAction(ChangeDoubleDottedDurationAction.NAME));        
 
99
        
 
100
        //--tupleto---
 
101
        this.tupleto = new MenuItem(this.menu, SWT.PUSH);
 
102
        this.tupleto.setImage(SystemImages.TUPLETO_IMAGE);
 
103
        this.tupleto.addSelectionListener(TuxGuitar.instance().getAction(ChangeTupletoDurationAction.NAME));        
 
104
                
 
105
        this.durationMenuItem.setMenu(menu);       
 
106
        
 
107
        this.loadProperties();
 
108
    }
 
109
 
 
110
    public void update(){        
 
111
    }
 
112
    
 
113
    public void loadProperties(){
 
114
        this.durationMenuItem.setText(TuxGuitar.getProperty("duration"));  
 
115
        this.whole.setText(TuxGuitar.getProperty("duration.whole"));  
 
116
        this.half.setText(TuxGuitar.getProperty("duration.half"));  
 
117
        this.quarter.setText(TuxGuitar.getProperty("duration.quarter"));
 
118
        this.eighth.setText(TuxGuitar.getProperty("duration.eighth"));  
 
119
        this.sixteenth.setText(TuxGuitar.getProperty("duration.sixteenth"));  
 
120
        this.thirtySecond.setText(TuxGuitar.getProperty("duration.thirtysecond"));
 
121
        this.sixtyFourth.setText(TuxGuitar.getProperty("duration.sixtyfourth"));
 
122
        this.dotted.setText(TuxGuitar.getProperty("duration.dotted"));
 
123
        this.doubleDotted.setText(TuxGuitar.getProperty("duration.doubledotted"));
 
124
        this.tupleto.setText(TuxGuitar.getProperty("duration.tupleto"));
 
125
    }     
 
126
}