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/CollaborationManager.js</include>
<include>collaboration/framework/AbstractCollaborativeFramework.js</include> <include>collaboration/framework/AbstractCollaborativeFramework.js</include>
<include>collaboration/framework/AbstractCollaborativeModelFactory.js</include> <include>collaboration/framework/AbstractCollaborativeModelFactory.js</include>
<include>widget/ModalDialogNotifier.js</include>
<include>widget/ToolbarNotifier.js</include> <include>widget/ToolbarNotifier.js</include>
<include>widget/ToolbarItem.js</include> <include>widget/ToolbarItem.js</include>
<include>widget/ToolbarPaneItem.js</include> <include>widget/ToolbarPaneItem.js</include>

View File

@ -24,7 +24,7 @@ mindplot.LocalStorageManager = new Class({
saveMapXml:function (mapId, mapXml, pref, saveHistory, events) { saveMapXml:function (mapId, mapXml, pref, saveHistory, events) {
localStorage.setItem(mapId + "-xml", mapXml); 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) { discardChanges:function (mapId) {
@ -49,7 +49,6 @@ mindplot.LocalStorageManager = new Class({
if (xml == null) { if (xml == null) {
throw new Error("Map could not be loaded"); throw new Error("Map could not be loaded");
} }
} }
var parser = new DOMParser(); var parser = new DOMParser();

View File

@ -44,10 +44,10 @@ mindplot.PersistenceManager = new Class({
var pref = JSON.encode(editorProperties); var pref = JSON.encode(editorProperties);
try { try {
this.saveMapXml(mapId, mapXml, pref, saveHistory, events,sync); this.saveMapXml(mapId, mapXml, pref, saveHistory, events, sync);
} catch (e) { } catch (e) {
console.log(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"); 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"); throw new Error("Method must be implemented");
}, },

View File

@ -55,7 +55,7 @@ mindplot.RESTPersistenceManager = new Class({
persistence.timestamp = responseText; persistence.timestamp = responseText;
}, },
onException:function (headerName, value) { onException:function (headerName, value) {
events.onError(); events.onError(persistence._buildError());
}, },
onFailure:function (xhr) { onFailure:function (xhr) {
var responseText = xhr.responseText; var responseText = xhr.responseText;
@ -65,11 +65,12 @@ mindplot.RESTPersistenceManager = new Class({
if (contentType != null && contentType.indexOf("application/json") != -1) { if (contentType != null && contentType.indexOf("application/json") != -1) {
try { try {
error = JSON.decode(responseText); error = JSON.decode(responseText);
events.onError(persistence._buildError(error));
} catch (e) { } 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"}, headers:{"Content-Type":"application/json", "Accept":"application/json"},
emulation:false, emulation:false,
@ -114,6 +115,20 @@ mindplot.RESTPersistenceManager = new Class({
urlEncoded:false urlEncoded:false
}); });
request.put("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) { if (saveHistory) {
$notify($msg('SAVING')); $notify($msg('SAVING'));
saveElem.setStyle('cursor', 'wait'); saveElem.setStyle('cursor', 'wait');
} else {
console.log("Saving without history ...");
} }
// Call persistence manager for saving ... // Call persistence manager for saving ...
@ -87,14 +85,16 @@ mindplot.widget.IMenu = new Class({
} }
menu.setRequireChange(false); menu.setRequireChange(false);
}, },
onError:function (error) { onError:function (error) {
if (saveHistory) { if (saveHistory) {
saveElem.setStyle('cursor', 'pointer'); saveElem.setStyle('cursor', 'pointer');
var msg = error ? error.globalErrors : null;
if (!msg) { if (error.severity == "INFO") {
msg = $msg('SAVE_COULD_NOT_BE_COMPLETED'); $notify(error.message);
} else {
$notifyModal(error.message);
} }
$notify(msg);
} }
} }
}, sync); }, sync);

View File

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