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.file;
11
import org.eclipse.swt.SWT;
12
import org.eclipse.swt.events.TypedEvent;
13
import org.herac.tuxguitar.gui.TuxGuitar;
14
import org.herac.tuxguitar.gui.actions.Action;
15
import org.herac.tuxguitar.gui.editors.TablatureEditor;
16
import org.herac.tuxguitar.gui.helper.SyncThread;
21
* TODO To change the template for this generated type comment go to
22
* Window - Preferences - Java - Code Style - Code Templates
24
public class SaveFileAction extends Action{
25
public static final String NAME = "action.file.save";
27
public SaveFileAction(TablatureEditor tablatureEditor) {
28
super(NAME,true,tablatureEditor);
31
public boolean doAction(TypedEvent e) {
32
final String fileName = TuxGuitar.instance().getFileHistory().getFilePath() + File.separator + TuxGuitar.instance().getFileHistory().getFileName();
34
if (TuxGuitar.instance().getFileHistory().isNewFile() || !isSuportedFormat(fileName)) {
35
TuxGuitar.instance().getAction(SaveAsFileAction.NAME).process(e);
37
getEditor().getTablature().changeCursor(SWT.CURSOR_WAIT);
38
new SyncThread(new Runnable() {
40
if(!TuxGuitar.isDisposed()){
41
getEditor().getSongManager().save(fileName);
42
getEditor().getTablature().changeCursor(SWT.CURSOR_ARROW);
51
private boolean isSuportedFormat(String fileName) {
52
return (fileName.endsWith(".tg") || fileName.endsWith(".gp3") || fileName.endsWith(".gp4"));