|
1 /* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
|
2 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
3 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
5 |
|
6 // helper function to shortcut component creation |
|
7 function doCreate(aContract, aInterface) |
|
8 { |
|
9 return Components.classes[aContract].createInstance(aInterface); |
|
10 } |
|
11 |
|
12 // for the items, loading a text file |
|
13 const IOSERVICE_CTRID = "@mozilla.org/network/io-service;1"; |
|
14 const nsIIOService = Components.interfaces.nsIIOService; |
|
15 const SIS_CTRID = "@mozilla.org/scriptableinputstream;1" |
|
16 const nsISIS = Components.interfaces.nsIScriptableInputStream; |
|
17 |
|
18 // rdf foo, onload handler |
|
19 const kRDFSvcContractID = "@mozilla.org/rdf/rdf-service;1"; |
|
20 const kRDFInMemContractID = |
|
21 "@mozilla.org/rdf/datasource;1?name=in-memory-datasource"; |
|
22 const kRDFContUtilsID = "@mozilla.org/rdf/container-utils;1"; |
|
23 const kRDFXMLSerializerID = "@mozilla.org/rdf/xml-serializer;1"; |
|
24 const kIOSvcContractID = "@mozilla.org/network/io-service;1"; |
|
25 const kStandardURL = Components.classes["@mozilla.org/network/standard-url;1"]; |
|
26 const nsIURL = Components.interfaces.nsIURL; |
|
27 const nsIStandardURL = Components.interfaces.nsIStandardURL; |
|
28 const nsIFilePicker = Components.interfaces.nsIFilePicker; |
|
29 const nsIXULTreeBuilder = Components.interfaces.nsIXULTreeBuilder; |
|
30 const nsIXULTemplateBuilder = Components.interfaces.nsIXULTemplateBuilder; |
|
31 const kIOSvc = Components.classes[kIOSvcContractID] |
|
32 .getService(Components.interfaces.nsIIOService); |
|
33 const nsIRDFService = Components.interfaces.nsIRDFService; |
|
34 const nsIRDFDataSource = Components.interfaces.nsIRDFDataSource; |
|
35 const nsIRDFRemoteDataSource = Components.interfaces.nsIRDFRemoteDataSource; |
|
36 const nsIRDFPurgeableDataSource = |
|
37 Components.interfaces.nsIRDFPurgeableDataSource; |
|
38 const nsIRDFResource = Components.interfaces.nsIRDFResource; |
|
39 const nsIRDFLiteral = Components.interfaces.nsIRDFLiteral; |
|
40 const nsIRDFInt = Components.interfaces.nsIRDFInt; |
|
41 const nsIRDFContainerUtils = Components.interfaces.nsIRDFContainerUtils; |
|
42 const nsIRDFXMLSerializer = Components.interfaces.nsIRDFXMLSerializer; |
|
43 const nsIRDFXMLSource = Components.interfaces.nsIRDFXMLSource; |
|
44 const kRDFSvc = |
|
45 Components.classes[kRDFSvcContractID].getService(nsIRDFService); |
|
46 const krTypeCat = kRDFSvc.GetResource("http://home.netscape.com/NC-rdf#category"); |
|
47 const krTypeFailCount = kRDFSvc.GetResource("http://home.netscape.com/NC-rdf#failCount"); |
|
48 const krTypeName = kRDFSvc.GetResource("http://home.netscape.com/NC-rdf#name"); |
|
49 const krTypeSucc = kRDFSvc.GetResource("http://home.netscape.com/NC-rdf#succ"); |
|
50 const krTypeOrigSucc = kRDFSvc.GetResource("http://home.netscape.com/NC-rdf#orig_succ"); |
|
51 const krTypeOrigFailCount = kRDFSvc.GetResource("http://home.netscape.com/NC-rdf#orig_failCount"); |
|
52 const krTypeOrigSuccCount = kRDFSvc.GetResource("http://home.netscape.com/NC-rdf#orig_succCount"); |
|
53 const krTypePath = kRDFSvc.GetResource("http://home.netscape.com/NC-rdf#path"); |
|
54 const krTypeParent = kRDFSvc.GetResource("http://home.netscape.com/NC-rdf#parent"); |
|
55 const krTypePurp = kRDFSvc.GetResource("http://home.netscape.com/NC-rdf#purp"); |
|
56 const krTypeSuccCount = kRDFSvc.GetResource("http://home.netscape.com/NC-rdf#succCount"); |
|
57 const kGood = kRDFSvc.GetLiteral("yes"); |
|
58 const kBad = kRDFSvc.GetLiteral("no"); |
|
59 const kMixed = kRDFSvc.GetLiteral("+-"); |
|
60 const kContUtils = doCreate(kRDFContUtilsID, nsIRDFContainerUtils); |
|
61 |
|
62 function doCreateRDFFP(aTitle, aMode) |
|
63 { |
|
64 var fp = doCreate("@mozilla.org/filepicker;1", nsIFilePicker); |
|
65 fp.init(window, aTitle, aMode); |
|
66 fp.appendFilter('*.rdf', '*.rdf'); |
|
67 fp.appendFilters(nsIFilePicker.filterAll); |
|
68 return fp; |
|
69 } |
|
70 |
|
71 function goDoCommand(aCommand) |
|
72 { |
|
73 try { |
|
74 var controller = |
|
75 top.document.commandDispatcher.getControllerForCommand(aCommand); |
|
76 if (controller && controller.isCommandEnabled(aCommand)) |
|
77 controller.doCommand(aCommand); |
|
78 } |
|
79 catch(e) { |
|
80 dump("An error "+e+" occurred executing the "+aCommand+" command\n"); |
|
81 } |
|
82 } |
|
83 |
|
84 function registerController(aController) |
|
85 { |
|
86 top.controllers.appendController(aController); |
|
87 } |