
#import "AppController.h"
#import <foundation/NSString.h>

@implementation AppController

- awakeFromNib
{
		/* Put the cursor in the first Query field when the app starts */
	[firstTextField selectText:self];
	return self;
}

- newWPDocument:sender
{
		/* Copy a template.wp document to the selected account's directory and open the copied file as Untitled. */
	[[Application workspace] openFile:"/tmp/UNTITLED.wp"
    withApplication:"WordPerfect"];
	
	return self;
}

- openWPDocument:sender
{
		/* Bring up an OpenPanel, set to begin in directory startDir, initially trying to select file startFile, and filtering for file types contained in fileTypes. */

	const char *startDir = "/tmp";
	const char *startFile = "";
	const char *fileTypes[2] = {"wp",NULL};

	OpenPanel *thePanel = [OpenPanel new];
	
	[thePanel allowMultipleFiles:NO];

	if ([thePanel runModalForDirectory:startDir file:startFile types:fileTypes] == NX_OKTAG)
			[[Application workspace] openFile:[thePanel filename]
   			withApplication:"WordPerfect"];
	
	return self;
}


- newMesaSpreadSheet:sender
{
		/* Copy a template.Mesa document to the selected account's directory and open the copied file as Untitled. */
	[[Application workspace] openFile:"/tmp/UNTITLED.Mesa"
    withApplication:"Mesa"];
	
	return self;
}

- openMesaSpreadSheet:sender
{
		/* Bring up an OpenPanel, set to begin in directory startDir, initially trying to select file startFile, and filtering for file types contained in fileTypes. */

	const char *startDir = "/tmp";
	const char *startFile = "";
	const char *fileTypes[2] = {"Mesa",NULL};

	OpenPanel *thePanel = [OpenPanel new];
	
	[thePanel allowMultipleFiles:NO];

	if ([thePanel runModalForDirectory:startDir file:startFile types:fileTypes] == NX_OKTAG)
			[[Application workspace] openFile:[thePanel filename]
   			withApplication:"Mesa"];
	
	return self;
}


@end
