Folder added to its parent without reloading the whole workspace

As we know the parant, we can simple add a child to it. There is no need to reload the workspace. I also took the liberty of renaming refreshWorkspace to updateTreeGraph, to avoid confusion between updating the tree graph and reloading the workspace from disk.
This commit is contained in:
Zevenberge 2017-12-02 21:49:08 +01:00
parent 2bf34ed691
commit c1f4a3b1c2
1 changed files with 22 additions and 14 deletions

View File

@ -1138,7 +1138,7 @@ class IDEFrame : AppFrame, ProgramExecutionStatusListener, BreakpointListChangeL
else else
ed.editorTool = new DefaultEditorTool(this); ed.editorTool = new DefaultEditorTool(this);
//openSourceFile(filename); //openSourceFile(filename);
refreshWorkspace(); updateTreeGraph();
ProjectSourceFile file = _wsPanel.findSourceFileItem(filename, false); ProjectSourceFile file = _wsPanel.findSourceFileItem(filename, false);
if (file) { if (file) {
ed.projectSourceFile = file; ed.projectSourceFile = file;
@ -1210,7 +1210,7 @@ class IDEFrame : AppFrame, ProgramExecutionStatusListener, BreakpointListChangeL
buildProject(BuildOperation.Upgrade, cast(Project)a.objectParam); buildProject(BuildOperation.Upgrade, cast(Project)a.objectParam);
return true; return true;
case IDEActions.RefreshProject: case IDEActions.RefreshProject:
refreshWorkspace(); updateTreeGraph();
return true; return true;
case IDEActions.RevealProjectInExplorer: case IDEActions.RevealProjectInExplorer:
revealProjectInExplorer(cast(Project)a.objectParam); revealProjectInExplorer(cast(Project)a.objectParam);
@ -1437,7 +1437,7 @@ class IDEFrame : AppFrame, ProgramExecutionStatusListener, BreakpointListChangeL
if (cast(Workspace)obj) { if (cast(Workspace)obj) {
Workspace ws = cast(Workspace)obj; Workspace ws = cast(Workspace)obj;
ws.refresh(); ws.refresh();
refreshWorkspace(); updateTreeGraph();
} else if (cast(Project)obj) { } else if (cast(Project)obj) {
project = cast(Project)obj; project = cast(Project)obj;
} else if (cast(ProjectFolder)obj) { } else if (cast(ProjectFolder)obj) {
@ -1456,7 +1456,7 @@ class IDEFrame : AppFrame, ProgramExecutionStatusListener, BreakpointListChangeL
} }
if (project) { if (project) {
project.refresh(); project.refresh();
refreshWorkspace(); updateTreeGraph();
} }
} }
@ -1483,7 +1483,7 @@ class IDEFrame : AppFrame, ProgramExecutionStatusListener, BreakpointListChangeL
Log.e("Cannot remove file"); Log.e("Cannot remove file");
} }
project.refresh(); project.refresh();
refreshWorkspace(); updateTreeGraph();
} }
// else ignore // else ignore
return true; return true;
@ -1500,7 +1500,7 @@ class IDEFrame : AppFrame, ProgramExecutionStatusListener, BreakpointListChangeL
if (res) { if (res) {
//res.project.reload(); //res.project.reload();
res.project.refresh(); res.project.refresh();
refreshWorkspace(); updateTreeGraph();
if (isSupportedSourceTextFileFormat(res.filename)) { if (isSupportedSourceTextFileFormat(res.filename)) {
openSourceFile(res.filename, null, true); openSourceFile(res.filename, null, true);
} }
@ -1519,9 +1519,11 @@ class IDEFrame : AppFrame, ProgramExecutionStatusListener, BreakpointListChangeL
if(result.id == ACTION_FILE_NEW_DIRECTORY.id) { if(result.id == ACTION_FILE_NEW_DIRECTORY.id) {
FileCreationResult res = cast(FileCreationResult)result.objectParam; FileCreationResult res = cast(FileCreationResult)result.objectParam;
if (res) { if (res) {
//res.project.reload(); ProjectFolder newFolder = new ProjectFolder(res.filename);
res.project.refresh(); if(folder) {
refreshWorkspace(); folder.addChild(newFolder);
}
updateTreeGraph();
} }
} }
}; };
@ -1543,6 +1545,12 @@ class IDEFrame : AppFrame, ProgramExecutionStatusListener, BreakpointListChangeL
ProjectFolder folder; ProjectFolder folder;
if (cast(Project)obj) { if (cast(Project)obj) {
project = cast(Project)obj; project = cast(Project)obj;
folder = project.items;
import std.stdio;
writeln("Root filename:", folder.filename);
for(int i = 0; i < folder.childCount; i++) {
writeln("Child [", i, "]: ", folder.child(i).filename);
}
} else if (cast(ProjectFolder)obj) { } else if (cast(ProjectFolder)obj) {
folder = cast(ProjectFolder)obj; folder = cast(ProjectFolder)obj;
project = folder.project; project = folder.project;
@ -1579,12 +1587,12 @@ class IDEFrame : AppFrame, ProgramExecutionStatusListener, BreakpointListChangeL
if (currentWorkspace is null || res.workspace !is currentWorkspace) { if (currentWorkspace is null || res.workspace !is currentWorkspace) {
// open new workspace // open new workspace
setWorkspace(res.workspace); setWorkspace(res.workspace);
refreshWorkspace(); updateTreeGraph();
hideHomeScreen(); hideHomeScreen();
} else { } else {
// project added to current workspace // project added to current workspace
loadProject(res.project); loadProject(res.project);
refreshWorkspace(); updateTreeGraph();
hideHomeScreen(); hideHomeScreen();
} }
} }
@ -1786,7 +1794,7 @@ class IDEFrame : AppFrame, ProgramExecutionStatusListener, BreakpointListChangeL
currentWorkspace.addProject(project); currentWorkspace.addProject(project);
loadProject(project); loadProject(project);
currentWorkspace.save(); currentWorkspace.save();
refreshWorkspace(); updateTreeGraph();
hideHomeScreen(); hideHomeScreen();
} }
return true; return true;
@ -1801,7 +1809,7 @@ class IDEFrame : AppFrame, ProgramExecutionStatusListener, BreakpointListChangeL
} }
} }
void refreshWorkspace() { void updateTreeGraph() {
_logPanel.logLine("Refreshing workspace"); _logPanel.logLine("Refreshing workspace");
_wsPanel.reloadItems(); _wsPanel.reloadItems();
closeRemovedDocuments(); closeRemovedDocuments();
@ -1867,7 +1875,7 @@ class IDEFrame : AppFrame, ProgramExecutionStatusListener, BreakpointListChangeL
void refreshProject(Project project) { void refreshProject(Project project) {
if (currentWorkspace && project.loadSelections()) { if (currentWorkspace && project.loadSelections()) {
currentWorkspace.cleanupUnusedDependencies(); currentWorkspace.cleanupUnusedDependencies();
refreshWorkspace(); updateTreeGraph();
} }
} }