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

« back to all changes in this revision

Viewing changes to src/org/herac/tuxguitar/gui/actions/note/ChangeTiedNoteAction.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 17-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.actions.note;
 
8
 
 
9
import org.eclipse.swt.events.TypedEvent;
 
10
import org.herac.tuxguitar.gui.actions.Action;
 
11
import org.herac.tuxguitar.gui.editors.TablatureEditor;
 
12
import org.herac.tuxguitar.gui.editors.tab.Caret;
 
13
import org.herac.tuxguitar.gui.editors.tab.MeasureComponent;
 
14
import org.herac.tuxguitar.gui.editors.tab.NoteCoords;
 
15
import org.herac.tuxguitar.gui.undo.undoables.measure.UndoableMeasureGeneric;
 
16
 
 
17
/**
 
18
 * @author julian
 
19
 *
 
20
 * TODO To change the template for this generated type comment go to
 
21
 * Window - Preferences - Java - Code Style - Code Templates
 
22
 */
 
23
public class ChangeTiedNoteAction extends Action{
 
24
    public static final String NAME = "action.note.general.tied";
 
25
    
 
26
    public ChangeTiedNoteAction(TablatureEditor tablatureEditor) {
 
27
        super(NAME,true,tablatureEditor);       
 
28
    }
 
29
 
 
30
    public boolean doAction(TypedEvent e) {
 
31
        Caret caret = getEditor().getTablature().getCaret();
 
32
        MeasureComponent component = caret.getMeasureCoords().getComponent(caret.getPosition(),caret.getSelectedString().getNumber());
 
33
        if(component instanceof NoteCoords){
 
34
            //comienza el undoable
 
35
                UndoableMeasureGeneric undoable = UndoableMeasureGeneric.startUndo();           
 
36
                
 
37
            NoteCoords note = (NoteCoords)component;   
 
38
            getSongManager().getMeasureManager().changeTieNote(note.getNote());            
 
39
            
 
40
            //termia el undoable
 
41
            getEditor().getUndoManager().addEdit(undoable.endUndo());               
 
42
        }
 
43
        updateTablature();          
 
44
        return true;
 
45
    }
 
46
    
 
47
 
 
48
    protected void updateTablature() {
 
49
        fireUpdate(getEditor().getTablature().getCaret().getMeasureCoords().getMeasure().getNumber());
 
50
        redraw();
 
51
    }        
 
52
 
 
53
}