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.menu;
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.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.MenuItems;
25
* TODO To change the template for this generated type comment go to
26
* Window - Preferences - Java - Code Style - Code Templates
28
public class EditMenuItem implements MenuItems{
30
private MenuItem editMenuItem;
32
private MenuItem undo;
33
private MenuItem redo;
34
private MenuItem modeSelection;
35
private MenuItem modeEdition;
36
private MenuItem notNaturalKey;
38
public EditMenuItem(Shell shell,Menu parent, int style) {
39
this.editMenuItem = new MenuItem(parent, style);
40
this.menu = new Menu(shell, SWT.DROP_DOWN);
43
public void showItems(){
44
//---------------------------------------------------
46
this.undo = new MenuItem(this.menu, SWT.PUSH);
47
this.undo.addSelectionListener(TuxGuitar.instance().getAction(UndoAction.NAME));
49
this.redo = new MenuItem(this.menu, SWT.PUSH);
50
this.redo.addSelectionListener(TuxGuitar.instance().getAction(RedoAction.NAME));
52
new MenuItem(this.menu, SWT.SEPARATOR);
53
//--TABLATURE EDIT MODE
54
this.modeSelection = new MenuItem(this.menu, SWT.RADIO);
55
this.modeSelection.addSelectionListener(TuxGuitar.instance().getAction(SetMouseModeSelectionAction.NAME));
57
this.modeEdition = new MenuItem(this.menu, SWT.RADIO);
58
this.modeEdition.addSelectionListener(TuxGuitar.instance().getAction(SetMouseModeEditionAction.NAME));
60
this.notNaturalKey = new MenuItem(this.menu, SWT.CHECK);
61
this.notNaturalKey.addSelectionListener(TuxGuitar.instance().getAction(SetNaturalKeyAction.NAME));
63
this.editMenuItem.setMenu(this.menu);
66
this.loadProperties();
70
EditorKit kit = TuxGuitar.instance().getTablatureEditor().getTablature().getEditorKit();
71
boolean running = TuxGuitar.instance().getPlayer().isRunning();
72
this.undo.setEnabled(!running && TuxGuitar.instance().getUndoableManager().canUndo());
73
this.redo.setEnabled(!running && TuxGuitar.instance().getUndoableManager().canRedo());
74
this.modeSelection.setSelection(kit.getMouseMode() == EditorKit.MOUSE_MODE_SELECTION);
75
this.modeSelection.setEnabled(!running);
76
this.modeEdition.setSelection(kit.getMouseMode() == EditorKit.MOUSE_MODE_EDITION);
77
this.modeEdition.setEnabled(!running);
78
this.notNaturalKey.setSelection(!kit.isNatural());
79
this.notNaturalKey.setEnabled(!running && kit.getMouseMode() == EditorKit.MOUSE_MODE_EDITION);
82
public void loadProperties(){
83
this.editMenuItem.setText(TuxGuitar.getProperty("edit.menu"));
84
this.undo.setText(TuxGuitar.getProperty("edit.undo"));
85
this.redo.setText(TuxGuitar.getProperty("edit.redo"));
86
this.modeSelection.setText(TuxGuitar.getProperty("edit.mouse-mode-selection"));
87
this.modeEdition.setText(TuxGuitar.getProperty("edit.mouse-mode-edition"));
88
this.notNaturalKey.setText(TuxGuitar.getProperty("edit.not-natural-key"));
91
public void loadIcons(){
92
this.undo.setImage(TuxGuitar.instance().getIconManager().getEditUndo());
93
this.redo.setImage(TuxGuitar.instance().getIconManager().getEditRedo());