[Sciviews-commits] r116 - in komodo/SciViews-K: . R components content content/js content/js/tools locale locale/en-GB locale/fr-FR skin skin/images

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed Feb 25 23:26:35 CET 2009


Author: prezez
Date: 2009-02-25 23:26:34 +0100 (Wed, 25 Feb 2009)
New Revision: 116

Added:
   komodo/SciViews-K/content/pkgManager.xul
   komodo/SciViews-K/locale/en-GB/main.properties
   komodo/SciViews-K/locale/fr-FR/main.properties
   komodo/SciViews-K/skin/images/R.png
   komodo/SciViews-K/skin/images/add.png
   komodo/SciViews-K/skin/images/database_link.png
   komodo/SciViews-K/skin/images/folder_home.png
   komodo/SciViews-K/skin/images/lm-blank.png
   komodo/SciViews-K/skin/images/package_install.png
   komodo/SciViews-K/skin/images/package_link.png
   komodo/SciViews-K/skin/images/run_all.png
   komodo/SciViews-K/skin/images/run_block.png
   komodo/SciViews-K/skin/images/run_function.png
   komodo/SciViews-K/skin/images/run_line.png
   komodo/SciViews-K/skin/images/run_para.png
   komodo/SciViews-K/skin/images/run_sel.png
   komodo/SciViews-K/skin/images/source_block.png
   komodo/SciViews-K/skin/images/source_function.png
   komodo/SciViews-K/skin/pkgManager.css
Modified:
   komodo/SciViews-K/R/
   komodo/SciViews-K/SciViews-K.kpf
   komodo/SciViews-K/components/
   komodo/SciViews-K/content/RBrowserOverlay.xul
   komodo/SciViews-K/content/js/commands.js
   komodo/SciViews-K/content/js/r-help.js
   komodo/SciViews-K/content/js/r.js
   komodo/SciViews-K/content/js/robjects.js
   komodo/SciViews-K/content/js/sciviews.js
   komodo/SciViews-K/content/js/tools/strings.js
   komodo/SciViews-K/content/overlayMain.xul
   komodo/SciViews-K/locale/
   komodo/SciViews-K/locale/en-GB/
   komodo/SciViews-K/locale/en-GB/sciviewsk.dtd
   komodo/SciViews-K/locale/fr-FR/
   komodo/SciViews-K/skin/
   komodo/SciViews-K/skin/images/
   komodo/SciViews-K/skin/sciviewsk.css
