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: function onNewResultView(event) michael@0: { michael@0: dump("onNewResultView\n"); michael@0: const db = runItem.prototype.kDatabase; michael@0: const kXalan = runItem.prototype.kXalan; michael@0: var index = view.boxObject.view.selection.currentIndex; michael@0: var res = view.builder.getResourceAtIndex(index); michael@0: var name = db.GetTarget(res, krTypeName, true); michael@0: if (!name) { michael@0: return false; michael@0: } michael@0: var cat = db.GetTarget(res, krTypeCat, true); michael@0: var path = db.GetTarget(res, krTypePath, true); michael@0: cat = cat.QueryInterface(nsIRDFLiteral); michael@0: name = name.QueryInterface(nsIRDFLiteral); michael@0: path = path.QueryInterface(nsIRDFLiteral); michael@0: xalan_fl = kXalan.resolve(cat.Value+"/"+path.Value); michael@0: xalan_ref = kXalan.resolve(cat.Value+"-gold/"+path.Value); michael@0: var currentResultItem = new Object(); michael@0: currentResultItem.testpath = xalan_fl; michael@0: currentResultItem.refpath = xalan_ref; michael@0: var currentRunItem = itemCache.getItem(res); michael@0: // XXX todo, keep a list of these windows, so that we can close them. michael@0: resultWin = window.openDialog('result-view.xul','_blank', michael@0: 'chrome,resizable,dialog=no', michael@0: currentResultItem, currentRunItem); michael@0: return true; michael@0: } michael@0: michael@0: var refInspector; michael@0: var resInspector; michael@0: michael@0: function onResultViewLoad(event) michael@0: { michael@0: dump("onResultViewLoad\n"); michael@0: aResultItem = window.arguments[0]; michael@0: aRunItem = window.arguments[1]; michael@0: var loadFlags = Components.interfaces.nsIWebNavigation.LOAD_FLAGS_NONE; michael@0: document.getElementById('src').webNavigation.loadURI('view-source:'+ michael@0: aResultItem.testpath+'.xml', loadFlags, null, null, null); michael@0: document.getElementById('style').webNavigation.loadURI('view-source:'+ michael@0: aResultItem.testpath+'.xsl', loadFlags, null, null, null); michael@0: michael@0: if (aRunItem && aRunItem.mRefDoc && aRunItem.mResDoc) { michael@0: document.getElementById("refSourceBox").setAttribute("class", "hidden"); michael@0: refInspector = new ObjectApp(); michael@0: refInspector.initialize("refInsp", aRunItem.mRefDoc); michael@0: resInspector = new ObjectApp(); michael@0: resInspector.initialize("resInsp", aRunItem.mResDoc); michael@0: } michael@0: else { michael@0: document.getElementById("inspectorBox").setAttribute("class", "hidden"); michael@0: document.getElementById('ref').webNavigation.loadURI('view-source:'+ michael@0: aResultItem.refpath+'.out', loadFlags, null, null, null); michael@0: } michael@0: return true; michael@0: } michael@0: michael@0: function onResultViewUnload(event) michael@0: { michael@0: dump("onResultUnload\n"); michael@0: } michael@0: michael@0: function ObjectApp() michael@0: { michael@0: } michael@0: michael@0: ObjectApp.prototype = michael@0: { michael@0: mDoc: null, michael@0: mPanelSet: null, michael@0: michael@0: initialize: function(aId, aDoc) michael@0: { michael@0: this.mDoc = aDoc; michael@0: this.mPanelSet = document.getElementById(aId).contentDocument.getElementById("bxPanelSet"); michael@0: this.mPanelSet.addObserver("panelsetready", this, false); michael@0: this.mPanelSet.initialize(); michael@0: }, michael@0: michael@0: doViewerCommand: function(aCommand) michael@0: { michael@0: this.mPanelSet.execCommand(aCommand); michael@0: }, michael@0: michael@0: getViewer: function(aUID) michael@0: { michael@0: return this.mPanelSet.registry.getViewerByUID(aUID); michael@0: }, michael@0: michael@0: onEvent: function(aEvent) michael@0: { michael@0: switch (aEvent.type) { michael@0: case "panelsetready": michael@0: { michael@0: this.mPanelSet.getPanel(0).subject = this.mDoc; michael@0: } michael@0: } michael@0: } michael@0: };