зеркало из https://github.com/mozilla/pjs.git
[ViXEn] Start laying groundwork for using Transaction Manager to handle editing requests.
Not part of build.
This commit is contained in:
Родитель
7a3ab7495c
Коммит
33ab9af7ac
|
@ -1,38 +0,0 @@
|
|||
#!nmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape 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/NPL/
|
||||
#
|
||||
# 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) 1998 Netscape Communications Corporation. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
|
||||
DEPTH=..\..\..\..
|
||||
include <$(DEPTH)/config/config.mak>
|
||||
|
||||
CHROME_DIR=packages\vixen
|
||||
CHROME_CONTENT_DIR=vixen\content
|
||||
|
||||
CHROME_CONTENT = \
|
||||
.\vfdCommands.xul \
|
||||
.\vfdCommands.js \
|
||||
.\vfdScratch.xul \
|
||||
.\vfdScratchDocument.xul \
|
||||
.\vixen.xul \
|
||||
.\vixen.js \
|
||||
.\xe_NavOverlay.xul \
|
||||
$(NULL)
|
||||
|
||||
include <$(DEPTH)\config\rules.mak>
|
|
@ -0,0 +1,45 @@
|
|||
/* -*- 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)
|
||||
*/
|
||||
|
||||
/**
|
||||
* This is a non-extensible palette. It will do for now.
|
||||
*/
|
||||
var vxPalette =
|
||||
{
|
||||
// we want to use controllers, but this will do to test our txns.
|
||||
insertButtonElement: function (aType)
|
||||
{
|
||||
_dd("insertButtonElement");
|
||||
var vixenMain = vxUtils.getWindow("vixen:main");
|
||||
var focusedWindow = vixenMain.vxShell.mFocusedWindow;
|
||||
var insertionPoint = focusedWindow.vxVFD.getInsertionPoint();
|
||||
|
||||
var vfdDocument = focusedWindow.vxVFD.getContent(true).document;
|
||||
_dd(vfdDocument);
|
||||
var buttontxn = new vxCreateElementTxn(vfdDocument, "button", insertionPoint.parent, insertionPoint.index);
|
||||
var txShell = focusedWindow.vxVFD.mTxMgrShell.doTransaction(buttontxn);
|
||||
}
|
||||
};
|
||||
|
||||
_dd("read vxPalette.js");
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
<?xml version="1.0"?>
|
||||
|
||||
<?xml-stylesheet href="chrome://communicator/skin/"?>
|
||||
|
||||
<window id="scratch" orient="vertical"
|
||||
title="Palette" windowtype="vixen:palette"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
||||
|
||||
<!-- utility functions -->
|
||||
<script src="chrome://vixen/content/vxUtils.js"></script>
|
||||
<script src="chrome://global/content/nsJSComponentManager.js"></script>
|
||||
|
||||
<!-- palette shell -->
|
||||
<script src="chrome://vixen/content/palette/vxPalette.js"></script>
|
||||
|
||||
<!-- supported txns -->
|
||||
<script src="chrome://vixen/content/vfd/vxChangeAttributeTxn.js"></script>
|
||||
<script src="chrome://vixen/content/vfd/vxCreateElementTxn.js"></script>
|
||||
|
||||
|
||||
<button value="Button" oncommand="vxPalette.insertButtonElement('button');"/>
|
||||
|
||||
</window>
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
#!nmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape 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/NPL/
|
||||
#
|
||||
# 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) 1998 Netscape Communications Corporation. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
|
||||
DEPTH=..\..\..\..\..
|
||||
include <$(DEPTH)/config/config.mak>
|
||||
|
||||
CHROME_DIR=packages\vixen
|
||||
CHROME_CONTENT_DIR=vixen\content\vfd
|
||||
|
||||
CHROME_CONTENT = \
|
||||
.\vfd.xul \
|
||||
.\vfd.js \
|
||||
.\vxVFDTransactionManager.js \
|
||||
.\vxVFDSelectionManager.js \
|
||||
.\scratch.xul \
|
||||
.\vxCreateElementTxn.js \
|
||||
.\vxChangeAttributeTxn.js \
|
||||
$(NULL)
|
||||
|
||||
include <$(DEPTH)\config\rules.mak>
|
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0"?>
|
||||
|
||||
<?xml-stylesheet href="chrome://communicator/skin/"?>
|
||||
|
||||
<window id="scratch" orient="vertical" class="dialog"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
||||
|
||||
</window>
|
|
@ -0,0 +1,93 @@
|
|||
/* -*- 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 vxVFD =
|
||||
{
|
||||
mParams : null,
|
||||
mTxMgrShell : null,
|
||||
mSelection : null,
|
||||
|
||||
getContent: function (asContext)
|
||||
{
|
||||
return asContext ? frames["vfdDocument"] : document.getElementById("vfdDocument");
|
||||
},
|
||||
|
||||
startup: function ()
|
||||
{
|
||||
// window parameters
|
||||
this.mParams = window.arguments[0];
|
||||
|
||||
// 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 windowNode = document.getElementById("vxVFD");
|
||||
windowNode.setAttribute("url", docURL);
|
||||
|
||||
// initialise the transaction manager shell
|
||||
this.mTxMgrShell = new vxVFDTransactionManager();
|
||||
|
||||
// initialise the selection manager
|
||||
this.mSelection = new vxVFDSelectionManager();
|
||||
},
|
||||
|
||||
focusVFD: function ()
|
||||
{
|
||||
var vixenMain = vxUtils.getWindow("vixen:main");
|
||||
// for a focused vfd, send "vfd,url"
|
||||
// vixenMain.vxShell.mFocusObserver.Notify({ }, "window_focus", ("vfd," + this.mParams.documentURL));
|
||||
vixenMain.vxShell.mFocusedWindow = window;
|
||||
_ddf("focused window, according to our parent, is", vixenMain.vxShell.mFocusedWindow);
|
||||
},
|
||||
|
||||
get vfdDocumentWindowNode()
|
||||
{
|
||||
var content = this.getContent(true);
|
||||
if (content && content.document) {
|
||||
if (content.document.hasChildNodes()) {
|
||||
var kids = content.document.childNodes;
|
||||
for (var i = 0; i < kids.length; i++) {
|
||||
if (kids[i].localName == "window")
|
||||
return kids[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
},
|
||||
|
||||
getInsertionPoint: function ()
|
||||
{
|
||||
if (this.mSelection && this.mSelection.selectionExists) {
|
||||
// compute the insertion point based on selection
|
||||
// XXX - TODO
|
||||
}
|
||||
else {
|
||||
// if no selection, return the window
|
||||
return { parent: this.vfdDocumentWindowNode, index: 0 };
|
||||
}
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
<?xml version="1.0"?>
|
||||
|
||||
<?xml-stylesheet href="chrome://communicator/skin/"?>
|
||||
|
||||
<window id="vxVFD" orient="vertical"
|
||||
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>
|
||||
|
||||
<!-- vfd shell -->
|
||||
<script src="chrome://vixen/content/vfd/vfd.js"></script>
|
||||
|
||||
<!-- transaction manager -->
|
||||
<script src="chrome://vixen/content/vfd/vxVFDTransactionManager.js"></script>
|
||||
<!-- selection manager -->
|
||||
<script src="chrome://vixen/content/vfd/vxVFDSelectionManager.js"></script>
|
||||
|
||||
<tabcontrol class="tabbed-edit" flex="1">
|
||||
<tabpanel flex="1">
|
||||
<iframe id="vfdDocument" name="vfdDocument" flex="1"/>
|
||||
<box id="vfdDOMTree" flex="1"/> <!-- from overlay -->
|
||||
</tabpanel>
|
||||
<tabbox>
|
||||
<tab value="Design"/>
|
||||
<tab value="DOM Tree"/>
|
||||
</tabbox>
|
||||
</tabcontrol>
|
||||
|
||||
</window>
|
||||
|
|
@ -0,0 +1,84 @@
|
|||
/* -*- 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)
|
||||
*/
|
||||
|
||||
/**
|
||||
* vxChangeAttributeTxn - Transaction for changing Attributes
|
||||
*
|
||||
* e.g., defocus or confirmation keystroke on field in attribute/property inspector,
|
||||
* var caTxn = vxChangeAttributeTxn(vxVFDDoc.getElementById(..),
|
||||
* ...value,
|
||||
* field.value,
|
||||
* false);
|
||||
* txMgr.doTransaction(caTxn); // txMgr is our own wrapper to
|
||||
* // nsITransactionManager that keeps
|
||||
* // UI elements in sync with the txMgr's deques.
|
||||
*
|
||||
* An example of attribute removal might be a selection of the attribute line, hitting
|
||||
* the delete key, or selecting the line, and choosing delete via a context menu.
|
||||
*/
|
||||
|
||||
function vxChangeAttributeTxn(aElement, aAttribute, aValue, aRemoveFlag)
|
||||
{
|
||||
this.mElement = aElement;
|
||||
this.mAttribute = aAttribute;
|
||||
this.mValue = aValue;
|
||||
this.mRemoveFlag = aRemoveFlag;
|
||||
}
|
||||
|
||||
vxChangeAttributeTxn.prototype = {
|
||||
doTransaction: function ()
|
||||
{
|
||||
this.mUndoValue = this.mElement.getAttribute(aAttribute);
|
||||
if (!this.mRemoveFlag)
|
||||
this.mElement.setAttribute(this.mAttribute, this.mValue);
|
||||
else
|
||||
this.mElement.removeAttribute(this.mAttribute);
|
||||
},
|
||||
|
||||
undoTransaction: function ()
|
||||
{
|
||||
if (this.mUndoValue)
|
||||
this.mElement.setAttribute(this.mAttribute, this.mUndoValue);
|
||||
else
|
||||
this.mElement.removeAttribute(this.mAttribute);
|
||||
},
|
||||
|
||||
redoTransaction: function ()
|
||||
{
|
||||
if (!this.mRemoveFlag)
|
||||
this.mElement.setAttribute(this.mAttribute, this.mValue);
|
||||
else
|
||||
this.mElement.removeAttribute(this.mAttribute);
|
||||
},
|
||||
|
||||
get commandString()
|
||||
{
|
||||
var commandString = "change-attribute,";
|
||||
commandString += this.mRemoveFlag ? "remove," : "set,";
|
||||
commandString += this.mElement.id + ",";
|
||||
commandString += this.mAttribute + ",";
|
||||
commandString += this.mValue;
|
||||
return commandString;
|
||||
}
|
||||
};
|
||||
|
|
@ -0,0 +1,84 @@
|
|||
/* -*- 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)
|
||||
*/
|
||||
|
||||
/**
|
||||
* vxCreateElementTxn - Transaction for creating DOM elements
|
||||
*
|
||||
* e.g., create a new element in the VFD document using the palette.
|
||||
*/
|
||||
|
||||
function vxCreateElementTxn(aDocument, aLocalName, aParentNode, aChildOffset)
|
||||
{
|
||||
this.mDocument = aDocument;
|
||||
this.mLocalName = aLocalName;
|
||||
this.mParentNode = aParentNode;
|
||||
this.mChildOffset = aChildOffset;
|
||||
}
|
||||
|
||||
vxCreateElementTxn.prototype = {
|
||||
doTransaction: function ()
|
||||
{
|
||||
this.mElement = this.mDocument.createElement(this.mLocalName);
|
||||
this.insertNode();
|
||||
},
|
||||
|
||||
undoTransaction: function ()
|
||||
{
|
||||
this.mParentNode.removeChild(this.mElement);
|
||||
},
|
||||
|
||||
redoTransaction: function ()
|
||||
{
|
||||
this.insertNode();
|
||||
},
|
||||
|
||||
insertNode: function ()
|
||||
{
|
||||
if (this.mParentNode.hasChildNodes() &&
|
||||
this.mParentNode.childNodes.length < this.mChildOffset+1) {
|
||||
var nextSibling = this.mParentNode.childNodes[this.mChildOffset+1]
|
||||
this.mParentNode.insertBefore(this.mElement, nextSibling);
|
||||
}
|
||||
else {
|
||||
this.mParentNode.appendChild(this.mElement);
|
||||
}
|
||||
},
|
||||
|
||||
get commandString()
|
||||
{
|
||||
var commandString = "create-element";
|
||||
commandString = this.mRemoveFlag ? "remove," : "set,";
|
||||
commandString += this.mElement.id + ",";
|
||||
commandString += this.mAttribute + ",";
|
||||
commandString += this.mValue;
|
||||
return commandString;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* txnStack["create-element"]("button", someBox, 3);
|
||||
**/
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
/* -*- 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)
|
||||
*/
|
||||
|
||||
function vxVFDSelectionManager ()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
vxVFDSelectionManager.prototype =
|
||||
{
|
||||
|
||||
};
|
||||
|
|
@ -0,0 +1,201 @@
|
|||
/* -*- 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)
|
||||
*/
|
||||
|
||||
function vxVFDTransactionManager()
|
||||
{
|
||||
const kTxMgrProgID = "component://netscape/transaction/manager";
|
||||
const kTxMgrIID = "nsITransactionManager";
|
||||
this.mTxMgr = nsJSComponentManager.getService(kTxMgrProgID, kTxMgrIID);
|
||||
}
|
||||
|
||||
vxVFDTransactionManager.prototype =
|
||||
{
|
||||
mTxMgr: null,
|
||||
mDoSeq: null,
|
||||
mUndoSeq: null,
|
||||
mTxnDS: null,
|
||||
|
||||
doTransaction: function (aTransaction)
|
||||
{
|
||||
// XXX Until the txmgr is fully scriptable, we need to perform the
|
||||
// transaction ourself
|
||||
aTransaction.doTransaction();
|
||||
|
||||
if (!this.mDoSeq) {
|
||||
// If a Transaction Seq does not exist, create one.
|
||||
this.makeSeq(vxVFDDoTransactionSeq);
|
||||
}
|
||||
_dd("we've successfully made a sequence\n");
|
||||
|
||||
// add the transaction to the stack
|
||||
this.mDoSeq.AppendElement(aTransaction);
|
||||
|
||||
if (!this.mTxMgr) {
|
||||
// If a Transaction Manager does not exist for this VFD,
|
||||
// create one.
|
||||
const kTxMgrPROGID = "component://netscape/transaction/manager";
|
||||
const kTxMgrIID = "nsITransactionManager";
|
||||
// XXX comment this out until this works
|
||||
// this.mTxMgr = nsJSComponentManager.getService(kTxMgrPROGID, kTxMgrIID);
|
||||
}
|
||||
|
||||
// do the transaction
|
||||
// XXX comment this out until this works
|
||||
// this.mTxMgr.doTransaction(aTransaction);
|
||||
},
|
||||
|
||||
undoTransaction: function ()
|
||||
{
|
||||
// XXX Until the txmgr is fully scriptable, we need to undo the
|
||||
// transaction ourself
|
||||
aTransaction.undoTransaction();
|
||||
|
||||
if (!this.mUndoSeq) {
|
||||
// If a Transaction Undo Seq does not exist, create one
|
||||
this.makeSeq(vxVFDUndoTransactionSeq);
|
||||
}
|
||||
|
||||
// remove the transaction at the top of the do seq
|
||||
var lastIndex = this.mDoSeq.GetCount() - 1;
|
||||
var txn = this.mDoSeq.RemoveElementAt(lastIndex, true);
|
||||
|
||||
// and add it to the undo seq
|
||||
this.mUndoSeq.AppendElement(txn);
|
||||
|
||||
// undo the transaction
|
||||
// XXX comment this out until this works
|
||||
// this.mTxMgr.undoTransaction();
|
||||
},
|
||||
|
||||
redoTransaction: function (aTransaction)
|
||||
{
|
||||
// XXX Until the txmgr is fully scriptable, we need to redo the
|
||||
// transaction ourself
|
||||
aTransaction.redoTransaction();
|
||||
|
||||
// remove the transaction at the top of the undo seq
|
||||
var lastIndex = this.mUndoSeq.GetCount() - 1;
|
||||
var txn = this.mDoSeq.RemoveElementAt(lastIndex, true);
|
||||
|
||||
// and add it to the do seq
|
||||
this.mDoSeq.AppendElement(txn);
|
||||
|
||||
// redo the transaction
|
||||
// XXX comment this out until this works
|
||||
// this.mTxMgr.redoTransaction();
|
||||
},
|
||||
|
||||
makeSeq: function (aResource)
|
||||
{
|
||||
const kContainerUtilsCID = "{d4214e92-fb94-11d2-bdd8-00104bde6048}";
|
||||
const kContainerUtilsIID = "nsIRDFContainerUtils";
|
||||
var utils = nsJSComponentManager.getServiceByID(kContainerUtilsCID, kContainerUtilsIID);
|
||||
this.mDoSeq = utils.MakeSeq(vxVFDTransactionDS, aResource);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Implements nsIRDFDataSource
|
||||
*/
|
||||
var vxVFDTransactionDS =
|
||||
{
|
||||
mResources: { },
|
||||
|
||||
HasAssertion: function (aSource, aProperty, aValue, aTruthValue)
|
||||
{
|
||||
_ddf("vxtxds::hasassertion", aValue);
|
||||
var res = aSource.Value;
|
||||
if (!res) throw Components.results.NS_ERROR_FAILURE;
|
||||
var prop = aProperty.Value;
|
||||
if (!prop) throw Components.results.NS_ERROR_FAILURE;
|
||||
_ddf("so, the values are", res + ", " + prop);
|
||||
|
||||
if (this.mResources[res] &&
|
||||
this.mResources[res][prop] &&
|
||||
this.mResources[res][prop].EqualsNode(aValue))
|
||||
return true;
|
||||
return false;
|
||||
},
|
||||
|
||||
Assert: function (aSource, aProperty, aValue, aTruthVal)
|
||||
{
|
||||
_dd("vxtxds::assert");
|
||||
var res = aSource.Value;
|
||||
if (!res) throw Components.results.NS_ERROR_FAILURE;
|
||||
var prop = aProperty.Value;
|
||||
if (!prop) throw Components.results.NS_ERROR_FAILURE;
|
||||
|
||||
this.mResources[res] = { };
|
||||
_ddf("going to assert into", res + ", " + prop);
|
||||
this.mResources[res][prop] = aValue;
|
||||
_ddf("value is now", this.mResources[res][prop]);
|
||||
},
|
||||
|
||||
Unassert: function (aSource, aProperty, aValue, aTruthVal)
|
||||
{
|
||||
_dd("vxtxds::unassert");
|
||||
var res = aSource.Value;
|
||||
if (!res) throw Components.results.NS_ERROR_FAILURE;
|
||||
var prop = aSource.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)
|
||||
{
|
||||
_dd("vxtxds::gettarget");
|
||||
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) {
|
||||
var thang = this.mResources[res][prop].QueryInterface(Components.interfaces.nsIRDFLiteral);
|
||||
_ddf("prop", thang.Value);
|
||||
return this.mResources[res][prop];
|
||||
}
|
||||
throw Components.results.NS_ERROR_FAILURE;
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Implements nsIRDFResource
|
||||
*/
|
||||
var vxVFDDoTransactionSeq =
|
||||
{
|
||||
Value: "vxVFDDoTransactionSeq"
|
||||
};
|
||||
|
||||
var vxVFDUndoTransactionSeq =
|
||||
{
|
||||
Value: "vxVFDUndoTransactionSeq"
|
||||
};
|
||||
|
||||
|
|
@ -1,79 +0,0 @@
|
|||
/* -*- 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.
|
||||
*
|
||||
* Original Author:
|
||||
* Ben Goodger <ben@netscape.com>
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
const XUL_NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
|
||||
var numButtons = 0;
|
||||
|
||||
var nsVFD = {
|
||||
|
||||
insertButtonElement: function (aButtonElementType)
|
||||
{
|
||||
switch (aButtonElementType) {
|
||||
case "button":
|
||||
var button = document.createElementNS(XUL_NS, "button");
|
||||
numButtons++;
|
||||
button.setAttribute("value", "Button"+numButtons);
|
||||
button.setAttribute("flex", "1");
|
||||
button.setAttribute("crop", "right");
|
||||
|
||||
this.genericInsertElement(button);
|
||||
break;
|
||||
case "toolbar-button":
|
||||
break;
|
||||
case "menu-button":
|
||||
break;
|
||||
}
|
||||
},
|
||||
|
||||
genericInsertElement: function (aElement)
|
||||
{
|
||||
var domDocument = getDocument();
|
||||
|
||||
// get the focused element so we know where to insert
|
||||
|
||||
// otherwise, just use the window
|
||||
var scratchWindow = getDocumentWindow(domDocument);
|
||||
|
||||
scratchWindow.appendChild(aElement);
|
||||
},
|
||||
};
|
||||
|
||||
function getDocumentWindow(aDocument)
|
||||
{
|
||||
if (!aDocument)
|
||||
aDocument = getDocument();
|
||||
|
||||
for (var i = 0; i < aDocument.childNodes.length; i++)
|
||||
if (aDocument.childNodes[i].localName == "window")
|
||||
return aDocument.childNodes[i];
|
||||
return null;
|
||||
}
|
||||
|
||||
function getDocument()
|
||||
{
|
||||
const WM_PROGID = "component://netscape/rdf/datasource?name=window-mediator";
|
||||
var wm = nsJSComponentManager.getService(WM_PROGID, "nsIWindowMediator");
|
||||
return wm.getMostRecentWindow("xuledit:document").frames["vfView"].document;
|
||||
}
|
|
@ -17,10 +17,8 @@
|
|||
- Copyright (C) 2000 Netscape Communications Corporation.
|
||||
- All Rights Reserved.
|
||||
|
||||
- Original Author:
|
||||
Ben Goodger <ben@netscape.com>
|
||||
|
||||
- Contributor(s):
|
||||
- Ben Goodger <ben@netscape.com> (Original Author)
|
||||
-->
|
||||
|
||||
<?xml-stylesheet href="chrome://communicator/skin/"?>
|
||||
|
|
|
@ -17,181 +17,115 @@
|
|||
* Copyright (C) 2000 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Original Author:
|
||||
* Ben Goodger <ben@netscape.com>
|
||||
*
|
||||
* Contributor(s):
|
||||
* Ben Goodger <ben@netscape.com> (Original Author)
|
||||
*/
|
||||
|
||||
|
||||
const _DEBUG = true;
|
||||
function _dd(aString)
|
||||
{
|
||||
if (_DEBUG)
|
||||
dump("*** " + aString + "\n");
|
||||
}
|
||||
|
||||
function _ddf(aString, aValue)
|
||||
{
|
||||
if (_DEBUG)
|
||||
dump("*** " + aString + " = " + aValue + "\n");
|
||||
}
|
||||
|
||||
const kMenuHeight = 130;
|
||||
const kPropertiesWidth = 170;
|
||||
const kProjectWidth = 170;
|
||||
|
||||
var gVixenShell;
|
||||
|
||||
function vx_Startup()
|
||||
var vxShell =
|
||||
{
|
||||
_dd("vx_Startup");
|
||||
|
||||
// initialise the vfd shell (this is not a service! need to shift to new_vfd)
|
||||
const kVixenProgid = "component://netscape/vixen/shell";
|
||||
gVixenShell = nsJSComponentManager.createInstance(kVixenProgid, "nsIVixenShell");
|
||||
gVixenShell.foopy = "Noopy";
|
||||
|
||||
_ddf("Foopy", gVixenShell.foopy);
|
||||
|
||||
// size the window
|
||||
window.moveTo(0,0);
|
||||
window.outerWidth = screen.availWidth;
|
||||
window.outerHeight = kMenuHeight;
|
||||
|
||||
// initialise commands
|
||||
controllers.insertControllerAt(0, defaultController);
|
||||
|
||||
// load a scratch document
|
||||
vx_LoadForm("chrome://vixen/content/vfdScratch.xul");
|
||||
|
||||
}
|
||||
mFocusObserver: null,
|
||||
mFocusedWindow: null,
|
||||
|
||||
function vx_Shutdown()
|
||||
{
|
||||
_dd("vx_Shutdown");
|
||||
|
||||
}
|
||||
|
||||
function vx_LoadForm(aURL)
|
||||
{
|
||||
hwnd = openDialog(aURL, "", "chrome,dialog=no,resizable,dependant");
|
||||
hwnd.moveTo(kPropertiesWidth + 5, kMenuHeight + 5);
|
||||
hwnd.outerWidth = screen.availWidth - (kPropertiesWidth * 2) - 5;
|
||||
hwnd.outerHeight = screen.availHeight - kMenuHeight - 20;
|
||||
}
|
||||
|
||||
var defaultController = {
|
||||
supportsCommand: function(command)
|
||||
startup: function ()
|
||||
{
|
||||
switch (command) {
|
||||
_dd("vx_Startup");
|
||||
|
||||
case "cmd_insert_button":
|
||||
case "cmd_insert_toolbarbutton":
|
||||
case "cmd_insert_menubutton":
|
||||
// Shell Startup
|
||||
// This requires several steps. Probably more, in time.
|
||||
|
||||
// position and initialise the application window
|
||||
vxShell.initAppWindow();
|
||||
|
||||
// load the property inspector
|
||||
// loadPropertyInspector();
|
||||
|
||||
// load document inspector window
|
||||
// loadDocumentInspector();
|
||||
|
||||
// load the palette
|
||||
vxShell.loadPalette();
|
||||
|
||||
// load a blank form (until projects come online)
|
||||
this.focusedWindow = vxShell.loadDocument(null);
|
||||
|
||||
// initialise the document focus observer
|
||||
const kObserverServicePROGID = "component://netscape/observer-service";
|
||||
const kObserverServiceIID = "nsIObserverService";
|
||||
this.mFocusObserver = nsJSComponentManager.getService(kObserverServicePROGID, kObserverServiceIID);
|
||||
|
||||
},
|
||||
|
||||
shutdown: function ()
|
||||
{
|
||||
_dd("vx_Shutdown");
|
||||
},
|
||||
|
||||
initAppWindow: function ()
|
||||
{
|
||||
// size the window
|
||||
moveTo(0,0);
|
||||
outerWidth = screen.availWidth;
|
||||
outerHeight = kMenuHeight;
|
||||
},
|
||||
|
||||
loadPalette: function ()
|
||||
{
|
||||
// open the palette window
|
||||
const features = "resizable=no,dependent,chrome,dialog=yes";
|
||||
var hPalette = openDialog("chrome://vixen/content/palette/vxPalette.xul", "", features);
|
||||
|
||||
case "cmd_insert_toplevel_menu":
|
||||
case "cmd_insert_menu":
|
||||
case "cmd_insert_menuseparator":
|
||||
case "cmd_insert_menulist":
|
||||
case "cmd_insert_combobox":
|
||||
|
||||
case "cmd_insert_textfield":
|
||||
case "cmd_insert_textarea":
|
||||
case "cmd_insert_rdf_editor":
|
||||
|
||||
case "cmd_insert_static":
|
||||
case "cmd_insert_wrapping":
|
||||
case "cmd_insert_image":
|
||||
case "cmd_insert_browser":
|
||||
|
||||
case "cmd_insert_box":
|
||||
case "cmd_insert_grid":
|
||||
case "cmd_insert_grid_row":
|
||||
case "cmd_insert_grid_col":
|
||||
case "cmd_insert_grid_spring":
|
||||
case "cmd_insert_splitter":
|
||||
return true;
|
||||
// size the palette window
|
||||
hPalette.moveTo(0, kMenuHeight + 5);
|
||||
hPalette.outerWidth = kPropertiesWidth;
|
||||
hPalette.outerHeight = screen.availHeight - kMenuHeight - 20;
|
||||
},
|
||||
|
||||
loadDocument: function (aURL)
|
||||
{
|
||||
_dd("vx_LoadDocument");
|
||||
// open a blank form designer window
|
||||
const features = "resizable=yes,dependent,chrome,dialog=yes";
|
||||
var params = {
|
||||
documentURL: aURL
|
||||
};
|
||||
var hVFD = window.openDialog("chrome://vixen/content/vfd/vfd.xul", "", features, params);
|
||||
_dd("we've opened a dialog succesfully");
|
||||
hVFD.moveTo(kPropertiesWidth + 5, kMenuHeight + 5);
|
||||
hVFD.outerWidth = screen.availWidth - kPropertiesWidth - kProjectWidth - 10;
|
||||
hVFD.outerHeight = screen.availHeight - kMenuHeight - 20;
|
||||
_dd("by all rights, we should be done");
|
||||
return hVFD;
|
||||
},
|
||||
|
||||
loadDocumentWithUI: function ()
|
||||
{
|
||||
const kFilePickerIID = "nsIFilePicker";
|
||||
const kFilePickerPROGID = "component://mozilla/filepicker";
|
||||
var filePicker = nsJSComponentManager.createInstance(kFilePickerPROGID, kFilePickerIID);
|
||||
if (filePicker) {
|
||||
const FP = Components.interfaces.nsIFilePicker;
|
||||
filePicker.init(window, "Open", FP.modeOpen);
|
||||
// XUL VFDs
|
||||
filePicker.appendFilter("XUL Files", "*.xul");
|
||||
// XXX-TODO: add filters for other types, e.g. string tables
|
||||
|
||||
default:
|
||||
return false;
|
||||
var filePicked = filePicker.show();
|
||||
if (filePicked == FP.returnOK && filePicker.file) {
|
||||
var file = filePicker.file.QueryInterface(Components.interfaces.nsILocalFile);
|
||||
return this.loadDocument(file.path);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
},
|
||||
|
||||
isCommandEnabled: function(command)
|
||||
appAbout: function ()
|
||||
{
|
||||
switch (command) {
|
||||
case "cmd_insert_button":
|
||||
case "cmd_insert_toolbarbutton":
|
||||
case "cmd_insert_menubutton":
|
||||
// XXX TEMP
|
||||
alert("ViXEn - The Visual XUL Environment.\nhttp://www.mozilla.org/projects/vixen/");
|
||||
}
|
||||
};
|
||||
|
||||
case "cmd_insert_toplevel_menu":
|
||||
case "cmd_insert_menu":
|
||||
case "cmd_insert_menuseparator":
|
||||
case "cmd_insert_menulist":
|
||||
case "cmd_insert_combobox":
|
||||
|
||||
case "cmd_insert_textfield":
|
||||
case "cmd_insert_textarea":
|
||||
case "cmd_insert_rdf_editor":
|
||||
|
||||
case "cmd_insert_static":
|
||||
case "cmd_insert_wrapping":
|
||||
case "cmd_insert_image":
|
||||
case "cmd_insert_browser":
|
||||
|
||||
case "cmd_insert_box":
|
||||
case "cmd_insert_grid":
|
||||
case "cmd_insert_grid_row":
|
||||
case "cmd_insert_grid_col":
|
||||
case "cmd_insert_grid_spring":
|
||||
case "cmd_insert_splitter":
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
},
|
||||
|
||||
doCommand: function(command)
|
||||
{
|
||||
switch (command)
|
||||
{
|
||||
|
||||
case "cmd_insert_button":
|
||||
nsVFD.insertButtonElement("button");
|
||||
return true;
|
||||
case "cmd_insert_toolbarbutton":
|
||||
case "cmd_insert_menubutton":
|
||||
|
||||
case "cmd_insert_toplevel_menu":
|
||||
case "cmd_insert_menu":
|
||||
case "cmd_insert_menuseparator":
|
||||
case "cmd_insert_menulist":
|
||||
case "cmd_insert_combobox":
|
||||
|
||||
case "cmd_insert_textfield":
|
||||
case "cmd_insert_textarea":
|
||||
case "cmd_insert_rdf_editor":
|
||||
|
||||
case "cmd_insert_static":
|
||||
case "cmd_insert_wrapping":
|
||||
case "cmd_insert_image":
|
||||
case "cmd_insert_browser":
|
||||
|
||||
case "cmd_insert_box":
|
||||
case "cmd_insert_grid":
|
||||
case "cmd_insert_grid_row":
|
||||
case "cmd_insert_grid_col":
|
||||
case "cmd_insert_grid_spring":
|
||||
case "cmd_insert_splitter":
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
},
|
||||
|
||||
onEvent: function(event)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,8 +25,6 @@
|
|||
|
||||
<?xml-stylesheet href="chrome://communicator/skin/"?>
|
||||
|
||||
<?xul-overlay href="chrome://vixen/content/vfdCommands.xul"?>
|
||||
|
||||
<!--<!DOCTYPE window [
|
||||
<!ENTITY % brandDTD SYSTEM "chrome://global/locale/brand.dtd" >
|
||||
%brandDTD;
|
||||
|
@ -35,22 +33,29 @@
|
|||
]>-->
|
||||
|
||||
<window id="xulEditMainWindow" class="color-dialog" orient="vertical"
|
||||
title="ViXEn"
|
||||
title="ViXEn" windowtype="vixen:main"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||
onload="vx_Startup()" onunload="vx_Shutdown();">
|
||||
onload="vxShell.startup();" onunload="vxShell.shutdown();">
|
||||
|
||||
<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/vixen.js"></script>
|
||||
<script language="JavaScript" src="chrome://vixen/content/vxUtils.js"></script>
|
||||
|
||||
<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"/>
|
||||
</menupopup>
|
||||
</menu>
|
||||
<menu id="menu_Help" value="Help" accesskey="h">
|
||||
<menupopup>
|
||||
<menuitem value="About" oncommand="vxShell.appAbout();"/>
|
||||
</menupopup>
|
||||
</menu>
|
||||
</menubar>
|
||||
<toolbar id="xuledit-toolbar" flex="1">
|
||||
<button class="button-toolbar" value="Button" oncommand="goDoCommand('cmd_insert_button');"/>
|
||||
|
|
|
@ -0,0 +1,46 @@
|
|||
/* -*- 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)
|
||||
*/
|
||||
|
||||
const _DEBUG = true;
|
||||
function _dd(aString)
|
||||
{
|
||||
if (_DEBUG)
|
||||
dump("*** " + aString + "\n");
|
||||
}
|
||||
|
||||
function _ddf(aString, aValue)
|
||||
{
|
||||
if (_DEBUG)
|
||||
dump("*** " + aString + " = " + aValue + "\n");
|
||||
}
|
||||
|
||||
var vxUtils = {
|
||||
getWindow: function (aWindowType)
|
||||
{
|
||||
const WM_PROGID = "component://netscape/rdf/datasource?name=window-mediator";
|
||||
var wm = nsJSComponentManager.getService(WM_PROGID, "nsIWindowMediator");
|
||||
return wm.getMostRecentWindow(aWindowType);
|
||||
}
|
||||
|
||||
};
|
||||
|
Загрузка…
Ссылка в новой задаче