[Phoenix-commits] rev 19192 - in public/yulup/src/trunk/yulup/prototypes/prototype1/src/chrome: content locale/de locale/en locale/es locale/fr locale/ku locale/tr locale/xml

andi at wyona.com andi at wyona.com
Fri Oct 6 23:19:15 CEST 2006


Author: andi
Date: 2006-10-06 23:19:14 +0200 (Fri, 06 Oct 2006)
New Revision: 19192

Added:
   public/yulup/src/trunk/yulup/prototypes/prototype1/src/chrome/content/progressdialog.js
   public/yulup/src/trunk/yulup/prototypes/prototype1/src/chrome/content/progressdialog.xul
Modified:
   public/yulup/src/trunk/yulup/prototypes/prototype1/src/chrome/content/editor.xul
   public/yulup/src/trunk/yulup/prototypes/prototype1/src/chrome/content/widget.js
   public/yulup/src/trunk/yulup/prototypes/prototype1/src/chrome/locale/de/yulup.dtd
   public/yulup/src/trunk/yulup/prototypes/prototype1/src/chrome/locale/en/yulup.dtd
   public/yulup/src/trunk/yulup/prototypes/prototype1/src/chrome/locale/es/yulup.dtd
   public/yulup/src/trunk/yulup/prototypes/prototype1/src/chrome/locale/fr/yulup.dtd
   public/yulup/src/trunk/yulup/prototypes/prototype1/src/chrome/locale/ku/yulup.dtd
   public/yulup/src/trunk/yulup/prototypes/prototype1/src/chrome/locale/tr/yulup.dtd
   public/yulup/src/trunk/yulup/prototypes/prototype1/src/chrome/locale/xml/yulup.dtd.xml
Log:
Added upload progress listener.


Modified: public/yulup/src/trunk/yulup/prototypes/prototype1/src/chrome/content/editor.xul
===================================================================
--- public/yulup/src/trunk/yulup/prototypes/prototype1/src/chrome/content/editor.xul	2006-10-06 21:18:48 UTC (rev 19191)
+++ public/yulup/src/trunk/yulup/prototypes/prototype1/src/chrome/content/editor.xul	2006-10-06 21:19:14 UTC (rev 19192)
@@ -74,6 +74,8 @@
           src="chrome://yulup/content/authentication.js"/>
   <script type="application/x-javascript"
           src="chrome://yulup/content/newmenu.js"/>
+  <script type="application/x-javascript"
+          src="chrome://yulup/content/progressdialog.js"/>
 
   <commandset id="uiYulupEditorFocusEventCommandset"
               commandupdater="true"

