diff --git a/mozilla/extensions/inspector/resources/content/extensions/titledSplitter.css b/mozilla/extensions/inspector/resources/content/extensions/titledSplitter.css new file mode 100644 index 00000000000..9870bbca700 --- /dev/null +++ b/mozilla/extensions/inspector/resources/content/extensions/titledSplitter.css @@ -0,0 +1,6 @@ + +@import url("chrome://inspector/skin/titledSplitter.css"); + +.titled-splitter { + -moz-binding: url("titledSplitter.xml#titledSplitter") !important; +} diff --git a/mozilla/extensions/inspector/resources/content/extensions/titledSplitter.xml b/mozilla/extensions/inspector/resources/content/extensions/titledSplitter.xml new file mode 100644 index 00000000000..7b7b4a1b23c --- /dev/null +++ b/mozilla/extensions/inspector/resources/content/extensions/titledSplitter.xml @@ -0,0 +1,86 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/mozilla/extensions/inspector/resources/content/extensions/treeEditable.css b/mozilla/extensions/inspector/resources/content/extensions/treeEditable.css new file mode 100644 index 00000000000..4e279a0ebc8 --- /dev/null +++ b/mozilla/extensions/inspector/resources/content/extensions/treeEditable.css @@ -0,0 +1,11 @@ + +@import url("chrome://inspector/skin/treeEditable.css"); + +.tree-editable { + -moz-binding: url("treeEditable.xml#treeEditable"); +} + +.treecell-editable { + -moz-binding: url("treeEditable.xml#treecellEditable"); +} + diff --git a/mozilla/extensions/inspector/resources/content/extensions/treeEditable.xml b/mozilla/extensions/inspector/resources/content/extensions/treeEditable.xml new file mode 100644 index 00000000000..bc95174b104 --- /dev/null +++ b/mozilla/extensions/inspector/resources/content/extensions/treeEditable.xml @@ -0,0 +1,161 @@ + + + + + + + + + + + + + + + + + new Function("event", this.getAttribute("onstartedit")); + + + + new Function("event", this.getAttribute("onafteredit")); + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/mozilla/extensions/inspector/resources/content/extensions/wsm-colorpicker.js b/mozilla/extensions/inspector/resources/content/extensions/wsm-colorpicker.js new file mode 100644 index 00000000000..730a966a8d2 --- /dev/null +++ b/mozilla/extensions/inspector/resources/content/extensions/wsm-colorpicker.js @@ -0,0 +1,47 @@ +/*************************************************************** +* wsm-colorpicker ---------------------------------------------- +* Quick script which adds support for the color picker widget +* to nsWidgetStateManager in the pref winodw. +* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +* REQUIRED IMPORTS: +****************************************************************/ + +function AddColorPicker(aCallback) +{ + window.addEventListener("load", AddColorPicker_delayCheck, false); + window.AddColorPicker_callback = aCallback; +} + +function AddColorPicker_delayCheck() +{ + if (parent.hPrefWindow) + AddColorPicker_addColorHandlers() + else + setTimeout("AddColorPicker_delayCheck()", 1); +} + +function AddColorPicker_addColorHandlers() +{ + parent.hPrefWindow.wsm.handlers.colorpicker = { + set: function (aElementID, aDataObject) + { + var wsm = parent.hPrefWindow.wsm; + var element = wsm.contentArea.document.getElementById( aElementID ); + element.color = aDataObject.color; + }, + + get: function (aElementID) + { + var wsm = parent.hPrefWindow.wsm; + var element = wsm.contentArea.document.getElementById( aElementID ); + var dataObject = wsm.generic_Get(element); + if(dataObject) { + dataObject.color = element.color; + return dataObject; + } + return null; + } + } + + window.AddColorPicker_callback(); +} diff --git a/mozilla/extensions/inspector/resources/content/jar.mn b/mozilla/extensions/inspector/resources/content/jar.mn index 992fccbe18e..f2d5aa01ee2 100644 --- a/mozilla/extensions/inspector/resources/content/jar.mn +++ b/mozilla/extensions/inspector/resources/content/jar.mn @@ -52,12 +52,7 @@ inspector.jar: content/inspector/search/modules/junkImgs/dialog.js (search/modules/junkImgs/dialog.js) content/inspector/sidebar/sidebar.xul (sidebar/sidebar.xul) content/inspector/sidebar/InspectorSidebar.js (sidebar/InspectorSidebar.js) - content/inspector/tests/test1.html (tests/test1.html) - content/inspector/tests/test2.xul (tests/test2.xul) - content/inspector/tests/selectors.xul (tests/selectors.xul) - content/inspector/tests/selectors.css (tests/selectors.css) content/inspector/tests/allskin.xul (tests/allskin.xul) - content/inspector/tests/allskin-ns.xul (tests/allskin-ns.xul) content/inspector/viewers/computedStyle/computedStyle.xul (viewers/computedStyle/computedStyle.xul) content/inspector/viewers/computedStyle/computedStyle.js (viewers/computedStyle/computedStyle.js) content/inspector/viewers/dom/dom.xul (viewers/dom/dom.xul) diff --git a/mozilla/extensions/inspector/resources/content/jsutil/rdf/RDFArray.js b/mozilla/extensions/inspector/resources/content/jsutil/rdf/RDFArray.js new file mode 100644 index 00000000000..9a797d66fe2 --- /dev/null +++ b/mozilla/extensions/inspector/resources/content/jsutil/rdf/RDFArray.js @@ -0,0 +1,159 @@ +/*************************************************************** +* RDFArray ----------------------------------------------- +* A convenience routine for creating an RDF-based 2d array +* indexed by number and hashkey. +* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +* REQUIRED IMPORTS: +* chrome://inspector/content/utils.js +* chrome://inspector/content/jsutil/xpcom/XPCU.js +* chrome://inspector/content/jsutil/rdf/RDFU.js +****************************************************************/ + +//////////// global constants //////////////////// + +RDFArray.URI = "http://www.joehewitt.com/mozilla/util/RDFArray#"; +RDFArray.RDF_URI = "http://www.w3.org/1999/02/22-rdf-syntax-ns#"; + +///// class RDFArray ///////////////////////// + +function RDFArray(aNSURI, aRootURN, aArcName) +{ + this.mNSURI = aNSURI; + this.mRootURN = aRootURN; + this.mArcName = aArcName ? aArcName : "list"; +} + +RDFArray.prototype = { + get datasource() { return this.mDS; }, + get length() { return this.mLength } , + + initialize: function() + { + this.mLength = 0; + + this.mDS = XPCU.createInstance("@mozilla.org/rdf/datasource;1?name=in-memory-datasource", "nsIRDFDataSource"); + + var root = gRDF.GetResource(this.mRootURN); + var res = gRDF.GetAnonymousResource(); + this.mDS.Assert(root, gRDF.GetResource(this.mNSURI+this.mArcName), res, true); + + this.mSeq = gRDFCU.MakeSeq(this.mDS, res); + }, + + add: function(aObject) + { + var res = this.createResourceFrom(aObject); + this.addResource(res); + }, + + addResource: function(aResource) + { + this.mSeq.AppendElement(aResource); + this.mLength++; + }, + + insertAt: function(aIndex, aObject) + { + var res = this.createResourceFrom(aObject); + this.insertResourceAt(aIndex, res); + }, + + insertResourceAt: function(aIndex, aResource) + { + }, + + removeAt: function(aIndex) + { + this.mSeq.RemoveElementAt(aIndex+1, true); + this.mLength--; + }, + + removeById: function(aId) + { + var proj = gRDF.GetResource(aId); + proj = XPCU.QI(proj, "nsIRDFNode"); + this.mSeq.RemoveElement(proj, true); + this.mLength--; + }, + + get: function(aIndex, aKey) + { + var res = RDFU.getSeqElementAt(this.mSeq, aIndex); + return RDFU.readAttribute(this.mDS, res, this.mNSURI+aKey); + }, + + set: function(aIndex, aKey, aValue) + { + var res = RDFU.getSeqElementAt(this.mSeq, aIndex); + RDFU.writeAttribute(this.mDS, res, this.mNSURI+aKey, aValue); + }, + + getResource: function(aIndex) + { + return RDFU.getSeqElementAt(this.mSeq, aIndex); + }, + + getResourceId: function(aIndex) + { + var el = RDFU.getSeqElementAt(this.mSeq, aIndex); + return el.Value; + }, + + save: function() + { + RDFU.saveDataSource(this.mDS); + }, + + + clear: function() + { + while (this.mLength) { + this.mSeq.RemoveElementAt(1, true); + this.mLength--; + } + }, + + createResourceFrom: function(aObject) + { + var el = gRDF.GetAnonymousResource(); + + // add a literal node for each property being added + for (var name in aObject) { + this.mDS.Assert(el, gRDF.GetResource(this.mNSURI+name), gRDF.GetLiteral(aObject[name]), true); + } + + return el; + } + +}; + +/////////// static factory methods ///////////////////////// + +RDFArray.fromContainer = function(aDS, aResourceID, aNSURI) +{ + var list = new RDFArray(aNSURI); + + list.mDS = aDS; + var seq = RDFU.findSeq(aDS, aResourceID); + list.mSeq = seq; + list.mLength = seq.GetCount(); + + return list; +} + +RDFArray.fromContainerArc = function(aDS, aSourceId, aTargetId, aNSURI) +{ + var list = new RDFArray(aNSURI); + list.mDS = aDS; + + var source = gRDF.GetResource(aSourceId); + var target = gRDF.GetResource(aTargetId); + var seqRes = aDS.GetTarget(source, target, true); + + var seq = RDFU.makeSeq(aDS, seqRes); + list.mSeq = seq; + list.mLength = seq.GetCount(); + + return list; +} + diff --git a/mozilla/extensions/inspector/resources/content/jsutil/rdf/RDFU.js b/mozilla/extensions/inspector/resources/content/jsutil/rdf/RDFU.js new file mode 100644 index 00000000000..2a004f082c0 --- /dev/null +++ b/mozilla/extensions/inspector/resources/content/jsutil/rdf/RDFU.js @@ -0,0 +1,114 @@ +/*************************************************************** +* RDFU ----------------------------------------------- +* Convenience routines for common RDF commands. +* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +* REQUIRED IMPORTS: +* chrome://inspector/content/jsutil/xpcom/XPCU.js +****************************************************************/ + +//////////// global constants //////////////////// + +try { +var gRDF = Components.classes['@mozilla.org/rdf/rdf-service;1'].getService(); +gRDF = gRDF.QueryInterface(Components.interfaces.nsIRDFService); + +var gRDFCU = Components.classes['@mozilla.org/rdf/container-utils;1'].getService(); +gRDFCU = gRDFCU.QueryInterface(Components.interfaces.nsIRDFContainerUtils); +} catch (ex) { alert("RDFU: " + ex); } +/////////////////////////////////////////////////// + +var RDFU = { + + getSeqElementAt: function(aSeq, aIndex) + { + var ordinal = gRDFCU.IndexToOrdinalResource(aIndex+1); + return aSeq.DataSource.GetTarget(aSeq.Resource, ordinal, true); + }, + + readAttribute: function(aDS, aRes, aName) + { + var attr = aDS.GetTarget(aRes, gRDF.GetResource(aName), true); + if (attr) + attr = XPCU.QI(attr, "nsIRDFLiteral"); + return attr ? attr.Value : null; + }, + + + writeAttribute: function(aDS, aRes, aName, aValue) + { + var attr = aDS.GetTarget(aRes, gRDF.GetResource(aName), true); + if (attr) + aDS.Change(aRes, gRDF.GetResource(aName), attr, gRDF.GetLiteral(aValue)); + }, + + + findSeq: function(aDS, aResName) + { + try { + var res = gRDF.GetResource(aResName); + seq = this.makeSeq(aDS, res); + } catch (ex) { + alert("Unable to find sequence:" + ex); + } + + return seq; + }, + + makeSeq: function(aDS, aRes) + { + var seq = XPCU.createInstance("@mozilla.org/rdf/container;1", "nsIRDFContainer"); + seq.Init(aDS, aRes); + return seq; + }, + + createSeq: function(aDS, aBaseRes, aArcRes) + { + var res = gRDF.GetAnonymousResource(); + aDS.Assert(aBaseRes, aArcRes, res, true); + var seq = gRDFCU.MakeSeq(aDS, res); + return seq; + }, + + loadDataSource: function(aURL, aListener) + { + var ds = gRDF.GetDataSource(aURL); + var rds = XPCU.QI(ds, "nsIRDFRemoteDataSource"); + + var observer = new DSLoadObserver(aListener); + + if (rds.loaded) { + observer.onEndLoad(ds); + } else { + var sink = XPCU.QI(ds, "nsIRDFXMLSink"); + sink.addXMLSinkObserver(observer); + } + }, + + saveDataSource: function(aDS) + { + var ds = XPCU.QI(aDS, "nsIRDFRemoteDataSource"); + ds.Flush(); + } +}; + +/////////// + +function DSLoadObserver(aListener) { this.mListener = aListener; } + +DSLoadObserver.prototype = +{ + onBeginLoad: function(aSink) { }, + onInterrupt: function(aSink) {}, + onResume: function(aSink) {}, + onError: function(aSink, aStatus, aErrorMsg) + { + this.mListener.onError(aErrorMsg); + }, + + onEndLoad: function(aSink) + { + var ds = XPCU.QI(aSink, "nsIRDFDataSource"); + this.mListener.onDataSourceReady(ds); + } + +}; diff --git a/mozilla/extensions/inspector/resources/content/jsutil/system/ClipboardUtils.js b/mozilla/extensions/inspector/resources/content/jsutil/system/ClipboardUtils.js new file mode 100644 index 00000000000..a96008b0ee1 --- /dev/null +++ b/mozilla/extensions/inspector/resources/content/jsutil/system/ClipboardUtils.js @@ -0,0 +1,35 @@ +/*************************************************************** +* ClipboardUtils ------------------------------------------------- +* Utility functions for painless clipboard interaction. +* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +* REQUIRED IMPORTS: +****************************************************************/ + +//////////// global variables ///////////////////// + +//////////// global constants //////////////////// + +//////////////////////////////////////////////////////////////////////////// +//// class ClipboardUtils + +var ClipboardUtils = { + + writeString: function(aString) + { + var clipboard = XPCU.getService("@mozilla.org/widget/clipboard;1", "nsIClipboard"); + var transferable = XPCU.createInstance("@mozilla.org/widget/transferable;1", "nsITransferable"); + + if (clipboard && transferable) { + transferable.addDataFlavor("text/unicode"); + + var data = XPCU.createInstance("@mozilla.org/supports-wstring;1", "nsISupportsWString"); + + if (data) { + data.data = aString; + transferable.setTransferData("text/unicode", data, aString.length * 2); + clipboard.setData(transferable, null, Components.interfaces.nsIClipboard.kGlobalClipboard); + } + } + } + +}; diff --git a/mozilla/extensions/inspector/resources/content/jsutil/system/DiskSearch.js b/mozilla/extensions/inspector/resources/content/jsutil/system/DiskSearch.js new file mode 100644 index 00000000000..fe43350ab88 --- /dev/null +++ b/mozilla/extensions/inspector/resources/content/jsutil/system/DiskSearch.js @@ -0,0 +1,59 @@ +/*************************************************************** +* DiskSearch ------------------------------------------------- +* A utility for handily searching the disk for files matching +* a certain criteria. +* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +* REQUIRED IMPORTS: +****************************************************************/ + +//////////// global variables ///////////////////// + +//////////// global constants //////////////////// + +//////////////////////////////////////////////////////////////////////////// +//// class DiskSearch + +var DiskSearch = +{ + findFiles: function(aRootDir, aExtList, aRecurse) + { + // has the file extensions so we don't have to + // linear search the array every time through + var extHash = {}; + for (var i = 0; i < aExtList.length; i++) { + extHash[aExtList[i]] = true; + } + + // recursively build the list of results + var results = []; + this.recurseDir(aRootDir, extHash, aRecurse, results); + return results; + }, + + recurseDir: function(aDir, aExtHash, aRecurse, aResults) + { + debug("("+aResults.length+") entering " + aDir.path + "\n"); + var entries = aDir.directoryEntries; + var entry, ext; + while (entries.hasMoreElements()) { + entry = XPCU.QI(entries.getNext(), "nsIFile"); + if (aRecurse && entry.isDirectory()) + this.recurseDir(entry, aExtHash, aRecurse, aResults); + ext = this.getExtension(entry.leafName); + if (ext) { + if (aExtHash[ext]) + aResults.push(entry.URL); + } + } + }, + + getExtension: function(aFileName) + { + var dotpt = aFileName.lastIndexOf("."); + if (dotpt) + return aFileName.substr(dotpt+1).toLowerCase(); + + return null; + } +}; + diff --git a/mozilla/extensions/inspector/resources/content/jsutil/system/FilePickerUtils.js b/mozilla/extensions/inspector/resources/content/jsutil/system/FilePickerUtils.js new file mode 100644 index 00000000000..bedda1cbeed --- /dev/null +++ b/mozilla/extensions/inspector/resources/content/jsutil/system/FilePickerUtils.js @@ -0,0 +1,86 @@ +/*************************************************************** +* FilePickerUtils ------------------------------------------------- +* A utility for easily dealing with the file picker dialog. +* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +* REQUIRED IMPORTS: +****************************************************************/ + +//////////// global constants //////////////////// + +const kFilePickerCID = "@mozilla.org/filepicker;1"; +const kLFileCID = "@mozilla.org/file/local;1"; + +const nsIFilePicker = Components.interfaces.nsIFilePicker; + +//////////////////////////////////////////////////////////////////////////// +//// class FilePickerUtils + +var FilePickerUtils = +{ + pickFile: function(aTitle, aInitPath, aFilters, aMode) + { + try { + var modeStr = aMode ? "mode" + aMode : "modeOpen"; + var mode; + try { + mode = nsIFilePicker[modeStr]; + } catch (ex) { + dump("WARNING: Invalid FilePicker mode '"+aMode+"'. Defaulting to 'Open'.\n"); + mode = nsIFilePicker.modeOpen; + } + + var fp = XPCU.createInstance(kFilePickerCID, "nsIFilePicker"); + fp.init(window, aTitle, mode); + + // join array of filter names into bit string + var filters = this.prepareFilters(aFilters); + + if (aInitPath) { + var dir = XPCU.createInstance(kLFileCID, "nsILocalFile"); + dir.initWithPath(aInitPath); + fp.displayDirectory = dir; + } + + if (fp.show() == nsIFilePicker.returnOK) { + return fp.file; + } + } catch (ex) { + dump("ERROR: Unable to open file picker.\n" + ex + "\n"); + } + return null; + }, + + pickDir: function(aTitle, aInitPath) + { + try { + var fp = XPCU.createInstance(kFilePickerCID, "nsIFilePicker"); + fp.init(window, aTitle, nsIFilePicker.modeGetFolder); + + if (aInitPath) { + var dir = XPCU.createInstance(kLFileCID, "nsILocalFile"); + dir.initWithPath(aInitPath); + fp.displayDirectory = dir; + } + + if (fp.show() == nsIFilePicker.returnOK) { + return fp.file; + } + } catch (ex) { + dump("ERROR: Unable to open directory picker.\n" + ex + "\n"); + } + + return null; + }, + + prepareFilters: function(aFilters) + { + // join array of filter names into bit string + var filters = 0; + for (var i = 0; i < aFilters.length; ++i) + filters = filters | nsIFilePicker[aFilters[i]]; + + return filters; + } + +}; + diff --git a/mozilla/extensions/inspector/resources/content/jsutil/system/PrefUtils.js b/mozilla/extensions/inspector/resources/content/jsutil/system/PrefUtils.js new file mode 100644 index 00000000000..c42b3deebca --- /dev/null +++ b/mozilla/extensions/inspector/resources/content/jsutil/system/PrefUtils.js @@ -0,0 +1,78 @@ +/*************************************************************** +* PrefUtils ------------------------------------------------- +* Utility for easily using the Mozilla preferences system. +* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +* REQUIRED IMPORTS: +****************************************************************/ + +//////////// global variables ///////////////////// + +//////////// global constants //////////////////// + +const nsIPref = Components.interfaces.nsIPref; + +//////////////////////////////////////////////////////////////////////////// +//// class PrefUtils + +var PrefUtils = +{ + mPrefs: null, + + init: function() + { + this.mPrefs = XPCU.getService("@mozilla.org/preferences;1", "nsIPref"); + }, + + addObserver: function(aDomain, aFunction) + { + if (!this.mPrefs) this.init(); + + this.mPrefs.addObserver(aDomain, aFunction); + }, + + removeObserver: function(aDomain, aFunction) + { + if (!this.mPrefs) this.init(); + + this.mPrefs.removeObserver(aDomain, aFunction); + }, + + setPref: function(aName, aValue) + { + if (!this.mPrefs) this.init(); + + var type = this.mPrefs.GetPrefType(aName); + try { + if (type == nsIPref.ePrefString) { + this.mPrefs.SetUnicharPref(aName, aValue); + } else if (type == nsIPref.ePrefBool) { + this.mPrefs.SetBoolPref(aName, aValue); + } else if (type == nsIPref.ePrefInt) { + this.mPrefs.SetIntPref(aName, aValue); + } + } catch(ex) { + debug("ERROR: Unable to write pref \"" + aName + "\".\n"); + } + }, + + getPref: function(aName) + { + if (!this.mPrefs) this.init(); + + var type = this.mPrefs.GetPrefType(aName); + try { + if (type == nsIPref.ePrefString) { + return this.mPrefs.CopyUnicharPref(aName); + } else if (type == nsIPref.ePrefBool) { + return this.mPrefs.GetBoolPref(aName); + } else if (type == nsIPref.ePrefInt) { + return this.mPrefs.GetIntPref(aName); + } + } catch(ex) { + debug("ERROR: Unable to read pref \"" + aName + "\".\n"); + } + return null; + } + +}; + diff --git a/mozilla/extensions/inspector/resources/content/jsutil/system/file.js b/mozilla/extensions/inspector/resources/content/jsutil/system/file.js new file mode 100644 index 00000000000..6df1367632b --- /dev/null +++ b/mozilla/extensions/inspector/resources/content/jsutil/system/file.js @@ -0,0 +1,701 @@ +/*** -*- Mode: Javascript; tab-width: 2; + +The contents of this file are subject to the Mozilla Public +License Version 1.1 (the "License"); you may not use this file +except in compliance with the License. You may obtain a copy of +the License at http://www.mozilla.org/MPL/ + +Software distributed under the License is distributed on an "AS +IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or +implied. See the License for the specific language governing +rights and limitations under the License. + +The Original Code is Collabnet code. +The Initial Developer of the Original Code is Collabnet. + +Portions created by Collabnet are +Copyright (C) 2000 Collabnet. All +Rights Reserved. + +Contributor(s): Pete Collins, Doug Turner, Brendan Eich, Warren Harris, Eric Plaster + + + File API (The purpose of this file is to make it a little easier to do file IO from js) + + file.js + + Function List + + // Constructor + File(aPath) // creates the File object and sets the file path + + open(aMode); // open a file handle for reading, writing or appending + close(); // closes a file handle + exists(); // check to see if a file exists + read(); // returns the contents of a file + readline(aDone); // returns the next line in the file. aDone == true at EOF + write(aContents, aPermissions); // permissions are optional + eof(); // check 'end of file' status + + // file attributes + permissions(); // returns the files permissions + dateModified(); // returns the last modified date in locale string + size(); // returns the file size + + // file string manipulation + path(); // returns the path + leaf(); // leaf is the endmost file string ex: foo.html in /myDir/foo.html + extension(); // returns a file extension if there is one + dirPath() // returns the dir part of a path + + // direct manipulation + nsIFIle() // returns an nsIFile obj + + // help! + help(); // currently dumps a list of available functions + + Instructions: + + First include this js file in your xul file. Next, create an File object: + + var file = new File("/path/file.ext"); + + To see if the file exists, call the exists() member. This is a good check before going into some + deep code to try and extract information from a non-existant file. + + To open a file for reading<"r">, writing<"w"> or appending<"a">, + just call: + + file.open("w"); + + where in this case you will be creating a new file called '/path/file.ext', with a mode of "w" + which means you want to write a new file. + + If you want to read from a file, just call: + + file.open("r"); + var theFilesContents = file.read(); + + The file contents will be returned to the caller so you can do something usefull with it. + + file.close(); + + Calling 'close()' destroys any created objects. If you forget to use file.close() no probs + all objects are discarded anyway. + + Warning: these API's are not for religious types + +************/ + +/****************** Globals **********************/ + +const JSLIB_FILE = "file.js"; + +const JSFILE_LOCAL_CID = "@mozilla.org/file/local;1"; +const JSFILE_F_CHANNEL_CID = "@mozilla.org/network/local-file-channel;1"; +const JSFILE_I_STREAM_CID = "@mozilla.org/scriptableinputstream;1"; + +const JSFILE_I_LOCAL_FILE = "nsILocalFile"; +const JSFILE_I_FILE_CHANNEL = "nsIFileChannel"; +const JSFILE_I_SCRIPTABLE_IN_STREAM = "nsIScriptableInputStream"; + +const JSFILE_INIT_W_PATH = "initWithPath"; + +const JSFILE_READ = 0x01; // 1 +const JSFILE_WRITE = 0x08; // 8 +const JSFILE_APPEND = 0x10; // 16 + +const JSFILE_READ_MODE = "r"; +const JSFILE_WRITE_MODE = "w"; +const JSFILE_APPEND_MODE = "a"; + +const JSFILE_DELETE = "delete"; + +const JSFILE_FILETYPE = 0x00; // 0 + +const JSFILE_CHUNK = 1024; // buffer for readline => set to 1k + +const JSFILE_OK = true; + +const JSFILE_FilePath = new Components.Constructor( JSFILE_LOCAL_CID, JSFILE_I_LOCAL_FILE, JSFILE_INIT_W_PATH); +const JSFILE_FileChannel = new Components.Constructor( JSFILE_F_CHANNEL_CID, JSFILE_I_FILE_CHANNEL ); +const JSFILE_InputStream = new Components.Constructor( JSFILE_I_STREAM_CID, JSFILE_I_SCRIPTABLE_IN_STREAM ); + +/****************** Globals **********************/ + + +/****************** File Object Class *********************/ + +function File(aPath) { + if(aPath) + this.mPath= aPath; +} // constructor + +File.prototype = { + + mPath : null, + mode : null, + fileInst : null, + fileChannel : null, + inputStream : null, + lineBuffer : null, + +/********************* OPEN *****************************/ +open : function(aSetMode) +{ + + if(!this.mPath) + { + dump(JSLIB_FILE+":open:ERROR: Missing member path argument\nNS_ERROR_NUMBER: "); + return Components.results.NS_ERROR_NOT_INITIALIZED; + } + + this.close(); + if(!aSetMode) + aSetMode=JSFILE_READ_MODE; + + try { this.fileInst = new JSFILE_FilePath(this.mPath); } + + catch (e) + { + dump(JSLIB_FILE+":open:ERROR: UNEXPECTED"+e.name+" "+e.message+"\nNS_ERROR_NUMBER: "); + return Components.results.NS_ERROR_UNEXPECTED; + } + +var fileExists = this.exists(); + + if(fileExists) { + if(this.fileInst.isDirectory()) + { + dump(JSLIB_FILE+":open:ERROR: Can't open directory "+this.mPath+" as a file!\nNS_ERROR_NUMBER: "); + return Components.results.NS_ERROR_FAILURE; + } + } + + var retval; + switch(aSetMode) + { + case JSFILE_WRITE_MODE: + { + if(fileExists) + { + try + { + this.fileInst[JSFILE_DELETE](false); + fileExists=false; + } + + catch(e) + { + dump(JSLIB_FILE+":open:ERROR: Failed to delete file "+this.mPath+"\nNS_ERROR_NUMBER: "); + this.close(); + return Components.results.NS_ERROR_FAILURE; + } + } + + if (!fileExists) + { + try + { + this.fileInst.create(JSFILE_FILETYPE, 0644); + fileExists=true; + } + + catch(e) + { + dump(JSLIB_FILE+":open:ERROR: Failed to create file "+this.mPath+"\nNS_ERROR_NUMBER: "); + this.close(); + return Components.results.NS_ERROR_FAILURE; + } + } + + this.mode=JSFILE_WRITE; + retval=JSFILE_OK; + break; + } + + case JSFILE_APPEND_MODE: + { + if(!fileExists) + { + try + { + this.fileInst.create(JSFILE_FILETYPE, 0644); + fileExists=true; + } + + catch(e) + { + dump(JSLIB_FILE+":open:ERROR: Failed to create file "+this.mPath+"\nNS_ERROR_NUMBER: "); + this.close(); + return Components.results.NS_ERROR_FAILURE; + } + } + + this.mode=JSFILE_APPEND; + retval=JSFILE_OK; + break; + } + + case JSFILE_READ_MODE: + { + if(!fileExists) + { + dump(JSLIB_FILE+"open:ERROR: "+this.mPath+" doesn't exist!\nNS_ERROR_NUMBER: "); + return Components.results.NS_ERROR_FAILURE + } + + try { + this.lineBuffer = new Array(); + this.fileChannel = new JSFILE_FileChannel(); + this.inputStream = new JSFILE_InputStream(); + + try { var perm = this.fileInst.permissions; } + + catch(e){ perm=null; } + + this.fileChannel.init(this.fileInst, JSFILE_READ, perm); + this.inputStream.init(this.fileChannel.openInputStream()); + retval=JSFILE_OK; + } + + catch (e) + { + dump(JSLIB_FILE+":open:ERROR: reading... "+e.name+" "+e.message+"\nNS_ERROR_NUMBER: "); + return Components.results.NS_ERROR_FAILURE; + } + + break; + } + + default: + dump(JSLIB_FILE+":open:WARNING: \""+setMode+"\" is an Invalid file mode\nNS_ERROR_NUMBER: "); + return Components.results.NS_ERROR_INVALID_ARG; + } + + return retval; +}, + +/********************* EXISTS ***************************/ +exists : function () +{ + var retval = null; + + try + { + var file = new JSFILE_FilePath(this.mPath); + retval=file.exists(); + } + + catch(e) + { + dump(JSLIB_FILE+":exists:ERROR: "+e.name+"\n"+e.message+"\nNS_ERROR_NUMBER: "); + return Components.results.NS_ERROR_UNEXPECTED; + } + + return retval; +}, + +/********************* WRITE ****************************/ +write : function(aBuffer, aPerms) +{ + if(!this.fileInst) + { + dump(JSLIB_FILE+":write:ERROR: Please open a file handle first\n NS_ERROR_NUMBER:"); + return Components.results.NS_ERROR_NOT_INITIALIZED; + } + + if(!aBuffer) + throw(JSLIB_FILE+":write:ERROR: must have a buffer to write!\n"); + + if(this.mode == JSFILE_READ) + throw(JSLIB_FILE+":write:ERROR: not in write or append mode!\n"); + + var buffSize = aBuffer.length; + + try + { + if(!this.fileChannel) + this.fileChannel = new JSFILE_FileChannel(); + + if(aPerms) + { + var checkPerms = this.validatePermissions(aPerms); + + if(!checkPerms) + { + dump(JSLIB_FILE+":write:ERROR: invalid permissions set: "+aPerms+"\nNS_ERROR_NUMBER: "); + return Components.results.NS_ERROR_INVALID_ARG + } + } + + if(!aPerms) + aPerms=0644; + + this.fileChannel.init(this.fileInst, this.mode, aPerms); + try + { + this.fileInst.permissions=aPerms; + } + + catch(e){ } + + var outStream = this.fileChannel.openOutputStream(); + + outStream.write(aBuffer, buffSize); + outStream.flush(); + outStream.close(); + } + + catch (e) + { + dump(JSLIB_FILE+":write:ERROR: "+e.name+"\n"+e.message+"\nNS_ERROR_NUMBER: "); + return Components.results.NS_ERROR_UNEXPECTED; + } + + return JSFILE_OK; +}, + +/********************* READ *****************************/ +read : function() +{ + var retval = null; + + try + { + if(!this.fileInst || !this.inputStream) + { + dump(JSLIB_FILE+":read:ERROR: Please open a valid file handle for reading\nNS_ERROR_NUMBER: "); + return Components.results.NS_ERROR_NOT_INITIALIZED; + } + + retval = this.inputStream.read(this.fileInst.fileSize); + this.inputStream.close(); + } + + catch (e) + { + dump(JSLIB_FILE+":read:ERROR: "+e.name+"\n"+e.message+"\nNS_ERROR_NUMBER: "); + return Components.results.NS_ERROR_FAILURE; + } + + return retval; +}, + +eof : function() +{ + if(!this.fileInst || !this.inputStream) + { + dump(JSLIB_FILE+":readline:ERROR: Please open a valid file handle for reading\nNS_ERROR_NUMBER: "); + return Components.results.NS_ERROR_NOT_INITIALIZED; + } + + if((this.lineBuffer.length > 0) || (this.inputStream.available() > 0)) + return false; + + else + return JSFILE_OK; + +}, + +/********************* READLINE *****************************/ +readline : function() +{ + var retval = null; + var buf = null; + + try + { + if(!this.fileInst || !this.inputStream) + { + dump(JSLIB_FILE+":readline:ERROR: Please open a valid file handle for reading\nNS_ERROR_NUMBER: "); + return Components.results.NS_ERROR_NOT_INITIALIZED; + } + + if(this.lineBuffer.length < 2) { + buf = this.inputStream.read(JSFILE_CHUNK); + if(buf) { + var tmp = null; + if(this.lineBuffer.length == 1) { + tmp = this.lineBuffer.shift(); + buf = tmp+buf; + } + this.lineBuffer = buf.split(/[\n\r]/); + } + } + retval = this.lineBuffer.shift(); + } + + catch (e) + { + dump(JSLIB_FILE+":readline:ERROR: "+e.name+" "+e.message+"\nNS_ERROR_NUMBER: "); + throw(e); + } + + return retval; +}, + +/********************* PATH *****************************/ +path : function () { return this.mPath; }, +/********************* PATH *****************************/ + +/********************* LEAF *****************************/ +leaf : function () +{ + if(!this.mPath) + { + dump(JSLIB_FILE+":leaf:ERROR: Missing path argument\nNS_ERROR_NUMBER: "); + return Components.results.NS_ERROR_INVALID_ARG; + } + + if(!this.exists()) + { + dump(JSLIB_FILE+":leaf:ERROR: File doesn't exist\nNS_ERROR_NUMBER: "); + return Components.results.NS_ERROR_FAILURE; + } + + var retval; + try + { + var fileInst = new JSFILE_FilePath(this.mPath); + retval=fileInst.leafName; + } + + catch(e) + { + dump(JSLIB_FILE+":leaf:ERROR: "+e.name+"\n"+e.message+"\nNS_ERROR_NUMBER: "); + return Components.results.NS_ERROR_FAILURE; + } + + return retval; +}, + +/********************* VALIDATE PERMISSIONS *************/ +validatePermissions : function(aNum) +{ + if ( parseInt(aNum.toString(10).length) < 3 ) + return false; + + return JSFILE_OK; +}, + +/********************* PERMISSIONS **********************/ +permissions : function () +{ + if(!this.mPath) + { + dump(JSLIB_FILE+":permissions:ERROR: Missing path argument\nNS_ERROR_NUMBER: "); + return Components.results.NS_ERROR_XPC_NOT_ENOUGH_ARGS; + } + + if(!this.exists()) + { + dump(JSLIB_FILE+":permissions:ERROR: File doesn't exist\nNS_ERROR_NUMBER: "); + return Components.results.NS_ERROR_FAILURE; + } + + var retval; + try + { + var fileInst = new JSFILE_FilePath(this.mPath); + retval=fileInst.permissions.toString(8); + } + + catch(e) + { + dump(JSLIB_FILE+":permissions:ERROR: "+e.name+"\n"+e.message+"\nNS_ERROR_NUMBER: "); + return Components.results.NS_ERROR_UNEXPECTED; + } + + return retval; +}, + +/********************* MODIFIED *************************/ +dateModified : function () +{ + if(!this.mPath) + { + dump(JSLIB_FILE+":dateModified:ERROR: Missing path argument\nNS_ERROR_NUMBER: "); + return Components.results.NS_ERROR_XPC_NOT_ENOUGH_ARGS; + } + + if(!this.exists()) + { + dump(JSLIB_FILE+":dateModified:ERROR: File doesn't exist\nNS_ERROR_NUMBER: "); + return Components.results.NS_ERROR_FAILURE; + } + + var retval; + try + { + var fileInst = new JSFILE_FilePath(this.mPath); + var date = new Date(fileInst.lastModificationDate).toLocaleString(); + retval=date; + } + + catch(e) + { + dump(JSLIB_FILE+":dateModified:ERROR: "+e.name+"\n"+e.message+"\nNS_ERROR_NUMBER: "); + return Components.results.NS_ERROR_UNEXPECTED; + } + + return retval; +}, + +/********************* SIZE *****************************/ +size : function () +{ + if(!this.mPath) + { + dump(JSLIB_FILE+":size:ERROR: Missing member path argument\nNS_ERROR_NUMBER: "); + return Components.results.NS_ERROR_NOT_INITIALIZED; + } + + if(!this.exists()) + { + dump(JSLIB_FILE+":size:ERROR: File doesn't exist\nNS_ERROR_NUMBER: "); + return Components.results.NS_ERROR_FAILURE; + } + + var retval; + try + { + var fileInst = new JSFILE_FilePath(this.mPath); + retval = fileInst.fileSize; + } + + catch(e) + { + dump(JSLIB_FILE+":size:ERROR: "+e.name+"\n"+e.message+"\nNS_ERROR_NUMBER: "); + return Components.results.NS_ERROR_UNEXPECTED; + } + + return retval; +}, + +/********************* EXTENSION ************************/ +extension : function () +{ + if(!this.mPath) + { + dump(JSLIB_FILE+":extension:ERROR: Missing member path argument\nNS_ERROR_NUMBER: "); + return Components.results.NS_ERROR_NOT_INITIALIZED; + } + + if(!this.exists()) + { + dump(JSLIB_FILE+":extension:ERROR: File doesn't exist\nNS_ERROR_NUMBER: "); + return Components.results.NS_ERROR_FAILURE; + } + + var retval; + try + { + var fileInst = new JSFILE_FilePath(this.mPath); + var leafName = fileInst.leafName; + var dotIndex = leafName.lastIndexOf('.'); + retval=(dotIndex >= 0) ? leafName.substring(dotIndex+1) : ""; + } + + catch(e) + { + dump(JSLIB_FILE+":extension:ERROR: "+e.name+"\n"+e.message+"\nNS_ERROR_NUMBER: "); + return Components.results.NS_ERROR_UNEXPECTED; + } + + return retval; +}, + +/********************* DIRPATH **************************/ +dirPath : function () +{ + if(!this.mPath) + { + dump(JSLIB_FILE+":dirPath:ERROR: Missing member path argument\nNS_ERROR_NUMBER: "); + return Components.results.NS_ERROR_NOT_INITIALIZED; + } + + var retval; + try + { + var fileInst = new JSFILE_FilePath(this.mPath); + + if(fileInst.isFile()) + retval=fileInst.path.replace(this.leaf(), ""); + + if(fileInst.isDirectory()) + retval=fileInst.path; + } + catch (e) + { + dump(JSLIB_FILE+":dirPath:ERROR: "+e.name+"\n"+e.message+"\nNS_ERROR_NUMBER: "); + return Components.results.NS_ERROR_UNEXPECTED; + } + + return retval; +}, + +/********************* nsIFILE **************************/ +nsIFile : function () +{ + if(!this.mPath) + { + dump(JSLIB_FILE+":nsIFile:ERROR: Missing member path argument\nNS_ERROR_NUMBER: "); + return Components.results.NS_ERROR_NOT_INITIALIZED; + } + + var retval; + try + { + retval = new JSFILE_FilePath(this.mPath); + } + + catch (e) + { + dump(JSLIB_FILE+":nsIFile:ERROR: "+e.name+"\n"+e.message+"\nNS_ERROR_NUMBER: "); + return Components.results.NS_ERROR_UNEXPECTED; + } + + return retval; +}, + +/********************* HELP *****************************/ +help : function() +{ + var help = + + "\n\nFunction List:\n" + + "\n" + + " open(aMode);\n" + + " exists();\n" + + " read();\n" + + " readline(aDone);\n" + + " write(aContents, aPermissions);\n" + + " leaf();\n" + + " permissions();\n" + + " dateModified();\n" + + " size();\n" + + " extension();\n" + + " dirPath();\n" + + " nsIFile();\n" + + " help();\n"; + + dump(help+"\n"); + + return ""; +}, + +/********************* CLOSE ****************************/ +close : function() +{ + /***************** Destroy Instances *********************/ + if(this.fileInst) delete this.fileInst; + if(this.fileChannel) delete this.fileChannel; + if(this.inputStream) delete this.inputStream; + if(this.mode) this.mode=null; + /***************** Destroy Instances *********************/ + + return JSFILE_OK; +} +}; + diff --git a/mozilla/extensions/inspector/resources/content/jsutil/xpcom/XPCU.js b/mozilla/extensions/inspector/resources/content/jsutil/xpcom/XPCU.js new file mode 100644 index 00000000000..ec097b6ffa6 --- /dev/null +++ b/mozilla/extensions/inspector/resources/content/jsutil/xpcom/XPCU.js @@ -0,0 +1,31 @@ + +var XPCU = +{ + getService: function(aURL, aInterface) + { + try { + return Components.classes[aURL].getService(Components.interfaces[aInterface]); + } catch (ex) { + dump("Error getting service: " + aURL + ", " + aInterface + "\n" + ex); + } + }, + + createInstance: function (aURL, aInterface) + { + try { + return Components.classes[aURL].createInstance(Components.interfaces[aInterface]); + } catch (ex) { + dump("Error creating instance: " + aURL + ", " + aInterface + "\n" + ex); + } + }, + + QI: function(aEl, aIName) + { + try { + return aEl.QueryInterface(Components.interfaces[aIName]); + } catch (ex) { + dump("Error in QI: " + aIName + "\n" + ex); + } + } + +}; \ No newline at end of file diff --git a/mozilla/extensions/inspector/resources/content/jsutil/xul/DNDUtils.js b/mozilla/extensions/inspector/resources/content/jsutil/xul/DNDUtils.js new file mode 100644 index 00000000000..7d5e5cdfdf9 --- /dev/null +++ b/mozilla/extensions/inspector/resources/content/jsutil/xul/DNDUtils.js @@ -0,0 +1,79 @@ +/*************************************************************** +* DNDUtils ------------------------------------------------- +* Utility functions for common drag and drop tasks. +* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +* REQUIRED IMPORTS: +****************************************************************/ + +//////////// global variables ///////////////////// + +var app; + +//////////// global constants //////////////////// + +//////////////////////////////////////////////////////////////////////////// +//// class DNDUtils + +var DNDUtils = +{ + invokeSession: function(aTarget, aTypes, aValues) + { + var transData, trans, supports; + var transArray = XPCU.createInstance("@mozilla.org/supports-array;1", "nsISupportsArray"); + for (var i = 0; i < aTypes.length; ++i) { + transData = this.createTransferableData(aValues[i]); + trans = XPCU.createInstance("@mozilla.org/widget/transferable;1", "nsITransferable"); + trans.addDataFlavor(aTypes[i]); + trans.setTransferData (aTypes[i], transData.data, transData.size); + supports = trans.QueryInterface(Components.interfaces.nsISupports); + transArray.AppendElement(supports); + } + + var nsIDragService = Components.interfaces.nsIDragService; + var dragService = XPCU.getService("@mozilla.org/widget/dragservice;1", "nsIDragService"); + dragService.invokeDragSession(aTarget, transArray, null, nsIDragService.DRAGDROP_ACTION_MOVE); + }, + + createTransferableData: function(aValue) + { + var obj = {}; + if (typeof(aValue) == "string") { + obj.data = XPCU.createInstance("@mozilla.org/supports-wstring;1", "nsISupportsWString"); + obj.data.data = aValue; + obj.size = aValue.length*2; + } else if (false) { + // TODO: create data for other primitive types + } + + return obj; + }, + + checkCanDrop: function(aType) + { + var dragService = XPCU.getService("@mozilla.org/widget/dragservice;1", "nsIDragService"); + var dragSession = dragService.getCurrentSession(); + + var gotFlavor = false; + for (var i = 0; i < arguments.length; ++i) + gotFlavor |= dragSession.isDataFlavorSupported(arguments[i]); + + dragSession.canDrop = gotFlavor; + return gotFlavor; + }, + + getData: function(aType, aIndex) + { + var dragService = XPCU.getService("@mozilla.org/widget/dragservice;1", "nsIDragService"); + var dragSession = dragService.getCurrentSession(); + + var trans = XPCU.createInstance("@mozilla.org/widget/transferable;1", "nsITransferable"); + trans.addDataFlavor(aType); + + dragSession.getData(trans, aIndex); + var data = new Object(); + trans.getAnyTransferData ({}, data, {}); + return data.value; + } + +}; + diff --git a/mozilla/extensions/inspector/resources/content/jsutil/xul/FrameExchange.js b/mozilla/extensions/inspector/resources/content/jsutil/xul/FrameExchange.js new file mode 100644 index 00000000000..48914338eac --- /dev/null +++ b/mozilla/extensions/inspector/resources/content/jsutil/xul/FrameExchange.js @@ -0,0 +1,36 @@ +/*************************************************************** +* FrameExchange ---------------------------------------------- +* Utility for passing specific data to a document loaded +* through an iframe +* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +* REQUIRED IMPORTS: +****************************************************************/ + +//////////// implementation //////////////////// + +var FrameExchange = { + mData: {}, + mCount: 0, + + loadURL: function(aFrame, aURL, aData) + { + var id = "entry-"+this.mCount; + this.mCount++; + + this.mData[id] = aData; + + var url = aURL + "?" + id; + aFrame.setAttribute("src", url); + }, + + receiveData: function(aWindow) + { + var id = aWindow.location.search.substr(1); + var data = this.mData[id]; + this.mData[id] = null; + + return data; + } +}; + + diff --git a/mozilla/extensions/inspector/resources/content/jsutil/xul/inFormManager.js b/mozilla/extensions/inspector/resources/content/jsutil/xul/inFormManager.js new file mode 100644 index 00000000000..5c8279b6cee --- /dev/null +++ b/mozilla/extensions/inspector/resources/content/jsutil/xul/inFormManager.js @@ -0,0 +1,107 @@ +/*************************************************************** +* inFormManager ------------------------------------------------- +* Manages the reading and writing of forms via simple maps of +* attribute/value pairs. A "form" is simply a XUL window which +* contains "form widgets" such as textfields and menulists. +* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +* REQUIRED IMPORTS: +****************************************************************/ + +//////////////////////////////////////////////////////////////////////////// +//// class inFormManager + +var inFormManager = +{ + // Object + readWindow: function(aWindow, aIds) + { + var el, fn; + var doc = aWindow.document; + var map = {}; + for (var i = 0; i < aIds.length; i++) { + el = doc.getElementById(aIds[i]); + if (el) { + this.persistIf(doc, el); + fn = this["read_"+el.localName]; + if (fn) + map[aIds[i]] = fn(el); + } + } + + return map; + }, + + // void + writeWindow: function(aWindow, aMap) + { + var el, fn; + var doc = aWindow.document; + for (var i = 0; i < aIds.length; i++) { + el = doc.getElementById(aIds[i]); + if (el) { + fn = this["write_"+el.localName]; + if (fn) + fn(el, aMap[aIds[i]]); + } + } + }, + + persistIf: function(aDoc, aEl) + { + if (aEl.getAttribute("persist") == "true" && aEl.hasAttribute("id")) { + aEl.setAttribute("value", aEl.value); + aDoc.persist(aEl.getAttribute("id"), "value"); + } + }, + + read_textfield: function(aEl) + { + return aEl.value; + }, + + read_menulist: function(aEl) + { + return aEl.getAttribute("data"); + }, + + read_checkbox: function(aEl) + { + return aEl.getAttribute("checked") == "true"; + }, + + read_radiogroup: function(aEl) + { + return aEl.getAttribute("data"); + }, + + read_colorpicker: function(aEl) + { + return aEl.getAttribute("color"); + }, + + write_textfield: function(aEl, aValue) + { + aEl.setAttribute("value", aValue); + }, + + write_menulist: function(aEl, aValue) + { + aEl.setAttribute("data", aValue); + }, + + write_checkbox: function(aEl, aValue) + { + aEl.setAttribute("checked", aValue); + }, + + write_radiogroup: function(aEl, aValue) + { + aEl.setAttribute("data", aValue); + }, + + write_colorpicker: function(aEl, aValue) + { + aEl.color = aValue; + } +}; + diff --git a/mozilla/extensions/inspector/resources/content/jsutil/xul/inTreeTableBuilder.js b/mozilla/extensions/inspector/resources/content/jsutil/xul/inTreeTableBuilder.js new file mode 100644 index 00000000000..18665992816 --- /dev/null +++ b/mozilla/extensions/inspector/resources/content/jsutil/xul/inTreeTableBuilder.js @@ -0,0 +1,659 @@ +/*************************************************************** +* inTreeTableBuilder ------------------------------------------------- +* Automatically builds up a tree so that it will display a tabular +* set of data with titled columns and optionally an icon for each row. +* The tree that is supplied must begin with no children other than +* a single template element. The template is required. +* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +* REQUIRED IMPORTS: +* chrome://inspector/content/jsutil/xul/DNDUtils.js +****************************************************************/ + +//////////// global variables ///////////////////// + +var inTreeTableBuilderPartCount = 0; + +//////////// global constants //////////////////// + +//////////////////////////////////////////////////////////////////////////// +//// class inTreeTableBuilder + +function inTreeTableBuilder(aTree, aNameSpace, aArcName) +{ + this.tree = aTree; + this.nameSpace = aNameSpace; + this.arcName = aArcName; + + this.mColumns = []; + this.mExtras = []; +} + +inTreeTableBuilder.prototype = +{ + mTree: null, + // datasource stuff + mNameSpace: null, + mArcName: null, + mIsRefContainer: true, + mIsContainer: false, + + // table structure stuff + mIsIconic: false, + mColumns: null, + mSplitters: true, + mItemFields: null, + mItemAttrs: null, + mAllowDND: false, + mLastDragCol: null, + mLastDragColWhere: null, + + //////////////////////////////////////////////////////////////////////////// + //// properties + + // the xul tree node we will construct + get tree() { return this.mTree }, + set tree(aVal) { this.mTree = aVal; aVal._treeBuilder = this }, + + // the namespace to use for all fields + get nameSpace() { return this.mNameSpace }, + set nameSpace(aVal) { this.mNameSpace = aVal }, + + // the name of the arc to the container + get arcName() { return this.mArcName }, + set arcName(aVal) { this.mArcName = aVal }, + + // is the datasource ref an arc to a container, or a container itself + get isRefContainer() { return this.mIsRefContainer }, + set isRefContainer(aVal) { this.mIsRefContainer = aVal }, + + // is each row a potential container? + get isContainer() { return this.mIsContainer }, + set isContainer(aVal) { this.mIsContainer = aVal }, + + // place an icon before the first column of each row + get isIconic() { return this.mIsIconic }, + set isIconic(aVal) { this.mIsIconic = aVal }, + + // put splitters between the columns? + get useSplitters() { return this.mSplitters }, + set useSplitters(aVal) { this.mSplitters = aVal }, + + // extra attributes to set on the treeitem + get itemAttributes() { return this.mItemAttrs }, + set itemAttributes(aVal) { this.mItemAttrs = aVal }, + + // extra data fields to set on the treeitem + get itemFields() { return this.mItemFields }, + set itemFields(aVal) { this.mItemFields = aVal }, + + // extra data fields to set on the treeitem + get allowDragColumns() { return this.mAllowDND }, + set allowDragColumns(aVal) { this.mAllowDND = aVal }, + + //////////////////////////////////////////////////////////////////////////// + //// event handlers + + get onColumnAdd() { return this.mOnColumnAdd }, + set onColumnAdd(aFn) { this.mOnColumnAdd = aFn }, + + get onColumnRemove() { return this.mOnColumnRemove }, + set onColumnRemove(aFn) { this.mOnColumnRemove = aFn }, + + //////////////////////////////////////////////////////////////////////////// + //// initialization + + initialize: function() + { + this.initColumns(); + this.initTemplate(); + }, + + initColumns: function() + { + // initialize the treehead + var treehead = document.createElementNS(kXULNSURI, "treehead"); + var treerow = document.createElementNS(kXULNSURI, "treerow"); + this.mTreeHeadRow = treerow; + + treehead.appendChild(treerow); + this.mTree.appendChild(treehead); + + // initialize the treecolgroup + var colgroup = document.createElementNS(kXULNSURI, "treecolgroup"); + this.mColGroup = colgroup; + this.mTree.appendChild(colgroup); + + this.initDND(); + }, + + initTemplate: function() + { + var template = this.mTree.getElementsByTagNameNS(kXULNSURI, "template")[0]; + this.mTemplate = template; + this.clearChildren(template); + + var rule = document.createElementNS(kXULNSURI, "rule"); + template.appendChild(rule); + this.mRule = rule; + + this.createDefaultConditions(); + + var bindings = document.createElementNS(kXULNSURI, "bindings"); + rule.appendChild(bindings); + this.mBindings = bindings; + + this.createDefaultAction(); + }, + + createDefaultConditions: function() + { + var conditions = document.createElementNS(kXULNSURI, "conditions"); + this.mRule.appendChild(conditions); + + var content = document.createElementNS(kXULNSURI, "content"); + content.setAttribute("uri", "?uri"); + conditions.appendChild(content); + + var triple = this.createTriple("?uri", this.mNameSpace+this.mArcName, + this.mIsRefContainer ? "?table" : "?item"); + conditions.appendChild(triple); + + if (this.mIsRefContainer) { + var member = this.createMember("?table", "?item"); + conditions.appendChild(member); + } + }, + + createDefaultAction: function() + { + var action = document.createElementNS(kXULNSURI, "action"); + this.mRule.appendChild(action); + + var treechildren = this.createTemplatePart("treechildren"); + action.appendChild(treechildren); + treechildren.setAttribute("flex", "1"); + var treeitem = this.createTemplatePart("treeitem"); + treechildren.appendChild(treeitem); + treeitem.setAttribute("uri", "?item"); + this.mTreeItem = treeitem; + var treerow = this.createTemplatePart("treerow"); + treeitem.appendChild(treerow); + this.mTreeRow = treerow; + + // assign the item attributes + if (this.mItemAttrs) + for (key in this.mItemAttrs) + treeitem.setAttribute(key, this.mItemAttrs[key]); + }, + + createDefaultBindings: function() + { + // assign the item fields + var binding; + if (this.mItemFields) { + for (key in this.mItemFields) { + binding = this.createBinding(this.mItemFields[key]); + this.mBindings.appendChild(binding); + this.mTreeItem.setAttribute(key, "?" + this.mItemFields[key]); + } + } + }, + + createTriple: function(aSubject, aPredicate, aObject) + { + var triple = document.createElementNS(kXULNSURI, "triple"); + triple.setAttribute("subject", aSubject); + triple.setAttribute("predicate", aPredicate); + triple.setAttribute("object", aObject); + + return triple; + }, + + createMember: function(aContainer, aChild) + { + var member = document.createElementNS(kXULNSURI, "member"); + member.setAttribute("container", aContainer); + member.setAttribute("child", aChild); + + return member; + }, + + reset: function() + { + this.mColumns = []; + this.mIsIconic = false; + + this.resetTree(); + }, + + resetTree: function() + { + this.clearChildren(this.mColGroup); + this.clearChildren(this.mTreeHeadRow); + this.clearChildren(this.mBindings); + this.clearChildren(this.mTreeRow); + this.createDefaultBindings(); + }, + + clearChildren: function(aEl) + { + while (aEl.childNodes.length) + aEl.removeChild(aEl.lastChild); + }, + + //////////////////////////////////////////////////////////////////////////// + //// column drag and drop + + initDND: function() + { + if (this.mAllowDND) { + // addEventListener doesn't work for dnd events, apparently... so we use the attributes + this.addDNDListener(this.mTree, "ondragenter"); + this.addDNDListener(this.mTree, "ondragover"); + this.addDNDListener(this.mTree, "ondragexit"); + this.addDNDListener(this.mTree, "ondraggesture"); + this.addDNDListener(this.mTree, "ondragdrop"); + } + }, + + onDragEnter: function(aEvent) + { + }, + + onDragOver: function(aEvent) + { + if (!DNDUtils.checkCanDrop("TreeTableBuilder/column-add")) + return; + + var idx = this.getColumnIndexFromX(aEvent.clientX, 50); + this.mColumnInsertIndex = idx; + var kids = this.mColGroup.childNodes; + var col = this.getColumnAt(idx); + if (idx == -1) + this.markColumnInsert(col, "after", idx); + else + this.markColumnInsert(col, "before", idx); + }, + + onDragExit: function(aEvent) + { + }, + + onDragDrop: function(aEvent) + { + this.markColumnInsert(null); + var dragService = XPCU.getService("@mozilla.org/widget/dragservice;1", "nsIDragService"); + var dragSession = dragService.getCurrentSession(); + + if (!dragSession.isDataFlavorSupported("TreeTableBuilder/column-add")) + return false; + + var trans = XPCU.createInstance("@mozilla.org/widget/transferable;1", "nsITransferable"); + trans.addDataFlavor("TreeTableBuilder/column-add"); + + dragSession.getData(trans, 0); + var data = new Object(); + trans.getAnyTransferData ({}, data, {}); + + var string = XPCU.QI(data.value, "nsISupportsWString"); + + this.insertColumn(this.mColumnInsertIndex, + { + name: string.data, + title: string.data, + flex: 1 + }); + this.build(); + // if we rebuildContent during this thread, it will crash in the dnd service + setTimeout(function(aTreeBuilder) { aTreeBuilder.buildContent() }, 1, this); + + // bug 56270 - dragSession.sourceDocument is null -- + // causes me to code this very temporary, very nasty hack + // to tell columnsDialog.js about the drop + if (this.mTree.onClientDrop) { + this.mTree.onClientDrop(); + } + }, + + markColumnInsert: function (aColumn, aWhere, aIdx) + { + var col = this.mLastDragCol; + var lastWhere = this.mLastDragColWhere; + if (col) + col.setAttribute("dnd-insert-"+lastWhere, "false"); + + if (aWhere != "before" && aWhere != "after") { + this.mLastDragCol = null; + this.mLastDragColWhere = null; + return; + } + + col = aColumn; + if (col) { + this.mLastDragCol = col; + this.mLastDragColWhere = aWhere; + col.setAttribute("dnd-insert-"+aWhere, "true"); + } + }, + + getColumnIndexFromX: function(aX, aThresh) + { + var colgroup = this.mColGroup; + var width = 0, cw; + var col; + var pct = aThresh/100; + for (var i = 0; i < this.columnCount; ++i) { + col = this.getColumnAt(i); + cw = col.boxObject.width; + width += cw; + if (width-(cw*pct) > aX) + return i; + } + + return -1; + }, + + getColumnIndexFromHeader: function(aHeader) + { + var headers = this.mTreeHeadRow.childNodes; + for (var i = 0; i < headers.length; ++i) { + if (headers[i] == aHeader) + return i; + } + return -1; + }, + + //// for drag-n-drop removal/arrangement of columns + + onDragGesture: function(aEvent) + { + var target = aEvent.target; + if (target.parentNode == this.mTreeHeadRow) { + var column = target.getAttribute("value"); + + var idx = this.getColumnIndexFromHeader(target); + if (idx == -1) return; + this.mColumnDragging = idx; + + DNDUtils.invokeSession(target, ["TreeTableBuilder/column-remove"], [column]); + } + }, + + addColumnDropTarget: function(aBox) + { + aBox._treeBuilderDropTarget = this; + this.addDNDListener(aBox, "ondragover", "Target"); + this.addDNDListener(aBox, "ondragdrop", "Target"); + }, + + removeColumnDropTarget: function(aBox) + { + aBox._treeBuilderDropTarget = this; + this.removeDNDListener(aBox, "ondragover", "Target"); + this.removeDNDListener(aBox, "ondragdrop", "Target"); + }, + + onDragOverTarget: function(aBox, aEvent) + { + DNDUtils.checkCanDrop("TreeTableBuilder/column-remove"); + }, + + onDragDropTarget: function(aBox, aEvent) + { + this.removeColumn(this.mColumnDragging); + this.build(); + // if we rebuildContent during this thread, it will crash in the dnd service + setTimeout(function(aTreeBuilder) { aTreeBuilder.buildContent() }, 1, this); + }, + + // these are horrible hacks to compensate for the lack of true multiple + // listener support for the DND events + + addDNDListener: function(aBox, aType, aModifier) + { + var js = "inTreeTableBuilder_"+aType+(aModifier?"_"+aModifier:"")+"(this, event);"; + + var attr = aBox.getAttribute(aType); + attr = attr ? attr : ""; + aBox.setAttribute(aType, attr + js); + }, + + removeDNDListener: function(aBox, aType, aModifier) + { + var js = "inTreeTableBuilder_"+aType+(aModifier?"_"+aModifier:"")+"(this, event);"; + + var attr = aBox.getAttribute(aType); + var idx = attr.indexOf(js); + if (idx != -1) + attr = attr.substr(0,idx) + attr.substr(idx+1); + aBox.setAttribute(aType, attr); + }, + + //////////////////////////////////////////////////////////////////////////// + //// column properties + + addColumn: function(aData) + { + this.mColumns.push(aData); + + if (this.mOnColumnAdd) + this.mOnColumnAdd(this.mColumns.length-1) + }, + + insertColumn: function(aIndex, aData) + { + var idx; + if (aIndex == -1) { + this.mColumns.push(aData); + idx = this.mColumns.length-1; + } else { + this.mColumns.splice(aIndex, 0, aData); + idx = aIndex; + } + + if (this.mOnColumnAdd) + this.mOnColumnAdd(idx); + }, + + removeColumn: function(aIndex) + { + this.mColumns.splice(aIndex, 1); + + if (this.mOnColumnRemove) + this.mOnColumnRemove(aIndex); + }, + + getColumnAt: function(aIndex) + { + var idx; + var kids = this.mColGroup.childNodes; + if (aIndex == -1) + idx = kids.length-1; + else { + // step by 2 to skip over splitters, if they are used + var step = this.mSplitters ? 2 : 1; + idx = aIndex*step; + } + return kids[idx] + }, + + get columnCount() { return this.mColumns.length }, + + getColumnName: function(aIndex) { return this.mColumns[aIndex].name }, + setColumnName: function(aIndex, aValue) { this.mColumns[aIndex].name = aValue }, + + getColumnTitle: function(aIndex) { return this.mColumns[aIndex].title }, + setColumnTitle: function(aIndex, aValue) { this.mColumns[aIndex].title = aValue }, + + getColumnClassName: function(aIndex) { return this.mColumns[aIndex].className }, + setColumnClassName: function(aIndex, aValue) { this.mColumns[aIndex].className = aValue }, + + getColumnFlex: function(aIndex) { return this.mColumns[aIndex].flex }, + setColumnFlex: function(aIndex, aValue) { this.mColumns[aIndex].flex = aValue }, + + getExtras: function(aIndex) { return this.mColumns[aIndex].extras }, + setExtras: function(aIndex, aValue) { this.mColumns[aIndex].extras = aExtras }, + + getAttrs: function(aIndex) { return this.mColumns[aIndex].attrs }, + setAttrs: function(aIndex, aValue) { this.mColumns[aIndex].attrs = aExtras }, + + //////////////////////////////////////////////////////////////////////////// + //// template building + + build: function(aBuildContent) + { + try { + this.resetTree(); + this.buildColGroup(); + this.buildTreeHead(); + this.buildTemplate(); + if (aBuildContent) + this.buildContent(); + } catch (ex) { + debug("### ERROR - inTreeTableBuilder::build failed.\n" + ex); + } + + //if ("dumpDOM" in window) + //dumpDOM(this.mTemplate); + + }, + + buildContent: function() + { + this.mTree.builder.rebuild(); + }, + + buildColGroup: function() + { + var cols = this.mColumns; + var colgroup = this.mColGroup; + var col, val, split; + for (var i = 0; i < cols.length; i++) { + col = document.createElementNS(kXULNSURI, "treecol"); + col.setAttribute("id", "treecol-"+cols[i].name); + col.setAttribute("persist", "width"); + val = cols[i].className; + if (val) + col.setAttribute("class", val); + val = cols[i].flex; + if (val) + col.setAttribute("flex", val); + + colgroup.appendChild(col); + + if (this.mSplitters && i < cols.length-1) { + split = document.createElementNS(kXULNSURI, "splitter"); + split.setAttribute("class", "tree-splitter"); + colgroup.appendChild(split); + } + } + }, + + buildTreeHead: function() + { + var cols = this.mColumns; + var row = this.mTreeHeadRow; + var cell, val; + for (var i = 0; i < cols.length; i++) { + cell = document.createElementNS(kXULNSURI, "treecell"); + cell.setAttribute("class", "treecell-header"); + val = cols[i].title; + if (val) + cell.setAttribute("value", val); + row.appendChild(cell); + } + }, + + buildTemplate: function() + { + var cols = this.mColumns; + var bindings = this.mBindings; + var row = this.mTreeRow; + var cell, binding, val, extras, attrs, key, className; + + if (this.mIsIconic) { + binding = this.createBinding("_icon"); + bindings.appendChild(binding); + } + + for (var i = 0; i < cols.length; ++i) { + val = cols[i].name; + if (!val) + throw "Column data is incomplete - missing name at index " + i + "."; + + cell = this.createTemplatePart("treecell"); + className = ""; + + // build the icon data field + if (i == 0 && this.mIsIconic) { + className += "treecell-iconic "; + cell.setAttribute("src", "?_icon"); + } + + // mark first node as a container, if necessary + if (i == 0 && this.mIsContainer) + className += "treecell-indent"; + + // build the default value data field + binding = this.createBinding(val); + bindings.appendChild(binding); + cell.setAttribute("value", "?" + val); + + cell.setAttribute("class", className); + row.appendChild(cell); + } + }, + + createBinding: function(aName) + { + var binding = document.createElementNS(kXULNSURI, "binding"); + binding.setAttribute("subject", "?item"); + binding.setAttribute("predicate", this.mNameSpace+aName); + binding.setAttribute("object", "?" + aName); + return binding; + }, + + createTemplatePart: function(aTagName) + { + var el = document.createElementNS(kXULNSURI, aTagName); + el.setAttribute("id", "templatePart"+inTreeTableBuilderPartCount); + inTreeTableBuilderPartCount++; + return el; + } + +}; + +function inTreeTableBuilder_ondraggesture(aTree, aEvent) +{ + return aTree._treeBuilder.onDragGesture(aEvent); +} + +function inTreeTableBuilder_ondragenter(aTree, aEvent) +{ + return aTree._treeBuilder.onDragEnter(aEvent); +} + +function inTreeTableBuilder_ondragover(aTree, aEvent) +{ + return aTree._treeBuilder.onDragOver(aEvent); +} + +function inTreeTableBuilder_ondragexit(aTree, aEvent) +{ + return aTree._treeBuilder.onDragExit(aEvent); +} + +function inTreeTableBuilder_ondragdrop(aTree, aEvent) +{ + return aTree._treeBuilder.onDragDrop(aEvent); +} + +function inTreeTableBuilder_ondragover_Target(aBox, aEvent) +{ + return aBox._treeBuilderDropTarget.onDragOverTarget(aBox, aEvent); +} + +function inTreeTableBuilder_ondragdrop_Target(aBox, aEvent) +{ + return aBox._treeBuilderDropTarget.onDragDropTarget(aBox, aEvent); +} diff --git a/mozilla/extensions/inspector/resources/content/makefile.win b/mozilla/extensions/inspector/resources/content/makefile.win new file mode 100644 index 00000000000..9b7d837fdd2 --- /dev/null +++ b/mozilla/extensions/inspector/resources/content/makefile.win @@ -0,0 +1,32 @@ +#!nmake +# +# The contents of this file are subject to the Netscape Public +# License Version 1.1 (the "License"); you may not use this file +# except in compliance with the License. You may obtain a copy of +# the License at http://www.mozilla.org/NPL/ +# +# Software distributed under the License is distributed on an "AS +# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or +# implied. See the License for the specific language governing +# rights and limitations under the License. +# +# The Original Code is mozilla.org code. +# +# The Initial Developer of the Original Code is Netscape +# Communications Corporation. Portions created by Netscape are +# Copyright (C) 1998 Netscape Communications Corporation. All +# Rights Reserved. +# +# Contributor(s): + +DEPTH=..\..\..\.. +include <$(DEPTH)/config/config.mak> + +install:: + $(MAKE_INSTALL) inspector-history.rdf $(DIST)\bin\chrome\inspector + $(MAKE_INSTALL) inspector-prefs.rdf $(DIST)\bin\chrome\inspector + $(MAKE_INSTALL) viewer-registry.rdf $(DIST)\bin\chrome\inspector + $(MAKE_INSTALL) search-registry.rdf $(DIST)\bin\chrome\inspector + $(MAKE_INSTALL) prefs\inspector.js $(DIST)\bin\defaults\pref + +include <$(DEPTH)\config\rules.mak> diff --git a/mozilla/extensions/inspector/resources/content/popupOverlay.xul b/mozilla/extensions/inspector/resources/content/popupOverlay.xul new file mode 100644 index 00000000000..daad8ef29d0 --- /dev/null +++ b/mozilla/extensions/inspector/resources/content/popupOverlay.xul @@ -0,0 +1,67 @@ + + + %dtd1; + %dtd2; +]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/mozilla/extensions/inspector/resources/content/prefs/inspector.js b/mozilla/extensions/inspector/resources/content/prefs/inspector.js new file mode 100644 index 00000000000..ed0aab402fe --- /dev/null +++ b/mozilla/extensions/inspector/resources/content/prefs/inspector.js @@ -0,0 +1,6 @@ +pref("inspector.blink.border-color", "#CC0000"); +pref("inspector.blink.border-width", 2); +pref("inspector.blink.duration", 2); +pref("inspector.blink.on", true); +pref("inspector.blink.speed", 100); +pref("inspector.dom.columns", "localName,@id"); diff --git a/mozilla/extensions/inspector/resources/content/prefs/pref-inspector.xul b/mozilla/extensions/inspector/resources/content/prefs/pref-inspector.xul new file mode 100644 index 00000000000..e4d66f30167 --- /dev/null +++ b/mozilla/extensions/inspector/resources/content/prefs/pref-inspector.xul @@ -0,0 +1,86 @@ + + + + + + + + + + + + + + + + <text value="Element Blinking"/> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/mozilla/extensions/inspector/resources/content/prefs/pref-sidebar.js b/mozilla/extensions/inspector/resources/content/prefs/pref-sidebar.js new file mode 100644 index 00000000000..0f6dd75ab95 --- /dev/null +++ b/mozilla/extensions/inspector/resources/content/prefs/pref-sidebar.js @@ -0,0 +1,127 @@ +/*************************************************************** +* SidebarPrefs ------------------------------------------------- +* The controller for the lovely sidebar prefs panel. +* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +* REQUIRED IMPORTS: +* chrome://inspector/content/jsutil/xpcom/XPCU.js +* chrome://inspector/content/jsutil/rdf/RDFU.js +****************************************************************/ + +//////////// global variables ///////////////////// + +var pref; + +//////////// global constants //////////////////// + +const kDirServiceCID = "@mozilla.org/file/directory_service;1" +const kStandardURLCID = "@mozilla.org/network/standard-url;1" +const kNCURI = "http://home.netscape.com/NC-rdf#"; +const kSidebarPanelId = "UPnls"; // directory services property to find panels.rdf +const kSidebarURNPanelList = "urn:sidebar:current-panel-list"; +const kSidebarURN3rdParty = "urn:sidebar:3rdparty-panel"; +const kSidebarURL = "chrome://inspector/content/sidebar/sidebar.xul"; +const kSidebarTitle = "Document Inspector"; + +////////////////////////////////////////////////// + +window.addEventListener("load", SidebarPrefs_initialize, false); + +function SidebarPrefs_initialize() +{ + pref = new SidebarPrefs(); + pref.initSidebarData(); +} + +///// class SidebarPrefs ///////////////////////// + +function SidebarPrefs() +{ +} + +SidebarPrefs.prototype = +{ + + init: function() + { + var not = this.isSidebarInstalled() ? "" : "Not"; + var el = document.getElementById("bxSidebar"+not+"Installed"); + el.setAttribute("collapsed", "false"); + }, + + /////////////////////////////////////////////////////////////////////////// + // Because nsSidebar has been so mean to me, I'm going to re-write it's + // addPanel code right here so I don't have to fight with it. Pbbbbt! + /////////////////////////////////////////////////////////////////////////// + + initSidebarData: function() + { + var file = this.getDirectoryFile(kSidebarPanelId); + if (file) + RDFU.loadDataSource(file, gSidebarLoadListener); + }, + + initSidebarData2: function(aDS) + { + var res = aDS.GetTarget(gRDF.GetResource(kSidebarURNPanelList), gRDF.GetResource(kNCURI + "panel-list"), true); + this.mDS = aDS; + this.mPanelSeq = RDFU.makeSeq(aDS, res); + this.mPanelRes = gRDF.GetResource(kSidebarURN3rdParty + ":" + kSidebarURL); + + this.init(); + }, + + isSidebarInstalled: function() + { + return this.mPanelSeq.IndexOf(this.mPanelRes) != -1; + }, + + installSidebar: function() + { + if (!this.isSidebarInstalled()) { + this.mDS.Assert(this.mPanelRes, gRDF.GetResource(kNCURI + "title"), gRDF.GetLiteral(kSidebarTitle), true); + this.mDS.Assert(this.mPanelRes, gRDF.GetResource(kNCURI + "content"), gRDF.GetLiteral(kSidebarURL), true); + this.mPanelSeq.AppendElement(this.mPanelRes); + this.forceSidebarRefresh(); + return true; + } else + return false; + }, + + forceSidebarRefresh: function() + { + var listRes = gRDF.GetResource(kSidebarURNPanelList); + var refreshRes = gRDF.GetResource(kNCURI + "refresh"); + var trueRes = gRDF.GetLiteral("true"); + this.mDS.Assert(listRes, refreshRes, trueRes, true); + this.mDS.Unassert(listRes, refreshRes, trueRes); + }, + + getDirectoryFile: function(aFileId) + { + try { + var dirService = XPCU.getService(kDirServiceCID, "nsIProperties"); + var file = dirService.get(aFileId, Components.interfaces.nsIFile); + if (!file.exists()) + return null; + + var fileURL = XPCU.createInstance(kStandardURLCID, "nsIFileURL"); + fileURL.file = file; + return fileURL.spec; + } catch (ex) { + return null; + } + } + +}; + +var gSidebarLoadListener = { + onDataSourceReady: function(aDS) + { + pref.initSidebarData2(aDS); + }, + + onError: function() + { + } +}; + diff --git a/mozilla/extensions/inspector/resources/content/prefs/pref-sidebar.xul b/mozilla/extensions/inspector/resources/content/prefs/pref-sidebar.xul new file mode 100644 index 00000000000..f88955f0acb --- /dev/null +++ b/mozilla/extensions/inspector/resources/content/prefs/pref-sidebar.xul @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/mozilla/extensions/inspector/resources/content/tests/allskin.xul b/mozilla/extensions/inspector/resources/content/tests/allskin.xul new file mode 100644 index 00000000000..becf097b670 --- /dev/null +++ b/mozilla/extensions/inspector/resources/content/tests/allskin.xul @@ -0,0 +1,82 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/mozilla/extensions/inspector/resources/content/toolboxOverlay.xul b/mozilla/extensions/inspector/resources/content/toolboxOverlay.xul new file mode 100644 index 00000000000..d108a086b83 --- /dev/null +++ b/mozilla/extensions/inspector/resources/content/toolboxOverlay.xul @@ -0,0 +1,97 @@ + + + %dtd1; + %dtd2; +]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +