package smart_gs.swingui.toolbar.action;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.List;
import smart_gs.logical.LineSegmentForEdit;
import smart_gs.smleditor.swingui.LineSegEditor;

public class LineSegEditorUndoActionListener implements ActionListener {
	LineSegEditor editor;

	public LineSegEditorUndoActionListener(LineSegEditor editor) {
		this.editor = editor;
	}

	@Override
	public void actionPerformed(ActionEvent arg0) {
		if (!editor.linestackIsEmpty()) {
			List<LineSegmentForEdit> lines = editor.popLinestack();
			editor.setLinesForEdit(lines);
			editor.rewriteLineSegIndexes();
			editor.repaint();
		}
	}
}
