|
@ -27,8 +27,8 @@ var contractTemplate = "contract Contract {\n}\n"; |
|
|
|
|
|
|
|
|
function saveCurrentDocument() |
|
|
function saveCurrentDocument() |
|
|
{ |
|
|
{ |
|
|
documentSaving(projectPath + currentDocumentId); |
|
|
|
|
|
var doc = projectListModel.get(getDocumentIndex(currentDocumentId)); |
|
|
var doc = projectListModel.get(getDocumentIndex(currentDocumentId)); |
|
|
|
|
|
documentSaving(doc); |
|
|
if (doc.isContract) |
|
|
if (doc.isContract) |
|
|
contractSaved(currentDocumentId); |
|
|
contractSaved(currentDocumentId); |
|
|
else |
|
|
else |
|
@ -53,12 +53,25 @@ function closeProject(callBack) { |
|
|
else |
|
|
else |
|
|
{ |
|
|
{ |
|
|
doCloseProject(); |
|
|
doCloseProject(); |
|
|
callBack(); |
|
|
if (callBack) |
|
|
|
|
|
callBack(); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
function saveProject() { |
|
|
function saveProject() { |
|
|
|
|
|
if (!isEmpty) { |
|
|
|
|
|
var projectData = saveProjectFile(); |
|
|
|
|
|
if (projectData !== null) |
|
|
|
|
|
{ |
|
|
|
|
|
projectSaving(projectData); |
|
|
|
|
|
projectSaved(); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function saveProjectFile() |
|
|
|
|
|
{ |
|
|
if (!isEmpty) { |
|
|
if (!isEmpty) { |
|
|
var projectData = { |
|
|
var projectData = { |
|
|
files: [], |
|
|
files: [], |
|
@ -72,12 +85,13 @@ function saveProject() { |
|
|
}; |
|
|
}; |
|
|
for (var i = 0; i < projectListModel.count; i++) |
|
|
for (var i = 0; i < projectListModel.count; i++) |
|
|
projectData.files.push(projectListModel.get(i).fileName); |
|
|
projectData.files.push(projectListModel.get(i).fileName); |
|
|
projectSaving(projectData); |
|
|
|
|
|
var json = JSON.stringify(projectData, null, "\t"); |
|
|
var json = JSON.stringify(projectData, null, "\t"); |
|
|
var projectFile = projectPath + projectFileName; |
|
|
var projectFile = projectPath + projectFileName; |
|
|
fileIo.writeFile(projectFile, json); |
|
|
fileIo.writeFile(projectFile, json); |
|
|
projectSaved(); |
|
|
return projectData; |
|
|
} |
|
|
} |
|
|
|
|
|
return null; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
function loadProject(path) { |
|
|
function loadProject(path) { |
|
@ -147,6 +161,7 @@ function addFile(fileName) { |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
projectListModel.append(docData); |
|
|
projectListModel.append(docData); |
|
|
|
|
|
saveProjectFile(); |
|
|
fileIo.watchFileChanged(p); |
|
|
fileIo.watchFileChanged(p); |
|
|
return docData.documentId; |
|
|
return docData.documentId; |
|
|
} |
|
|
} |
|
@ -160,6 +175,17 @@ function getDocumentIndex(documentId) |
|
|
return -1; |
|
|
return -1; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function getDocumentByPath(_path) |
|
|
|
|
|
{ |
|
|
|
|
|
for (var i = 0; i < projectListModel.count; i++) |
|
|
|
|
|
{ |
|
|
|
|
|
var doc = projectListModel.get(i); |
|
|
|
|
|
if (doc.path.indexOf(_path) !== -1) |
|
|
|
|
|
return doc.documentId; |
|
|
|
|
|
} |
|
|
|
|
|
return null; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
function openDocument(documentId) { |
|
|
function openDocument(documentId) { |
|
|
if (documentId !== currentDocumentId) { |
|
|
if (documentId !== currentDocumentId) { |
|
|
documentOpened(projectListModel.get(getDocumentIndex(documentId))); |
|
|
documentOpened(projectListModel.get(getDocumentIndex(documentId))); |
|
@ -243,12 +269,16 @@ function renameDocument(documentId, newName) { |
|
|
var i = getDocumentIndex(documentId); |
|
|
var i = getDocumentIndex(documentId); |
|
|
var document = projectListModel.get(i); |
|
|
var document = projectListModel.get(i); |
|
|
if (!document.isContract) { |
|
|
if (!document.isContract) { |
|
|
|
|
|
fileIo.stopWatching(document.path); |
|
|
var sourcePath = document.path; |
|
|
var sourcePath = document.path; |
|
|
var destPath = projectPath + newName; |
|
|
var destPath = projectPath + newName; |
|
|
fileIo.moveFile(sourcePath, destPath); |
|
|
fileIo.moveFile(sourcePath, destPath); |
|
|
document.path = destPath; |
|
|
document.path = destPath; |
|
|
document.name = newName; |
|
|
document.name = newName; |
|
|
|
|
|
document.fileName = newName; |
|
|
projectListModel.set(i, document); |
|
|
projectListModel.set(i, document); |
|
|
|
|
|
fileIo.watchFileChanged(destPath); |
|
|
|
|
|
saveProjectFile(); |
|
|
documentUpdated(documentId); |
|
|
documentUpdated(documentId); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
@ -263,7 +293,6 @@ function removeDocument(documentId) { |
|
|
var document = projectListModel.get(i); |
|
|
var document = projectListModel.get(i); |
|
|
if (!document.isContract) { |
|
|
if (!document.isContract) { |
|
|
projectListModel.remove(i); |
|
|
projectListModel.remove(i); |
|
|
fileIo.stopWatching(projectPath+ documentId); |
|
|
|
|
|
documentRemoved(documentId); |
|
|
documentRemoved(documentId); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|