|
| 1 | +import "FillDockContainer"; |
| 2 | + |
| 3 | +/** |
| 4 | + * The document manager is then central area of the dock layout hierarchy. |
| 5 | + * This is where more important panels are placed (e.g. the text editor in an IDE, |
| 6 | + * 3D view in a modelling package etc |
| 7 | + */ |
| 8 | +dockspawn.DocumentManagerContainer = function(dockManager) |
| 9 | +{ |
| 10 | + dockspawn.FillDockContainer.call(this, dockManager, dockspawn.TabHost.DIRECTION_TOP); |
| 11 | + this.minimumAllowedChildNodes = 0; |
| 12 | + this.element.classList.add("document-manager"); |
| 13 | + this.tabHost.createTabPage = this._createDocumentTabPage; |
| 14 | + this.tabHost.displayCloseButton = true; |
| 15 | +}; |
| 16 | +dockspawn.DocumentManagerContainer.prototype = new dockspawn.FillDockContainer(); |
| 17 | +dockspawn.DocumentManagerContainer.prototype.constructor = dockspawn.DocumentManagerContainer; |
| 18 | + |
| 19 | +dockspawn.DocumentManagerContainer.prototype._createDocumentTabPage = function(tabHost, container) |
| 20 | +{ |
| 21 | + return new dockspawn.DocumentTabPage(tabHost, container); |
| 22 | +}; |
| 23 | + |
| 24 | +dockspawn.DocumentManagerContainer.prototype.saveState = function(state) |
| 25 | +{ |
| 26 | + dockspawn.FillDockContainer.prototype.saveState.call(this, state); |
| 27 | + state.documentManager = true; |
| 28 | +}; |
| 29 | + |
| 30 | +/** Returns the selected document tab */ |
| 31 | +dockspawn.DocumentManagerContainer.prototype.selectedTab = function() |
| 32 | +{ |
| 33 | + return this.tabHost.activeTab; |
| 34 | +}; |
| 35 | + |
| 36 | +/** |
| 37 | + * Specialized tab page that doesn't display the panel's frame when docked in a tab page |
| 38 | + */ |
| 39 | +dockspawn.DocumentTabPage = function(host, container) |
| 40 | +{ |
| 41 | + dockspawn.TabPage.call(this, host, container); |
| 42 | + |
| 43 | + // If the container is a panel, extract the content element and set it as the tab's content |
| 44 | + if (this.container.containerType == "panel") |
| 45 | + { |
| 46 | + this.panel = container; |
| 47 | + this.containerElement = this.panel.elementContent; |
| 48 | + |
| 49 | + // detach the container element from the panel's frame. |
| 50 | + // It will be reattached when this tab page is destroyed |
| 51 | + // This enables the panel's frame (title bar etc) to be hidden |
| 52 | + // inside the tab page |
| 53 | + removeNode(this.containerElement); |
| 54 | + } |
| 55 | +}; |
| 56 | +dockspawn.DocumentTabPage.prototype = new dockspawn.TabPage(); |
| 57 | +dockspawn.DocumentTabPage.prototype.constructor = dockspawn.DocumentTabPage; |
| 58 | + |
| 59 | +dockspawn.DocumentTabPage.prototype.destroy = function() |
| 60 | +{ |
| 61 | + dockspawn.TabPage.prototype.destroy.call(this); |
| 62 | + |
| 63 | + // Restore the panel content element back into the panel frame |
| 64 | + removeNode(this.containerElement); |
| 65 | + this.panel.elementContentHost.appendChild(this.containerElement); |
| 66 | +}; |
0 commit comments