Added: public/yulup/src/trunk/yulup/prototypes/prototype1/src/chrome/content/progressdialog.js
===================================================================
--- public/yulup/src/trunk/yulup/prototypes/prototype1/src/chrome/content/progressdialog.js	2006-10-06 21:18:48 UTC (rev 19191)
+++ public/yulup/src/trunk/yulup/prototypes/prototype1/src/chrome/content/progressdialog.js	2006-10-06 21:19:14 UTC (rev 19192)
@@ -0,0 +1,118 @@
+/*
+ * ***** BEGIN LICENSE BLOCK *****
+ * Copyright 2006 Wyona AG Zurich
+ *
+ * This file is part of Yulup.
+ *
+ * Yulup is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Yulup is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Yulup; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ * ***** END LICENSE BLOCK *****
+ */
+
+/**
+ * @author Andreas Wuest
+ *
+ */
+
+const YULUP_PROGRESSDIALOG_CHROME_URI = "chrome://yulup/content/progressdialog.xul";
+
+function ProgressDialog(aWindow, aAction, aDocumentName) {
+    /* DEBUG */ dump("Yulup:progressdialog.js:ProgressDialog() invoked\n");
+
+    /* DEBUG */ YulupDebug.ASSERT(aWindow       != null);
+    /* DEBUG */ YulupDebug.ASSERT(aAction       != null);
+    /* DEBUG */ YulupDebug.ASSERT(aDocumentName != null);
+
+    this.__action       = aAction;
+    this.__documentName = aDocumentName;
+
+    this.__dialog = aWindow.openDialog(YULUP_PROGRESSDIALOG_CHROME_URI, "yulupProgressDialog" + Date.now(), "resizable=no", this);
+}
+
+ProgressDialog.prototype = {
+    __init        : false,
+    __dialog      : null,
+    __action      : null,
+    __documentName: null,
+    __currentPos  : 0,
+
+    /**
+     * Initialise the dialog.
+     *
+     * @return {Undefined} does not have a return value
+     */
+    onLoadHandler: function () {
+        /* DEBUG */ dump("Yulup:progressdialog.js:ProgressDialog.onLoadHandler() invoked\n");
+
+        this.__init = true;
+
+        this.__dialog.document.getElementById("uiYulupProgressDialogActionLabel").setAttribute("value", this.__action + ":");
+        this.__dialog.document.getElementById("uiYulupProgressDialogDocumentNameLabel").setAttribute("value", this.__documentName);
+    },
+
+    closeDialog: function () {
+        /* DEBUG */ dump("Yulup:progressdialog.js:ProgressDialog.closeDialog() invoked\n");
+
+        // close the dialog box
+        this.__dialog.document.getElementById("uiYulupProgressDialog").acceptDialog();
+    },
+
+    onProgress: function (aProgress, aProgressMax) {
+        var percentProgress = 0;
+        var byteProgress    = 0;
+        var byteMax         = 0;
+
+        /* DEBUG */ dump("Yulup:progressdialog.js:ProgressDialog.onProgress(\"" + aProgress + "\", \"" + aProgressMax + "\") invoked\n");
+
+        /* DEBUG */ YulupDebug.ASSERT(aProgress    != null);
+        /* DEBUG */ YulupDebug.ASSERT(aProgressMax != null);
+
+        if (this.__init) {
+            byteProgress = (aProgress / 1024);
+
+            if (aProgressMax == -1) {
+                this.__dialog.document.getElementById("uiYulupProgressDialogProgressMeter").setAttribute("mode", "undetermined");
+
+                this.__dialog.document.getElementById("uiYulupProgressDialogProgressLabel").setAttribute("value", byteProgress.toFixed(2) + " KiB");
+            } else {
+                percentProgress = (aProgressMax / aProgress) * 100;
+
+                this.__dialog.document.getElementById("uiYulupProgressDialogProgressMeter").setAttribute("value", percentProgress + "%");
+                this.__dialog.document.getElementById("uiYulupProgressDialogProgressMeter").setAttribute("mode", "determined");
+
+                byteMax = (aProgressMax / 1024);
+
+                this.__dialog.document.getElementById("uiYulupProgressDialogProgressLabel").setAttribute("value", byteProgress.toFixed(2) + " KiB / " + byteMax.toFixed(2) + " Kib");
+            }
+        }
+
+        this.__currentPos = aProgress;
+    },
+
+    requestFinished: function () {
+        var byteProgress   = 0;
+        var progressDialog = null;
+
+        /* DEBUG */ dump("Yulup:progressdialog.js:ProgressDialog.requestFinished() invoked\n");
+
+        byteProgress = (this.__currentPos / 1024);
+        this.__dialog.document.getElementById("uiYulupProgressDialogProgressLabel").setAttribute("value", "Finished (" + byteProgress.toFixed(2) + " KiB)");
+
+        progressDialog = this;
+
+        // close the dialog box after a short timeout
+        this.__dialog.setTimeout(function() { progressDialog.closeDialog(); }, 2000);
+    }
+};

