-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathwsAccess.js
More file actions
32 lines (30 loc) · 1.25 KB
/
wsAccess.js
File metadata and controls
32 lines (30 loc) · 1.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
function applicationStarted(pluginWorkspaceAccess) {
pluginWorkspaceAccess.addEditingSessionLifecycleListener(
new JavaAdapter(Packages.ro.sync.ecss.extensions.api.webapp.access.WebappEditingSessionLifecycleListener, {
editingSessionStarted: function (docId, authorDocumentModel) {
authorDocumentModel.getWSEditor().addEditorListener(new JavaAdapter(Packages.ro.sync.exml.workspace.api.listeners.WSEditorListener, {
editorAboutToBeSavedVeto: function() {
if (hasErrors(authorDocumentModel)) {
var workspaceAccess = authorDocumentModel.getAuthorAccess().getWorkspaceAccess();
workspaceAccess.showErrorMessage("Document is not valid");
return false;
}
return true;
}
}))
}
}));
}
/**
* Get the errors of a specific document.
* @param {string} authorDocumentModel The AuthorDocumentModel instance.
*
* @return {boolean} true if the document has validation errors.
*/
function hasErrors(authorDocumentModel) {
var errors = authorDocumentModel.getDocumentValidator().getValidationTask().call();
return errors && !errors.isEmpty();
}
function applicationClosing(pluginWorkspaceAccess) {
// Nothing to do.
}