Small cleanup

This commit is contained in:
Oystein Kristoffer Tveit 2021-02-23 17:10:33 +01:00
parent b658a1870a
commit 3edaf61c46
10 changed files with 38 additions and 29 deletions

View File

@ -14,7 +14,6 @@ import app.model.Model;
public class Main extends Application { public class Main extends Application {
private Stage window;
private Scene scene; private Scene scene;
private FXMLLoader fxmlLoader; private FXMLLoader fxmlLoader;
private Parent fxmlRoot; private Parent fxmlRoot;
@ -33,7 +32,6 @@ public class Main extends Application {
* Set up a window with title and icon. * Set up a window with title and icon.
*/ */
private void setupWindow(Stage window) { private void setupWindow(Stage window) {
this.window = window;
window.setTitle(TITLE); window.setTitle(TITLE);
window.getIcons().add(new Image(getClass().getResourceAsStream(ICON_PATH))); window.getIcons().add(new Image(getClass().getResourceAsStream(ICON_PATH)));
} }

View File

@ -55,7 +55,7 @@ public class MainController implements Initializable {
/** /**
* Change the CSS according to which language is being used. * Change the CSS according to which language is being used.
* @param event The event containing data about the language to switch to * @param event
*/ */
@Subscribe @Subscribe
private void handle(LanguageChangedEvent event) { private void handle(LanguageChangedEvent event) {
@ -73,6 +73,10 @@ public class MainController implements Initializable {
Model.getScene().getStylesheets().add(nextStyleSheet); Model.getScene().getStylesheets().add(nextStyleSheet);
} }
/**
* Handle an exit request for the whole program.
* @param event
*/
@Subscribe @Subscribe
private void handle(ExitApplicationEvent event) { private void handle(ExitApplicationEvent event) {
// TODO: send save file event, exit application safely. // TODO: send save file event, exit application safely.

View File

@ -30,6 +30,21 @@ public class MenubarController implements Initializable, Controller {
@FXML @FXML
private ToggleGroup languageToggleGroup; private ToggleGroup languageToggleGroup;
@Override
public void initialize(URL url, ResourceBundle resourceBundle) {
// TODO: implement
}
@Override
public void setEventBus(EventBus eventBus) {
this.eventBus = eventBus;
this.eventBus.register(this);
}
/* ------------------------------------------------------------------------ */
/* FILE */
/* ------------------------------------------------------------------------ */
@FXML @FXML
public String handleOpenFile() { public String handleOpenFile() {
FileChooser fc = new FileChooser(); FileChooser fc = new FileChooser();
@ -72,21 +87,6 @@ public class MenubarController implements Initializable, Controller {
// fc.showOpenDialog(stage); // fc.showOpenDialog(stage);
// } // }
@Override
public void initialize(URL url, ResourceBundle resourceBundle) {
// TODO: implement
}
@Override
public void setEventBus(EventBus eventBus) {
this.eventBus = eventBus;
this.eventBus.register(this);
}
/* ------------------------------------------------------------------------ */
/* FILE */
/* ------------------------------------------------------------------------ */
/** /**
* Handles the event where the language was change from the menu. * Handles the event where the language was change from the menu.
* @param event * @param event
@ -116,6 +116,15 @@ public class MenubarController implements Initializable, Controller {
this.eventBus.post(new ToggleCommentEvent()); this.eventBus.post(new ToggleCommentEvent());
} }
/* ------------------------------------------------------------------------ */
/* ABOUT */
/* ------------------------------------------------------------------------ */
/* ------------------------------------------------------------------------ */
/* SUBSCRIPTIONS */
/* ------------------------------------------------------------------------ */
/** /**
* Updates menubuttons whenever the language is changed * Updates menubuttons whenever the language is changed
* @param event * @param event
@ -132,8 +141,4 @@ public class MenubarController implements Initializable, Controller {
.setSelected(true); .setSelected(true);
} }
/* ------------------------------------------------------------------------ */
/* ABOUT */
/* ------------------------------------------------------------------------ */
} }

View File

@ -62,6 +62,8 @@ public class ModelineController implements Initializable, Controller {
*/ */
@Subscribe @Subscribe
private void handle(FileSaveStateChangedEvent event) { private void handle(FileSaveStateChangedEvent event) {
// TODO: Add CSS styleclass for coloring the saveState label
// whenever it changes
this.saveState.setText(event.getIsSaved() ? "Saved!" : "Modified"); this.saveState.setText(event.getIsSaved() ? "Saved!" : "Modified");
} }

View File

@ -1,5 +1,5 @@
package app.events; package app.events;
public class ExitApplicationEvent { public class ExitApplicationEvent extends Event {
} }

View File

@ -2,7 +2,7 @@ package app.events;
import app.model.Model; import app.model.Model;
public class FileSaveStateChangedEvent { public class FileSaveStateChangedEvent extends Event {
private boolean isSaved; private boolean isSaved;

View File

@ -1,7 +1,7 @@
package app.events; package app.events;
import app.languages.Java; import app.model.languages.Java;
import app.languages.Markdown; import app.model.languages.Markdown;
import app.model.Model; import app.model.Model;
public class LanguageChangedEvent extends Event { public class LanguageChangedEvent extends Event {

View File

@ -1,5 +1,5 @@
package app.events; package app.events;
public class ToggleCommentEvent { public class ToggleCommentEvent extends Event {
} }

View File

@ -1,4 +1,4 @@
package app.languages; package app.model.languages;
import java.net.URL; import java.net.URL;
import java.util.AbstractMap; import java.util.AbstractMap;

View File

@ -1,4 +1,4 @@
package app.languages; package app.model.languages;
import java.net.URL; import java.net.URL;
import java.util.AbstractMap; import java.util.AbstractMap;