added som comments
This commit is contained in:
parent
4a63aa6edf
commit
be748d9138
@ -4,8 +4,6 @@ import java.io.File;
|
|||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.nio.file.Files;
|
|
||||||
import java.nio.file.Paths;
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.ResourceBundle;
|
import java.util.ResourceBundle;
|
||||||
import java.util.Scanner;
|
import java.util.Scanner;
|
||||||
@ -138,7 +136,8 @@ public class EditorController implements Initializable, Controller {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates the content of the editor to a specific filepath
|
* Updates the content of the editor to a specific filepath. Otherwise it will
|
||||||
|
* open an error dialog to give the user feedback about what has happened.
|
||||||
*
|
*
|
||||||
* @param filePath The path of the file
|
* @param filePath The path of the file
|
||||||
* @throws FileNotFoundException
|
* @throws FileNotFoundException
|
||||||
@ -169,6 +168,11 @@ public class EditorController implements Initializable, Controller {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Saving/Writing to the file based on the spesific filepath. Otherwise it will
|
||||||
|
* open an error dialog to give the user feedback about what has happened.
|
||||||
|
*/
|
||||||
|
|
||||||
private void saveCodeArea(String filePath) {
|
private void saveCodeArea(String filePath) {
|
||||||
try (PrintWriter writer = new PrintWriter(new File(filePath))) {
|
try (PrintWriter writer = new PrintWriter(new File(filePath))) {
|
||||||
if (filePath.endsWith(".java") || filePath.endsWith(".md")) {
|
if (filePath.endsWith(".java") || filePath.endsWith(".md")) {
|
||||||
@ -179,18 +183,28 @@ public class EditorController implements Initializable, Controller {
|
|||||||
|
|
||||||
} catch (FileNotFoundException ex) {
|
} catch (FileNotFoundException ex) {
|
||||||
Alert error = new Alert(AlertType.ERROR);
|
Alert error = new Alert(AlertType.ERROR);
|
||||||
error.setContentText("Could not save file!\nMust be a java or md file. Try again.");
|
error.setContentText("Could not save file!\nMust be a java or md file or not null. Try again.");
|
||||||
|
|
||||||
error.showAndWait();
|
error.showAndWait();
|
||||||
System.err.println(filePath);
|
System.err.println(filePath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------------------ */
|
||||||
|
/* SUBSCRIPTIONS */
|
||||||
|
/* ------------------------------------------------------------------------ */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates Code Area (read from file) whenever the FileSelected is changed
|
||||||
|
*/
|
||||||
@Subscribe
|
@Subscribe
|
||||||
private void handle(FileSelectedEvent event) {
|
private void handle(FileSelectedEvent event) {
|
||||||
this.setEditorContent(event.getPath());
|
this.setEditorContent(event.getPath());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Save file (write to file) whenever the save in the menubare is selected
|
||||||
|
*/
|
||||||
@Subscribe
|
@Subscribe
|
||||||
private void handle(SaveFile event) {
|
private void handle(SaveFile event) {
|
||||||
this.saveCodeArea(event.getPath());
|
this.saveCodeArea(event.getPath());
|
||||||
|
@ -52,6 +52,10 @@ public class FiletreeController implements Initializable, Controller {
|
|||||||
this.eventBus.register(this);
|
this.eventBus.register(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------------------ */
|
||||||
|
/* FILETREE */
|
||||||
|
/* ------------------------------------------------------------------------ */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The displaying of the fileTree. The inputChosen(the path) is aquired from the
|
* The displaying of the fileTree. The inputChosen(the path) is aquired from the
|
||||||
* eventBus (OpeFileProjectEvent). The root is created as a CheckBoxItems and
|
* eventBus (OpeFileProjectEvent). The root is created as a CheckBoxItems and
|
||||||
@ -133,6 +137,13 @@ public class FiletreeController implements Initializable, Controller {
|
|||||||
parent.getChildren().add(element);
|
parent.getChildren().add(element);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------------------ */
|
||||||
|
/* MouseClick */
|
||||||
|
/* ------------------------------------------------------------------------ */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handles whenever a filetree item is clicked twice.
|
||||||
|
*/
|
||||||
@FXML
|
@FXML
|
||||||
private void handleMouseClick(MouseEvent event) {
|
private void handleMouseClick(MouseEvent event) {
|
||||||
if (event.getClickCount() == 2) {
|
if (event.getClickCount() == 2) {
|
||||||
@ -154,6 +165,14 @@ public class FiletreeController implements Initializable, Controller {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------------------ */
|
||||||
|
/* SUBSCRIPTIONS */
|
||||||
|
/* ------------------------------------------------------------------------ */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates the filetree whenever a new ProjectPath is selected.
|
||||||
|
*/
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
private void handle(OpenProjectEvent event) {
|
private void handle(OpenProjectEvent event) {
|
||||||
this.showTree(event.getPath());
|
this.showTree(event.getPath());
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
package app.controllers;
|
package app.controllers;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileNotFoundException;
|
|
||||||
import java.io.PrintWriter;
|
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
@ -38,7 +36,7 @@ import javafx.stage.FileChooser;
|
|||||||
import javafx.stage.Stage;
|
import javafx.stage.Stage;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A FXML controller that controls the filetree component of the UI
|
* A FXML controller that controls the menubar component of the UI
|
||||||
*/
|
*/
|
||||||
public class MenubarController implements Initializable, Controller {
|
public class MenubarController implements Initializable, Controller {
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user