package filemanager;

import com.vmx.Locale;
import javax.microedition.lcdui.*;

public class frmCrypt extends Form implements CommandListener
{
	Object parent;
	TextField tf;
	
	public frmCrypt(Object p)
	{
		super("");
		setTitle(Locale.getString(this, Locale.CRYPT_CMD));

		parent = p;
		
		if(Buffer.getSize() == 0)
		{
			Buffer.add(main.currentPath + main.currentFile, false);
		}
		
		tf = new TemplateTextField(Locale.getString(this, Locale.PASSWORD), "", 1024, TextField.ANY);
		append(tf);
		
		append(Locale.getString(this, Locale.CRYPT_USAGE));
		
		addCommand(new Command(Locale.getString(this, Locale.CANCEL_CMD), Command.BACK, 1));
		addCommand(new Command(Locale.getString(this, Locale.OK_CMD), Command.OK, 1));
		
		setCommandListener(this);
	}
	
	/**
	 * Обработчик команд
	 */
	public void commandAction(Command c, Displayable d)
	{
		main.dsp.setCurrent(parent);
		
		if(c.getCommandType() == Command.OK)
		{
			Buffer.startOperation(new CryptThread(tf.getString()));
		}
		else
		{
			Buffer.clear();
		}
	}
}
