/* AIRSourceViewer.js - Revision: 1.5 */ /* ADOBE SYSTEMS INCORPORATED Copyright 2007-2008 Adobe Systems Incorporated. All Rights Reserved. NOTICE: Adobe permits you to modify and distribute this file only in accordance with the terms of Adobe AIR SDK license agreement. You may have received this file from a source other than Adobe. Nonetheless, you may modify or distribute this file only in accordance with such agreement. */ // @the Source Viewer uses the namespace: if (typeof air == 'undefined') {air = {}}; air.SourceViewer = function() { throw ( new Error ( "\n\n" + "You cannot instantiate the 'air.SourceViewer' class. " + "Instead, use 'air.SourceViewer.getDefault()' to retrieve the " + "class' unique instance." + "\n\n" )); } air.SourceViewer.getDefault = function() { // The Source Viewer only works in the AIR application sandbox: if (typeof window.runtime == "undefined") { throw ( new Error ( "\n\n" + "The Source Browser module can only work inside the . Please include the SourceViewer.js file in the " + "application's main *.html file." + "\n\n" )); } // @return the existing instance if there is one; creating it otherwise: var context = arguments.callee; if (context.instance) { return context.instance }; /** * CLASS * air.SourceViewer * DESCRIPTION * A self-contained module to embed in HTML-based AIR applications. * It will display a customizable selection of source files in * an expandable tree structure. The user will be able * to select a file to view its source code. * SAMPLE USAGE * var viewer1 = air.SourceViewer.getDefault(); * viewer1.viewSource(); * * var viewer2 = air.SourceViewer.getDefault(); * var oConfig = { exclude: ['/icons', '/images'] }; * viewer2.setup(oConfig); * viewer2.viewSource(); * * @class * @public * @singleton */ function _SourceViewer() { /** * CONSTANTS * Private members that aren't ment to be altered in any way. * @private * @constant */ // @AIR runtime: var HTMLLoader = window.runtime.flash.html.HTMLLoader; var NativeWindowInitOptions = window.runtime.flash.display. NativeWindowInitOptions; var Rectangle = window.runtime.flash.geom.Rectangle; var NativeWindowType = window.runtime.flash.display. NativeWindowType; var File = window.runtime.flash.filesystem.File; var FileStream = window.runtime.flash.filesystem. FileStream; var Screen = window.runtime.flash.display.Screen; // @application var TEXT_EXTENSIONS = ['txt', 'xml', 'mxml', 'htm', 'html', 'js', 'as', 'css', 'properties', 'config', 'ini', 'bat', 'readme']; var IMAGE_EXTENSIONS = ['jpg', 'jpeg', 'png', 'gif']; var TEXT_TYPE = "text"; var IMAGE_TYPE = "image"; // @events var WINDOW_CREATED_EVENT = 'windowCreatedEvent'; var FILES_LIST_READY_EVENT = 'filesListReadyEvent'; var FILE_LISTED_EVENT = 'fileListedEvent'; var FOLDER_CHECKED_EVENT = 'folderCheckedEvent'; var FOLDER_FIRST_CLICKED_EVENT = 'folderFirstClickedEvent'; var FOLDER_STATE_CHANGED_EVENT = 'folderStateChanged'; var ITEM_MOUSE_OVER_EVENT = 'itemMouseOverEvent'; var ITEM_MOUSE_OUT_EVENT = 'itemMouseOutEvent'; var ITEM_MOUSE_CLICK_EVENT = 'itemMouseClickEvent'; var FILE_ITEM_CLICKED = 'fileItemClicked'; var FILE_CONTENT_READY_EVENT = 'fileContentReady'; // @strings var CANNOT_READ_TEXT_MESSAGE = 'Cannot retrieve text content from ' + 'this filetype.'; var IO_ERROR_MESSAGE = 'An IO Error occured while trying to ' + 'read this text.'; var ADOBE_TOKEN = 'ADOBE'; var COPYRIGHT_TOKEN = '©'; var AIR_TOKEN = 'AIR'; var TRADEMARK_TOKEN = '™'; var APP_LEGAL_NAME = 'HTML View Source Framework'; var APP_VERSION_MAJOR_MINOR = '1.5'; var TREE_DESCRIPTION_MESSAGE = 'Select a source file in the tree to '+ 'see its content in the right pane:'; var COPYRIGHT_MESSAGE = ''; /** * Flag to raise when the Source Viewer's window is open. * @field * @private */ var isMainWindowOpen; /** * The DOMProvider instance shared by all application components. It * is instantiated by WindowsManager.makeMainWindow(). * @field * @private */ var domProvider; /** * The CSSProvider instance shared by all application components. It * is instantiated by WindowsManager.makeMainWindow(). * @field * @private */ var cssProvider; /** * The UIBuilder instance shared by all application components. It * is instantiated by WindowsManager.makeMainWindow(). * @field * @private */ var uiBuilder; /** * The EventManager instance shared by all application components. * @field * @private */ var eventManager = new EventManager(); /** * The WindowsManager instance shared by all application components. * @field * @private */ var windowManager = new WindowsManager(); /** * The LayoutProvider instance shared by all application components. * @field * @private */ var layoutProvider = new LayoutProvider(); /** * The FileSystemWalker instance shared by all application components. * @field * @private */ var fileSystemWalker = new FileSystemWalker(); /** * The RequestedFilesRegistry instance shared by all application * components. * @field * @private */ var requestedFilesRegistry = new RequestedFilesRegistry(); /** * A hash that gets populated with references to DOM Elements * representing application's UI main sections. Namely, the hash's * structure is: * - header { HTML DOM element } * A reference to the DOM Element representing the header * (top most section) of the application's UI * - sidebar { HTML DOM element } * A reference to the DOM Element representing the sidebar * (left hand section) of the application's UI * - tree { HTML DOM element } * The