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 {
private Stage window;
private Scene scene;
private FXMLLoader fxmlLoader;
private Parent fxmlRoot;
@ -33,7 +32,6 @@ public class Main extends Application {
* Set up a window with title and icon.
*/
private void setupWindow(Stage window) {
this.window = window;
window.setTitle(TITLE);
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.
* @param event The event containing data about the language to switch to
* @param event
*/
@Subscribe
private void handle(LanguageChangedEvent event) {
@ -73,6 +73,10 @@ public class MainController implements Initializable {
Model.getScene().getStylesheets().add(nextStyleSheet);
}
/**
* Handle an exit request for the whole program.
* @param event
*/
@Subscribe
private void handle(ExitApplicationEvent event) {
// TODO: send save file event, exit application safely.

View File

@ -30,6 +30,21 @@ public class MenubarController implements Initializable, Controller {
@FXML
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
public String handleOpenFile() {
FileChooser fc = new FileChooser();
@ -72,21 +87,6 @@ public class MenubarController implements Initializable, Controller {
// 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.
* @param event
@ -116,6 +116,15 @@ public class MenubarController implements Initializable, Controller {
this.eventBus.post(new ToggleCommentEvent());
}
/* ------------------------------------------------------------------------ */
/* ABOUT */
/* ------------------------------------------------------------------------ */
/* ------------------------------------------------------------------------ */
/* SUBSCRIPTIONS */
/* ------------------------------------------------------------------------ */
/**
* Updates menubuttons whenever the language is changed
* @param event
@ -132,8 +141,4 @@ public class MenubarController implements Initializable, Controller {
.setSelected(true);
}
/* ------------------------------------------------------------------------ */
/* ABOUT */
/* ------------------------------------------------------------------------ */
}

View File

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

View File

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

View File

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

View File

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

View File

@ -1,5 +1,5 @@
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.util.AbstractMap;

View File

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