/* Copyright 2009 Palm, Inc.  All rights reserved. */
/*global Mojo, Class, $L */
/*jslint rhino:true, undef:true */

var RecentAssistant = Class.create({

    appMenuModel:
    {
        items: [
                 {
                   label: $L('Help...'),
                   command: Mojo.Menu.helpCmd,
                   disabled: true
                 }
               ]
    },


    initialize: function() {
        Mojo.Log.info("RecentAssistant: initialize.");
		this.appAssistant = Mojo.Controller.appController.assistant;
    },

    setup: function() {

        // Doesn't appear to be overridding the filepicker system menus
        this.controller.setupWidget(Mojo.Menu.appMenu,
                                    { omitDefaultItems: true },
                                    this.appMenuModel);
    },

    activate: function()
    {
        //Mojo.Log.info("RecentAssistant: activate");
		var params = {
            kind: 'file',

            extensions: this.appAssistant.fileExtensions,

            onSelect: function(file) {
                Mojo.Log.info("onSelect: '%s'", file.fullPath);

                if (this.appAssistant.checkFileType(file.fullPath)) {
					var args = { name: 'document', disableSceneScroller: true };
					var sceneParams = {file: file.fullPath};

					// FIXME Why can't I just do a pushScene?
					this.controller.stageController.swapScene(args, sceneParams);
                }
            }.bind(this)
        };

        Mojo.FilePicker.pickFile(params, this.controller.stageController);
    }
});
