package sml_editor.swingui.toolbar.action;

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

import smart_gs.logical.LineSegment;
import smart_gs.logical.Spread;
import smart_gs.swingui.AbstractGSWindow;
import smart_gs.util.DSCFileMaker;

public class SaveLineSegmentsAction implements ActionListener {
//	TODO@shayashi 2011.06.19 to write!!!
	private AbstractGSWindow gsWindow;
	private Spread spread;
	public SaveLineSegmentsAction(AbstractGSWindow gsWindow){
		this.gsWindow = gsWindow;
	}

	public void actionPerformed(ActionEvent e) {
		this.spread = this.gsWindow.getSpread();
		List<LineSegment> segments = spread.getLines();
		if(segments == null){
			return;
		}
		String folderPath = Spread.DSC_FOLDER_PATH+spread.getSpreadDirParent().getPath();
		String filename = spread.getFileNameWithoutExtension();
		String filetype = spread.getFileNameExtension();
		new DSCFileMaker(spread).saveLineSegments(segments, folderPath, filename, filetype);
	}
}