Added: public/yulup/src/trunk/yulup/prototypes/prototype1/src/chrome/content/progressdialog.xul
===================================================================
--- public/yulup/src/trunk/yulup/prototypes/prototype1/src/chrome/content/progressdialog.xul	2006-10-06 21:18:48 UTC (rev 19191)
+++ public/yulup/src/trunk/yulup/prototypes/prototype1/src/chrome/content/progressdialog.xul	2006-10-06 21:19:14 UTC (rev 19192)
@@ -0,0 +1,58 @@
+<?xml version="1.0"?>
+
+<!--
+# ***** BEGIN LICENSE BLOCK *****
+# Copyright 2006 Wyona AG Zurich
+#
+# This file is part of Yulup.
+#
+# Yulup is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# Yulup is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Yulup; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+#
+# ***** END LICENSE BLOCK *****
+-->
+
+<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
+
+<!DOCTYPE dialog SYSTEM "chrome://yulup/locale/yulup.dtd">
+
+<dialog id="uiYulupProgressDialog"
+        orient="vertical"
+        align="stretch"
+        title="&yulupProgressDialog.title;"
+        buttons="accept"
+        buttonlabelaccept="&yulupProgressDialogCloseButton.label;"
+        onload="window.arguments[0].onLoadHandler();"
+        style="font: -moz-dialog;"
+        xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+
+    <script type="application/x-javascript"
+            src="chrome://yulup/content/common.js"/>
+    <script type="application/x-javascript"
+            src="chrome://yulup/content/progressdialog.js"/>
+
+    <label id="uiYulupProgressDialogActionLabel" style="font-weight: bolder;"/>
+    <label id="uiYulupProgressDialogDocumentNameLabel"/>
+
+    <spacer style="height: 8px;"/>
+
+    <progressmeter id="uiYulupProgressDialogProgressMeter" mode="undetermined" value="0%"/>
+
+    <hbox align="center" pack="end">
+      <label id="uiYulupProgressDialogProgressLabel" value="0 KiB" style="font-size: x-small;"/>
+    </hbox>
+
+    <spacer style="height: 12px;"/>
+
+</dialog>

Modified: public/yulup/src/trunk/yulup/prototypes/prototype1/src/chrome/content/widget.js
===================================================================
--- public/yulup/src/trunk/yulup/prototypes/prototype1/src/chrome/content/widget.js	2006-10-06 21:18:48 UTC (rev 19191)
+++ public/yulup/src/trunk/yulup/prototypes/prototype1/src/chrome/content/widget.js	2006-10-06 21:19:14 UTC (rev 19192)
@@ -497,8 +497,10 @@
                 mimeType = "application/octet-stream";
             }
 
-            NetworkService.httpRequestUploadFile(returnObject.collectionURI.spec, sourceFile, null, mimeType, null, null, null, true);
+            var progressDialog = new ProgressDialog(window, "Uploading file", returnObject.collectionURI.spec);
 
