Skip to content

Commit

Permalink
Fix adobe#368: Highlight opened file on load (Cleaned up PR) (adobe#709)
Browse files Browse the repository at this point in the history
* FileViewController.js modified for fix 368

* FileViewController.js modified for fix 368
  • Loading branch information
Th30 authored and Gideon Thomas committed Apr 19, 2017
1 parent 01deb3f commit 97430c7
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions src/project/FileViewController.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ define(function (require, exports, module) {
* @private
*/
var _curDocChangedDueToMe = false;
var WORKING_SET_VIEW = "WorkingSetView";
var PROJECT_MANAGER = "ProjectManager";
var WORKING_SET_VIEW = "WorkingSetView";

/**
* @private
Expand All @@ -75,10 +75,10 @@ define(function (require, exports, module) {
* Change the doc selection to the working set when ever a new file is added to the working set
*/
EventDispatcher.on_duringInit(MainViewManager, "workingSetAdd", function (event, addedFile) {
// XXXBramble: always keep focus on the Project Manager vs. Working Set View
_fileSelectionFocus = WORKING_SET_VIEW;
exports.trigger("documentSelectionFocusChange");
});

/**
* Update the file selection focus whenever the contents of the editor area change
*/
Expand All @@ -87,11 +87,9 @@ define(function (require, exports, module) {
if (!_curDocChangedDueToMe) {
// The the cause of the doc change was not openAndSelectDocument, so pick the best fileSelectionFocus
perfTimerName = PerfUtils.markStart("FileViewController._oncurrentFileChange():\t" + (file ? (file.fullPath) : "(no open file)"));
if (file && MainViewManager.findInWorkingSet(paneId, file.fullPath) !== -1) {
_fileSelectionFocus = WORKING_SET_VIEW;
} else {
_fileSelectionFocus = PROJECT_MANAGER;
}

// XXXBramble: always keep focus on the Project Manager vs. Working Set View
_fileSelectionFocus = PROJECT_MANAGER;
}

exports.trigger("documentSelectionFocusChange");
Expand Down Expand Up @@ -120,13 +118,15 @@ define(function (require, exports, module) {
/**
* Modifies the selection focus in the project side bar. A file can either be selected
* in the working set (the open files) or in the file tree, but not both.
* @param {String} fileSelectionFocus - either PROJECT_MANAGER or WORKING_SET_VIEW
* @param {String} fileSelectionFocus - PROJECT_MANAGER
*/
function setFileViewFocus(fileSelectionFocus) {
if (fileSelectionFocus !== PROJECT_MANAGER && fileSelectionFocus !== WORKING_SET_VIEW) {
console.error("Bad parameter passed to FileViewController.setFileViewFocus");
return;
}
// XXXBramble: always keep focus on the Project Manager vs. Working Set View
fileSelectionFocus = PROJECT_MANAGER;

if (_fileSelectionFocus !== fileSelectionFocus) {
_fileSelectionFocus = fileSelectionFocus;
Expand All @@ -138,7 +138,7 @@ define(function (require, exports, module) {
* 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 - (PROJECT_MANAGER)
* @param {string} paneId - pane in which to open the document
* @return {$.Promise}
*/
Expand Down Expand Up @@ -210,12 +210,12 @@ 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
// selection focus only if doc is not null. When double-clicking on an
// 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
// to trigger documentSelectionFocusChange event.
_fileSelectionFocus = WORKING_SET_VIEW;
// XXXBramble: always keep focus on the Project Manager vs. Working Set View
_fileSelectionFocus = PROJECT_MANAGER;
_activatePane(paneId);

result.resolve(file);
Expand Down Expand Up @@ -255,7 +255,7 @@ define(function (require, exports, module) {


/**
* returns either WORKING_SET_VIEW or PROJECT_MANAGER
* returns either PROJECT_MANAGER
* @return {!String}
*/
function getFileSelectionFocus() {
Expand All @@ -273,6 +273,6 @@ define(function (require, exports, module) {
exports.openAndSelectDocument = openAndSelectDocument;
exports.openFileAndAddToWorkingSet = openFileAndAddToWorkingSet;
exports.setFileViewFocus = setFileViewFocus;
exports.WORKING_SET_VIEW = WORKING_SET_VIEW;
exports.PROJECT_MANAGER = PROJECT_MANAGER;
exports.WORKING_SET_VIEW = WORKING_SET_VIEW;
});

0 comments on commit 97430c7

Please sign in to comment.