Source: workspace.js

goog.provide('sync.api.Workspace');

goog.require('goog.events.EventTarget');
goog.require('sync.api.FileBrowsingDialog');


/**
 * Access to the Workspace in which the editor is opened.
 *
 * @constructor
 */
sync.api.Workspace = function() {
};
goog.inherits(sync.api.Workspace, goog.events.EventTarget);


/**
 * Sets the URL chooser used when the user is asked to provide and URL.
 * When there is not chooser set, the user will usually have to enter the
 * URLs in a text field.
 *
 * @param {sync.api.UrlChooser} urlChooser The URL chooser to set.
 */
sync.api.Workspace.prototype.setUrlChooser = function(urlChooser) {
};


/**
 * Creates a dialog that can have custom content and behavior.
 *
 * The advandatage of using this method is that the dialog will have 
 * a consistent appearance with the rest of the application and that 
 * it will work on all devices supported by the WebApp.
 *
 * @param {string=} opt_id The id that will be given to the dialog box.
 * For example, you can use it for specifying the width of the dialog in CSS.
 *
 * @return {sync.api.Dialog} The dialog.
 */
sync.api.Workspace.prototype.createDialog = function(opt_id) {
};

/**
 * Returns the view manager helper object that can be used to customize oXygen XML WebApp views.
 *
 * @return  {sync.view.ViewManager} The view manager.
 */
sync.api.Workspace.prototype.getViewManager = function() {
};

/**
 * Returns an object that can be used to display notifications to the user.
 *
 * @return {sync.api.NotificationsManager} the notifications manager.
 */
sync.api.Workspace.prototype.getNotificationManager = function() {
};


/**
 * The types of the Workspace events.
 *
 * @enum {string}
 */
sync.api.Workspace.EventType = {
  /**
   * Triggered before the editor content was loaded. See the {@link sync.api.Workspace.BeforeEditorOpenedEvent}
   * description for more details.
   *
   * Note that frameworks code cannot use this event since the framework is detected while the document is loaded.
   */
  BEFORE_EDITOR_LOADED: 'before_editor_loaded',
  /**
   * Triggered after the editor was loaded.
   */
  EDITOR_LOADED: 'editor_loaded',

  /**
   * Triggered before the dashboard is loaded.
   */
  BEFORE_DASHBOARD_LOADED: 'before_dashboard_loaded',
  /**
   * Triggered after the dashboard was loaded.
   */
  DASHBOARD_LOADED: 'dashboard_loaded'
};


/**
 * Event generated when an editor is loaded.
 *
 * <hr/>
 * <p>
 * Example of listening for this event:
 * </p>
 * <pre>
 * goog.events.listen(workspace, sync.api.Workspace.EventType.EDITOR_LOADED, function(e) {
 *   // e is of type sync.api.Workspace.EditorLifecycleEvent
 * });
 * </pre>
 *
 * @param {string} type The type of the event.
 * @param {sync.api.Editor} editor The editor that was loaded.
 *
 * @constructor
 */
sync.api.Workspace.EditorLifecycleEvent = function(type, editor) {
  this.type = type;

  /**
   * The editor which has been loaded.
   * @type {sync.api.Editor}
   */
  this.editor = editor;
};

/**
 * @typedef {Object} sync.api.Workspace.LoadingOptions The object used to open the editor.
 * @property {string} url The URL of the document.
 * @property {string=} title The title of the document. If not specified, it is inferred from URL.
 * @property {string=} userName The name of the user which will edit the document.
 * Used as the author for comments and displayed in the top-right corner.
 * If not specified, it is inferred from the <i>author</i> URL variable.
 * @property {string=} content The content of the document. If not specified, the server will load the content
 * from the given URL.
 * @property {string=} modes The available editing modes, comma-separated. If multiple values are passed
 * in, the first one will be active and the user can switch to another one using the GUI. Possible values:
 * <ul>
 *  <li>review - only the review actions are enabled
 *  <li>edit - full editing support is enabled
 * </ul>
 */

/**
 * Event generated before the editor is loaded. Its usage include:
 * <ul>
 *   <li> adding new actions to the editor's action manager.
 *   <li> changing the startup options of the editor.
 * </ul>
 *
 * If the options can only be computed asynchronously, one can cancel the editor loading
 * with preventDefault and call
 *
 * <pre><code>editor.load(options);</code></pre>
 *
 * later to load the editor with the new options.
 *
 * <hr/>
 * <p>
 * Example of listening for this event:
 * </p>
 * <pre>
 * goog.events.listen(workspace, sync.api.Workspace.EventType.BEFORE_EDITOR_LOADED, function(e) {
 *   // e is of type sync.api.Workspace.BeforeEditorOpenedEvent
 * });
 * </pre>
 *
 * @param {string} type The type of the event.
 * @param {sync.api.Editor} editor The editor that was loaded.
 * @param {sync.api.Workspace.LoadingOptions} options The options used to open the editor.
 *
 * @constructor
 */
sync.api.Workspace.BeforeEditorOpenedEvent = function(type, editor, options) {
  sync.api.Workspace.EditorLifecycleEvent.call(this, type, editor);
  /**
   * The options used to load the editor.
   *
   * If these options are changed during the {@link sync.api.Workspace.EventType.BEFORE_EDITOR_LOADED},
   * they will be taken into account during the editor loading.
   *
   * @type {sync.api.Workspace.LoadingOptions}
   */
  this.options = options;
};
goog.inherits(sync.api.Workspace.BeforeEditorOpenedEvent, sync.api.Workspace.EditorLifecycleEvent);

/**
 * Event generated before and after the Dashboard is loaded.
 *
 * <hr/>
 * <p>
 * Example of listening for this event:
 * </p>
 * <pre>
 * goog.events.listen(workspace, sync.api.Workspace.EventType.BEFORE_DASHBOARD_LOADED, function(e) {
 * });
 * goog.events.listen(workspace, sync.api.Workspace.EventType.DASHBOARD_LOADED, function(e) {
 * });
 * </pre>
 *
 *
 * @param {string} type The type of the event.
 *
 * @constructor
 */
sync.api.Workspace.DashboardLifecycleEvent = function(type) {
  this.type = type;
};