[Phoenix-commits] rev 14510 -
public/phoenix/trunk/phoenix/prototypes/prototype1/src/chrome/content
andi at wyona.com
andi at wyona.com
Wed Jun 21 22:31:00 CEST 2006
Author: andi
Date: 2006-06-21 22:30:58 +0200 (Wed, 21 Jun 2006)
New Revision: 14510
Modified:
public/phoenix/trunk/phoenix/prototypes/prototype1/src/chrome/content/controller.js
public/phoenix/trunk/phoenix/prototypes/prototype1/src/chrome/content/editor.js
public/phoenix/trunk/phoenix/prototypes/prototype1/src/chrome/content/networkservice.js
public/phoenix/trunk/phoenix/prototypes/prototype1/src/chrome/content/phoenix.js
Log:
Implemented "save" operation. Unfortunately, it fails with a not easy to resolve error in the networkservice.
Modified: public/phoenix/trunk/phoenix/prototypes/prototype1/src/chrome/content/controller.js
===================================================================
--- public/phoenix/trunk/phoenix/prototypes/prototype1/src/chrome/content/controller.js 2006-06-21 19:42:02 UTC (rev 14509)
+++ public/phoenix/trunk/phoenix/prototypes/prototype1/src/chrome/content/controller.js 2006-06-21 20:30:58 UTC (rev 14510)
@@ -135,12 +135,14 @@
};
// public instance attributes
- this.initialised = false;
- this.model = null;
- this.sourceModeView = null;
- this.wysiwygModeView = null;
- this.activeView = null;
- this.editStateController = null;
+ this.initialised = false;
+ this.model = null;
+ this.sourceModeView = null;
+ this.wysiwygModeView = null;
+ this.activeView = null;
+ this.editStateController = null;
+ this.neutronIntrospection = null;
+ this.currentNeutronFragment = null;
/* Parse the args string contained in the search part
* of the current URI. */
@@ -157,13 +159,15 @@
* paramters object from the manager. */
gMainBrowserWindow.phoenix.instancesManager.removeInstance(aParameterObject.instanceID);
- argParam = aParameterObject.parameter;
- argURI = aParameterObject.uri;
+ argParam = aParameterObject.parameter;
+ argURI = aParameterObject.uri;
+ this.neutronIntrospection = aParameterObject.introspection;
+ this.currentNeutronFragment = aParameterObject.fragment;
} else {
argParam = "blank";
}
- /* DEBUG */ dump("Phoenix:controller.js:PhoenixEditController: argParam = \"" + argParam + "\", argURI = \"" + argURI + "\"\n");
+ /* DEBUG */ dump("Phoenix:controller.js:PhoenixEditController: argParam = \"" + argParam + "\", argURI = \"" + argURI + "\", this.neutronIntrospection = \"" + this.neutronIntrospection + "\", this.currentNeutronFragment = \"" + this.currentNeutronFragment + "\"\n");
switch (argParam) {
case "blank":
@@ -320,6 +324,20 @@
switch (this.currentState) {
case this.STATE_DOCUMENTLOADED:
this.currentState = this.STATE_DOCUMENTREADY_PRISTINE;
+ // check for introspection (save and checkin)
+ if (gEditorController.neutronIntrospection) {
+ if (gEditorController.neutronIntrospection.queryFragmentSaveURI(gEditorController.currentNeutronFragment)) {
+ // enable save operation
+ document.getElementById("uiFileOperationSaveCMSMenuitem").setAttribute("disabled", false);
+ document.getElementById("uiFileOperationSave").setAttribute("disabled", false);
+ }
+ if (gEditorController.neutronIntrospection.queryFragmentCheckinURI(gEditorController.currentNeutronFragment)) {
+ // enable checkin operation
+ // TODO: at the moment, <save> == <checkin>
+ document.getElementById("uiFileOperationSaveCMSMenuitem").setAttribute("disabled", false);
+ document.getElementById("uiFileOperationSave").setAttribute("disabled", false);
+ }
+ }
break;
case this.STATE_DOCUMENTNEW:
this.currentState = this.STATE_DOCUMENTREADY_MODIFIED;
Modified: public/phoenix/trunk/phoenix/prototypes/prototype1/src/chrome/content/editor.js
===================================================================
--- public/phoenix/trunk/phoenix/prototypes/prototype1/src/chrome/content/editor.js 2006-06-21 19:42:02 UTC (rev 14509)
+++ public/phoenix/trunk/phoenix/prototypes/prototype1/src/chrome/content/editor.js 2006-06-21 20:30:58 UTC (rev 14510)
@@ -263,7 +263,27 @@
saveToCMS: function () {
/* DEBUG */ dump("Phoenix:editor.js:Editor.saveToCMS() invoked\n");
- throw new PhoenixEditorException("Method not implemented.");
+ //throw new PhoenixEditorException("Method not implemented.");
+
+ try {
+ switch (gEditorController.neutronIntrospection.queryFragmentSaveMethod(gEditorController.currentNeutronFragment)) {
+ case "PUT":
+ NetworkService.httpRequestPUT(gEditorController.neutronIntrospection.queryFragmentSaveURI(gEditorController.currentNeutronFragment).spec, null, gEditorController.model.getDocument(), null, Editor.documentUploadFinished);
+ break;
+ case "POST":
+ NetworkService.httpRequestPOST(gEditorController.neutronIntrospection.queryFragmentSaveURI(gEditorController.currentNeutronFragment).spec, null, gEditorController.model.getDocument(), null, Editor.documentUploadFinished);
+ break;
+ default:
+ // unknown request method
+ throw new PhoenixEditorException("Request method unknown.");
+ }
+ } catch (exception) {
+ dump("Phoenix:editor.js:Editor.saveToCMS: an error occurred saving to CMS: " + exception.toString() + "\n");
+ /* DEBUG */ PhoenixDebug.dumpExceptionToConsole("Phoenix:editor.js:Editor.saveToCMS", exception);
+
+ return false;
+ }
+ return true;
},
saveAsToFile: function () {
@@ -379,5 +399,9 @@
goUpdateClipboardEventCommands: function () {
Editor.goUpdateCommand('cmd_paste');
+ },
+
+ documentUploadFinished: function (aDocumentData) {
+ /* DEBUG */ dump("Phoenix:editor.js:Editor.documentUpoadFinished(\"" + aDocumentData + "\") invoked\n");
}
}
Modified: public/phoenix/trunk/phoenix/prototypes/prototype1/src/chrome/content/networkservice.js
===================================================================
--- public/phoenix/trunk/phoenix/prototypes/prototype1/src/chrome/content/networkservice.js 2006-06-21 19:42:02 UTC (rev 14509)
+++ public/phoenix/trunk/phoenix/prototypes/prototype1/src/chrome/content/networkservice.js 2006-06-21 20:30:58 UTC (rev 14510)
@@ -82,6 +82,8 @@
channel.QueryInterface(Components.interfaces.nsIUploadChannel);
channel.setUploadStream(stringInputStream, aContentType, -1);
+ // TODO: how to get grip of the nsIHttpChannel?
+ channel.QueryInterface(Components.interfaces.nsIHttpChannel);
channel.requestMethod = aRequestMethod;
if (aHeaderArray) {
Modified: public/phoenix/trunk/phoenix/prototypes/prototype1/src/chrome/content/phoenix.js
===================================================================
--- public/phoenix/trunk/phoenix/prototypes/prototype1/src/chrome/content/phoenix.js 2006-06-21 19:42:02 UTC (rev 14509)
+++ public/phoenix/trunk/phoenix/prototypes/prototype1/src/chrome/content/phoenix.js 2006-06-21 20:30:58 UTC (rev 14510)
@@ -56,16 +56,16 @@
* @paran {String} aParam an action to perform
* @return {Undefined}
*/
-function createNewEditor(aURI, aParam) {
+function createNewEditor(aURI, aParam, aFragment) {
var phoenixTab = null;
var targetURI = null;
var instanceID = null;
- /* DEBUG */ dump("Phoenix:phoenix.js:createNewEditor(\"" + aURI + "\", \"" + aParam + "\") invoked\n");
+ /* DEBUG */ dump("Phoenix:phoenix.js:createNewEditor(\"" + aURI + "\", \"" + aParam + "\", \"" + aFragment + "\") invoked\n");
try {
// prepare parameters for pick-up
- instanceID = gInstancesManager.addInstance(phoenixTab, (aURI ? aURI.spec : ""), (aParam ? aParam : ""), gCurrentIntrospection);
+ instanceID = gInstancesManager.addInstance(phoenixTab, (aURI ? aURI.spec : ""), (aParam ? aParam : ""), gCurrentIntrospection, aFragment);
// construct target URI
targetURI = PHOENIX_EDITOR_CHROME_URI + "?" + instanceID;
@@ -95,7 +95,7 @@
EditorInstancesManager.prototype = {
instanceHashtable: null,
- addInstance: function (aTab, aURI, aParam, aIntrospectionObject) {
+ addInstance: function (aTab, aURI, aParam, aIntrospectionObject, aFragment) {
var editorInstance = null;
var instanceID = null;
@@ -108,6 +108,7 @@
editorInstance.uri = aURI;
editorInstance.parameter = aParam;
editorInstance.introspection = aIntrospectionObject;
+ editorInstance.fragment = aFragment;
// add instance to the hash table
this.instanceHashtable[instanceID] = editorInstance;
@@ -155,7 +156,7 @@
/* DEBUG */ dump("Phoenix:phoenix.js:checkoutNoLockFromCMS(\"" + aFragment + "\") invoked\n");
if (gCurrentIntrospection) {
- createNewEditor(gCurrentIntrospection.queryFragmentOpenURI(aFragment));
+ createNewEditor(gCurrentIntrospection.queryFragmentOpenURI(aFragment), undefined, aFragment);
} else {
/* We should never have no introspection object when
* we reach this function. */
@@ -166,7 +167,7 @@
/* DEBUG */ dump("Phoenix:phoenix.js:checkoutFromCMS(\"" + aFragment + "\") invoked\n");
if (gCurrentIntrospection) {
- createNewEditor(gCurrentIntrospection.queryFragmentCheckoutURI(aFragment));
+ createNewEditor(gCurrentIntrospection.queryFragmentCheckoutURI(aFragment), undefined, aFragment);
} else {
/* We should never have no introspection object when
* we reach this function. */
More information about the Phoenix-commits
mailing list