michael@0: /* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: // helper function to shortcut component creation michael@0: function doCreate(aContract, aInterface) michael@0: { michael@0: return Components.classes[aContract].createInstance(aInterface); michael@0: } michael@0: michael@0: // for the items, loading a text file michael@0: const IOSERVICE_CTRID = "@mozilla.org/network/io-service;1"; michael@0: const nsIIOService = Components.interfaces.nsIIOService; michael@0: const SIS_CTRID = "@mozilla.org/scriptableinputstream;1" michael@0: const nsISIS = Components.interfaces.nsIScriptableInputStream; michael@0: michael@0: // rdf foo, onload handler michael@0: const kRDFSvcContractID = "@mozilla.org/rdf/rdf-service;1"; michael@0: const kRDFInMemContractID = michael@0: "@mozilla.org/rdf/datasource;1?name=in-memory-datasource"; michael@0: const kRDFContUtilsID = "@mozilla.org/rdf/container-utils;1"; michael@0: const kRDFXMLSerializerID = "@mozilla.org/rdf/xml-serializer;1"; michael@0: const kIOSvcContractID = "@mozilla.org/network/io-service;1"; michael@0: const kStandardURL = Components.classes["@mozilla.org/network/standard-url;1"]; michael@0: const nsIURL = Components.interfaces.nsIURL; michael@0: const nsIStandardURL = Components.interfaces.nsIStandardURL; michael@0: const nsIFilePicker = Components.interfaces.nsIFilePicker; michael@0: const nsIXULTreeBuilder = Components.interfaces.nsIXULTreeBuilder; michael@0: const nsIXULTemplateBuilder = Components.interfaces.nsIXULTemplateBuilder; michael@0: const kIOSvc = Components.classes[kIOSvcContractID] michael@0: .getService(Components.interfaces.nsIIOService); michael@0: const nsIRDFService = Components.interfaces.nsIRDFService; michael@0: const nsIRDFDataSource = Components.interfaces.nsIRDFDataSource; michael@0: const nsIRDFRemoteDataSource = Components.interfaces.nsIRDFRemoteDataSource; michael@0: const nsIRDFPurgeableDataSource = michael@0: Components.interfaces.nsIRDFPurgeableDataSource; michael@0: const nsIRDFResource = Components.interfaces.nsIRDFResource; michael@0: const nsIRDFLiteral = Components.interfaces.nsIRDFLiteral; michael@0: const nsIRDFInt = Components.interfaces.nsIRDFInt; michael@0: const nsIRDFContainerUtils = Components.interfaces.nsIRDFContainerUtils; michael@0: const nsIRDFXMLSerializer = Components.interfaces.nsIRDFXMLSerializer; michael@0: const nsIRDFXMLSource = Components.interfaces.nsIRDFXMLSource; michael@0: const kRDFSvc = michael@0: Components.classes[kRDFSvcContractID].getService(nsIRDFService); michael@0: const krTypeCat = kRDFSvc.GetResource("http://home.netscape.com/NC-rdf#category"); michael@0: const krTypeFailCount = kRDFSvc.GetResource("http://home.netscape.com/NC-rdf#failCount"); michael@0: const krTypeName = kRDFSvc.GetResource("http://home.netscape.com/NC-rdf#name"); michael@0: const krTypeSucc = kRDFSvc.GetResource("http://home.netscape.com/NC-rdf#succ"); michael@0: const krTypeOrigSucc = kRDFSvc.GetResource("http://home.netscape.com/NC-rdf#orig_succ"); michael@0: const krTypeOrigFailCount = kRDFSvc.GetResource("http://home.netscape.com/NC-rdf#orig_failCount"); michael@0: const krTypeOrigSuccCount = kRDFSvc.GetResource("http://home.netscape.com/NC-rdf#orig_succCount"); michael@0: const krTypePath = kRDFSvc.GetResource("http://home.netscape.com/NC-rdf#path"); michael@0: const krTypeParent = kRDFSvc.GetResource("http://home.netscape.com/NC-rdf#parent"); michael@0: const krTypePurp = kRDFSvc.GetResource("http://home.netscape.com/NC-rdf#purp"); michael@0: const krTypeSuccCount = kRDFSvc.GetResource("http://home.netscape.com/NC-rdf#succCount"); michael@0: const kGood = kRDFSvc.GetLiteral("yes"); michael@0: const kBad = kRDFSvc.GetLiteral("no"); michael@0: const kMixed = kRDFSvc.GetLiteral("+-"); michael@0: const kContUtils = doCreate(kRDFContUtilsID, nsIRDFContainerUtils); michael@0: michael@0: function doCreateRDFFP(aTitle, aMode) michael@0: { michael@0: var fp = doCreate("@mozilla.org/filepicker;1", nsIFilePicker); michael@0: fp.init(window, aTitle, aMode); michael@0: fp.appendFilter('*.rdf', '*.rdf'); michael@0: fp.appendFilters(nsIFilePicker.filterAll); michael@0: return fp; michael@0: } michael@0: michael@0: function goDoCommand(aCommand) michael@0: { michael@0: try { michael@0: var controller = michael@0: top.document.commandDispatcher.getControllerForCommand(aCommand); michael@0: if (controller && controller.isCommandEnabled(aCommand)) michael@0: controller.doCommand(aCommand); michael@0: } michael@0: catch(e) { michael@0: dump("An error "+e+" occurred executing the "+aCommand+" command\n"); michael@0: } michael@0: } michael@0: michael@0: function registerController(aController) michael@0: { michael@0: top.controllers.appendController(aController); michael@0: }