Temporal commit.

This commit is contained in:
Paulo Gustavo Veiga 2012-10-05 20:05:33 -03:00
parent cc57fae5cf
commit 24b4f4b190
6 changed files with 100 additions and 66 deletions

View File

@ -195,6 +195,7 @@
<include>collaboration/CollaborationManager.js</include>
<include>collaboration/framework/AbstractCollaborativeFramework.js</include>
<include>collaboration/framework/AbstractCollaborativeModelFactory.js</include>
<include>widget/ModalDialogNotifier.js</include>
<include>widget/ToolbarNotifier.js</include>
<include>widget/ToolbarItem.js</include>
<include>widget/ToolbarPaneItem.js</include>

View File

@ -24,7 +24,7 @@ mindplot.LocalStorageManager = new Class({
saveMapXml:function (mapId, mapXml, pref, saveHistory, events) {
localStorage.setItem(mapId + "-xml", mapXml);
events.onSuccess();
events.onError({message:"It's not possible to save your changes because your mindmap has been modified by '%s'. Refresh the page and try again.", severity:"FATAL"});
},
discardChanges:function (mapId) {
@ -49,7 +49,6 @@ mindplot.LocalStorageManager = new Class({
if (xml == null) {
throw new Error("Map could not be loaded");
}
}
var parser = new DOMParser();

View File

@ -44,10 +44,10 @@ mindplot.PersistenceManager = new Class({
var pref = JSON.encode(editorProperties);
try {
this.saveMapXml(mapId, mapXml, pref, saveHistory, events,sync);
this.saveMapXml(mapId, mapXml, pref, saveHistory, events, sync);
} catch (e) {
console.log(e);
events.onError();
events.onError(this._buildError());
}
},
@ -65,7 +65,7 @@ mindplot.PersistenceManager = new Class({
throw new Error("Method must be implemented");
},
saveMapXml:function (mapId, mapXml, pref, saveHistory, events,sync) {
saveMapXml:function (mapId, mapXml, pref, saveHistory, events, sync) {
throw new Error("Method must be implemented");
},

View File

@ -55,7 +55,7 @@ mindplot.RESTPersistenceManager = new Class({
persistence.timestamp = responseText;
},
onException:function (headerName, value) {
events.onError();
events.onError(persistence._buildError());
},
onFailure:function (xhr) {
var responseText = xhr.responseText;
@ -65,11 +65,12 @@ mindplot.RESTPersistenceManager = new Class({
if (contentType != null && contentType.indexOf("application/json") != -1) {
try {
error = JSON.decode(responseText);
events.onError(persistence._buildError(error));
} catch (e) {
throw "Unexpected error saving. Error response is not json object:" + responseText;
events.onError(persistence._buildError());
throw new Error("Unexpected error saving. Error response is not json object:" + responseText);
}
}
events.onError(error);
},
headers:{"Content-Type":"application/json", "Accept":"application/json"},
emulation:false,
@ -114,6 +115,20 @@ mindplot.RESTPersistenceManager = new Class({
urlEncoded:false
});
request.put("false");
},
_buildError:function (jsonSeverResponse) {
var message = jsonSeverResponse ? jsonSeverResponse.globalErrors[0] : null;
var severity = jsonSeverResponse ? jsonSeverResponse.globalSeverity : null;
if (!message) {
message = $msg('SAVE_COULD_NOT_BE_COMPLETED');
}
if (!severity) {
severity = "INFO";
}
return {severity:severity, message:message};
}
}
);

View File

@ -72,8 +72,6 @@ mindplot.widget.IMenu = new Class({
if (saveHistory) {
$notify($msg('SAVING'));
saveElem.setStyle('cursor', 'wait');
} else {
console.log("Saving without history ...");
}
// Call persistence manager for saving ...
@ -87,14 +85,16 @@ mindplot.widget.IMenu = new Class({
}
menu.setRequireChange(false);
},
onError:function (error) {
if (saveHistory) {
saveElem.setStyle('cursor', 'pointer');
var msg = error ? error.globalErrors : null;
if (!msg) {
msg = $msg('SAVE_COULD_NOT_BE_COMPLETED');
if (error.severity == "INFO") {
$notify(error.message);
} else {
$notifyModal(error.message);
}
$notify(msg);
}
}
}, sync);

View File

@ -16,68 +16,87 @@
* limitations under the License.
*/
mindplot.widget.ToolbarNotifier = new Class({
mindplot.widget.ModalDialogNotifier = new Class({
Extends:MooDialog,
initialize:function () {
var container = $('headerNotifier');
// In case of print,embedded no message is displayed ....
if (container) {
this._effect = new Fx.Elements(container, {
onComplete:function () {
container.setStyle('display', 'none');
}.bind(this),
link:'cancel',
duration:8000,
transition:Fx.Transitions.Expo.easeInOut
this.parent({
closeButton:false,
destroyOnClose:true,
autoOpen:true,
useEscKey:false,
title:"",
onInitialize:function (wrapper) {
wrapper.setStyle('opacity', 0);
this.wrapper.setStyle('display', 'none');
this.fx = new Fx.Morph(wrapper, {
duration:100,
transition:Fx.Transitions.Bounce.easeOut
});
}
},
logError:function (userMsg) {
this.logMessage(userMsg, mindplot.widget.ToolbarNotifier.MsgKind.ERROR);
onBeforeOpen:function () {
var panel = this._buildPanel();
this.setContent(panel);
this.overlay = new Overlay(this.options.inject, {
duration:this.options.duration
});
if (this.options.closeOnOverlayClick)
this.overlay.addEvent('click', this.close.bind(this));
this.overlay.open();
this.fx.start({
'margin-top':[-200, -100],
opacity:[0, 1]
}).chain(function () {
this.fireEvent('show');
this.wrapper.setStyle('display', 'block');
}.bind(this));
},
hide:function () {
onBeforeClose:function () {
this.fx.start({
'margin-top':[-100, 0],
opacity:0,
duration:200
}).chain(function () {
this.wrapper.setStyle('display', 'none');
this.fireEvent('hide');
}.bind(this));
}}
);
this.message = null;
},
logMessage:function (msg, fade) {
$assert(msg, 'msg can not be null');
show:function (message, title) {
$assert(message, "message can not be null");
this._messsage = message;
this.options.title.setText($defined(title) ? title : "Outch!!. An unexpected error has occurred");
this.open();
},
var container = $('headerNotifier');
destroy:function () {
this.parent();
this.overlay.destroy();
},
// In case of print,embedded no message is displayed ....
if (container) {
container.set('text', msg);
container.setStyle('display', 'block');
container.position({
relativeTo:$('header'),
position:'upperCenter',
edge:'centerTop'
_buildPanel:function () {
var result = new Element('div');
result.setStyles({
'text-align':'center',
width:'400px'
});
var p = new Element('p', {'text':this._messsage});
p.inject(result);
if (!$defined(fade) || fade) {
this._effect.start({
0:{
opacity:[1, 0]
}
});
var img = new Element('img', {'src':'images/alert-sign.png'});
img.inject(result);
} else {
container.setStyle('opacity', '1');
this._effect.pause();
return result;
}
}
}
});
mindplot.widget.ToolbarNotifier.MsgKind = {
INFO:1,
WARNING:2,
ERROR:3,
FATAL:4
};
var toolbarNotifier = new mindplot.widget.ToolbarNotifier();
$notify = toolbarNotifier.logMessage.bind(toolbarNotifier);
var dialogNotifier = new mindplot.widget.ModalDialogNotifier();
$notifyModal = dialogNotifier.show.bind(dialogNotifier);