2
* Created on 17-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.actions.duration;
9
import org.eclipse.swt.events.KeyEvent;
10
import org.eclipse.swt.events.TypedEvent;
11
import org.herac.tuxguitar.gui.actions.Action;
12
import org.herac.tuxguitar.gui.editors.TablatureEditor;
13
import org.herac.tuxguitar.gui.editors.tab.Caret;
14
import org.herac.tuxguitar.gui.undo.undoables.measure.UndoableMeasureGeneric;
15
import org.herac.tuxguitar.song.models.Duration;
16
import org.herac.tuxguitar.song.models.Tupleto;
21
* TODO To change the template for this generated type comment go to
22
* Window - Preferences - Java - Code Style - Code Templates
24
public class ChangeTupletoDurationAction extends Action{
25
public static final String NAME = "action.note.duration.change-tupleto";
27
public ChangeTupletoDurationAction(TablatureEditor tablatureEditor) {
28
super(NAME,true,tablatureEditor);
31
public boolean doAction(TypedEvent e) {
32
//comienza el undoable
33
UndoableMeasureGeneric undoable = UndoableMeasureGeneric.startUndo();
35
boolean isKeyEvent = false;
36
if(e instanceof KeyEvent){
40
Tupleto tupleto = defaultTupleto();
41
if(e.widget.getData() != null && e.widget.getData() instanceof Tupleto){
42
tupleto = (Tupleto)e.widget.getData();
45
if(getSelectedDuration().getTupleto().isEqual(tupleto)){
46
setTupleto(noTupleto());
52
if(getSelectedDuration().getTupleto().isEqual(Duration.NO_TUPLETO)){
53
setTupleto(defaultTupleto());
55
setTupleto(noTupleto());
61
getEditor().getUndoManager().addEdit(undoable.endUndo());
66
private Tupleto noTupleto(){
67
return new Tupleto(1,1);
70
private Tupleto defaultTupleto(){
71
return new Tupleto(3,2);
74
private void setTupleto(Tupleto tupleto){
75
getSelectedDuration().getTupleto().setEnters(tupleto.getEnters());
76
getSelectedDuration().getTupleto().setTimes(tupleto.getTimes());
79
private void setDurations() {
80
Caret caret = getEditor().getTablature().getCaret();
81
caret.changeDuration((Duration)getSelectedDuration().clone());
82
fireUpdate(getEditor().getTablature().getCaret().getMeasureCoords().getMeasure().getNumber());
86
public Duration getSelectedDuration(){
87
return getEditor().getTablature().getCaret().getDuration();