WebInspector.Panel = function(name)
{
WebInspector.View.call(this);
WebInspector.panels[name] = this;
this.element.addStyleClass("panel");
this.element.addStyleClass(name);
this._panelName = name;
this._shortcuts = ({});
WebInspector.settings[this._sidebarWidthSettingName()] = WebInspector.settings.createSetting(this._sidebarWidthSettingName(), undefined);
}
WebInspector.Panel.counterRightMargin = 25;
WebInspector.Panel.prototype = {
get name()
{
return this._panelName;
},
show: function()
{
WebInspector.View.prototype.show.call(this, WebInspector.inspectorView.panelsElement());
},
wasShown: function()
{
var panelStatusBar = document.getElementById("panel-status-bar")
var drawerViewAnchor = document.getElementById("drawer-view-anchor");
var statusBarItems = this.statusBarItems();
if (statusBarItems) {
this._statusBarItemContainer = document.createElement("div");
for (var i = 0; i < statusBarItems.length; ++i)
this._statusBarItemContainer.appendChild(statusBarItems[i]);
panelStatusBar.insertBefore(this._statusBarItemContainer, drawerViewAnchor);
}
var statusBarText = this.statusBarText();
if (statusBarText) {
this._statusBarTextElement = statusBarText;
panelStatusBar.appendChild(statusBarText);
}
this.focus();
},
willHide: function()
{
if (this._statusBarItemContainer && this._statusBarItemContainer.parentNode)
this._statusBarItemContainer.parentNode.removeChild(this._statusBarItemContainer);
delete this._statusBarItemContainer;
if (this._statusBarTextElement && this._statusBarTextElement.parentNode)
this._statusBarTextElement.parentNode.removeChild(this._statusBarTextElement);
delete this._statusBarTextElement;
},
reset: function()
{
this.searchCanceled();
},
defaultFocusedElement: function()
{
return this.sidebarTreeElement || this.element;
},
searchCanceled: function()
{
WebInspector.searchController.updateSearchMatchesCount(0, this);
},
performSearch: function(query)
{
this.searchCanceled();
},
jumpToNextSearchResult: function()
{
},
jumpToPreviousSearchResult: function()
{
},
canSearchAndReplace: function()
{
return false;
},
replaceSelectionWith: function(text)
{
},
replaceAllWith: function(query, text)
{
},
canFilter: function()
{
return false;
},
performFilter: function(query)
{
},
createSidebarView: function(parentElement, position, defaultWidth, defaultHeight)
{
if (this.splitView)
return;
if (!parentElement)
parentElement = this.element;
this.splitView = new WebInspector.SidebarView(position, this._sidebarWidthSettingName(), defaultWidth, defaultHeight);
this.splitView.show(parentElement);
this.splitView.addEventListener(WebInspector.SidebarView.EventTypes.Resized, this.sidebarResized.bind(this));
this.sidebarElement = this.splitView.sidebarElement;
},
createSidebarViewWithTree: function(parentElement, position, defaultWidth)
{
if (this.splitView)
return;
this.createSidebarView(parentElement, position);
this.sidebarTreeElement = document.createElement("ol");
this.sidebarTreeElement.className = "sidebar-tree";
this.splitView.sidebarElement.appendChild(this.sidebarTreeElement);
this.splitView.sidebarElement.addStyleClass("sidebar");
this.sidebarTree = new TreeOutline(this.sidebarTreeElement);
this.sidebarTree.panel = this;
},
_sidebarWidthSettingName: function()
{
return this._panelName + "SidebarWidth";
},
sidebarResized: function(event)
{
},
statusBarResized: function()
{
},
canShowAnchorLocation: function(anchor)
{
return false;
},
showAnchorLocation: function(anchor)
{
},
elementsToRestoreScrollPositionsFor: function()
{
return [];
},
handleShortcut: function(event)
{
var shortcutKey = WebInspector.KeyboardShortcut.makeKeyFromEvent(event);
var handler = this._shortcuts[shortcutKey];
if (handler && handler(event))
event.handled = true;
},
registerShortcuts: function(keys, handler)
{
for (var i = 0; i < keys.length; ++i)
this._shortcuts[keys[i].key] = handler;
},
__proto__: WebInspector.View.prototype
}
WebInspector.PanelDescriptor = function(name, title, className, scriptName, panel)
{
this._name = name;
this._title = title;
this._className = className;
this._scriptName = scriptName;
this._panel = panel;
}
WebInspector.PanelDescriptor.prototype = {
name: function()
{
return this._name;
},
title: function()
{
return this._title;
},
iconURL: function()
{
return this._iconURL;
},
setIconURL: function(iconURL)
{
this._iconURL = iconURL;
},
panel: function()
{
if (this._panel)
return this._panel;
if (this._scriptName)
loadScript(this._scriptName);
this._panel = new WebInspector[this._className];
return this._panel;
},
registerShortcuts: function() {}
}