[Phoenix-commits] rev 13811 - in
public/phoenix/trunk/phoenix/prototypes/prototype1/src: .
chrome/content
andi at wyona.com
andi at wyona.com
Thu Jun 1 22:49:18 CEST 2006
Author: andi
Date: 2006-06-01 22:49:17 +0200 (Thu, 01 Jun 2006)
New Revision: 13811
Modified:
public/phoenix/trunk/phoenix/prototypes/prototype1/src/HACKING.txt
public/phoenix/trunk/phoenix/prototypes/prototype1/src/chrome/content/editor.js
public/phoenix/trunk/phoenix/prototypes/prototype1/src/chrome/content/model.js
Log:
Show confirmation dialog before a document is being close.
Modified: public/phoenix/trunk/phoenix/prototypes/prototype1/src/HACKING.txt
===================================================================
--- public/phoenix/trunk/phoenix/prototypes/prototype1/src/HACKING.txt 2006-06-01 20:09:15 UTC (rev 13810)
+++ public/phoenix/trunk/phoenix/prototypes/prototype1/src/HACKING.txt 2006-06-01 20:49:17 UTC (rev 13811)
@@ -7,8 +7,10 @@
- if current model has modifications, ask user if he wants to save the current document before opening a new file
- localize file picker strings by using property files
+ * model.js:
+ - isDirty() should return false if document has not been modified since last persisting
+
* General directions:
- - "New" button which creates new XML file
- Parse introspection file
- Make "Edit" menu glow in case of available introspection
- Localise exceptions which are potentially shown to the user
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-01 20:09:15 UTC (rev 13810)
+++ public/phoenix/trunk/phoenix/prototypes/prototype1/src/chrome/content/editor.js 2006-06-01 20:49:17 UTC (rev 13811)
@@ -88,11 +88,28 @@
/* DEBUG */ dump("Phoenix:editor.js:Editor.replaceEditor: replaced editor\n");
},
+ checkClose: function () {
+ /* DEBUG */ dump("Phoenix:editor.js:Editor.checkClose() invoked\n");
+
+ if (gEditorController.model.isDirty()) {
+ // document has been changed
+ if (!window.confirm("The document has been changed. Really close this document?"))
+ return false;
+ }
+
+ return true;
+ },
+
createNew: function (aTemplate) {
/* DEBUG */ dump("Phoenix:editor.js:Editor.createNew(\"" + aTemplate + "\") invoked\n");
- Editor.replaceEditor(null, aTemplate);
- return true;
+ if (Editor.checkClose()) {
+ Editor.replaceEditor(null, aTemplate);
+
+ return true;
+ }
+
+ return false;
},
createNewFromTemplateLocal: function () {
@@ -110,30 +127,34 @@
/* DEBUG */ dump("Phoenix:editor.js:Editor.openFromFile() invoked\n");
- // open file picker dialog for local file system
- nsIFilePicker = Components.interfaces.nsIFilePicker;
- filePicker = Components.classes["@mozilla.org/filepicker;1"].createInstance(nsIFilePicker);
+ if (Editor.checkClose()) {
+ // open file picker dialog for local file system
+ nsIFilePicker = Components.interfaces.nsIFilePicker;
+ filePicker = Components.classes["@mozilla.org/filepicker;1"].createInstance(nsIFilePicker);
- filePicker.init(window, "Open File for Editing", nsIFilePicker.modeOpen);
- filePicker.appendFilters(nsIFilePicker.filterXML);
- filePicker.appendFilter("XHTML Files", "*.xhtml; *.html");
- filePicker.appendFilters(nsIFilePicker.filterAll);
+ filePicker.init(window, "Open File for Editing", nsIFilePicker.modeOpen);
+ filePicker.appendFilters(nsIFilePicker.filterXML);
+ filePicker.appendFilter("XHTML Files", "*.xhtml; *.html");
+ filePicker.appendFilters(nsIFilePicker.filterAll);
- if (filePicker.show() == nsIFilePicker.returnOK) {
- // cast nsIFileURL to nsIURI
- documentURI = filePicker.fileURL;
- documentURI.QueryInterface(Components.interfaces.nsIURI);
+ if (filePicker.show() == nsIFilePicker.returnOK) {
+ // cast nsIFileURL to nsIURI
+ documentURI = filePicker.fileURL;
+ documentURI.QueryInterface(Components.interfaces.nsIURI);
- /* DEBUG */ dump("Phoenix:editor.js:Editor.openFromFile: selected documentURI: \"" + documentURI.spec + "\"\n");
+ /* DEBUG */ dump("Phoenix:editor.js:Editor.openFromFile: selected documentURI: \"" + documentURI.spec + "\"\n");
- // replace the current editor
- Editor.replaceEditor(documentURI);
+ // replace the current editor
+ Editor.replaceEditor(documentURI);
- return true;
- } else {
- // user aborted
- return false;
+ return true;
+ } else {
+ // user aborted
+ return false;
+ }
}
+
+ return false;
},
openFromCMS: function () {
@@ -141,10 +162,14 @@
/* DEBUG */ dump("Phoenix:editor.js:Editor.openFromCMS() invoked\n");
- // open file picker dialog for CMS
+ if (Editor.checkClose()) {
+ // open file picker dialog for CMS
- // replace the current editor
- Editor.replaceEditor(documentURI);
+ // replace the current editor
+ Editor.replaceEditor(documentURI);
+ }
+
+ return false;
},
saveToFile: function () {
Modified: public/phoenix/trunk/phoenix/prototypes/prototype1/src/chrome/content/model.js
===================================================================
--- public/phoenix/trunk/phoenix/prototypes/prototype1/src/chrome/content/model.js 2006-06-01 20:09:15 UTC (rev 13810)
+++ public/phoenix/trunk/phoenix/prototypes/prototype1/src/chrome/content/model.js 2006-06-01 20:49:17 UTC (rev 13811)
@@ -53,6 +53,7 @@
documentDOM : null,
changed : false,
chandedDOM : false,
+ dirty : true,
setDocumentName: function (aDocumentName) {
/* DEBUG */ dump("Phoenix:model.js:setDocumentName(\"" + aDocumentName + "\") invoked\n");
@@ -79,6 +80,23 @@
return this.contentType;
},
+ /**
+ * If the document has been modified since it was persisted
+ * the last time, this method returns true.
+ *
+ * @return {Boolean} returns true is document has been modified since last save
+ */
+ isDirty: function () {
+ /* DEBUG */ dump("Phoenix:model.js:isDirty() invoked\n");
+ return this.dirty;
+ },
+
+ /**
+ * If the document has been modified since it was read into
+ * a view the last time, this method returns true.
+ *
+ * @return {Boolean} returns true is document has been modified since last view read
+ */
isChanged: function () {
/* DEBUG */ dump("Phoenix:model.js:isChanged() invoked\n");
return this.changed;
More information about the Phoenix-commits
mailing list