+            NetworkService.httpRequestUploadFile(returnObject.collectionURI.spec, sourceFile, null, mimeType, null, null, null, true, progressDialog);
+
             /*
             var dialog  = Components.classes["@mozilla.org/progressdialog;1"].createInstance(Components.interfaces.nsIProgressDialog);
             var persist = Components.classes["@mozilla.org/embedding/browser/nsWebBrowserPersist;1"].createInstance(Components.interfaces.nsIWebBrowserPersist);

Modified: public/yulup/src/trunk/yulup/prototypes/prototype1/src/chrome/locale/de/yulup.dtd
===================================================================
--- public/yulup/src/trunk/yulup/prototypes/prototype1/src/chrome/locale/de/yulup.dtd	2006-10-06 21:18:48 UTC (rev 19191)
+++ public/yulup/src/trunk/yulup/prototypes/prototype1/src/chrome/locale/de/yulup.dtd	2006-10-06 21:19:14 UTC (rev 19192)
@@ -11,6 +11,8 @@
 <!ENTITY editHelpMenuitem.label "Hilfe">
 <!ENTITY editDemoMenuitem.label "Demosite">
 <!ENTITY editVersionStringMenuitem.label "Yulup-Dev">
+<!ENTITY yulupProgressDialog.title "Progress">
+<!ENTITY yulupProgressDialogCloseButton.label "Close">
 <!ENTITY editToolbarbuttonWarnTooltip1.tooltip "Warnung:">
 <!ENTITY editToolbarbuttonWarnTooltip2.tooltip "Im Zusammenhang mit dem Introspection-Objekt das mit diesem Dokument assoziiert ist trat ein Fehler auf.">
 <!ENTITY editToolbarbuttonWarnTooltip3.tooltip "Das File existiert nicht, oder ist nicht in einer geeigneten Form.">

Modified: public/yulup/src/trunk/yulup/prototypes/prototype1/src/chrome/locale/en/yulup.dtd
===================================================================
--- public/yulup/src/trunk/yulup/prototypes/prototype1/src/chrome/locale/en/yulup.dtd	2006-10-06 21:18:48 UTC (rev 19191)
+++ public/yulup/src/trunk/yulup/prototypes/prototype1/src/chrome/locale/en/yulup.dtd	2006-10-06 21:19:14 UTC (rev 19192)
@@ -11,6 +11,8 @@
 <!ENTITY editHelpMenuitem.label "Help">
 <!ENTITY editDemoMenuitem.label "Demosite">
 <!ENTITY editVersionStringMenuitem.label "Yulup-Dev">
+<!ENTITY yulupProgressDialog.title "Progress">
+<!ENTITY yulupProgressDialogCloseButton.label "Close">
 <!ENTITY editToolbarbuttonWarnTooltip1.tooltip "Warning:">
 <!ENTITY editToolbarbuttonWarnTooltip2.tooltip "An error occurred regarding the introspection file associated with this document.">
 <!ENTITY editToolbarbuttonWarnTooltip3.tooltip "The file may either not exist, or is not in a suitable form.">

Modified: public/yulup/src/trunk/yulup/prototypes/prototype1/src/chrome/locale/es/yulup.dtd
===================================================================
--- public/yulup/src/trunk/yulup/prototypes/prototype1/src/chrome/locale/es/yulup.dtd	2006-10-06 21:18:48 UTC (rev 19191)
+++ public/yulup/src/trunk/yulup/prototypes/prototype1/src/chrome/locale/es/yulup.dtd	2006-10-06 21:19:14 UTC (rev 19192)
@@ -11,6 +11,8 @@
 <!ENTITY editHelpMenuitem.label "Help">
 <!ENTITY editDemoMenuitem.label "Demosite">
 <!ENTITY editVersionStringMenuitem.label "Yulup-Dev">
+<!ENTITY yulupProgressDialog.title "Progress">
+<!ENTITY yulupProgressDialogCloseButton.label "Close">
 <!ENTITY editToolbarbuttonWarnTooltip1.tooltip "Warning:">
 <!ENTITY editToolbarbuttonWarnTooltip2.tooltip "An error occurred regarding the introspection file associated with this document.">
 <!ENTITY editToolbarbuttonWarnTooltip3.tooltip "The file may either not exist, or is not in a suitable form.">

Modified: public/yulup/src/trunk/yulup/prototypes/prototype1/src/chrome/locale/fr/yulup.dtd
===================================================================
--- public/yulup/src/trunk/yulup/prototypes/prototype1/src/chrome/locale/fr/yulup.dtd	2006-10-06 21:18:48 UTC (rev 19191)
+++ public/yulup/src/trunk/yulup/prototypes/prototype1/src/chrome/locale/fr/yulup.dtd	2006-10-06 21:19:14 UTC (rev 19192)
@@ -11,6 +11,8 @@
 <!ENTITY editHelpMenuitem.label "Help">
 <!ENTITY editDemoMenuitem.label "Demosite">
 <!ENTITY editVersionStringMenuitem.label "Yulup-Dev">
+<!ENTITY yulupProgressDialog.title "Progress">
+<!ENTITY yulupProgressDialogCloseButton.label "Close">
 <!ENTITY editToolbarbuttonWarnTooltip1.tooltip "Warning:">
 <!ENTITY editToolbarbuttonWarnTooltip2.tooltip "An error occurred regarding the introspection file associated with this document.">
 <!ENTITY editToolbarbuttonWarnTooltip3.tooltip "The file may either not exist, or is not in a suitable form.">

Modified: public/yulup/src/trunk/yulup/prototypes/prototype1/src/chrome/locale/ku/yulup.dtd
===================================================================
--- public/yulup/src/trunk/yulup/prototypes/prototype1/src/chrome/locale/ku/yulup.dtd	2006-10-06 21:18:48 UTC (rev 19191)
+++ public/yulup/src/trunk/yulup/prototypes/prototype1/src/chrome/locale/ku/yulup.dtd	2006-10-06 21:19:14 UTC (rev 19192)
@@ -11,6 +11,8 @@
 <!ENTITY editHelpMenuitem.label "Help">
 <!ENTITY editDemoMenuitem.label "Demosite">
 <!ENTITY editVersionStringMenuitem.label "Yulup-Dev">
+<!ENTITY yulupProgressDialog.title "Progress">
+<!ENTITY yulupProgressDialogCloseButton.label "Close">
 <!ENTITY editToolbarbuttonWarnTooltip1.tooltip "Warning:">
 <!ENTITY editToolbarbuttonWarnTooltip2.tooltip "An error occurred regarding the introspection file associated with this document.">
 <!ENTITY editToolbarbuttonWarnTooltip3.tooltip "The file may either not exist, or is not in a suitable form.">

Modified: public/yulup/src/trunk/yulup/prototypes/prototype1/src/chrome/locale/tr/yulup.dtd
===================================================================
--- public/yulup/src/trunk/yulup/prototypes/prototype1/src/chrome/locale/tr/yulup.dtd	2006-10-06 21:18:48 UTC (rev 19191)
+++ public/yulup/src/trunk/yulup/prototypes/prototype1/src/chrome/locale/tr/yulup.dtd	2006-10-06 21:19:14 UTC (rev 19192)
@@ -11,6 +11,8 @@
 <!ENTITY editHelpMenuitem.label "Help">
 <!ENTITY editDemoMenuitem.label "Demosite">
 <!ENTITY editVersionStringMenuitem.label "Yulup-Dev">
+<!ENTITY yulupProgressDialog.title "Progress">
+<!ENTITY yulupProgressDialogCloseButton.label "Close">
 <!ENTITY editToolbarbuttonWarnTooltip1.tooltip "Warning:">
 <!ENTITY editToolbarbuttonWarnTooltip2.tooltip "An error occurred regarding the introspection file associated with this document.">
 <!ENTITY editToolbarbuttonWarnTooltip3.tooltip "The file may either not exist, or is not in a suitable form.">

Modified: public/yulup/src/trunk/yulup/prototypes/prototype1/src/chrome/locale/xml/yulup.dtd.xml
===================================================================
--- public/yulup/src/trunk/yulup/prototypes/prototype1/src/chrome/locale/xml/yulup.dtd.xml	2006-10-06 21:18:48 UTC (rev 19191)
+++ public/yulup/src/trunk/yulup/prototypes/prototype1/src/chrome/locale/xml/yulup.dtd.xml	2006-10-06 21:19:14 UTC (rev 19192)
@@ -65,6 +65,14 @@
     <name xml:lang="en">Yulup-Dev</name>
   </entity>
 
+  <entity id="yulupProgressDialog.title">
+    <name xml:lang="en">Progress</name>
+  </entity>
+
+  <entity id="yulupProgressDialogCloseButton.label">
+    <name xml:lang="en">Close</name>
+  </entity>
+
   <entity id="editToolbarbuttonWarnTooltip1.tooltip">
     <name xml:lang="en">Warning:</name>
     <name xml:lang="de">Warnung:</name>




More information about the Phoenix-commits mailing list