Log:
package management menu added to object browser
"rObjectsTree" object constructor cleanup
sv.getTextRange: function content selection method  rewritten
sv.getPart: is now wrapper for "sv.getTextRange" (the former kept only for backwards compatibility
added: addslashes method to String object
script internationalization:
added: sv.translate, stringbundle element to the overlay, and translatable strings in "main.properties"
new items in DTD
experimental idea: R package manager



Property changes on: komodo/SciViews-K/R
___________________________________________________________________
Name: svn:ignore
   + !*
*-dev.*


Modified: komodo/SciViews-K/SciViews-K.kpf
===================================================================
--- komodo/SciViews-K/SciViews-K.kpf	2009-02-22 13:39:43 UTC (rev 115)
+++ komodo/SciViews-K/SciViews-K.kpf	2009-02-25 22:26:34 UTC (rev 116)
@@ -1,9 +1,11 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- Komodo Project File - DO NOT EDIT -->
-<project id="6200c0ed-45ec-4f46-a159-284803d65c04" kpf_version="4" name="SciViews-K.kpf">
-<folder id="f5feb14c-33f6-a44d-ad41-ab38bf630926" idref="6200c0ed-45ec-4f46-a159-284803d65c04" name="Project">
-</folder>
-<macro async="0" icon="chrome://famfamfamsilk/skin/icons/wrench.png" id="08af6b57-9cc0-4848-9775-1bbecb5ab2c0" idref="f5feb14c-33f6-a44d-ad41-ab38bf630926" keyboard_shortcut="" language="JavaScript" name="Configure" rank="100" trigger="trigger_postopen" trigger_enabled="0">
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Komodo Project File - DO NOT EDIT -->
+<project id="6200c0ed-45ec-4f46-a159-284803d65c04" kpf_version="4" name="SciViews-K.kpf">
+<folder id="f5feb14c-33f6-a44d-ad41-ab38bf630926" idref="6200c0ed-45ec-4f46-a159-284803d65c04" name="Project">
+</folder>
+<file id="46c370a6-978b-4513-9cb8-056aebcf01f3" idref="aeee779f-9156-4b41-be2d-675d32098ff1" name="setup.xul" url="_prj_internal_/setup.xul">
+</file>
+<macro async="0" icon="chrome://famfamfamsilk/skin/icons/wrench.png" id="51c7310c-805d-4bcb-af72-57b51804be23" idref="aeee779f-9156-4b41-be2d-675d32098ff1" keyboard_shortcut="" language="JavaScript" name="Configure" rank="100" trigger="trigger_postopen" trigger_enabled="0">
 try {
 
 var libPart = ko.projects.findPart('macro', 'extension_lib', 'container');
@@ -66,8 +68,50 @@
 } catch(e) {
     alert(e);
 }
-</macro>
-<macro async="0" icon="chrome://famfamfamsilk/skin/icons/brick.png" id="1ea22b28-e1b5-a44d-a3e2-40e33f456acf" idref="f5feb14c-33f6-a44d-ad41-ab38bf630926" keyboard_shortcut="" language="JavaScript" name="extension_lib" rank="100" trigger="trigger_postopen" trigger_enabled="0">
+</macro>
+<macro async="0" icon="chrome://famfamfamsilk/skin/icons/lightning_go.png" id="a9aadbbc-4089-4c4e-b7ed-87089102aa06" idref="aeee779f-9156-4b41-be2d-675d32098ff1" keyboard_shortcut="" language="JavaScript" name="Build" rank="100" trigger="trigger_postopen" trigger_enabled="0">
+/**
+ * Script to build an xpi, running koext build in the current project root.
+ */
+
+var project = ko.macros.current.project;
+
+var os = Components.classes['@activestate.com/koOs;1'].
+  getService(Components.interfaces.koIOs);
+
+var koSysUtils = Components.classes["@activestate.com/koSysUtils;1"].
+  getService(Components.interfaces.koISysUtils);
+
+var appInfo = Components.classes["@mozilla.org/xre/app-info;1"].
+  getService(Components.interfaces.nsIXULRuntime);
+
+var koDirs = Components.classes['@activestate.com/koDirs;1'].
+  getService(Components.interfaces.koIDirs);
+
+var pythonExe = koDirs.pythonExe;
+var projectDir = ko.interpolate.interpolateStrings('%p');
+var scriptName = 'koext';
+
+if (appInfo.OS == 'WINNT') {
+  scriptName += ".py"; 
+}
+
+var arr = [koDirs.sdkDir, 'bin', scriptName]
+var app = os.path.joinlist(arr.length, arr);
+var cmd = '"'+pythonExe+'" "'+app+'" build -d "'+projectDir+'"';
+
+if (appInfo.OS == 'WINNT') {
+  cmd = '"' + cmd + '"';
+}
+var cwd = koDirs.mozBinDir;
+cmd += " {'cwd': u'"+cwd+"'}";
+
+ko.run.runEncodedCommand(window, cmd, function() {
+  ko.statusBar.AddMessage('Build complete', 'projects', 5000, true);
+  ko.projects.manager.saveProject(project);
+});
+</macro>
+<macro async="0" icon="chrome://famfamfamsilk/skin/icons/brick.png" id="ff0456a2-4546-480a-897e-6bc9f30d58a2" idref="aeee779f-9156-4b41-be2d-675d32098ff1" keyboard_shortcut="" language="JavaScript" name="extension_lib" rank="100" trigger="trigger_postopen" trigger_enabled="0">
 try {
     
 var extensionLib = function() {
@@ -227,8 +271,233 @@
 } catch(e) {
     allert(e);
 }
-</macro>
-<macro async="0" icon="chrome://famfamfamsilk/skin/icons/lightning_go.png" id="41904da6-0dd6-d747-8a6c-a2663e10578b" idref="f5feb14c-33f6-a44d-ad41-ab38bf630926" keyboard_shortcut="" language="JavaScript" name="Build" rank="100" trigger="trigger_postopen" trigger_enabled="0">
+</macro>
+<macro async="0" icon="chrome://famfamfamsilk/skin/icons/wrench.png" id="08af6b57-9cc0-4848-9775-1bbecb5ab2c0" idref="f5feb14c-33f6-a44d-ad41-ab38bf630926" keyboard_shortcut="" language="JavaScript" name="Configure" rank="100" trigger="trigger_postopen" trigger_enabled="0">
+try {
+
+var libPart = ko.projects.findPart('macro', 'extension_lib', 'container');
+eval(libPart.value);
+
+var koExt = new extensionLib();
+
+var project = ko.macros.current.project;
+
+var setupWin = project.getChildByAttributeValue('name','setup.xul', 1);
+var rdf = project.getChildByAttributeValue('name','install.rdf', 1);
+var data = {};
+
+var prefset = project.prefset;
+
+if(prefset.hasPrefHere('configured')) {
+    var rdf_xml = koExt.readFile(rdf.getFile().URI);
+    data = {
+        'valid': false,
+        'configured': true,
+        'vars': koExt.getRdfVars(rdf_xml)
+    };
+    data.vars['ext_name'] = koExt.getNiceName(data.vars.name);
+} else { // init data
+    data = {
+        'valid': false,
+        'configured': false,
+        'vars': {
+            'id': '',
+            'name': 'My Extension',
+            'creator': 'Me',
+            'version': '0.1',
+            'description': '',
+            'homepageURL': '',
+            'ext_name': ''
+        }
+    };
+}
+
+window.openDialog(
+    setupWin.getFile().URI,
+    "_blank",
+    "centerscreen,chrome,resizable,scrollbars,dialog=no,close,modal=yes",
+    data
+);
+
+if(data.valid) {
+    if(koExt.updateProject(data.vars)) {
+        prefset.setBooleanPref('configured', true);
+        var part = project.getChildByAttributeValue('name', 'oncreate',1);
+        if(part) { part.name = 'Configure'; }
+        var msg = 'Extension Project '+data.vars.name+' configured!';
+        ko.statusBar.AddMessage(msg, 'project', 3000, true);
+        ko.projects.manager.saveProject(project);
+    } else {
+        alert('Error encountered: '+koExt.error+"\nConfiguration aborted.");
+    }
+}
+
+} catch(e) {
+    alert(e);
+}
+</macro>
+<macro async="0" icon="chrome://famfamfamsilk/skin/icons/brick.png" id="1ea22b28-e1b5-a44d-a3e2-40e33f456acf" idref="f5feb14c-33f6-a44d-ad41-ab38bf630926" keyboard_shortcut="" language="JavaScript" name="extension_lib" rank="100" trigger="trigger_postopen" trigger_enabled="0">
+try {
+    
+var extensionLib = function() {
+    this.os = Components.classes['@activestate.com/koOs;1'].
+        getService(Components.interfaces.koIOs);
+    this.error = false;
+}
+
+extensionLib.prototype.getPath = function(relative) {
+    try {
+        var prj_path = ko.interpolate.interpolateStrings('%p');
+        path = this.os.path.join(prj_path, relative);
+        return path;
+    } catch(e) {
+        alert(e+"\narg name: "+name);
+    }
+}
+
+extensionLib.prototype.readFile = function(filename) {
+    // read the template file
+    try {
+        var fileEx = Components.classes["@activestate.com/koFileEx;1"]
+                .createInstance(Components.interfaces.koIFileEx);
+        fileEx.URI = filename;
+        fileEx.open('rb');
+        var content = fileEx.readfile();
+        fileEx.close();
+        return content;
+    } catch(e) {
+        alert(e+"\narg filename: "+filename);
+    }
+}
+
+extensionLib.prototype.writeFile = function(filename, content) {
+    try {
+        var fileEx = Components.classes["@activestate.com/koFileEx;1"]
+                .createInstance(Components.interfaces.koIFileEx);
+        fileEx.URI = filename;
+        fileEx.open('wb+');
+        fileEx.puts(content);
+        fileEx.close();
+    } catch(e) {
+        alert(e+"\narg filename: "+filename);
+    }
+}
+
+extensionLib.prototype.getRdfVars = function(txt) {
+    try {
+        var Rx = /\&lt;em\:([\w]+)[\ \S]*\&gt;([\S\ ]+?)\&lt;\//g;
+        var ext_vars = {};
+        while(results = Rx.exec(txt)) {
+            var idRx = /type|min|max|\{/;
+            if(!idRx.test(results[0])) { // filter out stuff we don't want
+                ext_vars[results[1]] = results[2];
+            }
+        }
+        return ext_vars;
+    } catch(e) {
+        alert(e+"\narg rdf_path: "+rdf_path);
+    }
+}
+
+extensionLib.prototype.getManifestVars = function(txt) {
+    try {
+        var rx1 = /content ([\S]+?) jar\:([\S]+?)\.jar/g;
+        var res1 = rx1.exec(txt);
+        var rx2 = /chrome:\/\/([\S]+?)\/content\/overlay\.xul/g;
+        var res2 = rx2.exec(txt);
+        return new Array(res1[1], res1[2], res2[1]);
+    } catch(e) {
+        alert(e+"\narg path: "+path);
+    }
+}
+
+extensionLib.prototype.getOverlayVars = function(txt) {
+    try {
+        var rx1 = /&lt;overlay id="([\S]+?)"/g;
+        var res1 = rx1.exec(txt);
+        var rx2 = /&lt;menuitem id="([\S]+?)"[\s]+?label="([\S\ ]+?)"/g;
+        var res2 = rx2.exec(txt);
+        return [res1[1], res2[1], res2[2]];
+    } catch(e) {
+        alert(e+"\narg path: "+path);
+    }
+}
+
+extensionLib.prototype.updateProject = function(vars) {
+    try {
+        var overlayPath = this.getPath('content/overlay.xul');
+        if(this.os.path.exists(overlayPath)) {
+            var ovl_str = this.readFile(overlayPath);
+            var ov_vars = this.getOverlayVars(ovl_str);
+            var ovl_new = [vars.ext_name+'Overlay', 'menu_'+vars.ext_name, vars.name];
+            this.writeFile(overlayPath, this.replaceAll(ov_vars, ovl_new, ovl_str));
+        } else { this.error = "Doesn't exist: "+overlayPath; return false; }
+        
+        var manifestPath = this.getPath('chrome.manifest');
+        if(this.os.path.exists(manifestPath)) {
+            var man_str = this.readFile(manifestPath);
+            var man_vars = this.getManifestVars(man_str);
+            var man_new = [vars.ext_name, vars.ext_name, vars.ext_name];
+            this.writeFile(manifestPath, this.replaceAll(man_vars, man_new, man_str));
+        } else { this.error = "Doesn't exist: "+overlayPath; return false; }
+        
+        var rdf_path = this.getPath('install.rdf');
+        if(this.os.path.exists(rdf_path)) {
+            var rdf_str = this.readFile(rdf_path);
+            var rdf_vars = this.getRdfVars(rdf_str);
+            this.writeFile(rdf_path, this.replaceAll(rdf_vars, vars, rdf_str));
+        } else { this.error = "Doesn't exist: "+overlayPath; return false; }
+        
+    } catch(e) {
+        this.error = e;
+        return false;
+    }
+    return true;
+}
+
+extensionLib.prototype.replaceAll = function(orig_vars, new_vars, str) {
+    try {
+        var out = str;
+        for(v in orig_vars) {
+            out = out.replace(orig_vars[v], new_vars[v]);
+        }
+        return out;
+    } catch(e) {
+        alert(e);
+    }
+}
+
+extensionLib.prototype.getNiceName = function(name) {
+    return this.trim(name).replace(/[\W]/g,'').toLowerCase();
+}
+
+extensionLib.prototype.trim = function(str) {
+    return str.replace(/^\s*/, '').replace(/\s*$/, '');
+}
+
+extensionLib.prototype.clone = function(obj) {
+    var newobj = {}; for(i in obj) {
+        newobj[i] = obj[i];
+    } return newobj;
+}
+
+extensionLib.prototype._dump = function(obj) {
+    var str = ''; for(i in obj) {
+        str += i+': '+obj[i]+'\n';
+    } return(str);
+}
+
+extensionLib.prototype._keys = function(obj) {
+  var out = new Array(); for(i in obj) {
+    out.push(i);
+  } return out;
+}
+
+} catch(e) {
+    allert(e);
+}
+</macro>
+<macro async="0" icon="chrome://famfamfamsilk/skin/icons/lightning_go.png" id="41904da6-0dd6-d747-8a6c-a2663e10578b" idref="f5feb14c-33f6-a44d-ad41-ab38bf630926" keyboard_shortcut="" language="JavaScript" name="Build" rank="100" trigger="trigger_postopen" trigger_enabled="0">
 /**
  * Script to build an xpi, running koext build in the current project root.
  */
@@ -269,15 +538,284 @@
   ko.statusBar.AddMessage('Build complete', 'projects', 5000, true);
   ko.projects.manager.saveProject(project);
 });
-</macro>
-<file id="ce09e80e-4f8e-784c-81c1-6564f46e2cf8" idref="f5feb14c-33f6-a44d-ad41-ab38bf630926" name="setup.xul" url="_prj_internal_/setup.xul">
-</file>
-<preference-set idref="6200c0ed-45ec-4f46-a159-284803d65c04">
-  <boolean id="configured">1</boolean>
-  <string id="import_exclude_matches">*.*~;*.bak;*.tmp;CVS;.#*;*.pyo;*.pyc;.svn;*%*;tmp*.html;.DS_Store;_prj_internal_</string>
-  <string id="import_include_matches"></string>
-  <boolean id="import_live">1</boolean>
-  <boolean id="import_recursive">1</boolean>
-  <string id="import_type">useFolders</string>
-</preference-set>
-</project>
+</macro>
+<file id="ce09e80e-4f8e-784c-81c1-6564f46e2cf8" idref="f5feb14c-33f6-a44d-ad41-ab38bf630926" name="setup.xul" url="_prj_internal_/setup.xul">
+</file>
+<file id="1d542d8f-6043-4618-85b2-750f688afb86" idref="fd57ad7e-32b5-46a5-8b5a-36f513b953ad" name="setup.xul" url="_prj_internal_/setup.xul">
+</file>
+<macro async="0" icon="chrome://famfamfamsilk/skin/icons/wrench.png" id="45c63c14-27f6-4b60-b387-43ea4946597f" idref="fd57ad7e-32b5-46a5-8b5a-36f513b953ad" keyboard_shortcut="" language="JavaScript" name="Configure" rank="100" trigger="trigger_postopen" trigger_enabled="0">
+try {
+
+var libPart = ko.projects.findPart('macro', 'extension_lib', 'container');
+eval(libPart.value);
+
+var koExt = new extensionLib();
+
+var project = ko.macros.current.project;
+
+var setupWin = project.getChildByAttributeValue('name','setup.xul', 1);
+var rdf = project.getChildByAttributeValue('name','install.rdf', 1);
+var data = {};
+
+var prefset = project.prefset;
+
+if(prefset.hasPrefHere('configured')) {
+    var rdf_xml = koExt.readFile(rdf.getFile().URI);
+    data = {
+        'valid': false,
+        'configured': true,
+        'vars': koExt.getRdfVars(rdf_xml)
+    };
+    data.vars['ext_name'] = koExt.getNiceName(data.vars.name);
+} else { // init data
+    data = {
+        'valid': false,
+        'configured': false,
+        'vars': {
+            'id': '',
+            'name': 'My Extension',
+            'creator': 'Me',
+            'version': '0.1',
+            'description': '',
+            'homepageURL': '',
+            'ext_name': ''
+        }
+    };
+}
+
+window.openDialog(
+    setupWin.getFile().URI,
+    "_blank",
+    "centerscreen,chrome,resizable,scrollbars,dialog=no,close,modal=yes",
+    data
+);
+
+if(data.valid) {
+    if(koExt.updateProject(data.vars)) {
+        prefset.setBooleanPref('configured', true);
+        var part = project.getChildByAttributeValue('name', 'oncreate',1);
+        if(part) { part.name = 'Configure'; }
+        var msg = 'Extension Project '+data.vars.name+' configured!';
+        ko.statusBar.AddMessage(msg, 'project', 3000, true);
+        ko.projects.manager.saveProject(project);
+    } else {
+        alert('Error encountered: '+koExt.error+"\nConfiguration aborted.");
+    }
+}
+
+} catch(e) {
+    alert(e);
+}
+</macro>
+<macro async="0" icon="chrome://famfamfamsilk/skin/icons/lightning_go.png" id="4b74a155-8acd-4a55-97e9-f193ab92dc4a" idref="fd57ad7e-32b5-46a5-8b5a-36f513b953ad" keyboard_shortcut="" language="JavaScript" name="Build" rank="100" trigger="trigger_postopen" trigger_enabled="0">
+/**
+ * Script to build an xpi, running koext build in the current project root.
+ */
+
+var project = ko.macros.current.project;
+
+var os = Components.classes['@activestate.com/koOs;1'].
+  getService(Components.interfaces.koIOs);
+
+var koSysUtils = Components.classes["@activestate.com/koSysUtils;1"].
+  getService(Components.interfaces.koISysUtils);
+
+var appInfo = Components.classes["@mozilla.org/xre/app-info;1"].
+  getService(Components.interfaces.nsIXULRuntime);
+
+var koDirs = Components.classes['@activestate.com/koDirs;1'].
+  getService(Components.interfaces.koIDirs);
+
+var pythonExe = koDirs.pythonExe;
+var projectDir = ko.interpolate.interpolateStrings('%p');
+var scriptName = 'koext';
+
+if (appInfo.OS == 'WINNT') {
+  scriptName += ".py"; 
+}
+
+var arr = [koDirs.sdkDir, 'bin', scriptName]
+var app = os.path.joinlist(arr.length, arr);
+var cmd = '"'+pythonExe+'" "'+app+'" build -d "'+projectDir+'"';
+
+if (appInfo.OS == 'WINNT') {
+  cmd = '"' + cmd + '"';
+}
+var cwd = koDirs.mozBinDir;
+cmd += " {'cwd': u'"+cwd+"'}";
+
+ko.run.runEncodedCommand(window, cmd, function() {
+  ko.statusBar.AddMessage('Build complete', 'projects', 5000, true);
+  ko.projects.manager.saveProject(project);
+});
+</macro>
+<macro async="0" icon="chrome://famfamfamsilk/skin/icons/brick.png" id="a2c99057-bcb3-43d5-8284-66628a53eadb" idref="fd57ad7e-32b5-46a5-8b5a-36f513b953ad" keyboard_shortcut="" language="JavaScript" name="extension_lib" rank="100" trigger="trigger_postopen" trigger_enabled="0">
+try {
+    
+var extensionLib = function() {
+    this.os = Components.classes['@activestate.com/koOs;1'].
+        getService(Components.interfaces.koIOs);
+    this.error = false;
+}
+
+extensionLib.prototype.getPath = function(relative) {
+    try {
+        var prj_path = ko.interpolate.interpolateStrings('%p');
+        path = this.os.path.join(prj_path, relative);
+        return path;
+    } catch(e) {
+        alert(e+"\narg name: "+name);
+    }
+}
+
+extensionLib.prototype.readFile = function(filename) {
+    // read the template file
+    try {
+        var fileEx = Components.classes["@activestate.com/koFileEx;1"]
+                .createInstance(Components.interfaces.koIFileEx);
+        fileEx.URI = filename;
+        fileEx.open('rb');
+        var content = fileEx.readfile();
+        fileEx.close();
+        return content;
+    } catch(e) {
+        alert(e+"\narg filename: "+filename);
+    }
+}
+
+extensionLib.prototype.writeFile = function(filename, content) {
+    try {
+        var fileEx = Components.classes["@activestate.com/koFileEx;1"]
+                .createInstance(Components.interfaces.koIFileEx);
+        fileEx.URI = filename;
+        fileEx.open('wb+');
+        fileEx.puts(content);
+        fileEx.close();
+    } catch(e) {
+        alert(e+"\narg filename: "+filename);
+    }
+}
+
+extensionLib.prototype.getRdfVars = function(txt) {
+    try {
+        var Rx = /\&lt;em\:([\w]+)[\ \S]*\&gt;([\S\ ]+?)\&lt;\//g;
+        var ext_vars = {};
+        while(results = Rx.exec(txt)) {
+            var idRx = /type|min|max|\{/;
+            if(!idRx.test(results[0])) { // filter out stuff we don't want
+                ext_vars[results[1]] = results[2];
+            }
+        }
+        return ext_vars;
+    } catch(e) {
+        alert(e+"\narg rdf_path: "+rdf_path);
+    }
+}
+
+extensionLib.prototype.getManifestVars = function(txt) {
+    try {
+        var rx1 = /content ([\S]+?) jar\:([\S]+?)\.jar/g;
+        var res1 = rx1.exec(txt);
+        var rx2 = /chrome:\/\/([\S]+?)\/content\/overlay\.xul/g;
+        var res2 = rx2.exec(txt);
+        return new Array(res1[1], res1[2], res2[1]);
+    } catch(e) {
+        alert(e+"\narg path: "+path);
+    }
+}
+
+extensionLib.prototype.getOverlayVars = function(txt) {
+    try {
+        var rx1 = /&lt;overlay id="([\S]+?)"/g;
+        var res1 = rx1.exec(txt);
+        var rx2 = /&lt;menuitem id="([\S]+?)"[\s]+?label="([\S\ ]+?)"/g;
+        var res2 = rx2.exec(txt);
+        return [res1[1], res2[1], res2[2]];
+    } catch(e) {
+        alert(e+"\narg path: "+path);
+    }
+}
+
+extensionLib.prototype.updateProject = function(vars) {
+    try {
+        var overlayPath = this.getPath('content/overlay.xul');
+        if(this.os.path.exists(overlayPath)) {
+            var ovl_str = this.readFile(overlayPath);
+            var ov_vars = this.getOverlayVars(ovl_str);
+            var ovl_new = [vars.ext_name+'Overlay', 'menu_'+vars.ext_name, vars.name];
+            this.writeFile(overlayPath, this.replaceAll(ov_vars, ovl_new, ovl_str));
+        } else { this.error = "Doesn't exist: "+overlayPath; return false; }
+        
+        var manifestPath = this.getPath('chrome.manifest');
+        if(this.os.path.exists(manifestPath)) {
+            var man_str = this.readFile(manifestPath);
+            var man_vars = this.getManifestVars(man_str);
+            var man_new = [vars.ext_name, vars.ext_name, vars.ext_name];
+            this.writeFile(manifestPath, this.replaceAll(man_vars, man_new, man_str));
+        } else { this.error = "Doesn't exist: "+overlayPath; return false; }
+        
+        var rdf_path = this.getPath('install.rdf');
+        if(this.os.path.exists(rdf_path)) {
+            var rdf_str = this.readFile(rdf_path);
+            var rdf_vars = this.getRdfVars(rdf_str);
+            this.writeFile(rdf_path, this.replaceAll(rdf_vars, vars, rdf_str));
+        } else { this.error = "Doesn't exist: "+overlayPath; return false; }
+        
+    } catch(e) {
+        this.error = e;
+        return false;
+    }
+    return true;
+}
+
+extensionLib.prototype.replaceAll = function(orig_vars, new_vars, str) {
+    try {
+        var out = str;
+        for(v in orig_vars) {
+            out = out.replace(orig_vars[v], new_vars[v]);
+        }
+        return out;
+    } catch(e) {
+        alert(e);
+    }
+}
+
+extensionLib.prototype.getNiceName = function(name) {
+    return this.trim(name).replace(/[\W]/g,'').toLowerCase();
+}
+
+extensionLib.prototype.trim = function(str) {
+    return str.replace(/^\s*/, '').replace(/\s*$/, '');
+}
+
+extensionLib.prototype.clone = function(obj) {
+    var newobj = {}; for(i in obj) {
+        newobj[i] = obj[i];
+    } return newobj;
+}
+
+extensionLib.prototype._dump = function(obj) {
+    var str = ''; for(i in obj) {
+        str += i+': '+obj[i]+'\n';
+    } return(str);
+}
+
+extensionLib.prototype._keys = function(obj) {
+  var out = new Array(); for(i in obj) {
+    out.push(i);
+  } return out;
+}
+
+} catch(e) {
+    allert(e);
+}
+</macro>
+<preference-set idref="6200c0ed-45ec-4f46-a159-284803d65c04">
+  <boolean id="configured">1</boolean>
+  <string id="import_exclude_matches">*.*~;*.bak;*.tmp;CVS;.#*;*.pyo;*.pyc;.svn;*%*;tmp*.html;.DS_Store;_prj_internal_</string>
+  <string id="import_include_matches"></string>
+  <boolean id="import_live">1</boolean>
+  <boolean id="import_recursive">1</boolean>
+  <string id="import_type">useFolders</string>
+</preference-set>
+</project>


Property changes on: komodo/SciViews-K/components
___________________________________________________________________
Name: svn:ignore
   + !*
*-dev.*


Modified: komodo/SciViews-K/content/RBrowserOverlay.xul
===================================================================
--- komodo/SciViews-K/content/RBrowserOverlay.xul	2009-02-22 13:39:43 UTC (rev 115)
+++ komodo/SciViews-K/content/RBrowserOverlay.xul	2009-02-25 22:26:34 UTC (rev 116)
@@ -81,12 +81,10 @@
   </menupopup>
 </popupset>
 
-
-
 <broadcasterset id="broadcasterset_global">
   <broadcaster
     id="cmd_robjects_viewSearchPath"
-    desc="&sciviews.robjects.tab;: &sciviews.robjects.showHide;"
+    tooltiptext="&sciviews.robjects.tab;: &sciviews.robjects.showHide;"
     label="&sciviews.robjects.showHide;"
     splitter="bottom_splitter"
     box="robjects_searchpath_panel"
@@ -186,17 +184,53 @@
 		  />
 		  <toolbarbutton
 		    id="sciviews_robjects_searchpath_button"
-                observes="cmd_robjects_viewSearchPath"
+            observes="cmd_robjects_viewSearchPath"
 		    buttonstyle="pictures"
 		    class="searchPath-icon"
+			checked="true"
+			persist="state checked"
 		  />
-              <toolbarbutton
-		    id="sciviews_robjects_loadPkg_button"
+		  <toolbarbutton
+		    id="r_objects_pkg_menu"
 		    buttonstyle="pictures"
-		    class="robjects-loadPkg-icon"
-                oncommand="sv.r.pkg.load();"
-		  />
+		    class="robjects-pkg-icon"
+			type="menu"
+			orient="horizontal">
+			<menupopup>
+			  <menuitem id="r_objects_pkg_load"
+						label="Load packages..."
+						accesskey="l"
+						class="menuitem-iconic r-pkg-load-icon"
+						oncommand="sv.r.pkg.load();" />
+			  <menuitem id="r_objects_pkg_load"
+						label="Attach workspace..."
+						accesskey="a"
+						class="menuitem-iconic r-data-attach"
+						oncommand="sv.r.loadWorkspace(null, true);" />
 
+			  <menuitem id="r_objects_pkg_install"
+						label="Install..."
+						accesskey="i"
+						class="menuitem-iconic r-pkg-install-icon"
+						oncommand="sv.r.pkg.install();" />
+			  <menuitem id="r_objects_pkg_installLocal"
+						label="Install from local files..."
+						accesskey="c"
+						class="menuitem-iconic r-pkg-install-local-icon"
+						oncommand="sv.r.pkg.installLocal();" />
+			  <menuitem id="r_objects_pkg_update"
+						label="Update"
+						accesskey="u"
+						class="menuitem-iconic r-pkg-update-icon"
+						oncommand="sv.r.pkg.update();" />
+			  <menuitem id="r_objects_pkg_remove"
+						label="Remove..."
+						accesskey="r"
+						class="menuitem-iconic r-pkg-remove-icon"
+						oncommand="sv.r.pkg.remove();" />
+			</menupopup>
+		  </toolbarbutton>
+
           <toolbarseparator style="min-width:10px;" flex="1"/>
           <toolbarbutton id="sciviews_robjects_filter"
                tooltiptext="&sciviews.robjects.filter.tip;"
@@ -240,11 +274,13 @@
 		</hbox>
         <vbox id="robjects_searchpath_panel"
           persist="height collapsed"
+		  flex="1"
           >
           <listbox flex="1" id="sciviews_robjects_searchpath_listbox"
 	    ondragdrop="nsDragAndDrop.drop(event,window.rObjectsTree.packageListObserver);"
 	    ondragover="nsDragAndDrop.dragOver(event,rObjectsTree.packageListObserver);"
 	    onkeypress="rObjectsTree.packageListKeyEvent(event);"
+	    oncommand="rObjectsTree.packageSelectedEvent(event);"
 	    />
         </vbox>
         <splitter

Modified: komodo/SciViews-K/content/js/commands.js
===================================================================
--- komodo/SciViews-K/content/js/commands.js	2009-02-22 13:39:43 UTC (rev 115)
+++ komodo/SciViews-K/content/js/commands.js	2009-02-25 22:26:34 UTC (rev 116)
@@ -5,43 +5,58 @@
 */
 
 
-sv.cmdsRControl_supported = function() {
+if (typeof(sv.command) == 'undefined') {
+    sv.command = {};
+}
+
+
+// sv.cmd object constructor:
+(function() {
+
+// private methods:
+function _RControl_supported() {
 	var currentView = ko.views.manager.currentView;
-	if (!currentView)
+	if (!currentView || !currentView.document)
 		return false;
 
 	return(currentView.document.language == "R");
 }
 
-sv.cmdsRControlSelection_supported = function() {
+function _RControlSelection_supported() {
 	var currentView = ko.views.manager.currentView;
-	if (!currentView)
+	if (!currentView || !currentView.scimoz)
 		return false;
 
 	var anythingSelected = (currentView.scimoz.selectionEnd - currentView.scimoz.selectionStart) != 0;
 	return(currentView.document.language == "R" && anythingSelected);
 }
 
+this.openPkgManager = function() {
+	window.openDialog(
+	  "chrome://sciviewsk/content/pkgManager.xul",
+	  "RPackageManager",
+	  "chrome=yes,dependent,centerscreen,resizable=yes,scrollbars=yes,status=no",
+	  sv);
+}
 
-sv.cmdsSetControllers = function() {
-	//alert("cmdsSetControllers!");
 
-	// make commands active only when current document language is R
+this.setControllers = function() {
+	// make these commands active only when current document language is R
 	var cmdNames = ["RunAll", "SourceAll", "RunBlock", "RunFunction", "RunLine", "RunPara",
 	 "SourceBlock", "SourceFunction", "SourcePara"];
 
 	var viewManager = ko.views.viewManager;
 	for (i in cmdNames) {
-		viewManager.prototype["is_cmd_sv_R" + cmdNames[i] + "_supported"] = sv.cmdsRControl_supported;
-		viewManager.prototype["is_cmd_sv_R" + cmdNames[i] + "_enabled"] = sv.cmdsRControl_supported;
+		viewManager.prototype["is_cmd_sv_R" + cmdNames[i] + "_supported"] = _RControl_supported;
+		viewManager.prototype["is_cmd_sv_R" + cmdNames[i] + "_enabled"] = _RControl_supported;
 	}
 
 	// make these commands active only when current document language is R
 	// ... and if some text is selected
 	cmdNames = [ "RunSelection", "SourceSelection"];
 	for (i in cmdNames) {
-		viewManager.prototype["is_cmd_sv_R" + cmdNames[i] + "_supported"] = sv.cmdsRControlSelection_supported;
-		viewManager.prototype["is_cmd_sv_R" + cmdNames[i] + "_enabled"] = sv.cmdsRControlSelection_supported;
+		viewManager.prototype["is_cmd_sv_R" + cmdNames[i] + "_supported"] = _RControlSelection_supported;
+		viewManager.prototype["is_cmd_sv_R" + cmdNames[i] + "_enabled"] = _RControlSelection_supported;
 	}
 
 	viewManager.prototype.do_cmd_sv_RRunLine = function() 	{ sv.r.send("line"); };
@@ -62,14 +77,14 @@
 	viewManager.prototype.do_cmd_sv_RSourceFunction = function()	{ sv.r.source("function"); };
 
 
-
+	// TODO: submenu with checkboxes to select preferred way to start R
 	viewManager.prototype.do_cmd_svStartR = function()	{
 		// runIn = "command-output-window", "new-console", "no-console"
 		//env strings: "ENV1=fooJ\nENV2=bar"
 		//gPrefSvc.prefs.getStringPref("runEnv");
 
-		var env = ["koPort=[[%pref:sciviews.server.socket]]", "koId=[[%pref:sciviews.client.id]]", "koHost=localhost",
-			 "koActivate=FALSE", "Rinitdir=~", "koServe=[[%pref:sciviews.client.socket]]", "Rid=Rgui"];
+		var env = ["koPort=%(pref:sciviews.server.socket)", "koId=%(pref:sciviews.client.id)", "koHost=localhost",
+			 "koActivate=FALSE", "Rinitdir=~", "koServe=%(pref:sciviews.client.socket)", "Rid=Rgui"];
 
 		var cwd = "%(path:hostUserDataDir)/XRE/extensions/sciviewsk at sciviews.org/templates";
 
@@ -79,18 +94,22 @@
 			try {
 				env[i] = ko.interpolate.interpolateStrings(env[i]);
 			} catch (e) {
-				alert(e);
+				alert(e + "\n" + env[i]);
 				return;
 			}
 		}
-		ko.run.runCommand(window, "Rgui --sdi", cwd, env.join("\n"), false, false, false, "new-console", false, false, false)
-
+		ko.run.runCommand(window, "Rgui --sdi", cwd, env.join("\n"), false, false, false, "no-console", false, false, false)
 	};
-
 }
 
-addEventListener("load", sv.cmdsSetControllers, false);
+}).apply(sv.command);
 
+
+
+
+//sv.cmdsSetControllers();
+addEventListener("load", sv.command.setControllers, false);
+
 /*
 
 //Useful garbage. delete it later.

Modified: komodo/SciViews-K/content/js/r-help.js
===================================================================
--- komodo/SciViews-K/content/js/r-help.js	2009-02-22 13:39:43 UTC (rev 115)
+++ komodo/SciViews-K/content/js/r-help.js	2009-02-25 22:26:34 UTC (rev 116)
@@ -1,8 +1,8 @@
 // this is replacement for language specific help on selection function
 // (cmd_helpLanguage command)
-// to handle R help not using system command
+// to handle R help (without using system command)
 
-// this should be keep updated with new versions of the original function
+// this should be kept updated with new versions of the original function
 ko.help.language = function () {
     var language = null;
     var view = ko.window.focusedView();
@@ -27,7 +27,6 @@
 			var topic;
 			try {
 				topic = ko.interpolate.interpolateStrings("%w").trim();
-				//alert("*" + topic + "*")
 				sv.r.help(topic);
 				return;
 			} catch (e) {}

Modified: komodo/SciViews-K/content/js/r.js
===================================================================
--- komodo/SciViews-K/content/js/r.js	2009-02-22 13:39:43 UTC (rev 115)
+++ komodo/SciViews-K/content/js/r.js	2009-02-25 22:26:34 UTC (rev 116)
@@ -63,6 +63,10 @@
 // sv.r.pkg.remove_select(pkgs); // Callback function for sv.r.pkg.remove()
 ////////////////////////////////////////////////////////////////////////////////
 
+// TODO: in overlay: add "source file" context menu item in the project tab
+
+
+
 // Define the 'sv.r' namespace
 if (typeof(sv.r) == 'undefined')
 	sv.r = {
@@ -208,20 +212,22 @@
 		var cmd = "cat(path.expand(" + getDirFromR + "))";
 
 		sv.r.evalCallback(cmd, function(curDir) {
-			if (navigator.platform.search(/^Win/) == 0)
-				curDir = curDir.replace(/\//g, "\\");
+			if (navigator.platform.search(/^Win/) == 0) {
+				curDir = curDir.replace(/\//g, '\\');
+			}
+			//sv.cmdout.append("curDir:"+curDir);
 			sv.r.setwd(curDir, ask, "this");
 		});
 		return;
 	}
 
 	if (ask || !dir) {
-		dir = ko.filepicker.getFolder(dir, "Choose working directory");
+		dir = ko.filepicker.getFolder(dir, sv.translate("ChooseWorkingDir"));
 	}
 
 	if (dir != null) {
-		sv.r.evalHidden(".odir <- setwd(\"" + dir.replace(/\\/g, "\\\\") + "\")");
-		sv.cmdout.message("Current R's working directory is: \"" + dir + "\"", 10000);
+		sv.r.evalHidden(".odir <- setwd(\"" + dir.addslashes() + "\")");
+		sv.cmdout.message(sv.translate("WorkingDirSetTo", dir), 10000);
 	}
     return;
 }
@@ -290,28 +296,34 @@
 			return false; // No current view, do nothing!
 		kv.setFocus();
 		var ke = kv.scimoz;
+		var doc = kv.document;
 
-		var file = kv.document.file.path.replace(/\\/g, "/");
+		var file;
+		if (!doc.isUntitled) {
+			file = doc.file.path.addslashes();
+		} else {
+			file = doc.baseName;
+		}
 
 		if (!what)
 			what = "all"; // Default value
 
 		// Special case: if "all" and document is saved, source the original file
-		if (what == "all" && !(kv.document.isUntitled || kv.document.isDirty)) {
+		if (what == "all" && !(doc.isUntitled || doc.isDirty)) {
 			res = sv.r.eval('source("' + file +  '", encoding = "' + kv.encoding + '")');
 		} else {
 
 			// else, save all or part in the temporary file and source that file.
 			// After executing, tell R to delete it.
 			var code = (what == "all")? ke.text : sv.getTextRange(what);
-			//sv.cmdout.clear();
-			sv.cmdout.append(':> source("' + file + '*") # unsaved buffer (' + what + ')');
[TRUNCATED]

To get the complete diff run:
    svnlook diff /svnroot/sciviews -r 116


More information about the Sciviews-commits mailing list