package smart_gs.swingui.tree.action;

import java.awt.Frame;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;

import javax.swing.JFileChooser;
import javax.swing.JOptionPane;
import javax.swing.tree.DefaultMutableTreeNode;

import smart_gs.logical.UsersNoteTree;
import smart_gs.logical.SpreadDirectory;
import smart_gs.logical.SpreadTree;
import smart_gs.logical.filter.ImageFileFilter;
import smart_gs.swingui.WorkspaceWindow;
import smart_gs.util.CanonicalPathString;
import smart_gs.util.GSStandardPath;

public class MakeUsersNoteAction implements ActionListener {
	DefaultMutableTreeNode parentNode;
	UsersNoteTree tree;
	
	public MakeUsersNoteAction(DefaultMutableTreeNode selectedNode, UsersNoteTree tree) {
		parentNode = selectedNode;
		this.tree = tree;
	}
	
	@Override
	public void actionPerformed(ActionEvent e) {
		String newNoteName;
		newNoteName = (String)JOptionPane.showInputDialog("Input Note Name:\n");
		if (newNoteName == null) return;
		if (newNoteName.equals("root")){
			JOptionPane.showMessageDialog(WorkspaceWindow.getInstance(),
					"root is a reserved name. Use another name","root is reserved",JOptionPane.ERROR_MESSAGE);
			return;
		}
		tree.makeUsersNote(parentNode, newNoteName);
	}
}


