Add some documentation

This commit is contained in:
2021-03-02 18:50:44 +01:00
parent 41362a45d4
commit 180627578b
8 changed files with 115 additions and 46 deletions

View File

@@ -32,6 +32,9 @@ import javafx.stage.DirectoryChooser;
import javafx.stage.FileChooser;
import javafx.stage.Stage;
/**
* A FXML controller that controls the filetree component of the UI
*/
public class MenubarController implements Initializable, Controller {
private EventBus eventBus;
@@ -57,6 +60,9 @@ public class MenubarController implements Initializable, Controller {
/* FILE */
/* ------------------------------------------------------------------------ */
/**
* Handles whenever the Open File button is pressed in the menubar
*/
@FXML
public void handleOpenFile() {
FileChooser fc = new FileChooser();
@@ -70,6 +76,9 @@ public class MenubarController implements Initializable, Controller {
this.eventBus.post(new FileSelectedEvent(correctFormat));
}
/**
* Handles whenever the Open Project button is pressed in the menubar
*/
@FXML
private void handleOpenProject() {
DirectoryChooser dc = new DirectoryChooser();
@@ -84,45 +93,33 @@ public class MenubarController implements Initializable, Controller {
}
// @FXML
// public void handleSaveFile() {
// FileChooser fc = new FileChooser();
// fc.setTitle("Save File");
// Stage stage = (Stage) menubar.getScene().getWindow();
// FileChooser.ExtensionFilter extentionjava = new
// FileChooser.ExtensionFilter(".java");
// FileChooser.ExtensionFilter extentionmd = new
// FileChooser.ExtensionFilter(".md");
// fc.getExtensionFilters().addAll(extentionjava, extentionmd);
// fc.showOpenDialog(stage);
// }
/**
* Handles the event where the language was change from the menu.
*
* @param event
* Handles whenever the programming language is changed from the menubar.
*/
@FXML
private void handleLanguageChange(ActionEvent event) {
this.eventBus.post(new LanguageChangedEvent(((RadioMenuItem) event.getSource()).getText()));
}
/**
* Handles whenever the wraptext togglebutton is pressed in the menubar
*/
@FXML
private void handleToggleWraptext(ActionEvent event) {
var isSelected = ((CheckMenuItem) event.getSource()).selectedProperty().get();
this.eventBus.post(new ToggleWrapTextEvent(isSelected));
}
/**
* Handles whenever the theme is changed from the menubar
*/
@FXML
private void handleThemeChange(ActionEvent event) {
this.eventBus.post(new ThemeChangedEvent(((RadioMenuItem) event.getSource()).getText()));
}
/**
* Handles the event where there was an exit request from the menu.
*
* @param event
* Handles whenever the exit button is pressed in the menubar
*/
@FXML
private void handleExitApplication(ActionEvent event) {
@@ -133,31 +130,49 @@ public class MenubarController implements Initializable, Controller {
/* EDIT */
/* ------------------------------------------------------------------------ */
/**
* Handles whenever the undo button is pressed in the menubar
*/
@FXML
private void handleUndo(ActionEvent event) {
this.eventBus.post(new UndoEvent());
}
/**
* Handles whenever the redo button is pressed in the menubar
*/
@FXML
private void handleRedo(ActionEvent event) {
this.eventBus.post(new RedoEvent());
}
/**
* Handles whenever the copy button is pressed in the menubar
*/
@FXML
private void handleCopy(ActionEvent event) {
this.eventBus.post(new CopyEvent());
}
/**
* Handles whenever the cut button is pressed in the menubar
*/
@FXML
private void handleCut(ActionEvent event) {
this.eventBus.post(new CutEvent());
}
/**
* Handles whenever the paste button is pressed in the menubar
*/
@FXML
private void handlePaste(ActionEvent event) {
this.eventBus.post(new PasteEvent());
}
/**
* Handles whenever the Toggle Comment button is pressed in the menubar
*/
@FXML
private void handleToggleComment(ActionEvent event) {
this.eventBus.post(new ToggleCommentEvent());
@@ -167,6 +182,9 @@ public class MenubarController implements Initializable, Controller {
/* ABOUT */
/* ------------------------------------------------------------------------ */
/**
* Handles whenever the About button is pressed in the menubar
*/
@FXML
private void handleAbout(ActionEvent event) {
String aboutLink = "https://gitlab.stud.idi.ntnu.no/oysteikt/tdt4100-project-2021v/-/blob/master/README.md";
@@ -179,8 +197,6 @@ public class MenubarController implements Initializable, Controller {
/**
* Updates menubuttons whenever the language is changed
*
* @param event
*/
@Subscribe
private void handle(LanguageChangedEvent event) {