[Zope-CVS] CVS: Packages/Moztop/moztop/content/Inspector - Explorer.js:1.4 ExplorerOverlay.xul:1.17

Sidnei da Silva sidnei@x3ng.com.br
Sun, 19 Jan 2003 10:06:13 -0500


Update of /cvs-repository/Packages/Moztop/moztop/content/Inspector
In directory cvs.zope.org:/tmp/cvs-serv25681/content/Inspector

Modified Files:
	Explorer.js ExplorerOverlay.xul 
Log Message:
First stab at a better copy-n-paste support. Will follow a interface definition & implementation in Zope3 (we didnt had copy support yet!)

=== Packages/Moztop/moztop/content/Inspector/Explorer.js 1.3 => 1.4 ===
--- Packages/Moztop/moztop/content/Inspector/Explorer.js:1.3	Fri Jan 17 10:50:47 2003
+++ Packages/Moztop/moztop/content/Inspector/Explorer.js	Sun Jan 19 10:06:10 2003
@@ -61,26 +61,15 @@
     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(":", "/");
+    var parent = getContainerPath()
+
     add(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 obj_name = getObjectName();
+    var parent = getContainerPath();
 
     var xmlRpc = getXmlRpc();
     xmlRpc.init(XMLRPC_BASE + parent);
@@ -92,21 +81,12 @@
 /* Rename a content object in the folder that is selected in the tree. */
 function renameContentObject() {
     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;
-    var parent = rdf.Value.replace('urn:explorer:data', '');
-    while (parent.indexOf(":") > -1)
-	parent = parent.replace(":", "/");
-
-    var parts = parent.split('/');
-    old_name = parts[parts.length-1];
-    parent = parent.substring(0, parent.length-old_name.length);
+    var old_name = getObjectName();
+    var parent = getContainerPath();
 
     rename(parent, old_name, new_name);
 }
 
-
 function rename(parent, old_name, new_name) {
     var xmlRpc = getXmlRpc();
     xmlRpc.init(XMLRPC_BASE + parent);
@@ -118,13 +98,54 @@
 }
 
 function cutContentObject() {
-    alert('Called cutContentObject.');
+    var obj_name = getObjectName();
+    var path = getContainerPath();
+
+    alert('Called cutContentObject for ' + obj_name + ' on ' + path +'.');
 }
 
 function copyContentObject() {
-    alert('Called copyContentObject.');
+    var obj_name = getObjectName();
+    var parent = getContainerPath();
+
+    var xmlRpc = getXmlRpc();
+    xmlRpc.init(XMLRPC_BASE + parent);
+    var name = xmlRpc.createType(xmlRpc.STRING, {});
+    name.data = obj_name;
+    xmlRpc.asyncCall(Listener, null, 'copyObject', [name], 1);
+
 }
 
 function pasteContentObject() {
-    alert('Called pasteContentObject.');
+    var path = getContainerPath();
+
+    alert('Called pasteContentObject on ' + path +'.');
 }
+
+/* Utility functions */
+function getPath() {
+    var tree = document.getElementById("navigationtree");
+    var index = tree.view.selection.currentIndex;
+    var rdf = tree.view.getItemAtIndex(index).resource;
+    var path = rdf.Value.replace('urn:explorer:data', '');
+    while (path.indexOf(":") > -1)
+	path = path.replace(":", "/");
+
+    return path
+}
+
+function getContainerPath() {
+    var path = getPath()
+    var obj_name = getObjectName()
+    var container = path.substring(0, path.length-obj_name.length);
+
+    return container
+}
+
+function getObjectName() {
+    var path = getPath()
+    var parts = path.split('/');
+    var obj_name = parts[parts.length-1];
+    
+    return obj_name
+}
\ No newline at end of file


=== Packages/Moztop/moztop/content/Inspector/ExplorerOverlay.xul 1.16 => 1.17 ===
--- Packages/Moztop/moztop/content/Inspector/ExplorerOverlay.xul:1.16	Fri Jan 17 10:50:47 2003
+++ Packages/Moztop/moztop/content/Inspector/ExplorerOverlay.xul	Sun Jan 19 10:06:10 2003
@@ -72,9 +72,16 @@
     <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" />
+    <button command="explorer-add:command" label="Add" />
+    <button command="explorer-delete:command" label="Delete" />
+    <button command="explorer-rename:command" label="Rename" />
+    <!--
+     XXX lets replace those buttons by icons. They are too wide and boring.
+
+    <button command="explorer-cut:command" label="Cut" />
+    <button command="explorer-copy:command" label="Copy" />
+    <button command="explorer-paste:command" label="Paste" />
+    -->
   </box>
 </box>
 
@@ -86,7 +93,9 @@
   <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();"/> 
+  <command id="explorer-cut:command" oncommand="cutContentObject();"/> 
+  <command id="explorer-copy:command" oncommand="copyContentObject();"/> 
+  <command id="explorer-paste:command" oncommand="pasteContentObject();"/> 
 </commandset> 
 
 <popupset>