diff --git a/mindplot/pom.xml b/mindplot/pom.xml
index f8e6e751..f0d8afdc 100644
--- a/mindplot/pom.xml
+++ b/mindplot/pom.xml
@@ -56,7 +56,7 @@
files="Overlay.js"/>
-
@@ -106,7 +106,9 @@
-
+
+
+
diff --git a/mindplot/src/main/javascript/Designer.js b/mindplot/src/main/javascript/Designer.js
index 0a503134..ef060973 100644
--- a/mindplot/src/main/javascript/Designer.js
+++ b/mindplot/src/main/javascript/Designer.js
@@ -345,21 +345,11 @@ mindplot.Designer = new Class({
return this._actionDispatcher._actionRunner.hasBeenChanged();
},
- save : function(onSavedHandler, saveHistory) {
- var mindmap = this.getMindmap();
- var properties = {zoom:this.getModel().getZoom(), layoutManager:this._layoutManager.getClassName()};
- var persistantManager = mindplot.PersistanceManager;
- persistantManager.save(mindmap, properties, onSavedHandler, saveHistory);
- this.fireEvent("save", {type:saveHistory});
-
- // Refresh undo state...
- //@Todo: Review all this. It should not be here ...
-
-// this._actionDispatcher.markAsChangeBase();
+ getMindmapProperties : function() {
+ return {zoom:this.getModel().getZoom(), layoutManager:this._layoutManager.getClassName()};
},
-
loadMap : function(mindmapModel) {
$assert(mindmapModel, "mindmapModel can not be null");
this._mindmap = mindmapModel;
diff --git a/mindplot/src/main/javascript/DesignerKeyboard.js b/mindplot/src/main/javascript/DesignerKeyboard.js
index 59144e29..8ffd0c91 100644
--- a/mindplot/src/main/javascript/DesignerKeyboard.js
+++ b/mindplot/src/main/javascript/DesignerKeyboard.js
@@ -99,13 +99,12 @@ mindplot.DesignerKeyboard = new Class({
'ctrl+s' : function(event) {
event.preventDefault();
- designer.save(null, true);
-
+ $('save').fireEvent('click');
},
'meta+s' : function(event) {
event.preventDefault();
- designer.save(null, true);
+ $('save').fireEvent('click');
},
'ctrl+i' : function() {
diff --git a/mindplot/src/main/javascript/DwrPersistenceManager.js b/mindplot/src/main/javascript/DwrPersistenceManager.js
new file mode 100644
index 00000000..303c0a90
--- /dev/null
+++ b/mindplot/src/main/javascript/DwrPersistenceManager.js
@@ -0,0 +1,83 @@
+/*
+ * Copyright [2011] [wisemapping]
+ *
+ * Licensed under WiseMapping Public License, Version 1.0 (the "License").
+ * It is basically the Apache License, Version 2.0 (the "License") plus the
+ * "powered by wisemapping" text requirement on every single page;
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the license at
+ *
+ * http://www.wisemapping.org/license
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+mindplot.DwrPersitenceManager = new Class({
+ Extends:mindplot.PersitenceManager,
+ initialize: function() {
+ this.parent();
+ },
+
+ saveMapXml : function(mapId, mapXml, pref, saveHistory, events) {
+ window.MapEditorService.saveMap(mapId, mapXml, pref, saveHistory, {
+ callback:function(response) {
+ if (response.msgCode != "OK") {
+ events.onError(response);
+ } else {
+ events.onSuccess(response);
+ }
+ },
+
+ errorHandler:function(message) {
+ events.onError(message);
+ },
+ verb:"POST",
+ async: true
+ }
+ )
+ },
+
+ load : function(mapId) {
+ $assert(mapId, "mapId can not be null");
+ throw "This must be implemented";
+
+// var result = {r:null};
+// window.MapEditorService.loadMap(mapId, {
+// callback:function(response) {
+//
+// if (response.msgCode == "OK") {
+// // Explorer Hack with local files ...
+// var xmlContent = response.content;
+// var domDocument = core.Utils.createDocumentFromText(xmlContent);
+// var serializer = mindplot.XMLMindmapSerializerFactory.getSerializerFromDocument(domDocument);
+// var mindmap = serializer.loadFromDom(domDocument);
+// mindmap.setId(mapId);
+//
+// result.r = mindmap;
+// } else {
+// // Handle error message ...
+// var msg = response.msgDetails;
+// var monitor = core.ToolbarNotifier.getInstance();
+// monitor.logFatal("We're sorry, an error has occurred and we can't load your map. Please try again in a few minutes.");
+//// wLogger.error(msg);
+// }
+// },
+// verb:"GET",
+// async: false,
+// errorHandler:function(msg) {
+// var monitor = core.ToolbarNotifier.getInstance();
+// monitor.logFatal("We're sorry, an error has occurred and we can't load your map. Please try again in a few minutes.");
+//// wLogger.error(msg);
+// }
+// });
+//
+// return result.r;
+ }
+ }
+);
+
+
diff --git a/mindplot/src/main/javascript/FilePersistenceManager.js b/mindplot/src/main/javascript/FilePersistenceManager.js
new file mode 100644
index 00000000..d6fd5f7a
--- /dev/null
+++ b/mindplot/src/main/javascript/FilePersistenceManager.js
@@ -0,0 +1,48 @@
+/*
+ * Copyright [2011] [wisemapping]
+ *
+ * Licensed under WiseMapping Public License, Version 1.0 (the "License").
+ * It is basically the Apache License, Version 2.0 (the "License") plus the
+ * "powered by wisemapping" text requirement on every single page;
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the license at
+ *
+ * http://www.wisemapping.org/license
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+mindplot.FilePersitenceManager = new Class({
+ Extends:mindplot.PersitenceManager,
+ initialize: function() {
+ this.parent();
+ },
+
+ saveMapXml : function(mapId, mapXml, pref, saveHistory, events) {
+ console.log(mapXml);
+ events.onSuccess();
+ },
+
+ load : function(mapId) {
+ $assert(mapId, "mapId can not be null");
+
+ var domDocument;
+ var xmlRequest = new Request({
+ url: '../maps/' + mapId + '.xml',
+ method: 'get',
+ async: false,
+ onSuccess: function(responseText, responseXML) {
+ domDocument = responseXML;
+ }
+ });
+ xmlRequest.send();
+ return this.loadFromDom(mapId, domDocument);
+ }
+ }
+);
+
+
diff --git a/mindplot/src/main/javascript/PersistanceManager.js b/mindplot/src/main/javascript/PersistanceManager.js
deleted file mode 100644
index 95c2d8ae..00000000
--- a/mindplot/src/main/javascript/PersistanceManager.js
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * Copyright [2011] [wisemapping]
- *
- * Licensed under WiseMapping Public License, Version 1.0 (the "License").
- * It is basically the Apache License, Version 2.0 (the "License") plus the
- * "powered by wisemapping" text requirement on every single page;
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the license at
- *
- * http://www.wisemapping.org/license
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-mindplot.PersistanceManager = {};
-
-mindplot.PersistanceManager.save = function(mindmap, editorProperties, onSavedHandler, saveHistory) {
- $assert(mindmap, "mindmap can not be null");
- $assert(editorProperties, "editorProperties can not be null");
-
- var mapId = mindmap.getId();
- $assert(mapId, "mapId can not be null");
-
- var serializer = mindplot.XMLMindmapSerializerFactory.getSerializerFromMindmap(mindmap);
- var xmlMap = serializer.toXML(mindmap);
- var xmlMapStr = core.Utils.innerXML(xmlMap);
-
- var pref = JSON.encode(editorProperties);
-
- window.MapEditorService.saveMap(mapId, xmlMapStr, pref, saveHistory,
- {
- callback:function(response) {
-
- if (response.msgCode != "OK") {
- monitor.logError("Save could not be completed. Please,try again in a couple of minutes.");
-// wLogger.error(response.msgDetails);
- } else {
- // Execute on success handler ...
- if ($defined(onSavedHandler)) {
- onSavedHandler();
- }
- }
- },
- errorHandler:function(message) {
- var monitor = core.ToolbarNotifier.getInstance();
- monitor.logError("Save could not be completed. Please,try again in a couple of minutes.");
-// wLogger.error(message);
- },
- verb:"POST",
- async: false
- });
-
-};
-
-mindplot.PersistanceManager.load = function(mapId) {
- $assert(mapId, "mapId can not be null");
-
- var result = {r:null};
- window.MapEditorService.loadMap(mapId, {
- callback:function(response) {
-
- if (response.msgCode == "OK") {
- // Explorer Hack with local files ...
- var xmlContent = response.content;
- var domDocument = core.Utils.createDocumentFromText(xmlContent);
- var serializer = mindplot.XMLMindmapSerializerFactory.getSerializerFromDocument(domDocument);
- var mindmap = serializer.loadFromDom(domDocument);
- mindmap.setId(mapId);
-
- result.r = mindmap;
- } else {
- // Handle error message ...
- var msg = response.msgDetails;
- var monitor = core.ToolbarNotifier.getInstance();
- monitor.logFatal("We're sorry, an error has occurred and we can't load your map. Please try again in a few minutes.");
-// wLogger.error(msg);
- }
- },
- verb:"GET",
- async: false,
- errorHandler:function(msg) {
- var monitor = core.ToolbarNotifier.getInstance();
- monitor.logFatal("We're sorry, an error has occurred and we can't load your map. Please try again in a few minutes.");
-// wLogger.error(msg);
- }
- });
-
- return result.r;
-};
-
-
diff --git a/mindplot/src/main/javascript/PersistenceManager.js b/mindplot/src/main/javascript/PersistenceManager.js
new file mode 100644
index 00000000..5f582442
--- /dev/null
+++ b/mindplot/src/main/javascript/PersistenceManager.js
@@ -0,0 +1,68 @@
+/*
+ * Copyright [2011] [wisemapping]
+ *
+ * Licensed under WiseMapping Public License, Version 1.0 (the "License").
+ * It is basically the Apache License, Version 2.0 (the "License") plus the
+ * "powered by wisemapping" text requirement on every single page;
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the license at
+ *
+ * http://www.wisemapping.org/license
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+mindplot.PersitenceManager = new Class({
+ initialize: function() {
+
+ },
+
+ save: function(mindmap, editorProperties, saveHistory, events) {
+ $assert(mindmap, "mindmap can not be null");
+ $assert(editorProperties, "editorProperties can not be null");
+
+ var mapId = mindmap.getId();
+ $assert(mapId, "mapId can not be null");
+
+ var serializer = mindplot.XMLMindmapSerializerFactory.getSerializerFromMindmap(mindmap);
+ var domMap = serializer.toXML(mindmap);
+ var mapXml = core.Utils.innerXML(domMap);
+
+ var pref = JSON.encode(editorProperties);
+ try {
+ this.saveMapXml(mapId, mapXml, pref, saveHistory, events);
+ } catch(e) {
+ console.log(e);
+ events.onError();
+ }
+ },
+
+ load: function(mapId) {
+ throw "Method must be implemented";
+ },
+
+ saveMapXml : function(mapId, mapXml, pref, saveHistory, events) {
+ throw "Method must be implemented";
+ },
+
+ loadFromDom : function(mapId, mapDom) {
+ $assert(mapId, "mapId can not be null");
+ $assert(mapDom, "mapDom can not be null");
+
+ var serializer = mindplot.XMLMindmapSerializerFactory.getSerializerFromDocument(mapDom);
+ return serializer.loadFromDom(mapDom, mapId);
+ }
+});
+
+mindplot.PersitenceManager.init = function(instance) {
+ mindplot.PersitenceManager._instance = instance;
+};
+
+mindplot.PersitenceManager.getInstance = function() {
+ return mindplot.PersitenceManager._instance;
+};
+
diff --git a/mindplot/src/main/javascript/widget/Menu.js b/mindplot/src/main/javascript/widget/Menu.js
index bc01dbbb..1551808a 100644
--- a/mindplot/src/main/javascript/widget/Menu.js
+++ b/mindplot/src/main/javascript/widget/Menu.js
@@ -245,15 +245,31 @@ mindplot.widget.Menu = new Class({
var saveElem = $('save');
if (saveElem) {
this.addButton('save', false, false, function() {
+
+ $notify("Saving ...");
saveElem.setStyle('cursor', 'wait');
- designer.save(function() {
- saveElem.setStyle('cursor', 'pointer');
- }, true);
+
+ // Load map content ...
+ var mindmap = designer.getMindmap();
+ var mindmapProp = designer.getMindmapProperties();
+
+ var persistenceManager = mindplot.PersitenceManager.getInstance();
+ persistenceManager.save(mindmap, mindmapProp, true, {
+ onSuccess: function() {
+ saveElem.setStyle('cursor', 'pointer');
+ $notify("Save complete");
+
+ },
+ onError: function() {
+ saveElem.setStyle('cursor', 'pointer');
+ $notify("Save could not be completed. Try latter");
+ }
+ });
});
}
- var discartElem = $('discard');
- if (discartElem) {
+ var discardElem = $('discard');
+ if (discardElem) {
this.addButton('discard', false, false, function() {
if (!readOnly) {
diff --git a/mindplot/src/main/javascript/widget/ToolbarNotifier.js b/mindplot/src/main/javascript/widget/ToolbarNotifier.js
index c4f65a3c..f03486da 100644
--- a/mindplot/src/main/javascript/widget/ToolbarNotifier.js
+++ b/mindplot/src/main/javascript/widget/ToolbarNotifier.js
@@ -34,22 +34,31 @@ mindplot.widget.ToolbarNotifier = new Class({
this.logMessage(userMsg, mindplot.widget.ToolbarNotifier.MsgKind.ERROR);
},
- logMessage : function(msg) {
+ hide:function() {
+
+ },
+
+ logMessage : function(msg, fade) {
$assert(msg, 'msg can not be null');
this._container.set('text', msg);
this._container.setStyle('display', 'block');
-
- this._effect.start({
- 0: {
- opacity: [1,0]
- }
- });
this._container.position({
relativeTo: $('header'),
position: 'upperCenter',
edge: 'centerTop'
});
+ if (!$defined(fade) || fade) {
+ this._effect.start({
+ 0: {
+ opacity: [1,0]
+ }
+ });
+
+ } else {
+ this._container.setStyle('opacity', '1');
+ this._effect.pause();
+ }
}
});
diff --git a/wise-doc/src/main/webapp/html/editor.html b/wise-doc/src/main/webapp/html/editor.html
index bf19a041..94ea12a0 100644
--- a/wise-doc/src/main/webapp/html/editor.html
+++ b/wise-doc/src/main/webapp/html/editor.html
@@ -53,22 +53,12 @@
});
} else if (collab == 'standalone' && mindReady) {
+ // Configure default persistence manager ...
+ mindplot.PersitenceManager.init(new mindplot.FilePersitenceManager());
+
// Load map from XML ...
- var domDocument;
- var xmlRequest = new Request({
- url: '../maps/map1.xml',
- method: 'get',
- async: false,
- onSuccess: function(responseText, responseXML) {
- domDocument = responseXML;
- }
- });
- xmlRequest.send();
-
- var serializer = mindplot.XMLMindmapSerializerFactory.getSerializerFromDocument(domDocument);
- var mindmap = serializer.loadFromDom(domDocument, mapId);
-
- // Now, load the map ...
+ var persitence = mindplot.PersitenceManager.getInstance();
+ var mindmap = persitence.load("map1");
designer.loadMap(mindmap);
// If not problem has arisen, close the dialog ...
@@ -77,12 +67,6 @@
}
}
});
- // @Todo: Hack for testing save ...
- window.MapEditorService = {};
- window.MapEditorService.saveMap = function(mapId, xmlMapStr, pref, saveHistory) {
- console.log(xmlMapStr);
- };
-
@@ -232,9 +216,7 @@
-
+
diff --git a/wise-webapp/src/main/webapp/jsp/mindmapEditor.jsp b/wise-webapp/src/main/webapp/jsp/mindmapEditor.jsp
index 88d981f1..a7de8fde 100644
--- a/wise-webapp/src/main/webapp/jsp/mindmapEditor.jsp
+++ b/wise-webapp/src/main/webapp/jsp/mindmapEditor.jsp
@@ -37,15 +37,18 @@
$(document).addEvent('loadcomplete', function(resource) {
mindReady = resource == 'mind' ? true : mindReady;
if (mindReady) {
+ // Configure default persistence ...
+ mindplot.PersitenceManager.init(new mindplot.DwrPersitenceManager());
+ var persitence = mindplot.PersitenceManager.getInstance();
+ // Initialize editor ...
var editorProperties = ${mindmap.properties};
editorProperties.collab = 'standalone';
editorProperties.readOnly = false;
designer = buildDesigner(editorProperties);
var domDocument = core.Utils.createDocumentFromText(mapXml);
- var serializer = mindplot.XMLMindmapSerializerFactory.getSerializerFromDocument(domDocument);
- var mindmap = serializer.loadFromDom(domDocument, mapId);
+ var mindmap = persitence.loadFromDom(mapId, domDocument);
// Now, load the map ...
designer.loadMap(mindmap);