|
|
@ -43,10 +43,14 @@ function closeProject() { |
|
|
|
|
|
|
|
function saveProject() { |
|
|
|
if (!isEmpty) { |
|
|
|
var projectData = { files: [] }; |
|
|
|
for (var i = 0; i < projectListModel.count; i++) |
|
|
|
projectData.files.push(projectListModel.get(i).fileName) |
|
|
|
projectSaving(projectData); |
|
|
|
var json = JSON.stringify(projectData); |
|
|
|
var projectFile = projectPath + projectFileName; |
|
|
|
fileIo.writeFile(projectFile, json); |
|
|
|
projectSaved(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
@ -55,11 +59,12 @@ function loadProject(path) { |
|
|
|
console.log("loading project at " + path); |
|
|
|
var projectFile = path + projectFileName; |
|
|
|
var json = fileIo.readFile(projectFile); |
|
|
|
projectData = JSON.parse(json); |
|
|
|
var projectData = JSON.parse(json); |
|
|
|
if (!projectData.title) { |
|
|
|
var parts = path.split("/"); |
|
|
|
projectData.title = parts[parts.length - 2]; |
|
|
|
} |
|
|
|
projectTitle = projectData.title; |
|
|
|
projectPath = path; |
|
|
|
if (!projectData.files) |
|
|
|
projectData.files = []; |
|
|
@ -68,32 +73,31 @@ function loadProject(path) { |
|
|
|
addFile(projectData.files[i]); |
|
|
|
} |
|
|
|
projectSettings.lastProjectPath = path; |
|
|
|
projectLoaded(); |
|
|
|
projectLoaded(projectData); |
|
|
|
} |
|
|
|
|
|
|
|
function addExistingFile() { |
|
|
|
addExistingFileDialog.open(); |
|
|
|
} |
|
|
|
|
|
|
|
function addProjectFiles(files) { |
|
|
|
for(var i = 0; i < files.length; i++) |
|
|
|
addFile(files[i]); |
|
|
|
} |
|
|
|
|
|
|
|
function addFile(fileName) { |
|
|
|
var p = projectPath + fileName; |
|
|
|
var extension = fileName.substring(fileName.length - 4, fileName.length); |
|
|
|
var extension = fileName.substring(fileName.lastIndexOf("."), fileName.length); |
|
|
|
var isContract = extension === ".sol"; |
|
|
|
var fileData = { |
|
|
|
var isHtml = extension === ".html"; |
|
|
|
var docData = { |
|
|
|
contract: false, |
|
|
|
path: p, |
|
|
|
fileName: fileName, |
|
|
|
name: isContract ? "Contract" : fileName, |
|
|
|
documentId: fileName, |
|
|
|
isText: isContract || extension === ".html" || extension === ".js", |
|
|
|
isText: isContract || isHtml || extension === ".js", |
|
|
|
isContract: isContract, |
|
|
|
isHtml: isHtml, |
|
|
|
}; |
|
|
|
|
|
|
|
projectListModel.append(fileData); |
|
|
|
projectListModel.append(docData); |
|
|
|
return docData.documentId; |
|
|
|
} |
|
|
|
|
|
|
|
function findDocument(documentId) |
|
|
@ -143,14 +147,12 @@ function doCreateProject(title, path) { |
|
|
|
function doAddExistingFiles(files) { |
|
|
|
for(var i = 0; i < files.length; i++) { |
|
|
|
var sourcePath = files[i]; |
|
|
|
console.log(sourcePath); |
|
|
|
var sourceFileName = sourcePath.substring(sourcePath.lastIndexOf("/") + 1, sourcePath.length); |
|
|
|
console.log(sourceFileName); |
|
|
|
var destPath = projectPath + sourceFileName; |
|
|
|
console.log(destPath); |
|
|
|
if (sourcePath !== destPath) |
|
|
|
fileIo.copyFile(sourcePath, destPath); |
|
|
|
addFile(sourceFileName); |
|
|
|
var id = addFile(sourceFileName); |
|
|
|
documentAdded(id) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
@ -168,12 +170,17 @@ function renameDocument(documentId, newName) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
function getDocument(documentId) { |
|
|
|
var i = findDocument(documentId); |
|
|
|
return projectListModel.get(i); |
|
|
|
} |
|
|
|
|
|
|
|
function removeDocument(documentId) { |
|
|
|
var i = findDocument(documentId); |
|
|
|
var document = projectListModel.get(i); |
|
|
|
if (!document.isContract) { |
|
|
|
projectListModel.remove(i); |
|
|
|
documentUpdated(documentId); |
|
|
|
documentRemoved(documentId); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
@ -189,7 +196,8 @@ function createAndAddFile(name, extension, content) { |
|
|
|
var fileName = generateFileName(name, extension); |
|
|
|
var filePath = projectPath + fileName; |
|
|
|
fileIo.writeFile(filePath, content); |
|
|
|
addFile(fileName); |
|
|
|
var id = addFile(fileName); |
|
|
|
documentAdded(id); |
|
|
|
} |
|
|
|
|
|
|
|
function generateFileName(name, extension) { |
|
|
|