Add some documentation
This commit is contained in:
@@ -32,6 +32,9 @@ import app.service.LanguageOperations;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.fxml.Initializable;
|
||||
|
||||
/**
|
||||
* A FXML controller that controls the editor component of the UI
|
||||
*/
|
||||
public class EditorController implements Initializable, Controller {
|
||||
|
||||
@FXML
|
||||
@@ -73,8 +76,11 @@ public class EditorController implements Initializable, Controller {
|
||||
}
|
||||
|
||||
/**
|
||||
* Uses Model.language to determine whether the current line/selection is
|
||||
* commented or not, and toggles the comment.
|
||||
* Uses the {@link app.model.ProgrammingLanguage ProgrammingLanguage} in
|
||||
* {@link app.model.Model Model} to determine whether the current line/selection
|
||||
* is commented or not, and toggles the comment.
|
||||
*
|
||||
* @see app.model.ProgrammingLanguage#commentLine(String) ProgrammingLanguage.commentLine(line)
|
||||
*/
|
||||
private void toggleComment() {
|
||||
if (editor.getSelectedText().equals("")) {
|
||||
@@ -101,6 +107,10 @@ public class EditorController implements Initializable, Controller {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the wraptext setting of the code area
|
||||
* @param isWrapText The new value for the setting
|
||||
*/
|
||||
private void setWrapText(boolean isWrapText) {
|
||||
this.editor.setWrapText(isWrapText);
|
||||
}
|
||||
@@ -120,34 +130,33 @@ public class EditorController implements Initializable, Controller {
|
||||
}
|
||||
|
||||
/**
|
||||
* Refreshes the editor whenever the language is changed.
|
||||
*
|
||||
* @param event
|
||||
* Updates the content of the editor to a specific filepath
|
||||
* @param filePath The path of the file
|
||||
* @throws FileNotFoundException
|
||||
*/
|
||||
|
||||
@Subscribe
|
||||
private void handle(FileSelectedEvent event) {
|
||||
try (Scanner sc = new Scanner(new File(event.getPath()))) {
|
||||
private void setEditorContent(String filePath) {
|
||||
try (Scanner sc = new Scanner(new File(filePath))) {
|
||||
editor.clear();
|
||||
while (sc.hasNextLine()) {
|
||||
editor.appendText(sc.nextLine());
|
||||
editor.appendText("\n");
|
||||
}
|
||||
} catch (FileNotFoundException ex) {
|
||||
System.out.println(event.getPath());
|
||||
// TODO: add better error handling and user feedback
|
||||
System.err.println(filePath);
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
private void handle(FileSelectedEvent event) {
|
||||
this.setEditorContent(event.getPath());
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
private void handle(LanguageChangedEvent event) {
|
||||
this.refreshHighlighting();
|
||||
}
|
||||
|
||||
/**
|
||||
* Toggles a language specific comment of the line/selection
|
||||
*
|
||||
* @param event
|
||||
*/
|
||||
@Subscribe
|
||||
private void handle(ToggleCommentEvent event) {
|
||||
this.toggleComment();
|
||||
|
||||
Reference in New Issue
Block a user