adobe/brackets — pull request #5530 by couzteau (2013-10-15 22:51:42+00:00)
Title: preview images - updated

This implementation provides a new class namely ImageViewer that enables EditorManager to display images in the editor-holder container.

Implementation highlights:
- DocumentCommmandHandler owns the decision of opening a file in an Editor or in a custom viewer. -
- EditorManager maintains the view state in a new local variable _currentlyViewedFile and associated and exported getter and setter methods for the same to store path to the file in view, i.e. a text document in the editor or the path in the image viewer. ProjectManager no longer uses getCurrentDocument to maintain the project tree, but uses getCurrentFile instead.
- To determine whether a file is an image or a text document LanguageManager's method getLanguageForPath should be used. For image files it detects a new mode with id 'image'.
- ImageViewer is the only custom viewer at this point, but the design is made to make the addition of more custom viewers easy, i.e. SVG viewer, video player, audio player, ...? To keep EditorManager code independent of ImageViewer implementation details, only the method showCustomViewer and the resize event handler have references to image viewer. These are wrapped with a language / mode test, so that these areas can easily be extended to accomodate other viewers.
References:
- Trello: https://trello.com/c/l9AcILkC/24-8-preview-images
- Spec: https://github.com/adobe/brackets/wiki/Preview-Images-Spec

Note: The code in this review does not yet include new unit tests and some tweaks to drag and drop and file open. That said drag & drop and file open do work. Currently drag&drop and file open will erroneously open images into the working set. In that scenario file close does not work properly. These issues will be fixed by Raymond in a 2nd pull request