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.mouse;
9
import org.eclipse.swt.events.TypedEvent;
10
import org.herac.tuxguitar.gui.actions.Action;
11
import org.herac.tuxguitar.gui.editors.TablatureEditor;
16
* TODO To change the template for this generated type comment go to Window - Preferences - Java - Code Style - Code Templates
19
public class SelectComponentAction extends Action {
20
public static final String NAME = "SELECT_COMPONENT";
22
public SelectComponentAction(TablatureEditor tablatureEditor) {
23
super(NAME, tablatureEditor);
26
public boolean doAction(TypedEvent e) {
30
if (e instanceof MouseEvent) {
31
MouseEvent mouseEvent = (MouseEvent) e;
35
Point point = TuxGuitar.instance().getTablatureEditor().getTablature().toControl(TuxGuitar.instance().getDisplay().getCursorLocation());
40
SongTrackCoords trackCoords = getTrackCoords(y);
41
if (trackCoords != null) {
42
MeasureCoords measureCoords = getMeasureCoords(trackCoords, x,y);
43
if (measureCoords != null) {
44
MeasureComponent measureComponent = getMeasureComponent(measureCoords, x);
45
InstrumentString instrumentString = getMeasureString(measureCoords, y);
46
if (measureComponent != null) {
47
getEditor().getTablature().getCaret().moveTo(trackCoords, measureCoords, measureComponent);
48
if (instrumentString != null) {
49
getEditor().getTablature().getCaret().setStringNumber(instrumentString.getNumber());
60
private SongTrackCoords getTrackCoords(int y) {
61
return getEditor().getTablature().getSongCoords().getTrackAt(y, -getEditor().getTablature().getVerticalBar().getSelection());
64
private MeasureCoords getMeasureCoords(SongTrackCoords trackCoords, int x,int y) {
65
return trackCoords.getMeasureAt(x,y, -getEditor().getTablature().getHorizontalBar().getSelection(),-getEditor().getTablature().getVerticalBar().getSelection());
68
private MeasureComponent getMeasureComponent(MeasureCoords measureCoords, int x) {
69
return measureCoords.getComponentAt(x);
72
private InstrumentString getMeasureString(MeasureCoords measureCoords, int y) {
73
return measureCoords.getStringAt(y);
b'\\ No newline at end of file'