mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-14 18:51:28 +00:00
ViXEn transaction system work, history window work, setting up master controller.
NOT PART OF BUILD.
This commit is contained in:
parent
3201eb5fe7
commit
194b602a15
@ -21,3 +21,60 @@
|
||||
* Ben Goodger <ben@netscape.com> (Original Author)
|
||||
*/
|
||||
|
||||
var vxHistory =
|
||||
{
|
||||
startup: function ()
|
||||
{
|
||||
var rootWindow = vxUtils.getWindow("vixen:main");
|
||||
if (rootWindow) {
|
||||
_dd("adding observer");
|
||||
rootWindow.vxShell.observerService.AddObserver(vfdFocusObserver, "vfd-focus");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var vfdFocusObserver = {
|
||||
Observe: function (aSubject, aTopic, aData)
|
||||
{
|
||||
_dd("do Observe");
|
||||
var historyTree = document.getElementById("historyTree");
|
||||
if (historyTree) {
|
||||
var datasources = historyTree.database.GetDataSources();
|
||||
while(datasources.hasMoreElements()) {
|
||||
var currDS = datasources.getNext();
|
||||
historyTree.database.RemoveDataSource(currDS);
|
||||
}
|
||||
var datasource = aSubject.QueryInterface(Components.interfaces.nsIRDFDataSource);
|
||||
if (datasource) {
|
||||
_dd("rebuilding history tree");
|
||||
_ddf("datasource", datasource);
|
||||
|
||||
historyTree.database.AddDataSource(datasource);
|
||||
|
||||
// XXX - inspect the datasource
|
||||
var RDFService = Components.classes["@mozilla.org/rdf/rdf-service;1"].getService();
|
||||
RDFService = RDFService.QueryInterface(Components.interfaces.nsIRDFService);
|
||||
gVxTransactionHead = RDFService.GetResource(kTxnHeadURI);
|
||||
gVxTransactionList = RDFService.GetResource(kVixenRDF + "transaction-list");
|
||||
var seq = datasource.GetTarget(gVxTransactionHead, gVxTransactionList, true);
|
||||
seq = seq.QueryInterface(Components.interfaces.nsIRDFResource);
|
||||
|
||||
gVxTxnDescription = RDFService.GetResource(kVixenRDF + "description");
|
||||
var container = Components.classes["@mozilla.org/rdf/container;1"].getService();
|
||||
container = container.QueryInterface(Components.interfaces.nsIRDFContainer);
|
||||
container.Init(datasource, seq);
|
||||
var elts = container.GetElements();
|
||||
while (elts.hasMoreElements()) {
|
||||
var currElt = elts.getNext();
|
||||
currElt = currElt.QueryInterface(Components.interfaces.nsIRDFResource);
|
||||
var commandString = datasource.GetTarget(currElt, gVxTxnDescription, true);
|
||||
commandString = commandString.QueryInterface(Components.interfaces.nsIRDFLiteral);
|
||||
_ddf("commandString", commandString.Value);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
<?xml-stylesheet href="chrome://communicator/skin/"?>
|
||||
|
||||
<window id="vxHistory" orient="vertical"
|
||||
windowtype="vixen:history"
|
||||
windowtype="vixen:history" class="dialog"
|
||||
title="Edit History for [Form1]"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||
onload="vxHistory.startup();">
|
||||
@ -17,8 +17,9 @@
|
||||
|
||||
<!-- transaction manager -->
|
||||
<script src="chrome://vixen/content/vfd/vxVFDTransactionManager.js"></script>
|
||||
<script src="chrome://vixen/content/txmgr/vxTransactionDataSource.js"></script>
|
||||
|
||||
<tree id="historyTree" style="width: 0px; height; 0px;"
|
||||
<tree id="historyTree" style="width: 0px; height; 0px;" class="inset"
|
||||
flex="1" multiple="true" datasources="rdf:null"
|
||||
ref="urn:mozilla:vixen:transactions">
|
||||
<treecolgroup>
|
||||
@ -36,17 +37,24 @@
|
||||
predicate="http://www.mozilla.org/projects/vixen/rdf#command-string"
|
||||
object="?command-string"/>
|
||||
</conditions>
|
||||
<bindings>
|
||||
<triple subject="?transaction"
|
||||
predicate="http://www.mozilla.org/projects/vixen/rdf#description"
|
||||
object="?description"/>
|
||||
</bindings>
|
||||
<action>
|
||||
<treechildren>
|
||||
<treeitem uri="?transaction">
|
||||
<treerow>
|
||||
<treecell value="?command-string"/>
|
||||
<treecell value="?description" command="?command-string"/>
|
||||
</treerow>
|
||||
</treeitem>
|
||||
</treechildren>
|
||||
</action>
|
||||
</rule>
|
||||
</template>
|
||||
|
||||
<treechildren id="historyKids"/>
|
||||
</tree>
|
||||
|
||||
</window>
|
||||
|
@ -34,7 +34,7 @@ var vxPalette =
|
||||
var nElements = this.incrementElementCount("button");
|
||||
var attributes = ["value", "id"];
|
||||
var values = ["Button " + nElements, "button_" + nElements];
|
||||
this.insertSingleElement("button", attributes, values);
|
||||
this.insertSingleElement("button", attributes, values, "Insert Button");
|
||||
},
|
||||
|
||||
insertTextFieldElement: function (aType)
|
||||
@ -42,7 +42,7 @@ var vxPalette =
|
||||
var nElements = this.incrementElementCount("textfield");
|
||||
var attributes = ["value", "id"];
|
||||
var values = ["Textfield " + nElements, "textfield_" + nElements];
|
||||
this.insertSingleElement("textfield", attributes, values);
|
||||
this.insertSingleElement("textfield", attributes, values, "Insert Textfield");
|
||||
},
|
||||
|
||||
insertRadioGroup: function ()
|
||||
@ -85,6 +85,7 @@ var vxPalette =
|
||||
var txns = [radiogroupTxn, radiogroupAttrTxn, radioTxn, radioAttrTxn];
|
||||
var aggregateTxn = new vxAggregateTxn(txns);
|
||||
aggregateTxn.init();
|
||||
aggregateTxn.description = "Insert Radiogroup";
|
||||
|
||||
var txmgr = focusedWindow.vxVFD.mTxMgrShell;
|
||||
txmgr.doTransaction(aggregateTxn);
|
||||
@ -98,7 +99,7 @@ var vxPalette =
|
||||
return ++this.mElementCount[aNodeName];
|
||||
},
|
||||
|
||||
insertSingleElement: function (aNodeName, aAttributes, aValues)
|
||||
insertSingleElement: function (aNodeName, aAttributes, aValues, aDescription)
|
||||
{
|
||||
var vixenMain = vxUtils.getWindow("vixen:main");
|
||||
var focusedWindow = vixenMain.vxShell.mFocusedWindow;
|
||||
@ -117,6 +118,7 @@ var vxPalette =
|
||||
// batch the transactions
|
||||
var aggregateTxn = new vxAggregateTxn([elementTxn, elementAttrTxn]);
|
||||
aggregateTxn.init();
|
||||
aggregateTxn.description = aDescription;
|
||||
|
||||
var txmgr = focusedWindow.vxVFD.mTxMgrShell;
|
||||
txmgr.doTransaction(aggregateTxn);
|
||||
|
@ -0,0 +1,126 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 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 mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 2000 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Ben Goodger <ben@netscape.com> (Original Author)
|
||||
*/
|
||||
|
||||
// Global Resource URIs
|
||||
const kTxnHeadURI = "urn:mozilla:vixen:transactions";
|
||||
const kTxnURI = "urn:mozilla:vixen:transaction:";
|
||||
const kTxnRootURI = kTxnURI + "root";
|
||||
const kVixenRDF = "http://www.mozilla.org/projects/vixen/rdf#";
|
||||
|
||||
// Global Resources
|
||||
var gVxTransaction = null; // meta resource for transaction information
|
||||
var gVxTransactionList = null; // arc to
|
||||
var gVxTransactionRoot = null; // transaction list
|
||||
|
||||
var gVxTxnCommandString = null; // command string for a transaction
|
||||
var gVxTxnDescription = null; // pretty description of a transaction
|
||||
|
||||
function vxTransactionDataSource()
|
||||
{
|
||||
// Obtain the RDF Service
|
||||
const kRDFServiceCONTRACTID = "@mozilla.org/rdf/rdf-service;1";
|
||||
this.mRDFS = Components.classes[kRDFServiceCONTRACTID].getService();
|
||||
if (!this.mRDFS) throw Components.results.NS_ERROR_FAILURE;
|
||||
this.mRDFS = this.mRDFS.QueryInterface(Components.interfaces.nsIRDFService);
|
||||
if (!this.mRDFS) throw Components.results.NS_ERROR_FAILURE;
|
||||
|
||||
// Create our internal in-memory datasource
|
||||
const kRDFIMDS = "@mozilla.org/rdf/datasource;1?name=in-memory-datasource";
|
||||
this.mDataSource = Components.classes[kRDFIMDS].createInstance();
|
||||
if (!this.mDataSource) throw Components.results.NS_ERROR_FAILURE;
|
||||
this.mDataSource = this.mDataSource.QueryInterface(Components.interfaces.nsIRDFDataSource);
|
||||
|
||||
// Initialize the global resources
|
||||
gVxTransaction = this.mRDFS.GetResource(kTxnHeadURI);
|
||||
gVxTransactionList = this.mRDFS.GetResource(kVixenRDF + "transaction-list");
|
||||
gVxTransactionRoot = this.mRDFS.GetResource(kTxnRootURI);
|
||||
|
||||
// Assert the datasource structure into the graph
|
||||
this.mDataSource.Assert(gVxTransaction,
|
||||
gVxTransactionList,
|
||||
gVxTransactionRoot, true);
|
||||
|
||||
// initialize other resources
|
||||
gVxTxnCommandString = this.mRDFS.GetResource(kVixenRDF + "command-string");
|
||||
gVxTxnDescription = this.mRDFS.GetResource(kVixenRDF + "description");
|
||||
|
||||
}
|
||||
|
||||
vxTransactionDataSource.prototype =
|
||||
{
|
||||
HasAssertion: function (aSource, aProperty, aValue, aTruthValue)
|
||||
{
|
||||
return this.mDataSource.HasAssertion(aSource, aProperty, aValue, aTruthValue);
|
||||
},
|
||||
|
||||
Assert: function (aSource, aProperty, aValue, aTruthValue)
|
||||
{
|
||||
this.mDataSource.Assert(aSource, aProperty, aValue, aTruthValue);
|
||||
},
|
||||
|
||||
Unassert: function (aSource, aProperty, aValue, aTruthValue)
|
||||
{
|
||||
this.mDataSource.Unassert(aSource, aProperty, aValue, aTruthValue);
|
||||
},
|
||||
|
||||
GetTarget: function (aSource, aProperty, aTruthValue)
|
||||
{
|
||||
return this.mDataSource.GetTarget(aSource, aProperty, aTruthValue);
|
||||
},
|
||||
|
||||
GetTargets: function (aSource, aProperty, aTruthValue)
|
||||
{
|
||||
return this.mDataSource.GetTargets(aSource, aProperty, aTruthValue);
|
||||
},
|
||||
|
||||
GetSource: function (aProperty, aTarget, aTruthValue)
|
||||
{
|
||||
return this.mDataSource.GetSource(aProperty, aTarget, aTruthValue);
|
||||
},
|
||||
|
||||
GetSources: function (aProperty, aTarget, aTruthValue)
|
||||
{
|
||||
return this.mDataSource.GetSources(aProperty, aTarget, aTruthValue);
|
||||
},
|
||||
|
||||
ArcLabelsIn: function (aNode)
|
||||
{
|
||||
return this.mDataSource.ArcLabelsIn(aNode);
|
||||
},
|
||||
|
||||
ArcLabelsOut: function (aSource)
|
||||
{
|
||||
return this.mDataSource.ArcLabelsOut(aSource);
|
||||
},
|
||||
|
||||
AddObserver: function (aObserver)
|
||||
{
|
||||
this.mDataSource.AddObserver(aObserver);
|
||||
},
|
||||
|
||||
RemoveObserver: function (aObserver)
|
||||
{
|
||||
this.mDataSource.RemoveObserver(aObserver);
|
||||
}
|
||||
};
|
||||
|
@ -39,9 +39,8 @@ var vxVFD =
|
||||
|
||||
// load the document
|
||||
var content = this.getContent(false);
|
||||
var docURL = this.mParams.documentURL;
|
||||
const scratch = "chrome://vixen/content/vfd/scratch.xul";
|
||||
content.setAttribute("src", docURL ? docURL : scratch);
|
||||
var docURL = this.mParams.documentURL || "chrome://vixen/content/vfd/scratch.xul";
|
||||
content.setAttribute("src", docURL);
|
||||
|
||||
var windowNode = document.getElementById("vxVFD");
|
||||
windowNode.setAttribute("url", docURL);
|
||||
@ -60,16 +59,8 @@ var vxVFD =
|
||||
// vixenMain.vxShell.mFocusObserver.Notify({ }, "window_focus", ("vfd," + this.mParams.documentURL));
|
||||
vixenMain.vxShell.mFocusedWindow = window;
|
||||
|
||||
// XXX-HACK until we set up observers
|
||||
var history = vxUtils.getWindow("vixen:history");
|
||||
if (history) {
|
||||
var doc = history.document;
|
||||
var historyTree = doc.getElementById("historyTree");
|
||||
if (historyTree) {
|
||||
historyTree.database.AddDataSource(vxVFDTransactionDS);
|
||||
historyTree.builder.rebuild();
|
||||
}
|
||||
}
|
||||
if (this.mTxMgrShell)
|
||||
vixenMain.vxShell.observerService.Notify(this.mTxMgrShell.mDataSource.mDataSource, "vfd-focus", null);
|
||||
},
|
||||
|
||||
get vfdDocumentWindowNode()
|
||||
|
@ -2,12 +2,15 @@
|
||||
|
||||
<?xml-stylesheet href="chrome://communicator/skin/"?>
|
||||
|
||||
<?xul-overlay href="chrome://vixen/content/vxKeysetOverlay.xul"?>
|
||||
|
||||
<window id="vxVFD" orient="vertical"
|
||||
windowtype="vixen:formdesigner"
|
||||
title="Visual Form Designer [Form1]"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||
onload="vxVFD.startup();"
|
||||
onfocus="vxVFD.focusVFD();">
|
||||
|
||||
|
||||
<!-- utility functions -->
|
||||
<script src="chrome://global/content/nsJSComponentManager.js"></script>
|
||||
<script src="chrome://vixen/content/vxUtils.js"></script>
|
||||
@ -17,10 +20,14 @@
|
||||
|
||||
<!-- transaction manager -->
|
||||
<script src="chrome://vixen/content/vfd/vxVFDTransactionManager.js"></script>
|
||||
<script src="chrome://vixen/content/txmgr/vxTransactionDataSource.js"></script>
|
||||
|
||||
<!-- selection manager -->
|
||||
<script src="chrome://vixen/content/vfd/vxVFDSelectionManager.js"></script>
|
||||
|
||||
<iframe id="vfdDocument" name="vfdDocument" flex="1"/>
|
||||
<keyset id="keyset"/>
|
||||
|
||||
<iframe id="vfdDocument" name="vfdDocument" src="about:blank" style="width:0px;" flex="1"/>
|
||||
|
||||
</window>
|
||||
|
@ -29,6 +29,8 @@ vxBaseTxn.prototype = {
|
||||
mID: null,
|
||||
|
||||
mListeners: [],
|
||||
|
||||
description: "",
|
||||
|
||||
notifyListeners: function (aEvent, aTransaction, aIRQ)
|
||||
{
|
||||
|
@ -21,14 +21,11 @@
|
||||
* Ben Goodger <ben@netscape.com> (Original Author)
|
||||
*/
|
||||
|
||||
const kTxnPrefix = "urn:mozilla:vixen:transactions:";
|
||||
|
||||
function vxVFDTransactionManager()
|
||||
{
|
||||
this.mTxnStack = new vxVFDTransactionStack();
|
||||
|
||||
vxVFDTransactionDS.init();
|
||||
|
||||
this.mDataSource = new vxTransactionDataSource();
|
||||
|
||||
// a record of transaction execution listeners that have attached
|
||||
// themselves to us.
|
||||
this.mTransactionListeners = [];
|
||||
@ -58,7 +55,7 @@ vxVFDTransactionManager.prototype =
|
||||
|
||||
if (!this.mTxnSeq) {
|
||||
// If a Transaction Seq does not exist, create one.
|
||||
this.mTxnSeq = this.makeSeq(vxVFDTransactionSeq);
|
||||
this.mTxnSeq = this.makeSeq(gVxTransactionRoot);
|
||||
}
|
||||
|
||||
if (this.mTxnStack.index < this.mTxnStack.mStack.length - 1) {
|
||||
@ -74,12 +71,11 @@ vxVFDTransactionManager.prototype =
|
||||
// append the transaction to our list
|
||||
this.mTxnStack.push(aTransaction);
|
||||
|
||||
// create a resource for the transaction and add to the
|
||||
// stack
|
||||
var resource = new RDFResource(kTxnPrefix + (this.mTxnStack.index-1));
|
||||
var commandProperty = new RDFLiteral(kTxnPrefix + "command-string");
|
||||
var commandString = new RDFLiteral(aTransaction.commandString);
|
||||
vxVFDTransactionDS.Assert(resource, commandProperty, commandString, true);
|
||||
var resource = this.mDataSource.mRDFS.GetResource(kTxnURI + (this.mTxnStack.index-1));
|
||||
var commandLiteral = this.mDataSource.mRDFS.GetLiteral(aTransaction.commandString);
|
||||
this.mDataSource.Assert(resource, gVxTxnCommandString, commandLiteral, true);
|
||||
var descriptionLiteral = this.mDataSource.mRDFS.GetLiteral(aTransaction.description);
|
||||
this.mDataSource.Assert(resource, gVxTxnDescription, descriptionLiteral, true);
|
||||
this.mTxnSeq.AppendElement(resource);
|
||||
|
||||
for (i = 0; i < this.mTransactionListeners.length; i++) {
|
||||
@ -156,7 +152,7 @@ vxVFDTransactionManager.prototype =
|
||||
const kContainerUtilsCID = "{d4214e92-fb94-11d2-bdd8-00104bde6048}";
|
||||
const kContainerUtilsIID = "nsIRDFContainerUtils";
|
||||
var utils = nsJSComponentManager.getServiceByID(kContainerUtilsCID, kContainerUtilsIID);
|
||||
return utils.MakeSeq(vxVFDTransactionDS, aResource);
|
||||
return utils.MakeSeq(this.mDataSource, aResource);
|
||||
},
|
||||
|
||||
/**
|
||||
@ -181,119 +177,6 @@ vxVFDTransactionManager.prototype =
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Implements nsIRDFDataSource
|
||||
*/
|
||||
var vxVFDTransactionDS =
|
||||
{
|
||||
init: function ()
|
||||
{
|
||||
var arc = new RDFResource("http://www.mozilla.org/projects/vixen/rdf#transaction-list");
|
||||
this.Assert(vxVFDTransactions, arc, vxVFDTransactionSeq, true);
|
||||
},
|
||||
|
||||
mResources: { },
|
||||
|
||||
HasAssertion: function (aSource, aProperty, aValue, aTruthValue)
|
||||
{
|
||||
var res = aSource.Value;
|
||||
if (!res) throw Components.results.NS_ERROR_FAILURE;
|
||||
var prop = aProperty.Value;
|
||||
if (!prop) throw Components.results.NS_ERROR_FAILURE;
|
||||
|
||||
if (this.mResources[res] &&
|
||||
this.mResources[res][prop] &&
|
||||
this.mResources[res][prop].EqualsNode(aValue))
|
||||
return true;
|
||||
return false;
|
||||
},
|
||||
|
||||
Assert: function (aSource, aProperty, aValue, aTruthVal)
|
||||
{
|
||||
var res = aSource.Value;
|
||||
if (!res) throw Components.results.NS_ERROR_FAILURE;
|
||||
var prop = aProperty.Value;
|
||||
if (!prop) throw Components.results.NS_ERROR_FAILURE;
|
||||
|
||||
if (!(res in this.mResources))
|
||||
this.mResources[res] = { };
|
||||
this.mResources[res][prop] = aValue;
|
||||
},
|
||||
|
||||
Unassert: function (aSource, aProperty, aValue, aTruthVal)
|
||||
{
|
||||
var res = aSource.Value;
|
||||
if (!res) throw Components.results.NS_ERROR_FAILURE;
|
||||
var prop = aProperty.Value;
|
||||
if (!prop) throw Components.results.NS_ERROR_FAILURE;
|
||||
if (!aValue) throw Components.results.NS_ERROR_FAILURE;
|
||||
|
||||
if (!this.mResources[res][prop])
|
||||
throw Components.results.NS_ERROR_FAILURE;
|
||||
|
||||
this.mResources[res][prop] = undefined;
|
||||
},
|
||||
|
||||
GetTarget: function (aSource, aProperty, aTruthValue)
|
||||
{
|
||||
var res = aSource.Value;
|
||||
if (!res) throw Components.results.NS_ERROR_FAILURE;
|
||||
var prop = aProperty.Value;
|
||||
if (!prop) throw Components.results.NS_ERROR_FAILURE;
|
||||
|
||||
if (this.mResources[res] != undefined &&
|
||||
this.mResources[res][prop] != undefined) {
|
||||
return this.mResources[res][prop].QueryInterface(Components.interfaces.nsIRDFNode);
|
||||
}
|
||||
throw Components.results.NS_ERROR_FAILURE;
|
||||
return null;
|
||||
},
|
||||
|
||||
GetTargets: function (aSource, aProperty, aTruthValue)
|
||||
{
|
||||
var targets = [].concat(this.GetTarget(aSource, aProperty, aTruthValue));
|
||||
return new ArrayEnumerator(targets);
|
||||
},
|
||||
|
||||
mObservers: [],
|
||||
AddObserver: function (aObserver)
|
||||
{
|
||||
this.mObservers[this.mObservers.length] = aObserver;
|
||||
},
|
||||
|
||||
RemoveObserver: function (aObserver)
|
||||
{
|
||||
for (var i = 0; i < this.mObservers.length; i++) {
|
||||
if (this.mObservers[i] == aObserver) {
|
||||
this.mObservers.splice(i, 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* The resource that wraps the transaction Seq (urn:mozilla:vixen:transactions)
|
||||
*/
|
||||
var vxVFDTransactions =
|
||||
{
|
||||
Value: "urn:mozilla:vixen:transactions"
|
||||
};
|
||||
|
||||
/**
|
||||
* The Transaction Seq
|
||||
*/
|
||||
var vxVFDTransactionSeq =
|
||||
{
|
||||
Value: "http://www.mozilla.org/projects/vixen/rdf#txnList"
|
||||
};
|
||||
|
||||
function stripRDFPrefix (aString)
|
||||
{
|
||||
var len = "http://www.w3.org/1999/02/22-rdf-syntax-ns#".length;
|
||||
return aString.substring(len, aString.length);
|
||||
}
|
||||
|
||||
/**
|
||||
* Transaction stack
|
||||
*/
|
||||
|
@ -22,6 +22,7 @@
|
||||
*/
|
||||
|
||||
const kMenuHeight = 130;
|
||||
const kPaletteWidth = 130;
|
||||
const kPropertiesWidth = 170;
|
||||
const kProjectWidth = 170;
|
||||
|
||||
@ -37,6 +38,10 @@ var vxShell =
|
||||
// Shell Startup
|
||||
// This requires several steps. Probably more, in time.
|
||||
|
||||
// append the controller
|
||||
var mainWindow = document.getElementById("vixenMain");
|
||||
mainWindow.controllers.insertControllerAt(0, CentralController);
|
||||
|
||||
// position and initialise the application window
|
||||
vxShell.initAppWindow();
|
||||
|
||||
@ -50,15 +55,15 @@ var vxShell =
|
||||
vxShell.loadPalette();
|
||||
|
||||
// load the history window
|
||||
// vxShell.loadHistory();
|
||||
vxShell.loadHistory();
|
||||
|
||||
// load a blank form (until projects come online)
|
||||
vxShell.focusedWindow = vxShell.loadDocument(null);
|
||||
vxShell.focusedWindow = vxShell.loadFormDesigner(null);
|
||||
|
||||
// initialise the document focus observer
|
||||
const kObserverServiceCONTRACTID = "@mozilla.org/observer-service;1";
|
||||
const kObserverServiceIID = "nsIObserverService";
|
||||
vxShell.mFocusObserver = nsJSComponentManager.getService(kObserverServiceCONTRACTID, kObserverServiceIID);
|
||||
vxShell.observerService = nsJSComponentManager.getService(kObserverServiceCONTRACTID, kObserverServiceIID);
|
||||
|
||||
},
|
||||
|
||||
@ -83,7 +88,7 @@ var vxShell =
|
||||
|
||||
// size the palette window
|
||||
hPalette.moveTo(0, kMenuHeight + 5);
|
||||
hPalette.outerWidth = kPropertiesWidth;
|
||||
hPalette.outerWidth = kPaletteWidth;
|
||||
hPalette.outerHeight = screen.availHeight - kMenuHeight - 60;
|
||||
},
|
||||
|
||||
@ -99,22 +104,30 @@ var vxShell =
|
||||
hHistory.outerHeight = screen.availHeight - kMenuHeight - 60;
|
||||
},
|
||||
|
||||
loadDocument: function (aURL)
|
||||
newDocument: function ()
|
||||
{
|
||||
_dd("vx_LoadDocument");
|
||||
// need to ask for document type in dialog
|
||||
this.loadFormDesigner(null);
|
||||
},
|
||||
|
||||
loadFormDesigner: function (aURL)
|
||||
{
|
||||
_ddf("vx_LoadDocument", aURL);
|
||||
// open a blank form designer window
|
||||
const features = "resizable=yes,dependent,chrome,dialog=yes";
|
||||
var params = {
|
||||
documentURL: aURL
|
||||
};
|
||||
|
||||
var rv = vxUtils.positionDocumentWindow("vixen:formdesigner");
|
||||
var hVFD = window.openDialog("chrome://vixen/content/vfd/vfd.xul", "", features, params);
|
||||
hVFD.moveTo(kPropertiesWidth + 5, kMenuHeight + 5);
|
||||
hVFD.outerWidth = screen.availWidth - kPropertiesWidth - kProjectWidth - 10;
|
||||
hVFD.outerHeight = screen.availHeight - kMenuHeight - 20;
|
||||
hVFD.moveTo(rv.x, rv.y);
|
||||
hVFD.outerWidth = screen.availWidth - kPropertiesWidth - kPaletteWidth - 20;
|
||||
hVFD.outerHeight = screen.availHeight - kMenuHeight - 40;
|
||||
return hVFD;
|
||||
},
|
||||
|
||||
loadDocumentWithUI: function ()
|
||||
loadFormDesignerWithUI: function ()
|
||||
{
|
||||
const kFilePickerIID = "nsIFilePicker";
|
||||
const kFilePickerCONTRACTID = "@mozilla.org/filepicker;1";
|
||||
@ -129,7 +142,7 @@ var vxShell =
|
||||
var filePicked = filePicker.show();
|
||||
if (filePicked == FP.returnOK && filePicker.file) {
|
||||
var file = filePicker.file.QueryInterface(Components.interfaces.nsILocalFile);
|
||||
return this.loadDocument(file.path);
|
||||
return this.loadFormDesigner(file.path);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
@ -147,7 +160,20 @@ var vxShell =
|
||||
{
|
||||
this.mFocusedWindow.vxVFD.mTxMgrShell.redoTransaction();
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* Save VFD
|
||||
*/
|
||||
saveDocument: function ()
|
||||
{
|
||||
var vixenShell = Components.classes["@mozilla.org/vixen/shell;1"].createInstance();
|
||||
if (vixenShell) {
|
||||
vixenShell = vixenShell.QueryInterface(Components.interfaces.nsIVixenShell);
|
||||
var focusedVFDDocument = this.mFocusedWindow.vxVFD.getContent(true).document;
|
||||
var documentAsString = vixenShell.encodeDocumentToString(focusedVFDDocument);
|
||||
_ddf("document as string", documentAsString);
|
||||
}
|
||||
},
|
||||
|
||||
appAbout: function ()
|
||||
{
|
||||
|
@ -25,6 +25,8 @@
|
||||
|
||||
<?xml-stylesheet href="chrome://communicator/skin/"?>
|
||||
|
||||
<?xul-overlay href="chrome://vixen/content/vxKeysetOverlay.xul"?>
|
||||
|
||||
<!--<!DOCTYPE window [
|
||||
<!ENTITY % brandDTD SYSTEM "chrome://global/locale/brand.dtd" >
|
||||
%brandDTD;
|
||||
@ -32,7 +34,7 @@
|
||||
%xuleditDTD;
|
||||
]>-->
|
||||
|
||||
<window id="xulEditMainWindow" class="color-dialog" orient="vertical"
|
||||
<window id="vixenMain" class="color-dialog" orient="vertical"
|
||||
title="ViXEn" windowtype="vixen:main"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||
onload="vxShell.startup();" onunload="vxShell.shutdown();">
|
||||
@ -40,20 +42,23 @@
|
||||
<script language="JavaScript" src="chrome://global/content/nsJSComponentManager.js"></script>
|
||||
<script language="JavaScript" src="chrome://global/content/globalOverlay.js"></script>
|
||||
|
||||
<script language="JavaScript" src="chrome://vixen/content/vxKeysetOverlay.js"></script>
|
||||
<script language="JavaScript" src="chrome://vixen/content/vixen.js"></script>
|
||||
<script language="JavaScript" src="chrome://vixen/content/vxUtils.js"></script>
|
||||
|
||||
<keyset id="vxKeyset">
|
||||
<key id="undo" key="z" oncommand="vxShell.undo();" modifiers="accel"/>
|
||||
<key id="redo" key="z" oncommand="vxShell.redo();" modifiers="accel, shift"/>
|
||||
</keyset>
|
||||
<keyset id="keyset"/>
|
||||
|
||||
<toolbox id="xuledit-toolbox" flex="1">
|
||||
<menubar id="xuledit-menubar">
|
||||
<menu id="menu_File" value="File" accesskey="f">
|
||||
<menupopup>
|
||||
<menuitem value="Open..." accesskey="o" oncommand="vxShell.loadDocumentWithUI();"/>
|
||||
<menuitem value="Exit" accesskey="x"/>
|
||||
<menuitem value="New..." accesskey="n" oncommand="vxShell.newDocument();"/>
|
||||
<menuseparator/>
|
||||
<menuitem value="Open..." accesskey="o" oncommand="vxShell.loadFormDesignerWithUI();"/>
|
||||
<menuseparator/>
|
||||
<menuitem value="Save As..." accesskey="a" oncommand="vxShell.saveDocument();"/>
|
||||
<menuseparator/>
|
||||
<menuitem value="Exit" accesskey="x" key="quitKey"/>
|
||||
</menupopup>
|
||||
</menu>
|
||||
<menu id="menu_Edit" value="Edit" accesskey="e">
|
||||
|
101
extensions/vixen/resources/content/vxKeysetOverlay.js
Normal file
101
extensions/vixen/resources/content/vxKeysetOverlay.js
Normal file
@ -0,0 +1,101 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 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 mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 2000 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Ben Goodger <ben@netscape.com> (Original Author)
|
||||
*/
|
||||
|
||||
var CentralController = {
|
||||
supportsCommand: function (aCommand)
|
||||
{
|
||||
_dd("supportscommand!");
|
||||
switch (aCommand) {
|
||||
case "cmd_quit":
|
||||
case "cmd_close":
|
||||
case "cmd_save":
|
||||
case "cmd_undo":
|
||||
case "cmd_redo":
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
},
|
||||
|
||||
isCommandEnabled: function (aCommand)
|
||||
{
|
||||
switch (aCommand) {
|
||||
case "cmd_quit":
|
||||
return true;
|
||||
case "cmd_close":
|
||||
// see if there's a document window open
|
||||
return true;
|
||||
case "cmd_save":
|
||||
// see if the current document is dirty
|
||||
return true;
|
||||
case "cmd_undo":
|
||||
// peek at the transaction stack for the current document
|
||||
return true;
|
||||
case "cmd_redo":
|
||||
// peek at the transaction stack for the current document
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
},
|
||||
|
||||
doCommand: function (aCommand)
|
||||
{
|
||||
_dd("doCommand!");
|
||||
switch (aCommand) {
|
||||
case "cmd_quit":
|
||||
// attempt to save changes to open documents and projects
|
||||
// kill the app
|
||||
vxUtils.shutDown();
|
||||
break;
|
||||
case "cmd_close":
|
||||
// find the most recent document
|
||||
var focusedWindow = vxUtils.getWindow("vixen:main").vxShell.mFocusedWindow;
|
||||
// attempt to save the loaded document if dirty
|
||||
this.doCommand("cmd_save");
|
||||
// close the window
|
||||
focusedWindow.close();
|
||||
break;
|
||||
case "cmd_save":
|
||||
// attempt to save the document in the active window
|
||||
break;
|
||||
case "cmd_undo":
|
||||
// the code in vxShell should eventually move into this file.
|
||||
vxUtils.getWindow("vixen:main").vxShell.undo();
|
||||
break;
|
||||
case "cmd_redo":
|
||||
// the code in vxShell should eventually move into this file.
|
||||
vxUtils.getWindow("vixen:main").vxShell.redo();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
},
|
||||
|
||||
onEvent: function (aEvent)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
25
extensions/vixen/resources/content/vxKeysetOverlay.xul
Normal file
25
extensions/vixen/resources/content/vxKeysetOverlay.xul
Normal file
@ -0,0 +1,25 @@
|
||||
<?xml version="1.0"?>
|
||||
|
||||
<!DOCTYPE window SYSTEM "chrome://vixen/locale/vxKeysetOverlay.dtd">
|
||||
|
||||
<overlay id="vixenKeysetOverlay"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
||||
|
||||
<script src="chrome://vixen/content/vxKeysetOverlay.js"></script>
|
||||
|
||||
<keyset id="keyset">
|
||||
<key id="quitKey" key="&vxQuitKey.commandKey;" modifiers="accel"
|
||||
oncommand="goDoCommand('cmd_quit');"/>
|
||||
<key id="closeKey" key="&vxCloseKey.commandKey;" modifiers="accel"
|
||||
oncommand="goDoCommand('cmd_close');"/>
|
||||
<key id="saveKey" key="&vxSaveKey.commandKey;" modifiers="accel"
|
||||
oncommand="goDoCommand('cmd_save');"/>
|
||||
<key id="undo" key="&vxUndoKey.commandKey;" modifiers="accel"
|
||||
oncommand="vxShell.undo();"/>
|
||||
<key id="redo" key="&vxRedoKey.commandKey;" modifiers="accel,shift"
|
||||
oncommand="vxShell.redo();"/>
|
||||
</keyset>
|
||||
|
||||
</overlay>
|
||||
|
||||
|
@ -40,8 +40,26 @@ var vxUtils = {
|
||||
const WM_CONTRACTID = "@mozilla.org/rdf/datasource;1?name=window-mediator";
|
||||
var wm = nsJSComponentManager.getService(WM_CONTRACTID, "nsIWindowMediator");
|
||||
return wm.getMostRecentWindow(aWindowType);
|
||||
}
|
||||
},
|
||||
|
||||
positionDocumentWindow: function (aWindowType)
|
||||
{
|
||||
var prevFD = vxUtils.getWindow(aWindowType);
|
||||
var x = kPaletteWidth + 5;
|
||||
var y = kMenuHeight + 5;
|
||||
if (prevFD) {
|
||||
x = prevFD.screenX + 10;
|
||||
y = prevFD.screenY + 10;
|
||||
var w = prevFD.outerWidth;
|
||||
var h = prevFD.outerHeight;
|
||||
if ((x + w) > (screen.availWidth - kPropertiesWidth) ||
|
||||
(y + h) > (screen.availHeight)) {
|
||||
x = kPaletteWidth + 5;
|
||||
y = kMenuHeight + 5;
|
||||
}
|
||||
}
|
||||
return { x: x, y: y };
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -1,29 +1,33 @@
|
||||
vixen.jar:
|
||||
content/vixen/contents.rdf (content/contents.rdf)
|
||||
content/vixen/vfdCommands.js (content/vfdCommands.js)
|
||||
content/vixen/vfdCommands.xul (content/vfdCommands.xul)
|
||||
content/vixen/vfdScratch.xul (content/vfdScratch.xul)
|
||||
content/vixen/vfdScratchDocument.xul (content/vfdScratchDocument.xul)
|
||||
content/vixen/vixen.js (content/vixen.js)
|
||||
content/vixen/vixen.xul (content/vixen.xul)
|
||||
content/vixen/vxUtils.js (content/vxUtils.js)
|
||||
content/vixen/xe_NavOverlay.xul (content/xe_NavOverlay.xul)
|
||||
content/vixen/palette/vxPalette.js (content/palette/vxPalette.js)
|
||||
content/vixen/palette/vxPalette.xul (content/palette/vxPalette.xul)
|
||||
content/vixen/vfd/scratch.xul (content/vfd/scratch.xul)
|
||||
content/vixen/vfd/vfd.js (content/vfd/vfd.js)
|
||||
content/vixen/vfd/vfd.xul (content/vfd/vfd.xul)
|
||||
+ content/vixen/vfd/vxChangeAttributeTxn.js (content/vfd/vxChangeAttributeTxn.js)
|
||||
content/vixen/vfd/vxCreateElementTxn.js (content/vfd/vxCreateElementTxn.js)
|
||||
content/vixen/vfd/vxVFDSelectionManager.js (content/vfd/vxVFDSelectionManager.js)
|
||||
content/vixen/vfd/vxVFDTransactionManager.js (content/vfd/vxVFDTransactionManager.js)
|
||||
content/vixen/vfd/vxAggregateTxn.js (content/vfd/vxAggregateTxn.js)
|
||||
content/vixen/vfd/vxBaseTxn.js (content/vfd/vxBaseTxn.js)
|
||||
content/vixen/history/history.xul (content/history/history.xul)
|
||||
content/vixen/history/history.js (content/history/history.js)
|
||||
skin/modern/vixen/contents.rdf (skin/contents.rdf)
|
||||
skin/modern/vixen/vfdScratch.css (skin/vfdScratch.css)
|
||||
locale/en-US/vixen/contents.rdf (locale/en-US/contents.rdf)
|
||||
locale/en-US/vixen/vfdScratch.dtd (locale/en-US/vfdScratch.dtd)
|
||||
locale/en-US/vixen/xuledit.dtd (locale/en-US/xuledit.dtd)
|
||||
content/vixen/contents.rdf (content/contents.rdf)
|
||||
content/vixen/vfdCommands.js (content/vfdCommands.js)
|
||||
content/vixen/vfdCommands.xul (content/vfdCommands.xul)
|
||||
content/vixen/vfdScratch.xul (content/vfdScratch.xul)
|
||||
content/vixen/vfdScratchDocument.xul (content/vfdScratchDocument.xul)
|
||||
content/vixen/vixen.js (content/vixen.js)
|
||||
content/vixen/vixen.xul (content/vixen.xul)
|
||||
content/vixen/vxUtils.js (content/vxUtils.js)
|
||||
content/vixen/xe_NavOverlay.xul (content/xe_NavOverlay.xul)
|
||||
content/vixen/vxKeysetOverlay.xul (content/vxKeysetOverlay.xul)
|
||||
content/vixen/vxKeysetOverlay.js (content/vxKeysetOverlay.js)
|
||||
content/vixen/palette/vxPalette.js (content/palette/vxPalette.js)
|
||||
content/vixen/palette/vxPalette.xul (content/palette/vxPalette.xul)
|
||||
content/vixen/vfd/scratch.xul (content/vfd/scratch.xul)
|
||||
content/vixen/vfd/vfd.js (content/vfd/vfd.js)
|
||||
content/vixen/vfd/vfd.xul (content/vfd/vfd.xul)
|
||||
content/vixen/vfd/vxChangeAttributeTxn.js (content/vfd/vxChangeAttributeTxn.js)
|
||||
content/vixen/vfd/vxCreateElementTxn.js (content/vfd/vxCreateElementTxn.js)
|
||||
content/vixen/vfd/vxVFDSelectionManager.js (content/vfd/vxVFDSelectionManager.js)
|
||||
content/vixen/vfd/vxVFDTransactionManager.js (content/vfd/vxVFDTransactionManager.js)
|
||||
content/vixen/txmgr/vxTransactionDataSource.js (content/txmgr/vxTransactionDataSource.js);
|
||||
content/vixen/vfd/vxAggregateTxn.js (content/vfd/vxAggregateTxn.js)
|
||||
content/vixen/vfd/vxBaseTxn.js (content/vfd/vxBaseTxn.js)
|
||||
content/vixen/history/history.xul (content/history/history.xul)
|
||||
content/vixen/history/history.js (content/history/history.js)
|
||||
skin/modern/vixen/contents.rdf (skin/contents.rdf)
|
||||
skin/modern/vixen/vfdScratch.css (skin/vfdScratch.css)
|
||||
locale/en-US/vixen/vxKeysetOverlay.dtd (locale/en-US/vxKeysetOverlay.dtd)
|
||||
locale/en-US/vixen/contents.rdf (locale/en-US/contents.rdf)
|
||||
locale/en-US/vixen/vfdScratch.dtd (locale/en-US/vfdScratch.dtd)
|
||||
locale/en-US/vixen/xuledit.dtd (locale/en-US/xuledit.dtd)
|
||||
|
||||
|
28
extensions/vixen/resources/locale/en-US/vxKeysetOverlay.dtd
Normal file
28
extensions/vixen/resources/locale/en-US/vxKeysetOverlay.dtd
Normal file
@ -0,0 +1,28 @@
|
||||
<!--
|
||||
- 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 mozilla.org code.
|
||||
|
||||
- The Initial Developer of the Original Code is Netscape
|
||||
- Communications Corporation. Portions created by Netscape are
|
||||
- Copyright (C) 2000 Netscape Communications Corporation.
|
||||
- All Rights Reserved.
|
||||
|
||||
- Contributor(s):
|
||||
Ben Goodger <ben@netscape.com> (Original Author)
|
||||
-->
|
||||
|
||||
<!ENTITY vxQuitKey.commandKey "q">
|
||||
<!ENTITY vxCloseKey.commandKey "w">
|
||||
<!ENTITY vxSaveKey.commandKey "s">
|
||||
<!ENTITY vxUndoKey.commandKey "z">
|
||||
<!ENTITY vxRedoKey.commandKey "z">
|
||||
|
Loading…
Reference in New Issue
Block a user