[Zope-CVS] CVS: Packages/Moztop/moztop/content/Inspector - Explorer.js:1.1 ExplorerOverlay.xul:1.11
Stephan Richter
srichter@cbu.edu
Thu, 16 Jan 2003 00:03:39 -0500
Update of /cvs-repository/Packages/Moztop/moztop/content/Inspector
In directory cvs.zope.org:/tmp/cvs-serv17745/moztop/content/Inspector
Modified Files:
ExplorerOverlay.xul
Added Files:
Explorer.js
Log Message:
Rename and Delete Objects from the Explorer are now working.
=== Added File Packages/Moztop/moztop/content/Inspector/Explorer.js ===
/*****************************************************************************
*
* Copyright (c) 2002, 2003 Zope Corporation and Contributors.
* All Rights Reserved.
*
* This software is subject to the provisions of the Zope Public License,
* Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
* WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
* FOR A PARTICULAR PURPOSE.
*
******************************************************************************
Explorer library; here to manage Content Object Tree.
$Id: Explorer.js,v 1.1 2003/01/16 05:03:07 srichter Exp $
******************************************************************************/
/* XML-RPC client setup. */
function getClient() {
return Components.classes['@mozilla.org/xml-rpc/client;1']
.createInstance(Components.interfaces.nsIXmlRpcClient);
}
var xmlRpcClient;
function getXmlRpc() {
if (!xmlRpcClient) xmlRpcClient = getClient();
return xmlRpcClient;
}
var Listener = {
onResult: function(client, ctxt, result) {
result = result.QueryInterface(
Components.interfaces.nsISupportsCString);
alert(result.toString());
},
onFault: function(client, ctxt, fault) {
alert('Fault! ' + fault + '\n');
},
onError: function(client, ctxt, status, errorMsg) {
alert('Error! <(' + status.toString(16) + ') ' + errorMsg + '>\n');
}
};
/* Send the Add request via XML-RPC and handle the result. */
function sendAddRequest(parent, obj_type, obj_name) {
var xmlRpc = getXmlRpc();
xmlRpc.init(XMLRPC_BASE + parent);
var type = xmlRpc.createType(xmlRpc.STRING, {});
type.data = obj_type;
var name = xmlRpc.createType(xmlRpc.STRING, {});
name.data = obj_name;
xmlRpc.asyncCall(Listener, null, 'createAndAdd', [type, name], 2);
}
/* Add a content object to the folder that is selected in the tree. */
function addContentObject() {
var type = document.getElementById("field_obj_type").selectedItem.label;
var name = document.getElementById("field_obj_name").value;
var tree = document.getElementById("navigationtree");
index = tree.view.selection.currentIndex;
rdf = tree.view.getItemAtIndex(index).resource;
var parent = rdf.Value.replace('urn:explorer:data', '') + '/';
while (parent.indexOf(":") > -1)
parent = parent.replace(":", "/");
sendAddRequest(parent, type, name);
}
/* Delete a content object from the folder that is selected in the tree. */
function deleteContentObject() {
var tree = document.getElementById("navigationtree");
index = tree.view.selection.currentIndex;
rdf = tree.view.getItemAtIndex(index).resource;
var parent = rdf.Value.replace('urn:explorer:data', '');
while (parent.indexOf(":") > -1)
parent = parent.replace(":", "/");
var parts = parent.split('/');
obj_name = parts[parts.length-1];
parent = parent.substring(0, parent.length-obj_name.length);
var xmlRpc = getXmlRpc();
xmlRpc.init(XMLRPC_BASE + parent);
var name = xmlRpc.createType(xmlRpc.STRING, {});
name.data = obj_name;
xmlRpc.asyncCall(Listener, null, 'deleteObject', [name], 1);
}
/* Rename a content object in the folder that is selected in the tree. */
function renameContentObject() {
var nobj_name = document.getElementById("field_obj_name").value;
var tree = document.getElementById("navigationtree");
index = tree.view.selection.currentIndex;
rdf = tree.view.getItemAtIndex(index).resource;
var parent = rdf.Value.replace('urn:explorer:data', '');
while (parent.indexOf(":") > -1)
parent = parent.replace(":", "/");
var parts = parent.split('/');
obj_name = parts[parts.length-1];
parent = parent.substring(0, parent.length-obj_name.length);
var xmlRpc = getXmlRpc();
xmlRpc.init(XMLRPC_BASE + parent);
var old_name = xmlRpc.createType(xmlRpc.STRING, {});
old_name.data = obj_name;
var new_name = xmlRpc.createType(xmlRpc.STRING, {});
new_name.data = nobj_name;
xmlRpc.asyncCall(Listener, null, 'renameObject', [old_name, new_name], 2);
}
=== Packages/Moztop/moztop/content/Inspector/ExplorerOverlay.xul 1.10 => 1.11 ===
--- Packages/Moztop/moztop/content/Inspector/ExplorerOverlay.xul:1.10 Wed Jan 15 12:38:48 2003
+++ Packages/Moztop/moztop/content/Inspector/ExplorerOverlay.xul Thu Jan 16 00:03:07 2003
@@ -4,6 +4,8 @@
xmlns:z="http://www.zope.org/rdf/content#"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/x-javascript" src="Explorer.js"/>
+
<tabpanel id="explorer-panel">
<tree flex="1" style="width:20em;"
id="navigationtree"
@@ -50,20 +52,25 @@
</rule>
</template>
</tree>
-<box orient="horizontal">
- <menulist id="field_obj_type" label="Type">
- <menupopup>
- <menuitem label="Folder" />
- <menuitem label="File" />
- <menuitem label="Image" />
- <menuitem label="ZPTPage" />
- <menuitem label="DTMLPage" />
- <menuitem label="SQLScript" />
- </menupopup>
- </menulist>
- <textbox id="field_obj_name" value="Name" flex="1"/>
- <button onclick="addContentObject();" label="Add" flex="1"/>
- <spacer flex="5" />
+<box orient="vertical">
+ <box orient="horizontal">
+ <menulist id="field_obj_type" label="Type">
+ <menupopup>
+ <menuitem label="Folder" />
+ <menuitem label="File" />
+ <menuitem label="Image" />
+ <menuitem label="ZPTPage" />
+ <menuitem label="DTMLPage" />
+ <menuitem label="SQLScript" />
+ </menupopup>
+ </menulist>
+ <textbox id="field_obj_name" value="Name" flex="1" />
+ </box>
+ <box orient="horizontal">
+ <button onclick="addContentObject();" label="Add" />
+ <button onclick="deleteContentObject();" label="Delete" />
+ <button onclick="renameContentObject();" label="Rename" />
+ </box>
</box>
</tabpanel>