src/view/MainViewManager.js
function _open(paneId, file, optionsIn) {
        var result = new $.Deferred(),
            options = optionsIn || {};

        function doPostOpenActivation() {
            if (!options.noPaneActivate) {
                setActivePaneId(paneId);
            }
        }

        if (!file || !_getPane(paneId)) {
            return result.reject("bad argument").promise();
        }


        // See if there is already a view for the file
        var pane = _getPane(paneId);

        // See if there is a factory to create a view for this file
        //  we want to do this first because, we don't want our internal
        //  editor to edit files for which there are suitable viewfactories
        var factory = MainViewFactory.findSuitableFactoryForPath(file.fullPath);

        if (factory) {
            file.exists(function (fileError, fileExists) {
                if (fileExists) {
                    // let the factory open the file and create a view for it
                    factory.openFile(file, pane)
                        .done(function () {
                            // if we opened a file that isn't in the project
                            //  then add the file to the working set
                            if (!ProjectManager.isWithinProject(file.fullPath)) {
                                addToWorkingSet(paneId, file);
                            }
                            doPostOpenActivation();
                            result.resolve(file);
                        })
                        .fail(function (fileError) {
                            result.reject(fileError);
                        });
                } else {
                    result.reject(fileError || FileSystemError.NOT_FOUND);
                }
            });
        } else {
            DocumentManager.getDocumentForPath(file.fullPath, file)
                .done(function (doc) {
                    if (doc) {
                        _edit(paneId, doc, $.extend({}, options, {
                            noPaneActivate: true
                        }));
                        doPostOpenActivation();
                        result.resolve(doc.file);
                    } else {
                        result.resolve(null);
                    }
                })
                .fail(function (fileError) {
                    result.reject(fileError);
                });
        }

       result.done(function () {
           _makeFileMostRecent(paneId, file);
       });

        return result;
    }
function _open(paneId, file, optionsIn) {
        var result = new $.Deferred(),
            options = optionsIn || {};

        function doPostOpenActivation() {
            if (!options.noPaneActivate) {
                setActivePaneId(paneId);
            }
        }

        if (!file || !_getPane(paneId)) {
            return result.reject("bad argument").promise();
        }


        // See if there is already a view for the file
        var pane = _getPane(paneId);

        // See if there is a factory to create a view for this file
        //  we want to do this first because, we don't want our internal
        //  editor to edit files for which there are suitable viewfactories
        var factory = MainViewFactory.findSuitableFactoryForPath(file.fullPath);

        if (factory) {
            file.exists(function (fileError, fileExists) {
                if (fileExists) {
                    // let the factory open the file and create a view for it
                    factory.openFile(file, pane)
                        .done(function () {
                            // if we opened a file that isn't in the project
                            //  then add the file to the working set
                            if (!ProjectManager.isWithinProject(file.fullPath)) {
                                addToWorkingSet(paneId, file);
                            }
                            doPostOpenActivation();
                            result.resolve(file);
                        })
                        .fail(function (fileError) {
                            result.reject(fileError);
                        });
                } else {
                    result.reject(fileError || FileSystemError.NOT_FOUND);
                }
            });
        } else {
            DocumentManager.getDocumentForPath(file.fullPath, file)
                .done(function (doc) {
                    if (doc) {
                        _edit(paneId, doc, $.extend({}, options, {
                            noPaneActivate: true
                        }));
                        doPostOpenActivation();
                        result.resolve(doc.file);
                    } else {
                        result.resolve(null);
                    }
                })
                .fail(function (fileError) {
                    result.reject(fileError);
                });
        }

       result.done(function () {
           _makeFileMostRecent(paneId, file);
       });

        return result;
    }
function _open ( paneId , file , optionsIn ) { var result = new $ . Deferred ( ) , options = optionsIn || { } ; function doPostOpenActivation ( ) { if ( ! options . noPaneActivate ) { setActivePaneId ( paneId ) ; } } if ( ! file || ! _getPane ( paneId ) ) { return result . reject ( "bad argument" ) . promise ( ) ; } // See if there is already a view for the file var pane = _getPane ( paneId ) ; // See if there is a factory to create a view for this file //  we want to do this first because, we don't want our internal //  editor to edit files for which there are suitable viewfactories var factory = MainViewFactory . findSuitableFactoryForPath ( file . fullPath ) ; if ( factory ) { file . exists ( function ( fileError , fileExists ) { if ( fileExists ) { // let the factory open the file and create a view for it factory . openFile ( file , pane ) . done ( function ( ) { // if we opened a file that isn't in the project //  then add the file to the working set if ( ! ProjectManager . isWithinProject ( file . fullPath ) ) { addToWorkingSet ( paneId , file ) ; } doPostOpenActivation ( ) ; result . resolve ( file ) ; } ) . fail ( function ( fileError ) { result . reject ( fileError ) ; } ) ; } else { result . reject ( fileError || FileSystemError . NOT_FOUND ) ; } } ) ; } else { DocumentManager . getDocumentForPath ( file . fullPath , file ) . done ( function ( doc ) { if ( doc ) { _edit ( paneId , doc , $ . extend ( { } , options , { noPaneActivate : true } ) ) ; doPostOpenActivation ( ) ; result . resolve ( doc . file ) ; } else { result . resolve ( null ) ; } } ) . fail ( function ( fileError ) { result . reject ( fileError ) ; } ) ; } result . done ( function ( ) { _makeFileMostRecent ( paneId , file ) ; } ) ; return result ; }
Opens a file in the specified pane this can be used to open a file with a custom viewer
or a document for editing.  If it's a document for editing, edit is called on the document
@param {!string} paneId - id of the pane in which to open the document
@param {!File} file - file to open
@param {{noPaneActivate:boolean=}=} optionsIn - options
@return {jQuery.Promise}  promise that resolves to a File object or
rejects with a File error or string
Opens a file in the specified pane this can be used to open a file with a custom viewer or a document for editing . If it s a document for editing edit is called on the document