[Zope-CVS] CVS: Packages/Moztop/moztop/content/Inspector - AddDialog.js:1.1 AddDialog.xul:1.1 RenameDialog.js:1.1 RenameDialog.xul:1.1 Explorer.js:1.3 ExplorerOverlay.xul:1.16
Stephan Richter
srichter@cbu.edu
Fri, 17 Jan 2003 10:51:21 -0500
Update of /cvs-repository/Packages/Moztop/moztop/content/Inspector
In directory cvs.zope.org:/tmp/cvs-serv9861/moztop/content/Inspector
Modified Files:
Explorer.js ExplorerOverlay.xul
Added Files:
AddDialog.js AddDialog.xul RenameDialog.js RenameDialog.xul
Log Message:
- Thanks to Jan for the updated icons! They are getting better every time.
- Finished implmenting the Context Menu in the Explorer. Add, Rename and
Delete work now.
=== Added File Packages/Moztop/moztop/content/Inspector/AddDialog.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.
*
******************************************************************************
Add dialog functionality.
$Id: AddDialog.js,v 1.1 2003/01/17 15:50:47 srichter Exp $
******************************************************************************/
function addObject() {
var type = document.getElementById("field_type").selectedItem.label;
var name = document.getElementById("field_name").value;
var doc = getDocumentOfWindowWithId("moztop-main-window");
var tree = doc.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(":", "/");
/* XXX There is a bug in the Dialog object code somehow, since the
listener cannot find the Components or any other global variable. */
add(parent, type, name);
}
=== Added File Packages/Moztop/moztop/content/Inspector/AddDialog.xul ===
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
<?xml-stylesheet href="chrome://moztop/skin" type="text/css"?>
<dialog id="rename-dialog" title="Rename object"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
buttons="accept,cancel"
ondialogaccept="addObject();">
<script type="application/x-javascript"
src="chrome://moztop/content/global.js"/>
<script type="application/x-javascript"
src="chrome://moztop/content/setup.js"/>
<script type="application/x-javascript"
src="chrome://moztop/content/Inspector/Explorer.js"/>
<script type="application/x-javascript" src="AddDialog.js"/>
<grid flex="1">
<columns>
<column/>
<column flex="1"/>
</columns>
<rows>
<row>
<label control="field_type" value="New Object Type"/>
<menulist id="field_type" label="Type">
<menupopup>
<menuitem label="Folder" />
<menuitem label="File" />
<menuitem label="Image" />
<menuitem label="ZPTPage" />
<menuitem label="DTMLPage" />
<menuitem label="SQLScript" />
</menupopup>
</menulist>
</row>
<row>
<label control="field_name" value="Name"/>
<textbox id="field_name" flex="1"/>
</row>
</rows>
</grid>
</dialog>
=== Added File Packages/Moztop/moztop/content/Inspector/RenameDialog.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.
*
******************************************************************************
Rename dialog functionality.
$Id: RenameDialog.js,v 1.1 2003/01/17 15:50:47 srichter Exp $
******************************************************************************/
function fillDialog() {
var doc = getDocumentOfWindowWithId("moztop-main-window");
var tree = doc.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];
var oldNameLabel = document.getElementById("field_oldName");
oldNameLabel.setAttribute('value', obj_name);
var newNameTextbox = document.getElementById("field_newName");
newNameTextbox.setAttribute('value', obj_name);
}
function renameObject() {
var old_name = document.getElementById("field_oldName").value;
var new_name = document.getElementById("field_newName").value;
var doc = getDocumentOfWindowWithId("moztop-main-window");
var tree = doc.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(":", "/");
parent = parent.substring(0, parent.length-old_name.length);
/* XXX There is a bug in the Dialog object code somehow, since the
listener cannot find the Components or any other global variable. */
rename(parent, old_name, new_name);
}
=== Added File Packages/Moztop/moztop/content/Inspector/RenameDialog.xul ===
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
<?xml-stylesheet href="chrome://moztop/skin" type="text/css"?>
<dialog id="rename-dialog" title="Rename object"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
buttons="accept,cancel"
onload="fillDialog();"
ondialogaccept="renameObject();">
<script type="application/x-javascript"
src="chrome://moztop/content/global.js"/>
<script type="application/x-javascript"
src="chrome://moztop/content/setup.js"/>
<script type="application/x-javascript"
src="chrome://moztop/content/Inspector/Explorer.js"/>
<script type="application/x-javascript" src="RenameDialog.js"/>
<grid flex="1">
<columns>
<column/>
<column flex="1"/>
</columns>
<rows>
<row>
<label control="field_oldName" value="Old Name"/>
<label id="field_oldName" value="Old Name"/>
</row>
<row>
<label control="field_newName" value="New Name"/>
<textbox id="field_newName" flex="1"/>
</row>
</rows>
</grid>
</dialog>
=== Packages/Moztop/moztop/content/Inspector/Explorer.js 1.2 => 1.3 ===
--- Packages/Moztop/moztop/content/Inspector/Explorer.js:1.2 Thu Jan 16 12:19:01 2003
+++ Packages/Moztop/moztop/content/Inspector/Explorer.js Fri Jan 17 10:50:47 2003
@@ -46,7 +46,7 @@
};
/* Send the Add request via XML-RPC and handle the result. */
-function sendAddRequest(parent, obj_type, obj_name) {
+function add(parent, obj_type, obj_name) {
var xmlRpc = getXmlRpc();
xmlRpc.init(XMLRPC_BASE + parent);
var type = xmlRpc.createType(xmlRpc.STRING, {});
@@ -66,7 +66,7 @@
var parent = rdf.Value.replace('urn:explorer:data', '') + '/';
while (parent.indexOf(":") > -1)
parent = parent.replace(":", "/");
- sendAddRequest(parent, type, name);
+ add(parent, type, name);
}
/* Delete a content object from the folder that is selected in the tree. */
@@ -91,7 +91,7 @@
/* 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 new_name = document.getElementById("field_obj_name").value;
var tree = document.getElementById("navigationtree");
index = tree.view.selection.currentIndex;
rdf = tree.view.getItemAtIndex(index).resource;
@@ -100,16 +100,21 @@
parent = parent.replace(":", "/");
var parts = parent.split('/');
- obj_name = parts[parts.length-1];
- parent = parent.substring(0, parent.length-obj_name.length);
+ old_name = parts[parts.length-1];
+ parent = parent.substring(0, parent.length-old_name.length);
+
+ rename(parent, old_name, new_name);
+}
+
+function rename(parent, old_name, new_name) {
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);
+ var oldName = xmlRpc.createType(xmlRpc.STRING, {});
+ oldName.data = old_name;
+ var newName = xmlRpc.createType(xmlRpc.STRING, {});
+ newName.data = new_name;
+ xmlRpc.asyncCall(Listener, null, 'renameObject', [oldName, newName], 2);
}
function cutContentObject() {
=== Packages/Moztop/moztop/content/Inspector/ExplorerOverlay.xul 1.15 => 1.16 ===
--- Packages/Moztop/moztop/content/Inspector/ExplorerOverlay.xul:1.15 Thu Jan 16 20:48:29 2003
+++ Packages/Moztop/moztop/content/Inspector/ExplorerOverlay.xul Fri Jan 17 10:50:47 2003
@@ -79,9 +79,13 @@
</box>
<commandset id="explorercommands">
- <command id="explorer-add:command" oncommand="addContentObject();"/>
+ <command id="explorer-add:command"
+ oncommand="window.openDialog('Inspector/AddDialog.xul',
+ 'Add', 'chrome,modal,centerscreen,width=300,height=100');"/>
<command id="explorer-delete:command" oncommand="deleteContentObject();"/>
- <command id="explorer-rename:command" oncommand="renameContentObject();"/>
+ <command id="explorer-rename:command"
+ oncommand="window.openDialog('Inspector/RenameDialog.xul',
+ 'Rename', 'chrome,modal,centerscreen,width=300,height=100');"/>
<command id="explorer-cut:command" oncommand="deleteContentObject();"/>
</commandset>