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

Implement Splitview #8913

Merged
merged 3 commits into from
Sep 4, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/LiveDevelopment/Agents/GotoAgent.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ define(function GotoAgent(require, exports, module) {

var DocumentManager = require("document/DocumentManager");
var EditorManager = require("editor/EditorManager");
var MainViewManager = require("view/MainViewManager");

/** Return the URL without the query string
* @param {string} URL
Expand Down Expand Up @@ -172,7 +173,7 @@ define(function GotoAgent(require, exports, module) {
path = decodeURI(path);
var promise = DocumentManager.getDocumentForPath(path);
promise.done(function onDone(doc) {
DocumentManager.setCurrentDocument(doc);
MainViewManager._edit(MainViewManager.ACTIVE_PANE, doc);
if (location) {
openLocation(location, noFlash);
}
Expand Down
18 changes: 17 additions & 1 deletion src/LiveDevelopment/Documents/HTMLDocument.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,10 @@ define(function HTMLDocumentModule(require, exports, module) {
self._onChange(event, editor, change);
});

$(this.editor).on("beforeDestroy.HTMLDocument", function (event, editor) {
self._onDestroy(event, editor);
});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JeffryBooher How come this is necessary for HTMLDocument, but not CSSDocument or CSSPreprocessorDocument? All three of them have a detachFromEditor() that needs to get run...

I'm also not clear on why this change is needed, though. It already listens to "activeEditorChange", which should be enough to always clean up when needed. Was this added for a unit test or something maybe, where the EditorManager events weren't firing?


// Experimental code
if (LiveDevelopment.config.experimental) {
$(HighlightAgent).on("highlight.HTMLDocument", function (event, node) {
Expand Down Expand Up @@ -266,6 +270,18 @@ define(function HTMLDocumentModule(require, exports, module) {
});
};

/**
* Triggered when the editor is being destroyed
* @param {$.Event} event Event
* @param {!Editor} editor The editor being destroyed
*/
HTMLDocument.prototype._onDestroy = function (event, editor) {
if (this.editor === editor) {
this.detachFromEditor();
}
};


/**
* Triggered on change by the editor
* @param {$.Event} event Event
Expand Down Expand Up @@ -396,4 +412,4 @@ define(function HTMLDocumentModule(require, exports, module) {

// Export the class
module.exports = HTMLDocument;
});
});
76 changes: 40 additions & 36 deletions src/LiveDevelopment/LiveDevelopment.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,38 +68,39 @@ define(function LiveDevelopment(require, exports, module) {
var _ = require("thirdparty/lodash");

// Status Codes
var STATUS_ERROR = exports.STATUS_ERROR = -1;
var STATUS_INACTIVE = exports.STATUS_INACTIVE = 0;
var STATUS_CONNECTING = exports.STATUS_CONNECTING = 1;
var STATUS_LOADING_AGENTS = exports.STATUS_LOADING_AGENTS = 2;
var STATUS_ACTIVE = exports.STATUS_ACTIVE = 3;
var STATUS_OUT_OF_SYNC = exports.STATUS_OUT_OF_SYNC = 4;
var STATUS_SYNC_ERROR = exports.STATUS_SYNC_ERROR = 5;

var Async = require("utils/Async"),
Dialogs = require("widgets/Dialogs"),
DefaultDialogs = require("widgets/DefaultDialogs"),
DocumentManager = require("document/DocumentManager"),
EditorManager = require("editor/EditorManager"),
FileServer = require("LiveDevelopment/Servers/FileServer").FileServer,
FileSystemError = require("filesystem/FileSystemError"),
FileUtils = require("file/FileUtils"),
LiveDevServerManager = require("LiveDevelopment/LiveDevServerManager"),
NativeApp = require("utils/NativeApp"),
PreferencesDialogs = require("preferences/PreferencesDialogs"),
ProjectManager = require("project/ProjectManager"),
Strings = require("strings"),
StringUtils = require("utils/StringUtils"),
UserServer = require("LiveDevelopment/Servers/UserServer").UserServer;
var STATUS_ERROR = exports.STATUS_ERROR = -1;
var STATUS_INACTIVE = exports.STATUS_INACTIVE = 0;
var STATUS_CONNECTING = exports.STATUS_CONNECTING = 1;
var STATUS_LOADING_AGENTS = exports.STATUS_LOADING_AGENTS = 2;
var STATUS_ACTIVE = exports.STATUS_ACTIVE = 3;
var STATUS_OUT_OF_SYNC = exports.STATUS_OUT_OF_SYNC = 4;
var STATUS_SYNC_ERROR = exports.STATUS_SYNC_ERROR = 5;

var Async = require("utils/Async"),
Dialogs = require("widgets/Dialogs"),
DefaultDialogs = require("widgets/DefaultDialogs"),
DocumentManager = require("document/DocumentManager"),
EditorManager = require("editor/EditorManager"),
FileServer = require("LiveDevelopment/Servers/FileServer").FileServer,
FileSystemError = require("filesystem/FileSystemError"),
FileUtils = require("file/FileUtils"),
LiveDevServerManager = require("LiveDevelopment/LiveDevServerManager"),
MainViewManager = require("view/MainViewManager"),
NativeApp = require("utils/NativeApp"),
PreferencesDialogs = require("preferences/PreferencesDialogs"),
ProjectManager = require("project/ProjectManager"),
Strings = require("strings"),
StringUtils = require("utils/StringUtils"),
UserServer = require("LiveDevelopment/Servers/UserServer").UserServer;

// Inspector
var Inspector = require("LiveDevelopment/Inspector/Inspector");
var Inspector = require("LiveDevelopment/Inspector/Inspector");

// Documents
var CSSDocument = require("LiveDevelopment/Documents/CSSDocument"),
var CSSDocument = require("LiveDevelopment/Documents/CSSDocument"),
CSSPreprocessorDocument = require("LiveDevelopment/Documents/CSSPreprocessorDocument"),
HTMLDocument = require("LiveDevelopment/Documents/HTMLDocument"),
JSDocument = require("LiveDevelopment/Documents/JSDocument");
HTMLDocument = require("LiveDevelopment/Documents/HTMLDocument"),
JSDocument = require("LiveDevelopment/Documents/JSDocument");

// Document errors
var SYNC_ERROR_CLASS = "live-preview-sync-error";
Expand Down Expand Up @@ -185,7 +186,7 @@ define(function LiveDevelopment(require, exports, module) {
* @type {BaseServer}
*/
var _server;

function _isPromisePending(promise) {
return promise && promise.state() === "pending";
}
Expand Down Expand Up @@ -1321,18 +1322,18 @@ define(function LiveDevelopment(require, exports, module) {
}
}

// TODO: need to run _onDocumentChange() after load if doc != currentDocument here? Maybe not, since activeEditorChange
// TODO: need to run _onFileChanged() after load if doc != currentDocument here? Maybe not, since activeEditorChange
// doesn't trigger it, while inline editors can still cause edits in doc other than currentDoc...
_getInitialDocFromCurrent().done(function (doc) {
var prepareServerPromise = (doc && _prepareServer(doc)) || new $.Deferred().reject(),
otherDocumentsInWorkingFiles;

if (doc && !doc._masterEditor) {
otherDocumentsInWorkingFiles = DocumentManager.getWorkingSet().length;
DocumentManager.addToWorkingSet(doc.file);
otherDocumentsInWorkingFiles = MainViewManager.getWorkingSet(MainViewManager.ALL_PANES).length;
MainViewManager.addToWorkingSet(MainViewManager.ACTIVE_PANE, doc.file);

if (!otherDocumentsInWorkingFiles) {
DocumentManager.setCurrentDocument(doc);
MainViewManager._edit(MainViewManager.ACTIVE_PANE, doc);
}
}

Expand Down Expand Up @@ -1374,9 +1375,9 @@ define(function LiveDevelopment(require, exports, module) {

/**
* @private
* DocumentManager currentDocumentChange event handler.
* MainViewManager.currentFileChange event handler.
*/
function _onDocumentChange() {
function _onFileChanged() {
var doc = _getCurrentDocument();

if (!doc || !Inspector.connected()) {
Expand Down Expand Up @@ -1475,10 +1476,13 @@ define(function LiveDevelopment(require, exports, module) {
// We may get interim added/removed events when pushing incremental updates
$(CSSAgent).on("styleSheetAdded.livedev", _styleSheetAdded);

$(DocumentManager).on("currentDocumentChange", _onDocumentChange)
$(MainViewManager)
.on("currentFileChange", _onFileChanged);
$(DocumentManager)
.on("documentSaved", _onDocumentSaved)
.on("dirtyFlagChange", _onDirtyFlagChange);
$(ProjectManager).on("beforeProjectClose beforeAppClose", close);
$(ProjectManager)
.on("beforeProjectClose beforeAppClose", close);

// Register user defined server provider
LiveDevServerManager.registerServer({ create: _createUserServer }, 99);
Expand Down
22 changes: 14 additions & 8 deletions src/brackets.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ define(function (require, exports, module) {
EditorManager = require("editor/EditorManager"),
CSSInlineEditor = require("editor/CSSInlineEditor"),
JSUtils = require("language/JSUtils"),
WorkingSetView = require("project/WorkingSetView"),
WorkingSetSort = require("project/WorkingSetSort"),
WorkingSetView = require("project/WorkingSetView"),
WorkingSetSort = require("project/WorkingSetSort"),
DocumentCommandHandlers = require("document/DocumentCommandHandlers"),
FileViewController = require("project/FileViewController"),
FileSyncManager = require("project/FileSyncManager"),
Expand Down Expand Up @@ -105,6 +105,7 @@ define(function (require, exports, module) {
DeprecationWarning = require("utils/DeprecationWarning"),
ViewCommandHandlers = require("view/ViewCommandHandlers"),
ThemeManager = require("view/ThemeManager"),
MainViewManager = require("view/MainViewManager"),
_ = require("thirdparty/lodash");

// DEPRECATED: In future we want to remove the global CodeMirror, but for now we
Expand All @@ -118,7 +119,7 @@ define(function (require, exports, module) {
return CodeMirror;
}
});

// Load modules that self-register and just need to get included in the main project
require("command/DefaultMenus");
require("document/ChangedDocumentTracker");
Expand All @@ -139,6 +140,9 @@ define(function (require, exports, module) {
require("file/NativeFileSystem");
require("file/NativeFileError");

// Compatibility shim for PanelManager to WorkspaceManager migration
require("view/PanelManager");

PerfUtils.addMeasurement("brackets module dependencies resolved");

// Local variables
Expand Down Expand Up @@ -188,6 +192,8 @@ define(function (require, exports, module) {
LanguageManager : LanguageManager,
LiveDevelopment : require("LiveDevelopment/LiveDevelopment"),
LiveDevServerManager : require("LiveDevelopment/LiveDevServerManager"),
MainViewManager : MainViewManager,
MainViewFactory : require("view/MainViewFactory"),
Menus : Menus,
MultiRangeInlineEditor : require("editor/MultiRangeInlineEditor").MultiRangeInlineEditor,
NativeApp : NativeApp,
Expand All @@ -198,7 +204,6 @@ define(function (require, exports, module) {
ScrollTrackMarkers : require("search/ScrollTrackMarkers"),
UpdateNotification : require("utils/UpdateNotification"),
WorkingSetView : WorkingSetView,

doneLoading : false
};

Expand All @@ -213,8 +218,6 @@ define(function (require, exports, module) {
function _onReady() {
PerfUtils.addMeasurement("window.document Ready");

EditorManager.setEditorHolder($("#editor-holder"));

// Let the user know Brackets doesn't run in a web browser yet
if (brackets.inBrowser) {
Dialogs.showModalDialog(
Expand Down Expand Up @@ -248,6 +251,9 @@ define(function (require, exports, module) {

// Load the initial project after extensions have loaded
extensionLoaderPromise.always(function () {
// Signal that extensions are loaded
AppInit._dispatchReady(AppInit.EXTENSIONS_LOADED);

// Finish UI initialization
ViewCommandHandlers.restoreFontSize();
var initialProjectPath = ProjectManager.getInitialProjectPath();
Expand All @@ -265,7 +271,7 @@ define(function (require, exports, module) {
if (ProjectManager.isWelcomeProjectPath(initialProjectPath)) {
FileSystem.resolve(initialProjectPath + "index.html", function (err, file) {
if (!err) {
var promise = CommandManager.execute(Commands.FILE_ADD_TO_WORKING_SET, { fullPath: file.fullPath });
var promise = CommandManager.execute(Commands.CMD_ADD_TO_WORKINGSET_AND_OPEN, { fullPath: file.fullPath });
promise.then(deferred.resolve, deferred.reject);
} else {
deferred.reject();
Expand Down Expand Up @@ -409,7 +415,7 @@ define(function (require, exports, module) {
$target.is("input:not([type])") || // input with no type attribute defaults to text
$target.is("textarea") ||
$target.is("select");

if (!isFormElement) {
e.preventDefault();
}
Expand Down
Loading