Skip to content
This repository has been archived by the owner on Sep 6, 2021. It is now read-only.

Commit

Permalink
- fixed typo in FileViewController.WORKINGSET_VIEW which caused error…
Browse files Browse the repository at this point in the history
…s opening files from working set
  • Loading branch information
ingorichter committed Sep 9, 2014
1 parent 5181528 commit 83b95c4
Show file tree
Hide file tree
Showing 2 changed files with 158 additions and 159 deletions.
79 changes: 39 additions & 40 deletions src/project/FileViewController.js
Original file line number Diff line number Diff line change
@@ -1,37 +1,37 @@
/*
* Copyright (c) 2012 Adobe Systems Incorporated. All rights reserved.
*
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
*
*/

/*jslint vars: true, plusplus: true, devel: true, nomen: true, indent: 4, maxerr: 50 */
/*global define, $ */

/**
* Responsible for coordinating file selection between views by permitting only one view
* to show the current file selection at a time. Currently, only WorkingSetView and
* to show the current file selection at a time. Currently, only WorkingSetView and
* ProjectManager can show file selection. In general the WorkingSetView takes higher
* priority until the user selects a file in the ProjectManager.
*
* Events dispatched:
* - documentSelectionFocusChange - indicates a document change has caused the focus to
* - documentSelectionFocusChange - indicates a document change has caused the focus to
* change between the working set and file tree.
*
* - fileViewFocusChange - indicates the selection focus has changed between the working
Expand All @@ -41,7 +41,7 @@
* - select a file in WorkingSetView > select in WorkingSetView
* - add a file to the WorkingSetView > select in WorkingSetView
* - select a file in ProjectManager > select in ProjectManager
* - open a file from places other than the WorkingSetView or ProjectManager >
* - open a file from places other than the WorkingSetView or ProjectManager >
* select file in WorkignSetView if its in the working set, otherwise select in ProjectManager
*/

Expand All @@ -52,16 +52,15 @@ define(function (require, exports, module) {
var DocumentManager = require("document/DocumentManager"),
MainViewManager = require("view/MainViewManager"),
CommandManager = require("command/CommandManager"),
EditorManager = require("editor/EditorManager"),
PerfUtils = require("utils/PerfUtils"),
Commands = require("command/Commands"),
DeprecationWarning = require("utils/DeprecationWarning");

/**
* Tracks whether a "currentFileChange" notification occured due to a call to
/**
* Tracks whether a "currentFileChange" notification occured due to a call to
* openAndSelectDocument.
* @see FileviewController.openAndSelectDocument
* @private
* @private
*/
var _curDocChangedDueToMe = false;
var WORKINGSET_VIEW = "WorkingSetView";
Expand All @@ -72,16 +71,16 @@ define(function (require, exports, module) {
* @see FileViewController.getFileSelectionFocus()
*/
var _fileSelectionFocus = PROJECT_MANAGER;
/**

/**
* Change the doc selection to the working set when ever a new file is added to the working set
*/
$(MainViewManager).on("workingSetAdd", function (event, addedFile) {
_fileSelectionFocus = WORKINGSET_VIEW;
$(exports).triggerHandler("documentSelectionFocusChange");
});

/**
/**
* Update the file selection focus whenever the contents of the editor area change
*/
$(MainViewManager).on("currentFileChange", function (event, file, paneId) {
Expand All @@ -102,8 +101,8 @@ define(function (require, exports, module) {
PerfUtils.addMeasurement(perfTimerName);
}
});
/**

/**
* @private
* @param {string=} paneId - the Pane to activate
*/
Expand All @@ -114,7 +113,7 @@ define(function (require, exports, module) {
MainViewManager.focusActivePane();
}
// If fullPath corresonds to the current doc being viewed then opening the file won't
// trigger a currentFileChange event, so we need to trigger a documentSelectionFocusChange
// trigger a currentFileChange event, so we need to trigger a documentSelectionFocusChange
// in this case to signify the selection focus has changed even though the current document has not.
$(exports).triggerHandler("documentSelectionFocusChange");
}
Expand All @@ -134,11 +133,11 @@ define(function (require, exports, module) {
$(exports).triggerHandler("fileViewFocusChange");
}

/**
/**
* Opens a document if it's not open and selects the file in the UI corresponding to
* fileSelectionFocus
* @param {!fullPath} fullPath - full path of the document to open
* @param {string} fileSelectionFocus - (WORKING_SET_VIEW || PROJECT_MANAGER)
* @param {string} fileSelectionFocus - (WORKINGSET_VIEW || PROJECT_MANAGER)
* @param {string} paneId - pane in which to open the document
* @return {$.Promise}
*/
Expand All @@ -158,9 +157,9 @@ define(function (require, exports, module) {
_fileSelectionFocus = fileSelectionFocus;

paneId = (paneId || MainViewManager.ACTIVE_PANE);

// If fullPath corresonds to the current doc being viewed then opening the file won't
// trigger a currentFileChange event, so we need to trigger a documentSelectionFocusChange
// trigger a currentFileChange event, so we need to trigger a documentSelectionFocusChange
// in this case to signify the selection focus has changed even though the current document has not.
var currentPath = MainViewManager.getCurrentlyViewedPath(paneId);
if (currentPath === fullPath) {
Expand All @@ -170,20 +169,20 @@ define(function (require, exports, module) {
result = CommandManager.execute(Commands.FILE_OPEN, {fullPath: fullPath,
paneId: paneId});
}

// clear after notification is done
result.always(function () {
_curDocChangedDueToMe = false;
});

return result;
}

/**
/**
* Opens the specified document if it's not already open, adds it to the working set,
* and selects it in the WorkingSetView
* @param {!fullPath}
* @param {string=} paneId - Pane in which to add the view. If omitted, the command default is to use the ACTIVE_PANE
* @param {string=} paneId - Pane in which to add the view. If omitted, the command default is to use the ACTIVE_PANE
* @return {!$.Promise}
*/
function openFileAndAddToWorkingSet(fullPath, paneId) {
Expand All @@ -195,7 +194,7 @@ define(function (require, exports, module) {
// is already the current one. In that case we will want to notify with
// documentSelectionFocusChange so the views change their selection
promise.done(function (file) {
// CMD_ADD_TO_WORKINGSET_AND_OPEN command sets the current document. Update the
// CMD_ADD_TO_WORKINGSET_AND_OPEN command sets the current document. Update the
// selection focus only if doc is not null. When double-clicking on an
// image file, we get a null doc here but we still want to keep _fileSelectionFocus
// as PROJECT_MANAGER. Regardless of doc is null or not, call _activatePane
Expand All @@ -207,8 +206,8 @@ define(function (require, exports, module) {

return result.promise();
}
/**

/**
* Opens the specified document if it's not already open, adds it to the working set,
* and selects it in the WorkingSetView
* @deprecated use FileViewController.openFileAndAddToWorkingSet() instead
Expand All @@ -221,20 +220,20 @@ define(function (require, exports, module) {
openFileAndAddToWorkingSet(fullPath)
.done(function (file) {
var doc;

if (file) {
doc = DocumentManager.getOpenDocumentForPath(file.fullPath);
}

result.resolve(doc);
})
.fail(function (err) {
result.reject(err);
});
return result.promise();
}



/**
* returns either WORKINGSET_VIEW or PROJECT_MANAGER
Expand Down
Loading

0 comments on commit 83b95c4

Please sign in to comment.