Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package gui;
- import javafx.application.Application;
- import javafx.geometry.Insets;
- import javafx.scene.Scene;
- import javafx.scene.layout.GridPane;
- import javafx.stage.Stage;
- import service.DatabaseManager;
- public class MainClass extends Application
- {
- // private Button btnAdd = new Button("Add team");
- // private Button btnEdit = new Button("Edit team");
- // private Button btnRemove = new Button("Remove team");
- public static void main(String[] args)
- {
- Application.launch(args);
- }
- @Override
- public void init()
- {
- String databaseName = "DanishCrownDB";
- String user = "sa";
- String password = "password";
- DatabaseManager.getInstance().openConnection(databaseName, user, password);
- DatabaseManager.getInstance().getLoadingManager().initSomeObjects();
- }
- @Override
- public void stop()
- {
- DatabaseManager.getInstance().getLoadingManager().deleteSomeObjects();
- DatabaseManager.getInstance().closeConnection();
- }
- @Override
- public void start(Stage stage)
- {
- stage.setTitle("Loading Manager");
- GridPane pane = new GridPane();
- this.initContent(pane);
- Scene scene = new Scene(pane);
- stage.setScene(scene);
- stage.show();
- }
- private void initContent(GridPane pane)
- {
- pane.setPadding(new Insets(15, 10, 15, 10));
- pane.setHgap(10);
- pane.setVgap(5);
- pane.setGridLinesVisible(false);
- // --------------------------------------------------------------
- // fill the listView
- // pane.add(lvTeams, 0, 0);
- //
- // ChangeListener<Team> listenerBook = (ov, oldBook, newBook) -> controller
- // .manageButtonsVisibility();
- // lvTeams.getSelectionModel().selectedItemProperty().addListener(listenerBook);
- //
- // btnAdd.setOnAction(event -> controller.addAction());
- // btnEdit.setOnAction(event -> controller.editAction());
- // btnRemove.setOnAction(event -> controller.removeAction());
- //
- // VBox vBox = new VBox();
- // vBox.setSpacing(10.0);
- // vBox.getChildren().addAll(btnAdd, btnEdit, btnRemove);
- // pane.add(vBox, 1, 0);
- // ------------- UPDATE OF CONTROLS -------------
- // this.updateControls();
- }
- // private void updateControls()
- // {
- // controller.updateControls();
- // }
- // ---------------------------------------------------------
- private Controller controller = new Controller();
- private class Controller
- {
- // public void updateControls()
- // {
- // // update teams
- // lvTeams.getItems()
- // .setAll(DatabaseManager.getInstance().getTeamsManager().getAllTeams());
- //
- // // update buttons
- // this.manageButtonsVisibility();
- // }
- // ------------------------------------
- // public void addAction()
- // {
- // TeamDialog teamDialog = new TeamDialog("Create new team");
- // teamDialog.showAndWait();
- //
- // boolean isCreated = teamDialog.getResult();
- // if (isCreated) {
- // this.updateControls();
- // }
- // }
- //
- // public void editAction()
- // {
- // Team selected = lvTeams.getSelectionModel().getSelectedItem();
- //
- // TeamDialog teamDialog = new TeamDialog("Edit team");
- // teamDialog.setTeam(selected);
- // teamDialog.showAndWait();
- //
- // boolean isCreated = teamDialog.getResult();
- // if (isCreated) {
- // this.updateControls();
- // }
- // }
- //
- // public void removeAction()
- // {
- // Team selected = lvTeams.getSelectionModel().getSelectedItem();
- // int id = selected.getId();
- //
- // Alert alert = new Alert(AlertType.CONFIRMATION);
- // alert.setTitle("Confirmation");
- // alert.setHeaderText("Delete \"" + selected.getName() + "\"?");
- // alert.setContentText("Deletion can't be undone");
- //
- // Optional<ButtonType> result = alert.showAndWait();
- //
- // if (result.isPresent() && result.get() == ButtonType.OK) {
- // DatabaseManager.getInstance().getTeamsManager().deleteTeam(id);
- // this.updateControls();
- // }
- // }
- // ------------------------------------
- // private void manageButtonsVisibility()
- // {
- // Team selected = lvTeams.getSelectionModel().getSelectedItem();
- //
- // if (selected == null) {
- // btnEdit.setDisable(true);
- // btnRemove.setDisable(true);
- // } else {
- // btnEdit.setDisable(false);
- // btnRemove.setDisable(false);
- // }
- // }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement