can now double click on directory without error

master
Oystein 2021-04-07 04:53:36 +02:00
parent 2ecda54d7f
commit 382ae5cbbc
2 changed files with 9 additions and 3 deletions

View File

@ -4,6 +4,8 @@ import java.io.File;
import java.io.FileNotFoundException;
import java.io.PrintWriter;
import java.net.URL;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.Collection;
import java.util.ResourceBundle;
import java.util.Scanner;
@ -144,6 +146,7 @@ public class EditorController implements Initializable, Controller {
private void setEditorContent(String filePath) {
if (filePath == null) {
editor.clear();
editor.appendText("// New File");
return;
}
try (Scanner sc = new Scanner(new File(filePath))) {

View File

@ -10,6 +10,7 @@ import javafx.scene.input.MouseEvent;
import java.io.File;
import java.net.URL;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
@ -136,7 +137,6 @@ public class FiletreeController implements Initializable, Controller {
private void handleMouseClick(MouseEvent event) {
if (event.getClickCount() == 2) {
TreeItem<String> item = filetree.getSelectionModel().getSelectedItem();
String root = Model.getProjectPath().getFileName().toString();
String path = "";
while (!root.equals(item.getValue())) {
@ -146,8 +146,11 @@ public class FiletreeController implements Initializable, Controller {
path = Model.getProjectPath() + path;
Path pathToString = Paths.get(path);
Model.setActiveFilePath(pathToString);
this.eventBus.post(new FileSelectedEvent(path));
if (!Files.isDirectory(pathToString)) {
Model.setActiveFilePath(pathToString);
this.eventBus.post(new FileSelectedEvent(path));
}
}
}