[Zope-CVS] CVS: Packages/Moztop/moztop/content/StatusBar - LogManager.js:1.1 LogMessagesOverlay.xul:1.2 TaskManager.js:1.7

Stephan Richter srichter@cbu.edu
Sat, 15 Mar 2003 11:28:24 -0500


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

Modified Files:
	LogMessagesOverlay.xul TaskManager.js 
Added Files:
	LogManager.js 
Log Message:
Cleaned up LogManager. Much more cleaning up needed, before I can see whats
going on.


=== Added File Packages/Moztop/moztop/content/StatusBar/LogManager.js ===
/*****************************************************************************
*
* Copyright (c) 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.
*
******************************************************************************
Library to handle log messages.

$Id: LogManager.js,v 1.1 2003/03/15 16:28:23 srichter Exp $

******************************************************************************/

/* Now subclass, then add methods */
LogManager.prototype = new DataSourceManager();
LogManager.prototype.constructor = LogManager;
LogManager.superclass = DataSourceManager;

function LogManager () {

    /* This prototype manages interaction with the log viewer.  
       It creates an RDFDataSource from rdfds.js, grabs the 
       existing datasource from the logmessages-tree.  It also 
       knows how to add messages and view the selected message.
       Finally, it has a method for viewing the RDF contents in 
       a popup text box. */

    // Initialization preocess
    if( !(this instanceof LogManager) )
	return new LogManager( );
    DataSourceManager.call(this);

    // Grep the right resource URL for storing it at the right place
    this.profileurl = this.getProfileDirURL();

    // Initialize RDF data source
    this.elementid = "logmessages-tree";
    this.ds = new RDFDataSource();
    this.urn = "urn:moztop:logmessages";

    // Define namespaces required for this RDF graph
    this.dcns = "http://www.purl.org/dc/1.1#";
    this.zoperdfns = "http://www.zope.org/rdf#";
    this.ncns ="http://home.netscape.com/NC-rdf#";

    // Setup log message property names
    this.titleprop = this.dcns + "title";
    this.descriptionprop = this.dcns + "description";
    this.timeprop = this.zoperdfns + "time";
    this.messageprop = this.zoperdfns + "message";
}


LogManager.prototype.attachDataSource = function()  {
    /* Called once when log is first loaded */
    var lms=this.ds.getNode(this.urn);
    lms.makeSeq();
    
    // Now attach the datasource
    var logmessages=document.getElementById(this.elementid);
    logmessages.database.AddDataSource(this.ds.getRawDataSource());
    logmessages.builder.rebuild();
    
    // Create a log message on startup
    this.addMessage("startup","TaskManager.attachDataSource", 
                    "Moztop started");
    return;
}


LogManager.prototype.addMessage = function(msgtitle, msglocation, msg) {
    /* title is the short message, msg is full text displayed on dblclick 
       
       msglocation and msg are optional, so that one can use the log manager
       for debugging as well.
    */
    // Create message date
    var date = new Date();
    var now = date.getHours()+":"+date.getMinutes()+":"+date.getSeconds();
    
    // If there was no location specified, make it null
    if (!msglocation)
	msglocation = "None specified";

    // If there was no message passed, make the message equal the title
    if (!msg)
	msg = msgtitle;

    // Create new RDF message node in graph
    var rootnode = this.ds.getNode(this.urn);
    var thismsg = this.ds.getNode(this.urn + ":" + date.getTime());

    // Add a new log message to the RDF graph.
    rootnode.addChild(thismsg);
    thismsg.addTarget(this.titleprop, msgtitle);
    thismsg.addTarget(this.descriptionprop, msglocation);
    thismsg.addTarget(this.timeprop, now);
    thismsg.addTarget(this.messageprop, msg);
}


LogManager.prototype.viewSelectedMessage = function () {
    /* When a user doubleclicks on a message in the log, this 
       is called.  It finds the selected item in the tree 
       and pops up a dialog box with the contents of the log message. */

    var tree = document.getElementById(this.elementid);
    var index = tree.view.selection.currentIndex;
    var rdf = tree.view.getItemAtIndex(index).resource;
    
    // Grab the RDF value and popup a dialog window
    var node = this.ds.getNode(rdf.Value);
    var msg = node.getTarget(this.messageprop);
    window.openDialog("chrome://moztop/content/StatusBar/LogMessageDialog.xul",
		      "viewlogmessage", "chrome", msg.getValue());
}


/* Initialize the data in the tree object. */
function initLogManager() {
    // Remember that logmanager was defined globally, but not initialized.
    logmanager = LogManager();
    logmanager.attachDataSource();
}


=== Packages/Moztop/moztop/content/StatusBar/LogMessagesOverlay.xul 1.1 => 1.2 ===
--- Packages/Moztop/moztop/content/StatusBar/LogMessagesOverlay.xul:1.1	Sat Feb 15 06:01:59 2003
+++ Packages/Moztop/moztop/content/StatusBar/LogMessagesOverlay.xul	Sat Mar 15 11:28:23 2003
@@ -4,6 +4,7 @@
          xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
 
 <tabpanel id="logmessages-panel" orient="vertical" flex="1">
