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

[MERGEABLE] Splitview With Image and Custom View Support #8753

Merged
merged 62 commits into from
Aug 26, 2014

Conversation

JeffryBooher
Copy link
Contributor

https://trello.com/c/A22yIIal/1282-splitview-add-view-provider-mechanics

This PR is can be merged into jeff/splitview-1x2 when ready



/*jslint vars: true, plusplus: true, devel: true, nomen: true, indent: 4, maxerr: 50 */
/*global define, $, window, Mustache */
Copy link
Contributor

Choose a reason for hiding this comment

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

This module doesn't use Mustache

@redmunds
Copy link
Contributor

@JeffryBooher Done with initial code review.

"use strict";

/**
* @typedef {canOpenFile:function(path:string):boolean, openFile:function(path:string, pane:Pane)} Factory
Copy link
Member

Choose a reason for hiding this comment

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

This is changes a few things from the old implementation:

  • It's keyed off of arbitrary path filtering rather than Language, which is more flexible but less efficient (and a little more work for extension developers). Any particular reasoning behind that change?
  • The old terminology was "custom view provider" and the new term is "view factory." I sort of like the old naming better -- in particular, "provider" is a term we already use elsewhere in Brackets.

Also, this doesn't document what openFile() is expected to do, or what it returns. It looks like the expectation is that it constructs a View and calls pane.addView() with it, returning a Promise that is resolves when that's done (or is rejected with a FileSystemError object). Would it be cleaner to just have it return a Promise that resolves with a View, and then Bracket core takes care of adding it to the right pane? That would be a little more in line with how other provider extensibility points work...

(This should also reference where to find docs for the View interface -- it took me a min to find it at the top of the Pane.js module body).

Copy link
Member

Choose a reason for hiding this comment

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

I was also a little thrown again by how MainViewManager.addView() takes a File, while Pane.addView() takes a View. That naming feels confusing. But if we change the provider to not call Pane.addView() directly, then maybe that API can be more hidden, reducing the potential for confusion...

@@ -96,6 +96,8 @@ define(function (require, exports, module) {
* adjustScrollPos: function(state:Object=, heightDelta:number) - called to restore the scroll state and adjust the height by heightDelta
* switchContainers: function($newContainer:jQuery} - called to reparent the view to a new container
* getContainer: function() - called to get the current container @return {!jQuery} - the view's parent container
* getViewState: function() @return {?*} - Called when the pane wants the view to save its view state. Return any data you needed to restore the view state later or undefined to not store any state
* restoreViewState: function(!viewState:*) - Called to restore the view state. The viewState argument is whatever data was returned from getViewState()
Copy link
Member

Choose a reason for hiding this comment

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

We should specify that these must be JSONifiable -- otherwise serialization will fail

JeffryBooher added a commit that referenced this pull request Aug 26, 2014
[MERGEABLE] Splitview With Image and Custom View Support
@JeffryBooher JeffryBooher merged commit 463cabc into jeff/splitview-1x2 Aug 26, 2014
@JeffryBooher JeffryBooher deleted the jeff/splitview-factory branch August 26, 2014 20:28
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants