/* $Id: SaveActionListener.java 506 2012-06-01 08:23:43Z ohura $ */
package smart_gs.swingui.toolbar.action;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import smart_gs.swingui.WorkspaceWindow;
import webdav.WebDavListenerAction;

public class SaveActionListener implements ActionListener {
	protected int mode = 0;
	
	public SaveActionListener(int mode){
		this.mode = mode;
	}

	public void actionPerformed(ActionEvent e) {		
		if(mode == 1){
			WebDavListenerAction webDavListenerAction = new WebDavListenerAction();
			webDavListenerAction.save();
		}else if(mode == 2){
			WorkspaceWindow window = WorkspaceWindow.getInstance();
			boolean ans = window.saveAll(window.getCurrentFile());
			if( ans == false ) return;
			window.unlock();
			window.setLastsave(0);
		}else{
			WorkspaceWindow window = WorkspaceWindow.getInstance();
//			20101107 shayashi introduced the assignment for clarity
			boolean ans = window.saveAll();
			if( ans == false ) return;
			window.unlock();
			window.setLastsave(0);
		}
	}
}
