forked from phcode-dev/staging.phcode.dev
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathFileViewController.js
More file actions
1 lines (1 loc) · 4.03 KB
/
FileViewController.js
File metadata and controls
1 lines (1 loc) · 4.03 KB
1
define(function(require,exports,module){var DocumentManager=require("document/DocumentManager"),EventDispatcher=require("utils/EventDispatcher"),MainViewManager=require("view/MainViewManager"),CommandManager=require("command/CommandManager"),PerfUtils=require("utils/PerfUtils"),Commands=require("command/Commands"),DeprecationWarning=require("utils/DeprecationWarning"),_curDocChangedDueToMe=!1,WORKING_SET_VIEW="WorkingSetView",PROJECT_MANAGER="ProjectManager",_fileSelectionFocus=PROJECT_MANAGER;function _activatePane(paneId){paneId?MainViewManager.setActivePaneId(paneId):MainViewManager.focusActivePane(),exports.trigger("documentSelectionFocusChange")}function setFileViewFocus(fileSelectionFocus){fileSelectionFocus===PROJECT_MANAGER||fileSelectionFocus===WORKING_SET_VIEW?_fileSelectionFocus!==fileSelectionFocus&&(_fileSelectionFocus=fileSelectionFocus,exports.trigger("fileViewFocusChange")):console.error("Bad parameter passed to FileViewController.setFileViewFocus")}function openAndSelectDocument(fullPath,fileSelectionFocus,paneId){var result,curDocChangedDueToMe=_curDocChangedDueToMe,currentPath;function _getDerivedPaneContext(){function _secondPaneContext(){return(window.event.ctrlKey||window.event.metaKey)&&window.event.altKey?MainViewManager.SECOND_PANE:null}function _firstPaneContext(){return window.event.ctrlKey||window.event.metaKey?MainViewManager.FIRST_PANE:null}return window.event&&(_secondPaneContext()||_firstPaneContext())}if(fileSelectionFocus===PROJECT_MANAGER||fileSelectionFocus===WORKING_SET_VIEW)return _curDocChangedDueToMe=!0,_fileSelectionFocus=fileSelectionFocus,paneId=paneId||_getDerivedPaneContext()||MainViewManager.ACTIVE_PANE,MainViewManager.getCurrentlyViewedPath(paneId)===fullPath?(_activatePane(paneId),result=(new $.Deferred).resolve().promise()):result=CommandManager.execute(Commands.FILE_OPEN,{fullPath:fullPath,paneId:paneId}),result.always(function(){_curDocChangedDueToMe=curDocChangedDueToMe}),result;console.error("Bad parameter passed to FileViewController.openAndSelectDocument")}function openFileAndAddToWorkingSet(fullPath,paneId){var result=new $.Deferred,promise;return CommandManager.execute(Commands.CMD_ADD_TO_WORKINGSET_AND_OPEN,{fullPath:fullPath,paneId:paneId}).done(function(file){_fileSelectionFocus=WORKING_SET_VIEW,_activatePane(paneId),result.resolve(file)}).fail(function(err){result.reject(err)}),result.promise()}function openWithExternalApplication(fullPath){exports.trigger("openWithExternalApplication",fullPath)}function addToWorkingSetAndSelect(fullPath){DeprecationWarning.deprecationWarning("Use FileViewController.openFileAndAddToWorkingSet() instead of FileViewController.addToWorkingSetAndSelect().",!0);var result=new $.Deferred;return openFileAndAddToWorkingSet(fullPath).done(function(file){var doc;file&&(doc=DocumentManager.getOpenDocumentForPath(file.fullPath)),result.resolve(doc)}).fail(function(err){result.reject(err)}),result.promise()}function getFileSelectionFocus(){return _fileSelectionFocus}EventDispatcher.on_duringInit(MainViewManager,"workingSetAdd",function(event,addedFile){_fileSelectionFocus=WORKING_SET_VIEW,exports.trigger("documentSelectionFocusChange")}),EventDispatcher.on_duringInit(MainViewManager,"currentFileChange",function(event,file,paneId){var perfTimerName;_curDocChangedDueToMe||(perfTimerName=PerfUtils.markStart("FileViewController._oncurrentFileChange():\t"+(file?file.fullPath:"(no open file)")),_fileSelectionFocus=file&&-1!==MainViewManager.findInWorkingSet(paneId,file.fullPath)?WORKING_SET_VIEW:PROJECT_MANAGER),exports.trigger("documentSelectionFocusChange"),_curDocChangedDueToMe||PerfUtils.addMeasurement(perfTimerName)}),EventDispatcher.makeEventDispatcher(exports),exports.addToWorkingSetAndSelect=addToWorkingSetAndSelect,exports.getFileSelectionFocus=getFileSelectionFocus,exports.openAndSelectDocument=openAndSelectDocument,exports.openFileAndAddToWorkingSet=openFileAndAddToWorkingSet,exports.setFileViewFocus=setFileViewFocus,exports.WORKING_SET_VIEW=WORKING_SET_VIEW,exports.PROJECT_MANAGER=PROJECT_MANAGER,exports.openWithExternalApplication=openWithExternalApplication});