+
 <tree id="logmessages-tree" flex="1" height="100"
       ref="urn:moztop:logmessages" datasources="rdf:null" 
       ondblclick="logmanager.viewSelectedMessage();">
@@ -30,6 +31,7 @@
       </rule>
     </template>
 </tree>
+
 </tabpanel>
 
 </overlay>


=== Packages/Moztop/moztop/content/StatusBar/TaskManager.js 1.6 => 1.7 ===
--- Packages/Moztop/moztop/content/StatusBar/TaskManager.js:1.6	Sat Feb 15 06:01:59 2003
+++ Packages/Moztop/moztop/content/StatusBar/TaskManager.js	Sat Mar 15 11:28:23 2003
@@ -17,100 +17,6 @@
 
 ******************************************************************************/
 
-/* Now subclass, then add methods */
-LogManager.prototype = new DataSourceManager();
-LogManager.prototype.constructor = LogManager;
-LogManager.superclass = DataSourceManager;
-
-function LogManager () {
-
-    /* This prototype manages interaction with the log viewer.  
-       It creates an RDFDataSource from rdfds.js, grabs the 
-       existing datasource from the logmessages-tree.  It also 
-       knows how to add messages and view the selected message.
-       Finally, it has a method for viewing the RDF contents in 
-       a popup text box. */
-
-  if( !(this instanceof LogManager) ) return new LogManager( );
-  DataSourceManager.call(this);
-
-  this.dcns = "http://www.purl.org/dc/1.1#";
-  this.zoperdfns = "http://www.zope.org/rdf#";
-  this.ncns ="http://home.netscape.com/NC-rdf#";
-
-  this.titleprop = this.dcns + "title";
-  this.descriptionprop = this.dcns + "description";
-  this.resourcetypeprop = this.zoperdfns + "resourcetype";
-  this.urlprop = this.zoperdfns + "url";
-  this.usernameprop = this.zoperdfns + "username";
-  this.passwordprop = this.zoperdfns + "password";
-  this.styleidprop = this.zoperdfns + "styleid";
-  this.subitemsprop = this.ncns + "subitems";
-
-  this.profileurl = this.getProfileDirURL();
-  this.elementid = null;
-
-  this.elementid = "logmessages-tree";
-  this.ds = new RDFDataSource();
-  this.urn = "urn:moztop:logmessages";
-  this.timeprop = "http://www.zope.org/rdf#time";
-  this.messageprop = "http://www.zope.org/rdf#message";
-
-}
-
-
-LogManager.prototype.attachDataSource=
-  function() 
-{
-    /* Called once when log is first loaded */
-  var lms=this.ds.getNode(this.urn);
-  lms.makeSeq();
-
-  // Now attach the datasource
-  var logmessages=document.getElementById(this.elementid);
-  logmessages.database.AddDataSource(this.ds.getRawDataSource());
-  logmessages.builder.rebuild();
-
-  // Create a log message on startup
-  this.addMessage('startup','TaskManager.attachDataSource', "Moztop started");
-  return;
-}
-
-LogManager.prototype.addMessage = function (msgtitle, msglocation, msg) {
-    /* title is the short message, msg is full text displayed on dblclick */
-    var d = new Date();
-    var now = d.getHours() + ":" + d.getMinutes() + ":" + d.getSeconds();
-    var rootnode = this.ds.getNode(this.urn);
-    var thismsg = this.ds.getNode(this.urn + ":" + d.getTime());
-    rootnode.addChild(thismsg);
-    thismsg.addTarget(this.titleprop,msgtitle);
-    thismsg.addTarget(this.descriptionprop,msglocation);
-    thismsg.addTarget(this.timeprop,now);
-    thismsg.addTarget(this.messageprop,msg);
-
-}
-
-LogManager.prototype.viewSelectedMessage = function () {
-
-  // When a user doubleclicks on a message in the log, this 
-  // is called.  It finds the selected item in the tree 
-  // and pops up a dialog box with the contents of the log message.
-
-  var tree = document.getElementById(this.elementid);
-  var index = tree.view.selection.currentIndex;
-  var rdf = tree.view.getItemAtIndex(index).resource;
-
-  // Grab the RDF value and popup a dialog window
-  var n = this.ds.getNode(rdf.Value);
-  var nt = n.getTarget(this.messageprop);
-  window.openDialog("chrome://moztop/content/StatusBar/LogMessageDialog.xul",
-		    "viewlogmessage","chrome",nt.getValue());
-}
-
-
-
-
-
 /* Initialize Tasks datasource. */
 var tasks_source =
   Components
@@ -119,10 +25,6 @@
 
 /* Initialize the data in the tree object. */
 function initTaskList() {
-
-  // Remember that logmanager was defined globally, but not initialized.
-    logmanager = LogManager();
-    logmanager.attachDataSource();
     var tree = document.getElementById("tasks-tree");
     tree.database.AddDataSource(tasks_source);
     tree.setAttribute("ref", "urn:tasks:data");