1
package org.herac.tuxguitar.gui.editors.effects;
3
import org.eclipse.swt.SWT;
4
import org.eclipse.swt.events.SelectionAdapter;
5
import org.eclipse.swt.events.SelectionEvent;
6
import org.eclipse.swt.layout.GridData;
7
import org.eclipse.swt.layout.GridLayout;
8
import org.eclipse.swt.widgets.Button;
9
import org.eclipse.swt.widgets.Composite;
10
import org.eclipse.swt.widgets.Group;
11
import org.eclipse.swt.widgets.Shell;
12
import org.herac.tuxguitar.gui.TuxGuitar;
13
import org.herac.tuxguitar.gui.util.DialogUtils;
14
import org.herac.tuxguitar.song.models.TGDuration;
15
import org.herac.tuxguitar.song.models.TGNote;
16
import org.herac.tuxguitar.song.models.effects.TGEffectTremoloPicking;
18
public class TremoloPickingEditor extends SelectionAdapter{
20
public static final int WIDTH = 400;
22
public static final int HEIGHT = 0;
24
private Button thirtySecondButton;
25
private Button sixTeenthButton;
26
private Button eighthButton;
28
protected TGEffectTremoloPicking result;
30
public TremoloPickingEditor(){
34
public TGEffectTremoloPicking show(final TGNote note){
35
final Shell dialog = DialogUtils.newDialog(TuxGuitar.instance().getShell(), SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL);
37
dialog.setLayout(new GridLayout());
38
dialog.setText(TuxGuitar.getProperty("effects.tremolo-picking-editor"));
40
Composite composite = new Composite(dialog,SWT.NONE);
41
composite.setLayout(new GridLayout());
42
composite.setLayoutData(new GridData(SWT.FILL,SWT.FILL,true,true));
44
int horizontalSpan = 2;
46
//-----defaults-------------------------------------------------
47
int duration = TGDuration.EIGHTH;
48
if(note.getEffect().isTremoloPicking()){
49
duration = note.getEffect().getTremoloPicking().getDuration().getValue();
52
//---------------------------------------------------
53
//------------------DURATION-------------------------
54
//---------------------------------------------------
55
Group durationGroup = makeGroup(composite,horizontalSpan, TuxGuitar.getProperty("duration"));
56
durationGroup.setLayout(new GridLayout(3,false));
58
this.thirtySecondButton = new Button(durationGroup,SWT.RADIO);
59
this.thirtySecondButton.setImage(TuxGuitar.instance().getIconManager().getDuration(TGDuration.THIRTY_SECOND));
60
this.thirtySecondButton.setLayoutData(makeGridData(1));
61
this.thirtySecondButton.setSelection(duration == TGDuration.THIRTY_SECOND);
63
this.sixTeenthButton = new Button(durationGroup,SWT.RADIO);
64
this.sixTeenthButton.setImage(TuxGuitar.instance().getIconManager().getDuration(TGDuration.SIXTEENTH));
65
this.sixTeenthButton.setLayoutData(makeGridData(1));
66
this.sixTeenthButton.setSelection(duration == TGDuration.SIXTEENTH);
68
this.eighthButton = new Button(durationGroup,SWT.RADIO);
69
this.eighthButton.setImage(TuxGuitar.instance().getIconManager().getDuration(TGDuration.EIGHTH));
70
this.eighthButton.setLayoutData(makeGridData(1));
71
this.eighthButton.setSelection(duration == TGDuration.EIGHTH);
72
//---------------------------------------------------
73
//------------------BUTTONS--------------------------
74
//---------------------------------------------------
75
Composite buttons = new Composite(dialog, SWT.NONE);
76
buttons.setLayout(new GridLayout(3,false));
77
buttons.setLayoutData(new GridData(SWT.END,SWT.BOTTOM,true,true));
79
final Button buttonOK = new Button(buttons, SWT.PUSH);
80
buttonOK.setText(TuxGuitar.getProperty("ok"));
81
buttonOK.setLayoutData(getButtonData());
82
buttonOK.addSelectionListener(new SelectionAdapter() {
83
public void widgetSelected(SelectionEvent arg0) {
84
TremoloPickingEditor.this.result = getTremoloPicking();
89
Button buttonClean = new Button(buttons, SWT.PUSH);
90
buttonClean.setText(TuxGuitar.getProperty("clean"));
91
buttonClean.setLayoutData(getButtonData());
92
buttonClean.addSelectionListener(new SelectionAdapter() {
93
public void widgetSelected(SelectionEvent arg0) {
94
TremoloPickingEditor.this.result = null;
99
Button buttonCancel = new Button(buttons, SWT.PUSH);
100
buttonCancel.setText(TuxGuitar.getProperty("cancel"));
101
buttonCancel.setLayoutData(getButtonData());
102
buttonCancel.addSelectionListener(new SelectionAdapter() {
103
public void widgetSelected(SelectionEvent arg0) {
104
TremoloPickingEditor.this.result = note.getEffect().getTremoloPicking();
109
dialog.setDefaultButton( buttonOK );
111
DialogUtils.openDialog(dialog, DialogUtils.OPEN_STYLE_CENTER | DialogUtils.OPEN_STYLE_PACK | DialogUtils.OPEN_STYLE_WAIT);
115
private Group makeGroup(Composite parent,int horizontalSpan,String text){
116
Group group = new Group(parent, SWT.SHADOW_ETCHED_IN);
117
group.setLayoutData(makeGridData(horizontalSpan));
123
private GridData getButtonData(){
124
GridData data = new GridData(SWT.FILL, SWT.FILL, true, true);
125
data.minimumWidth = 80;
126
data.minimumHeight = 25;
130
private GridData makeGridData(int horizontalSpan){
131
GridData data = new GridData(SWT.FILL,SWT.FILL,true,true);
132
data.horizontalSpan = horizontalSpan;
136
public TGEffectTremoloPicking getTremoloPicking(){
137
TGEffectTremoloPicking effect = TuxGuitar.instance().getSongManager().getFactory().newEffectTremoloPicking();
138
if(this.thirtySecondButton.getSelection()){
139
effect.getDuration().setValue(TGDuration.THIRTY_SECOND);
140
}else if(this.sixTeenthButton.getSelection()){
141
effect.getDuration().setValue(TGDuration.SIXTEENTH);
142
}else if(this.eighthButton.getSelection()){
143
effect.getDuration().setValue(TGDuration.EIGHTH);