mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
fixed bug with empty task files, improved navigation to task
This commit is contained in:
+10
-2
@@ -20,6 +20,7 @@ import com.intellij.openapi.util.Condition;
|
||||
import com.intellij.openapi.vfs.LocalFileSystem;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.vfs.VirtualFileManager;
|
||||
import com.intellij.openapi.vfs.newvfs.NewVirtualFile;
|
||||
import com.intellij.openapi.vfs.newvfs.impl.VirtualDirectoryImpl;
|
||||
import com.intellij.openapi.wm.ex.ToolWindowManagerAdapter;
|
||||
import com.intellij.openapi.wm.ex.ToolWindowManagerEx;
|
||||
@@ -188,7 +189,6 @@ public class StudyDirectoryProjectGenerator extends PythonProjectGenerator imple
|
||||
final VirtualFile taskDir = firstTask.getTaskDir(myProject);
|
||||
if (taskDir == null) return;
|
||||
final Map<String, TaskFile> taskFiles = firstTask.getTaskFiles();
|
||||
|
||||
VirtualFile activeVirtualFile = null;
|
||||
for (Map.Entry<String, TaskFile> entry : taskFiles.entrySet()) {
|
||||
final String name = entry.getKey();
|
||||
@@ -204,8 +204,16 @@ public class StudyDirectoryProjectGenerator extends PythonProjectGenerator imple
|
||||
if (activeVirtualFile != null) {
|
||||
final PsiFile file = PsiManager.getInstance(myProject).findFile(activeVirtualFile);
|
||||
ProjectView.getInstance(project).select(file, activeVirtualFile, true);
|
||||
initialized[0] = true;
|
||||
} else {
|
||||
String first = StudyUtils.getFirst(taskFiles.keySet());
|
||||
if (first != null) {
|
||||
NewVirtualFile firstFile = ((VirtualDirectoryImpl)taskDir).refreshAndFindChild(first);
|
||||
if (firstFile != null) {
|
||||
FileEditorManager.getInstance(project).openFile(firstFile, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
initialized[0] = true;
|
||||
}
|
||||
}, ModalityState.current(), new Condition() {
|
||||
@Override
|
||||
|
||||
+15
-6
@@ -19,7 +19,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.util.Set;
|
||||
import java.util.Map;
|
||||
|
||||
public class StudyDirectoryNode extends PsiDirectoryNode {
|
||||
private final PsiDirectory myValue;
|
||||
@@ -144,15 +144,24 @@ public class StudyDirectoryNode extends PsiDirectoryNode {
|
||||
FileEditorManager.getInstance(myProject).closeFile(openFile);
|
||||
}
|
||||
VirtualFile child = null;
|
||||
Set<String> fileNames = task.getTaskFiles().keySet();
|
||||
for (String name : fileNames) {
|
||||
child = taskDir.findChild(name);
|
||||
if (child != null) {
|
||||
FileEditorManager.getInstance(myProject).openFile(child, true);
|
||||
Map<String, TaskFile> taskFiles = task.getTaskFiles();
|
||||
for (Map.Entry<String, TaskFile> entry: taskFiles.entrySet()) {
|
||||
VirtualFile file = taskDir.findChild(entry.getKey());
|
||||
if (file != null) {
|
||||
FileEditorManager.getInstance(myProject).openFile(file, true);
|
||||
}
|
||||
if (!entry.getValue().getTaskWindows().isEmpty()) {
|
||||
child = file;
|
||||
}
|
||||
}
|
||||
if (child != null) {
|
||||
ProjectView.getInstance(myProject).select(child, child, false);
|
||||
FileEditorManager.getInstance(myProject).openFile(child, true);
|
||||
} else {
|
||||
VirtualFile[] children = taskDir.getChildren();
|
||||
if (children.length > 0) {
|
||||
ProjectView.getInstance(myProject).select(children[0], children[0], false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user