delay service instanciation

This commit is contained in:
chanial%noos.fr 2002-10-14 01:26:08 +00:00
parent 9b156f0f7b
commit c16bd86d61
7 changed files with 112 additions and 69 deletions

View File

@ -376,6 +376,11 @@ function Startup()
function delayedStartup(aElt)
{
// loads the services
initServices();
initBMService();
gBrowser.addEventListener("load", function(evt) { setTimeout(loadEventHandlers, 0, evt); }, true);
if (gMustLoadSidebar) {
@ -4151,7 +4156,7 @@ function handleLinkClick(event, href, linkNode)
return true;
}
var saveModifier = true;
if (pref) {
if (gPrefService) {
try {
saveModifier = gPrefService.getBoolPref("ui.key.saveLink.shift");
}

View File

@ -107,6 +107,8 @@ var gCreateInFolder = "NC:NewBookmarkFolder";
function Startup()
{
initServices();
initBMService();
gFld_Name = document.getElementById("name");
gFld_URL = document.getElementById("url");
gCB_AddGroup = document.getElementById("addgroup");

View File

@ -69,15 +69,18 @@
* properties, one for each group member.
*/
var gSelectedFolder = null;
var gName = null;
var gGroup = null;
var gList = null;
var gIndentation = null; // temporary hack to indent the folders
const gNameArc = RDF.GetResource(NC_NS+"Name");
var gSelectedFolder;
var gName;
var gGroup;
var gList;
var gIndentation; // temporary hack to indent the folders
var gNameArc;
function Startup()
{
initServices();
initBMService();
gNameArc = RDF.GetResource(NC_NS+"Name");
gName = document.getElementById("name");
gGroup = document.getElementById("addgroup");
gList = document.getElementById("select-menu");
@ -108,7 +111,7 @@ function onOK()
var url, rSource;
if (gGroup && gGroup.checked) {
rSource = BMDS.createFolder(gName.value);
const groups = window.arguments[5];
const groups = window.arguments[5];
for (var i = 0; i < groups.length; ++i) {
url = getNormalizedURL(groups[i].url);
BMDS.createBookmarkInContainer(groups[i].name, url,

View File

@ -36,40 +36,80 @@
#
# ***** END LICENSE BLOCK *****
const NC_NS = "http://home.netscape.com/NC-rdf#";
const RDF_NS = "http://www.w3.org/1999/02/22-rdf-syntax-ns#";
const XUL_NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
const NC_NS_CMD = NC_NS + "command?cmd=";
var NC_NS, RDF_NS, XUL_NS, NC_NS_CMD;
// definition of the services frequently used for bookmarks
// PCH: a better place would be in a specific file.
const kRDFContractID = "@mozilla.org/rdf/rdf-service;1";
const kRDFSVCIID = Components.interfaces.nsIRDFService;
const kRDFRSCIID = Components.interfaces.nsIRDFResource;
const kRDFLITIID = Components.interfaces.nsIRDFLiteral
var RDF = Components.classes[kRDFContractID].getService(kRDFSVCIID);
//XXX RDF is defined as a |var| to avoid const redefinitions in sidebarOverlay.js
var kRDFContractID;
var kRDFSVCIID;
var kRDFRSCIID;
var kRDFLITIID;
var RDF;
const kRDFCContractID = "@mozilla.org/rdf/container;1";
const kRDFCIID = Components.interfaces.nsIRDFContainer;
const RDFC = Components.classes[kRDFCContractID].getService(kRDFCIID);
var kRDFCContractID;
var kRDFCIID;
var RDFC;
const kRDFCUContractID = "@mozilla.org/rdf/container-utils;1";
const kRDFCUIID = Components.interfaces.nsIRDFContainerUtils;
const RDFCU = Components.classes[kRDFCUContractID].getService(kRDFCUIID);
var kRDFCUContractID;
var kRDFCUIID;
var RDFCU;
const BMDS = RDF.GetDataSource("rdf:bookmarks");
const BMSVC = BMDS.QueryInterface(Components.interfaces.nsIBookmarksService);
var BMDS;
var BMSVC;
const kSOUNDContractID = "@mozilla.org/sound;1";
const kSOUNDIID = Components.interfaces.nsISound;
const SOUND = Components.classes[kSOUNDContractID].createInstance(kSOUNDIID);
var kSOUNDContractID;
var kSOUNDIID;
var SOUND;
const kWINDOWContractID = "@mozilla.org/appshell/window-mediator;1";
const kWINDOWIID = Components.interfaces.nsIWindowMediator;
const WINDOWSVC = Components.classes[kWINDOWContractID].getService(kWINDOWIID);
var kWINDOWContractID;
var kWINDOWIID;
var WINDOWSVC;
var gBMtxmgr;
// should be moved in a separate file
function initServices()
{
NC_NS = "http://home.netscape.com/NC-rdf#";
RDF_NS = "http://www.w3.org/1999/02/22-rdf-syntax-ns#";
XUL_NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
NC_NS_CMD = NC_NS + "command?cmd=";
kRDFContractID = "@mozilla.org/rdf/rdf-service;1";
kRDFSVCIID = Components.interfaces.nsIRDFService;
kRDFRSCIID = Components.interfaces.nsIRDFResource;
kRDFLITIID = Components.interfaces.nsIRDFLiteral;
RDF = Components.classes[kRDFContractID].getService(kRDFSVCIID);
kRDFCContractID = "@mozilla.org/rdf/container;1";
kRDFCIID = Components.interfaces.nsIRDFContainer;
RDFC = Components.classes[kRDFCContractID].getService(kRDFCIID);
kRDFCUContractID = "@mozilla.org/rdf/container-utils;1";
kRDFCUIID = Components.interfaces.nsIRDFContainerUtils;
RDFCU = Components.classes[kRDFCUContractID].getService(kRDFCUIID);
kSOUNDContractID = "@mozilla.org/sound;1";
kSOUNDIID = Components.interfaces.nsISound;
SOUND = Components.classes[kSOUNDContractID].createInstance(kSOUNDIID);
kWINDOWContractID = "@mozilla.org/appshell/window-mediator;1";
kWINDOWIID = Components.interfaces.nsIWindowMediator;
WINDOWSVC = Components.classes[kWINDOWContractID].getService(kWINDOWIID);
}
function initBMService()
{
BMDS = RDF.GetDataSource("rdf:bookmarks");
BMSVC = BMDS.QueryInterface(Components.interfaces.nsIBookmarksService);
BookmarkInsertTransaction.prototype.RDFC = RDFC;
BookmarkInsertTransaction.prototype.BMDS = BMDS;
BookmarkRemoveTransaction.prototype.RDFC = RDFC;
BookmarkRemoveTransaction.prototype.BMDS = BMDS;
BookmarkImportTransaction.prototype.RDFC = RDFC;
BookmarkImportTransaction.prototype.BMDS = BMDS;
}
var gBMtxmgr;
/**
* XXX - 04/16/01
* ACK! massive command name collision problems are causing big issues
@ -1548,33 +1588,9 @@ var BookmarksUtils = {
title = url;
}
this.addBookmark(url, title, docCharset, aShowDialog);
},
// still to be done, ignore that
addBookmark: function (aURL, aTitle, aCharSet, aShowDialog)
{
if (aShowDialog)
openDialog("chrome://browser/content/bookmarks/addBookmark2.xul", "",
"centerscreen,chrome,dialog=yes,resizable=no,dependent", aTitle, aURL, null, aCharSet);
else {
// User has elected to override the file dialog and always file bookmarks
// into the default bookmark folder.
var rSource;
if (!BMSVC.IsBookmarked(aURL))
rSource = BookmarksUtils.createBookmark(aTitle, aURL, aCharSet);
else
rSource = RDF.GetResource(aURL);
var selection, target;
selection = BookmarksUtils.getSelectionFromResource(rSource);
target = BookmarksUtils.getNewBookmarkFolder();
target = BookmarksUtils.getSelectionFromResource(target);
target = BookmarksUtils.getTargetFromSelection(target);
var transactionSet = new BookmarksTransactionSet;
var transaction = BookmarksUtils.getInsertTransaction("newbookmark", selection, target);
this.doBookmarkTransaction(transaction);
}
openDialog("chrome://browser/content/bookmarks/addBookmark2.xul", "",
"centerscreen,chrome,dialog=yes,resizable=no,dependent", title,
url, null, docCharset);
},
getBrowserTargetFromEvent: function (aEvent)

View File

@ -43,6 +43,8 @@ var gSearchBox;
// tree widget, etc.
function Startup()
{
initServices();
initBMService();
var bookmarksView = document.getElementById("bookmarks-view");
bookmarksView.treeBoxObject.selection.select(0);
gSearchBox = document.getElementById("search-box");

View File

@ -40,21 +40,20 @@
// Ask rjc@netscape.com if you want to know why exactly this is.
// This is the set of fields that are visible in the window.
var gFields = ["name", "shortcut", "description", "url"];
var gFields;
// ...and this is a parallel array that contains the RDF properties
// that they are associated with.
var gProperties = [NC_NS + "Name",
NC_NS + "ShortcutURL",
NC_NS + "Description",
NC_NS + "URL"];
var gProperties;
var Bookmarks = RDF.GetDataSource("rdf:bookmarks");
var gBookmarkURL = "";
var Bookmarks;
var gBookmarkURL;
function showDescription()
{
initServices();
initBMService();
gBookmarkURL = window.arguments[0];
var resource = RDF.GetResource(gBookmarkURL);
@ -79,6 +78,20 @@ function showDescription()
function Init()
{
// This is the set of fields that are visible in the window.
gFields = ["name", "shortcut", "description", "url"];
// ...and this is a parallel array that contains the RDF properties
// that they are associated with.
gProperties = [NC_NS + "Name",
NC_NS + "ShortcutURL",
NC_NS + "Description",
NC_NS + "URL"];
Bookmarks = RDF.GetDataSource("rdf:bookmarks");
gBookmarkURL = "";
var x;
var resource = RDF.GetResource(gBookmarkURL);
// Initialize the properties panel by copying the values from the

View File

@ -41,6 +41,8 @@ var gOK;
function Startup()
{
initServices();
initBMService();
var textNode = document.createTextNode(window.arguments[0]);
document.getElementById("selectBookmarkDescription").appendChild(textNode);
gBookmarkTree = document.getElementById("bookmarks-view");