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

« back to all changes in this revision

Viewing changes to src/org/herac/tuxguitar/gui/items/tool/EditToolItems.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.SystemImages;
13
 
import org.herac.tuxguitar.gui.TuxGuitar;
14
 
import org.herac.tuxguitar.gui.actions.edit.RedoAction;
15
 
import org.herac.tuxguitar.gui.actions.edit.SetMouseModeEditionAction;
16
 
import org.herac.tuxguitar.gui.actions.edit.SetMouseModeSelectionAction;
17
 
import org.herac.tuxguitar.gui.actions.edit.SetNaturalKeyAction;
18
 
import org.herac.tuxguitar.gui.actions.edit.UndoAction;
19
 
import org.herac.tuxguitar.gui.editors.tab.edit.EditorKit;
20
 
import org.herac.tuxguitar.gui.items.ToolItems;
21
 
/**
22
 
 * @author julian
23
 
 *
24
 
 * TODO To change the template for this generated type comment go to
25
 
 * Window - Preferences - Java - Code Style - Code Templates
26
 
 */
27
 
public class EditToolItems extends ToolItems {
28
 
    public static final String NAME = "edit.items";
29
 
    private ToolBar toolBar;   
30
 
    private ToolItem undo;
31
 
    private ToolItem redo;
32
 
    
33
 
    private ToolItem modeSelection;
34
 
    private ToolItem modeEdition;
35
 
    private ToolItem notNaturalKey;    
36
 
    
37
 
    public EditToolItems(){
38
 
        super(NAME);
39
 
    }
40
 
   
41
 
    public void showItems(ToolBar toolBar){
42
 
        this.toolBar = toolBar;               
43
 
        this.undo = new ToolItem(toolBar, SWT.PUSH);
44
 
        this.undo.setImage(SystemImages.EDIT_UNDO);
45
 
        this.undo.addSelectionListener(TuxGuitar.instance().getAction(UndoAction.NAME));
46
 
       
47
 
        this.redo = new ToolItem(toolBar, SWT.PUSH);
48
 
        this.redo.setImage(SystemImages.EDIT_REDO);
49
 
        this.redo.addSelectionListener(TuxGuitar.instance().getAction(RedoAction.NAME));
50
 
 
51
 
        new ToolItem(toolBar, SWT.SEPARATOR);
52
 
        
53
 
        this.modeSelection = new ToolItem(toolBar, SWT.RADIO);
54
 
        this.modeSelection.setImage(SystemImages.EDIT_MODE_SELECTION);
55
 
        this.modeSelection.addSelectionListener(TuxGuitar.instance().getAction(SetMouseModeSelectionAction.NAME));        
56
 
        
57
 
        this.modeEdition = new ToolItem(toolBar, SWT.RADIO);
58
 
        this.modeEdition.setImage(SystemImages.EDIT_MODE_EDITION);
59
 
        this.modeEdition.addSelectionListener(TuxGuitar.instance().getAction(SetMouseModeEditionAction.NAME));        
60
 
        
61
 
        this.notNaturalKey = new ToolItem(toolBar, SWT.CHECK);
62
 
        this.notNaturalKey.setImage(SystemImages.EDIT_MODE_EDITION_NO_NATURAL);
63
 
        this.notNaturalKey.addSelectionListener(TuxGuitar.instance().getAction(SetNaturalKeyAction.NAME));  
64
 
        
65
 
        this.loadProperties();
66
 
    }
67
 
    
68
 
    
69
 
    public void update(){
70
 
        this.undo.setEnabled(getEditor().getUndoManager().canUndo());
71
 
        this.redo.setEnabled(getEditor().getUndoManager().canRedo());
72
 
        this.modeSelection.setSelection(getEditor().getTablature().getEditorKit().getMouseMode() == EditorKit.MOUSE_MODE_SELECTION);
73
 
        this.modeEdition.setSelection(getEditor().getTablature().getEditorKit().getMouseMode() == EditorKit.MOUSE_MODE_EDITION);
74
 
        this.notNaturalKey.setSelection(!getEditor().getTablature().getEditorKit().isNatural());
75
 
        this.notNaturalKey.setEnabled(getEditor().getTablature().getEditorKit().getMouseMode() == EditorKit.MOUSE_MODE_EDITION);        
76
 
    }
77
 
    
78
 
    public void loadProperties(){
79
 
        this.undo.setToolTipText(TuxGuitar.getProperty("edit.undo"));  
80
 
        this.redo.setToolTipText(TuxGuitar.getProperty("edit.redo"));  
81
 
        this.modeSelection.setToolTipText(TuxGuitar.getProperty("edit.mouse-mode-selection"));
82
 
        this.modeEdition.setToolTipText(TuxGuitar.getProperty("edit.mouse-mode-edition"));
83
 
        this.notNaturalKey.setToolTipText(TuxGuitar.getProperty("edit.not-natural-key"));        
84
 
    }        
85
 
}
86