2010-08-17 14:55:47 -07:00
|
|
|
/* -*- Mode: js2; js2-basic-offset: 2; indent-tabs-mode: nil; -*- */
|
2011-05-27 11:58:05 -07:00
|
|
|
/* vim: set ft=javascript ts=2 et sw=2 tw=80: */
|
2012-05-21 04:12:37 -07:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2010-08-17 14:55:47 -07:00
|
|
|
|
2012-05-25 03:28:47 -07:00
|
|
|
"use strict";
|
|
|
|
|
2010-08-17 14:55:47 -07:00
|
|
|
const Cc = Components.classes;
|
|
|
|
const Ci = Components.interfaces;
|
|
|
|
const Cu = Components.utils;
|
|
|
|
|
|
|
|
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
|
|
|
|
2012-05-29 05:48:05 -07:00
|
|
|
XPCOMUtils.defineLazyModuleGetter(this, "WebConsoleUtils",
|
2012-09-26 10:07:57 -07:00
|
|
|
"resource://gre/modules/devtools/WebConsoleUtils.jsm");
|
2010-08-17 14:55:47 -07:00
|
|
|
|
2012-10-31 09:13:28 -07:00
|
|
|
this.EXPORTED_SYMBOLS = ["PropertyPanel", "PropertyTreeView"];
|
2010-08-17 14:55:47 -07:00
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////
|
|
|
|
//// PropertyTreeView.
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This is an implementation of the nsITreeView interface. For comments on the
|
|
|
|
* interface properties, see the documentation:
|
|
|
|
* https://developer.mozilla.org/en/XPCOM_Interface_Reference/nsITreeView
|
|
|
|
*/
|
2012-10-31 09:13:28 -07:00
|
|
|
this.PropertyTreeView = function() {
|
2010-08-17 14:55:47 -07:00
|
|
|
this._rows = [];
|
2012-09-26 10:02:04 -07:00
|
|
|
this._objectActors = [];
|
2010-08-17 14:55:47 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
PropertyTreeView.prototype = {
|
|
|
|
/**
|
|
|
|
* Stores the visible rows of the tree.
|
2012-05-25 03:28:47 -07:00
|
|
|
* @private
|
2010-08-17 14:55:47 -07:00
|
|
|
*/
|
|
|
|
_rows: null,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Stores the nsITreeBoxObject for this tree.
|
2012-05-25 03:28:47 -07:00
|
|
|
* @private
|
2010-08-17 14:55:47 -07:00
|
|
|
*/
|
|
|
|
_treeBox: null,
|
|
|
|
|
2012-05-25 03:28:47 -07:00
|
|
|
/**
|
2012-09-26 10:02:04 -07:00
|
|
|
* Track known object actor IDs. We clean these when the panel is
|
|
|
|
* destroyed/cleaned up.
|
|
|
|
*
|
2012-05-25 03:28:47 -07:00
|
|
|
* @private
|
2012-09-26 10:02:04 -07:00
|
|
|
* @type array
|
2012-05-25 03:28:47 -07:00
|
|
|
*/
|
2012-09-26 10:02:04 -07:00
|
|
|
_objectActors: null,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Map fake object actors to their IDs. This is used when we inspect local
|
|
|
|
* objects.
|
|
|
|
* @private
|
|
|
|
* @type Object
|
|
|
|
*/
|
|
|
|
_localObjectActors: null,
|
|
|
|
|
|
|
|
_releaseObject: null,
|
|
|
|
_objectPropertiesProvider: null,
|
2012-05-25 03:28:47 -07:00
|
|
|
|
2010-08-17 14:55:47 -07:00
|
|
|
/**
|
|
|
|
* Use this setter to update the content of the tree.
|
|
|
|
*
|
2012-05-25 03:28:47 -07:00
|
|
|
* @param object aData
|
|
|
|
* A meta object that holds information about the object you want to
|
|
|
|
* display in the property panel. Object properties:
|
|
|
|
* - object:
|
|
|
|
* This is the raw object you want to display. You can only provide
|
|
|
|
* this object if you want the property panel to work in sync mode.
|
2012-09-26 10:02:04 -07:00
|
|
|
* - objectProperties:
|
2012-05-25 03:28:47 -07:00
|
|
|
* An array that holds information on the remote object being
|
|
|
|
* inspected. Each element in this array describes each property in the
|
2012-09-26 10:02:04 -07:00
|
|
|
* remote object. See WebConsoleUtils.inspectObject() for details.
|
|
|
|
* - objectPropertiesProvider:
|
2012-05-25 03:28:47 -07:00
|
|
|
* A function that is invoked when a new object is needed. This is
|
|
|
|
* called when the user tries to expand an inspectable property. The
|
|
|
|
* callback must take four arguments:
|
2012-09-26 10:02:04 -07:00
|
|
|
* - actorID:
|
|
|
|
* The object actor ID from which we request the properties.
|
2012-05-25 03:28:47 -07:00
|
|
|
* - callback:
|
|
|
|
* The callback function to be invoked when the remote object is
|
2012-09-26 10:02:04 -07:00
|
|
|
* received. This function takes one argument: the array of
|
|
|
|
* descriptors for each property in the object represented by the
|
|
|
|
* actor.
|
|
|
|
* - releaseObject:
|
|
|
|
* Function to invoke when an object actor should be released. The
|
|
|
|
* function must take one argument: the object actor ID.
|
2010-08-17 14:55:47 -07:00
|
|
|
*/
|
2012-05-25 03:28:47 -07:00
|
|
|
set data(aData) {
|
2010-08-17 14:55:47 -07:00
|
|
|
let oldLen = this._rows.length;
|
2012-05-25 03:28:47 -07:00
|
|
|
|
2012-09-26 10:02:04 -07:00
|
|
|
this.cleanup();
|
2012-05-25 03:28:47 -07:00
|
|
|
|
|
|
|
if (!aData) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-09-26 10:02:04 -07:00
|
|
|
if (aData.objectPropertiesProvider) {
|
|
|
|
this._objectPropertiesProvider = aData.objectPropertiesProvider;
|
|
|
|
this._releaseObject = aData.releaseObject;
|
|
|
|
this._propertiesToRows(aData.objectProperties, 0);
|
|
|
|
this._rows = aData.objectProperties;
|
2012-05-25 03:28:47 -07:00
|
|
|
}
|
|
|
|
else if (aData.object) {
|
2012-09-26 10:02:04 -07:00
|
|
|
this._localObjectActors = Object.create(null);
|
2012-05-25 03:28:47 -07:00
|
|
|
this._rows = this._inspectObject(aData.object);
|
|
|
|
}
|
|
|
|
else {
|
2012-09-26 10:02:04 -07:00
|
|
|
throw new Error("First argument must have an objectActor or an " +
|
|
|
|
"object property!");
|
2012-05-25 03:28:47 -07:00
|
|
|
}
|
|
|
|
|
2010-08-17 14:55:47 -07:00
|
|
|
if (this._treeBox) {
|
|
|
|
this._treeBox.beginUpdateBatch();
|
|
|
|
if (oldLen) {
|
|
|
|
this._treeBox.rowCountChanged(0, -oldLen);
|
|
|
|
}
|
|
|
|
this._treeBox.rowCountChanged(0, this._rows.length);
|
|
|
|
this._treeBox.endUpdateBatch();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
2012-05-25 03:28:47 -07:00
|
|
|
* Update a remote object so it can be used with the tree view. This method
|
|
|
|
* adds properties to each array element.
|
2010-08-17 14:55:47 -07:00
|
|
|
*
|
2012-05-25 03:28:47 -07:00
|
|
|
* @private
|
|
|
|
* @param array aObject
|
|
|
|
* The remote object you want prepared for use with the tree view.
|
|
|
|
* @param number aLevel
|
|
|
|
* The level you want to give to each property in the remote object.
|
2010-08-17 14:55:47 -07:00
|
|
|
*/
|
2012-09-26 10:02:04 -07:00
|
|
|
_propertiesToRows: function PTV__propertiesToRows(aObject, aLevel)
|
2010-08-17 14:55:47 -07:00
|
|
|
{
|
2012-09-26 10:02:04 -07:00
|
|
|
aObject.forEach(function(aItem) {
|
|
|
|
aItem._level = aLevel;
|
|
|
|
aItem._open = false;
|
|
|
|
aItem._children = null;
|
|
|
|
|
|
|
|
if (this._releaseObject) {
|
|
|
|
["value", "get", "set"].forEach(function(aProp) {
|
|
|
|
let val = aItem[aProp];
|
|
|
|
if (val && val.actor) {
|
|
|
|
this._objectActors.push(val.actor);
|
2012-11-05 08:41:59 -08:00
|
|
|
if (typeof val.displayString == "object" &&
|
|
|
|
val.displayString.type == "longString") {
|
|
|
|
this._objectActors.push(val.displayString.actor);
|
|
|
|
}
|
2012-09-26 10:02:04 -07:00
|
|
|
}
|
|
|
|
}, this);
|
|
|
|
}
|
|
|
|
}, this);
|
2012-05-25 03:28:47 -07:00
|
|
|
},
|
2012-05-25 06:44:17 -07:00
|
|
|
|
2012-05-25 03:28:47 -07:00
|
|
|
/**
|
|
|
|
* Inspect a local object.
|
|
|
|
*
|
|
|
|
* @private
|
|
|
|
* @param object aObject
|
|
|
|
* The object you want to inspect.
|
2012-09-26 10:02:04 -07:00
|
|
|
* @return array
|
|
|
|
* The array of properties, each being described in a way that is
|
|
|
|
* usable by the tree view.
|
2012-05-25 03:28:47 -07:00
|
|
|
*/
|
|
|
|
_inspectObject: function PTV__inspectObject(aObject)
|
|
|
|
{
|
2012-09-26 10:02:04 -07:00
|
|
|
this._objectPropertiesProvider = this._localPropertiesProvider.bind(this);
|
|
|
|
let children =
|
|
|
|
WebConsoleUtils.inspectObject(aObject, this._localObjectGrip.bind(this));
|
|
|
|
this._propertiesToRows(children, 0);
|
2012-05-25 03:28:47 -07:00
|
|
|
return children;
|
|
|
|
},
|
2012-05-25 06:44:17 -07:00
|
|
|
|
2012-05-25 03:28:47 -07:00
|
|
|
/**
|
2012-09-26 10:02:04 -07:00
|
|
|
* Make a local fake object actor for the given object.
|
|
|
|
*
|
|
|
|
* @private
|
|
|
|
* @param object aObject
|
|
|
|
* The object to make an actor for.
|
|
|
|
* @return object
|
|
|
|
* The fake actor grip that represents the given object.
|
|
|
|
*/
|
|
|
|
_localObjectGrip: function PTV__localObjectGrip(aObject)
|
|
|
|
{
|
|
|
|
let grip = WebConsoleUtils.getObjectGrip(aObject);
|
|
|
|
grip.actor = "obj" + gSequenceId();
|
|
|
|
this._localObjectActors[grip.actor] = aObject;
|
|
|
|
return grip;
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* A properties provider for when the user inspects local objects (not remote
|
2012-05-25 03:28:47 -07:00
|
|
|
* ones).
|
|
|
|
*
|
|
|
|
* @private
|
2012-09-26 10:02:04 -07:00
|
|
|
* @param string aActor
|
|
|
|
* The ID of the object actor you want.
|
2012-05-25 03:28:47 -07:00
|
|
|
* @param function aCallback
|
2012-09-26 10:02:04 -07:00
|
|
|
* The function you want to receive the list of properties.
|
2012-05-25 03:28:47 -07:00
|
|
|
*/
|
2012-09-26 10:02:04 -07:00
|
|
|
_localPropertiesProvider:
|
|
|
|
function PTV__localPropertiesProvider(aActor, aCallback)
|
2012-05-25 03:28:47 -07:00
|
|
|
{
|
2012-09-26 10:02:04 -07:00
|
|
|
let object = this._localObjectActors[aActor];
|
|
|
|
let properties =
|
|
|
|
WebConsoleUtils.inspectObject(object, this._localObjectGrip.bind(this));
|
|
|
|
aCallback(properties);
|
2010-08-17 14:55:47 -07:00
|
|
|
},
|
|
|
|
|
|
|
|
/** nsITreeView interface implementation **/
|
|
|
|
|
|
|
|
selection: null,
|
|
|
|
|
|
|
|
get rowCount() { return this._rows.length; },
|
|
|
|
setTree: function(treeBox) { this._treeBox = treeBox; },
|
2012-09-26 10:02:04 -07:00
|
|
|
getCellText: function PTV_getCellText(idx, column)
|
|
|
|
{
|
2012-05-25 03:28:47 -07:00
|
|
|
let row = this._rows[idx];
|
2012-09-26 10:02:04 -07:00
|
|
|
return row.name + ": " + WebConsoleUtils.getPropertyPanelValue(row);
|
2012-05-25 03:28:47 -07:00
|
|
|
},
|
|
|
|
getLevel: function(idx) {
|
2012-09-26 10:02:04 -07:00
|
|
|
return this._rows[idx]._level;
|
2012-05-25 03:28:47 -07:00
|
|
|
},
|
|
|
|
isContainer: function(idx) {
|
2012-09-26 10:02:04 -07:00
|
|
|
return typeof this._rows[idx].value == "object" && this._rows[idx].value &&
|
|
|
|
this._rows[idx].value.inspectable;
|
2012-05-25 03:28:47 -07:00
|
|
|
},
|
|
|
|
isContainerOpen: function(idx) {
|
2012-09-26 10:02:04 -07:00
|
|
|
return this._rows[idx]._open;
|
2012-05-25 03:28:47 -07:00
|
|
|
},
|
2010-08-17 14:55:47 -07:00
|
|
|
isContainerEmpty: function(idx) { return false; },
|
|
|
|
isSeparator: function(idx) { return false; },
|
|
|
|
isSorted: function() { return false; },
|
|
|
|
isEditable: function(idx, column) { return false; },
|
|
|
|
isSelectable: function(row, col) { return true; },
|
|
|
|
|
|
|
|
getParentIndex: function(idx)
|
|
|
|
{
|
|
|
|
if (this.getLevel(idx) == 0) {
|
|
|
|
return -1;
|
|
|
|
}
|
2012-05-25 03:28:47 -07:00
|
|
|
for (var t = idx - 1; t >= 0; t--) {
|
2010-08-17 14:55:47 -07:00
|
|
|
if (this.isContainer(t)) {
|
|
|
|
return t;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
},
|
|
|
|
|
|
|
|
hasNextSibling: function(idx, after)
|
|
|
|
{
|
2012-09-26 10:02:04 -07:00
|
|
|
let thisLevel = this.getLevel(idx);
|
|
|
|
return this._rows.slice(after + 1).some(function (r) r._level == thisLevel);
|
2010-08-17 14:55:47 -07:00
|
|
|
},
|
|
|
|
|
|
|
|
toggleOpenState: function(idx)
|
|
|
|
{
|
2012-05-25 03:28:47 -07:00
|
|
|
let item = this._rows[idx];
|
2012-09-26 10:02:04 -07:00
|
|
|
if (!this.isContainer(idx)) {
|
2010-08-17 14:55:47 -07:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-09-26 10:02:04 -07:00
|
|
|
if (item._open) {
|
2012-05-25 03:28:47 -07:00
|
|
|
this._treeBox.beginUpdateBatch();
|
2012-09-26 10:02:04 -07:00
|
|
|
item._open = false;
|
2010-08-17 14:55:47 -07:00
|
|
|
|
2012-09-26 10:02:04 -07:00
|
|
|
var thisLevel = item._level;
|
2010-08-17 14:55:47 -07:00
|
|
|
var t = idx + 1, deleteCount = 0;
|
|
|
|
while (t < this._rows.length && this.getLevel(t++) > thisLevel) {
|
|
|
|
deleteCount++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (deleteCount) {
|
|
|
|
this._rows.splice(idx + 1, deleteCount);
|
|
|
|
this._treeBox.rowCountChanged(idx + 1, -deleteCount);
|
|
|
|
}
|
2012-05-25 03:28:47 -07:00
|
|
|
this._treeBox.invalidateRow(idx);
|
|
|
|
this._treeBox.endUpdateBatch();
|
2010-08-17 14:55:47 -07:00
|
|
|
}
|
|
|
|
else {
|
2012-05-25 03:28:47 -07:00
|
|
|
let levelUpdate = true;
|
2012-09-26 10:02:04 -07:00
|
|
|
let callback = function _onRemoteResponse(aProperties) {
|
2012-05-25 03:28:47 -07:00
|
|
|
this._treeBox.beginUpdateBatch();
|
|
|
|
if (levelUpdate) {
|
2012-09-26 10:02:04 -07:00
|
|
|
this._propertiesToRows(aProperties, item._level + 1);
|
|
|
|
item._children = aProperties;
|
2012-05-25 03:28:47 -07:00
|
|
|
}
|
2010-08-17 14:55:47 -07:00
|
|
|
|
2012-09-26 10:02:04 -07:00
|
|
|
this._rows.splice.apply(this._rows, [idx + 1, 0].concat(item._children));
|
2010-08-17 14:55:47 -07:00
|
|
|
|
2012-09-26 10:02:04 -07:00
|
|
|
this._treeBox.rowCountChanged(idx + 1, item._children.length);
|
2012-05-25 03:28:47 -07:00
|
|
|
this._treeBox.invalidateRow(idx);
|
|
|
|
this._treeBox.endUpdateBatch();
|
2012-09-26 10:02:04 -07:00
|
|
|
item._open = true;
|
2012-05-25 03:28:47 -07:00
|
|
|
}.bind(this);
|
|
|
|
|
2012-09-26 10:02:04 -07:00
|
|
|
if (!item._children) {
|
|
|
|
this._objectPropertiesProvider(item.value.actor, callback);
|
2012-05-25 03:28:47 -07:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
levelUpdate = false;
|
2012-09-26 10:02:04 -07:00
|
|
|
callback(item._children);
|
2012-05-25 03:28:47 -07:00
|
|
|
}
|
2010-08-17 14:55:47 -07:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
getImageSrc: function(idx, column) { },
|
|
|
|
getProgressMode : function(idx,column) { },
|
|
|
|
getCellValue: function(idx, column) { },
|
|
|
|
cycleHeader: function(col, elem) { },
|
|
|
|
selectionChanged: function() { },
|
|
|
|
cycleCell: function(idx, column) { },
|
|
|
|
performAction: function(action) { },
|
|
|
|
performActionOnCell: function(action, index, column) { },
|
|
|
|
performActionOnRow: function(action, row) { },
|
|
|
|
getRowProperties: function(idx, column, prop) { },
|
|
|
|
getCellProperties: function(idx, column, prop) { },
|
|
|
|
getColumnProperties: function(column, element, prop) { },
|
|
|
|
|
|
|
|
setCellValue: function(row, col, value) { },
|
|
|
|
setCellText: function(row, col, value) { },
|
|
|
|
drop: function(index, orientation, dataTransfer) { },
|
2012-05-25 03:28:47 -07:00
|
|
|
canDrop: function(index, orientation, dataTransfer) { return false; },
|
|
|
|
|
2012-09-26 10:02:04 -07:00
|
|
|
/**
|
|
|
|
* Cleanup the property tree view.
|
|
|
|
*/
|
|
|
|
cleanup: function PTV_cleanup()
|
2012-05-25 03:28:47 -07:00
|
|
|
{
|
2012-09-26 10:02:04 -07:00
|
|
|
if (this._releaseObject) {
|
|
|
|
this._objectActors.forEach(this._releaseObject);
|
|
|
|
delete this._objectPropertiesProvider;
|
|
|
|
delete this._releaseObject;
|
|
|
|
}
|
|
|
|
if (this._localObjectActors) {
|
|
|
|
delete this._localObjectActors;
|
|
|
|
delete this._objectPropertiesProvider;
|
2012-05-25 03:28:47 -07:00
|
|
|
}
|
|
|
|
|
2012-09-26 10:02:04 -07:00
|
|
|
this._rows = [];
|
|
|
|
this._objectActors = [];
|
2012-05-25 03:28:47 -07:00
|
|
|
},
|
2010-08-17 14:55:47 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////
|
|
|
|
//// Helper for creating the panel.
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates a DOMNode and sets all the attributes of aAttributes on the created
|
|
|
|
* element.
|
|
|
|
*
|
|
|
|
* @param nsIDOMDocument aDocument
|
|
|
|
* Document to create the new DOMNode.
|
|
|
|
* @param string aTag
|
|
|
|
* Name of the tag for the DOMNode.
|
|
|
|
* @param object aAttributes
|
|
|
|
* Attributes set on the created DOMNode.
|
|
|
|
* @returns nsIDOMNode
|
|
|
|
*/
|
|
|
|
function createElement(aDocument, aTag, aAttributes)
|
|
|
|
{
|
|
|
|
let node = aDocument.createElement(aTag);
|
|
|
|
for (var attr in aAttributes) {
|
|
|
|
node.setAttribute(attr, aAttributes[attr]);
|
|
|
|
}
|
|
|
|
return node;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates a new DOMNode and appends it to aParent.
|
|
|
|
*
|
|
|
|
* @param nsIDOMDocument aDocument
|
|
|
|
* Document to create the new DOMNode.
|
|
|
|
* @param nsIDOMNode aParent
|
|
|
|
* A parent node to append the created element.
|
|
|
|
* @param string aTag
|
|
|
|
* Name of the tag for the DOMNode.
|
|
|
|
* @param object aAttributes
|
|
|
|
* Attributes set on the created DOMNode.
|
|
|
|
* @returns nsIDOMNode
|
|
|
|
*/
|
|
|
|
function appendChild(aDocument, aParent, aTag, aAttributes)
|
|
|
|
{
|
|
|
|
let node = createElement(aDocument, aTag, aAttributes);
|
|
|
|
aParent.appendChild(node);
|
|
|
|
return node;
|
|
|
|
}
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////
|
|
|
|
//// PropertyPanel
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates a new PropertyPanel.
|
|
|
|
*
|
2012-05-25 03:28:47 -07:00
|
|
|
* @see PropertyTreeView
|
2010-08-17 14:55:47 -07:00
|
|
|
* @param nsIDOMNode aParent
|
|
|
|
* Parent node to append the created panel to.
|
|
|
|
* @param string aTitle
|
|
|
|
* Title for the panel.
|
|
|
|
* @param string aObject
|
2012-05-25 03:28:47 -07:00
|
|
|
* Object to display in the tree. For details about this object please
|
|
|
|
* see the PropertyTreeView constructor in this file.
|
2010-08-17 14:55:47 -07:00
|
|
|
* @param array of objects aButtons
|
|
|
|
* Array with buttons to display at the bottom of the panel.
|
|
|
|
*/
|
2012-10-31 09:13:28 -07:00
|
|
|
this.PropertyPanel = function PropertyPanel(aParent, aTitle, aObject, aButtons)
|
2010-08-17 14:55:47 -07:00
|
|
|
{
|
2012-05-25 03:28:47 -07:00
|
|
|
let document = aParent.ownerDocument;
|
|
|
|
|
2010-08-17 14:55:47 -07:00
|
|
|
// Create the underlying panel
|
2012-05-25 03:28:47 -07:00
|
|
|
this.panel = createElement(document, "panel", {
|
2010-08-17 14:55:47 -07:00
|
|
|
label: aTitle,
|
|
|
|
titlebar: "normal",
|
|
|
|
noautofocus: "true",
|
2011-02-14 11:00:21 -08:00
|
|
|
noautohide: "true",
|
|
|
|
close: "true",
|
2010-08-17 14:55:47 -07:00
|
|
|
});
|
|
|
|
|
|
|
|
// Create the tree.
|
2012-05-25 03:28:47 -07:00
|
|
|
let tree = this.tree = createElement(document, "tree", {
|
2010-09-13 03:15:48 -07:00
|
|
|
flex: 1,
|
|
|
|
hidecolumnpicker: "true"
|
|
|
|
});
|
2010-08-17 14:55:47 -07:00
|
|
|
|
2012-05-25 03:28:47 -07:00
|
|
|
let treecols = document.createElement("treecols");
|
|
|
|
appendChild(document, treecols, "treecol", {
|
2010-08-17 14:55:47 -07:00
|
|
|
primary: "true",
|
2010-09-13 03:15:48 -07:00
|
|
|
flex: 1,
|
|
|
|
hideheader: "true",
|
|
|
|
ignoreincolumnpicker: "true"
|
2010-08-17 14:55:47 -07:00
|
|
|
});
|
|
|
|
tree.appendChild(treecols);
|
|
|
|
|
2012-05-25 03:28:47 -07:00
|
|
|
tree.appendChild(document.createElement("treechildren"));
|
2010-08-17 14:55:47 -07:00
|
|
|
this.panel.appendChild(tree);
|
|
|
|
|
|
|
|
// Create the footer.
|
2012-05-25 03:28:47 -07:00
|
|
|
let footer = createElement(document, "hbox", { align: "end" });
|
|
|
|
appendChild(document, footer, "spacer", { flex: 1 });
|
2010-08-17 14:55:47 -07:00
|
|
|
|
|
|
|
// The footer can have butttons.
|
|
|
|
let self = this;
|
|
|
|
if (aButtons) {
|
|
|
|
aButtons.forEach(function(button) {
|
2012-05-25 03:28:47 -07:00
|
|
|
let buttonNode = appendChild(document, footer, "button", {
|
2010-08-17 14:55:47 -07:00
|
|
|
label: button.label,
|
2010-10-11 14:37:34 -07:00
|
|
|
accesskey: button.accesskey || "",
|
|
|
|
class: button.class || "",
|
2010-08-17 14:55:47 -07:00
|
|
|
});
|
|
|
|
buttonNode.addEventListener("command", button.oncommand, false);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2012-05-25 03:28:47 -07:00
|
|
|
appendChild(document, footer, "resizer", { dir: "bottomend" });
|
2010-08-17 14:55:47 -07:00
|
|
|
this.panel.appendChild(footer);
|
|
|
|
|
|
|
|
aParent.appendChild(this.panel);
|
|
|
|
|
|
|
|
// Create the treeView object.
|
|
|
|
this.treeView = new PropertyTreeView();
|
|
|
|
this.treeView.data = aObject;
|
|
|
|
|
|
|
|
// Set the treeView object on the tree view. This has to be done *after* the
|
|
|
|
// panel is shown. This is because the tree binding must be attached first.
|
|
|
|
this.panel.addEventListener("popupshown", function onPopupShow()
|
|
|
|
{
|
|
|
|
self.panel.removeEventListener("popupshown", onPopupShow, false);
|
|
|
|
self.tree.view = self.treeView;
|
|
|
|
}, false);
|
2011-02-14 11:00:21 -08:00
|
|
|
|
|
|
|
this.panel.addEventListener("popuphidden", function onPopupHide()
|
|
|
|
{
|
|
|
|
self.panel.removeEventListener("popuphidden", onPopupHide, false);
|
|
|
|
self.destroy();
|
|
|
|
}, false);
|
2010-08-17 14:55:47 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2012-05-25 03:28:47 -07:00
|
|
|
* Destroy the PropertyPanel. This closes the panel and removes it from the
|
|
|
|
* browser DOM.
|
2010-08-17 14:55:47 -07:00
|
|
|
*/
|
|
|
|
PropertyPanel.prototype.destroy = function PP_destroy()
|
|
|
|
{
|
2012-05-25 03:28:47 -07:00
|
|
|
this.treeView.data = null;
|
2010-08-17 14:55:47 -07:00
|
|
|
this.panel.parentNode.removeChild(this.panel);
|
|
|
|
this.treeView = null;
|
|
|
|
this.panel = null;
|
|
|
|
this.tree = null;
|
2012-05-25 06:44:17 -07:00
|
|
|
}
|
2012-05-25 03:28:47 -07:00
|
|
|
|
2012-09-26 10:02:04 -07:00
|
|
|
|
|
|
|
function gSequenceId()
|
|
|
|
{
|
|
|
|
return gSequenceId.n++;
|
|
|
|
}
|
|
|
|
gSequenceId.n = 0;
|