Advertisement
Guest User

Untitled

a guest
Apr 19th, 2016
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 4.96 KB | None | 0 0
  1.  
  2. package gui;
  3.  
  4. import javafx.application.Application;
  5. import javafx.geometry.Insets;
  6. import javafx.scene.Scene;
  7. import javafx.scene.layout.GridPane;
  8. import javafx.stage.Stage;
  9. import service.DatabaseManager;
  10.  
  11. public class MainClass extends Application
  12. {
  13. //    private Button btnAdd = new Button("Add team");
  14. //    private Button btnEdit = new Button("Edit team");
  15. //    private Button btnRemove = new Button("Remove team");
  16.  
  17.     public static void main(String[] args)
  18.     {
  19.         Application.launch(args);
  20.     }
  21.  
  22.     @Override
  23.     public void init()
  24.     {
  25.         String databaseName = "DanishCrownDB";
  26.         String user = "sa";
  27.         String password = "password";
  28.  
  29.         DatabaseManager.getInstance().openConnection(databaseName, user, password);
  30.         DatabaseManager.getInstance().getLoadingManager().initSomeObjects();
  31.     }
  32.  
  33.     @Override
  34.     public void stop()
  35.     {
  36.         DatabaseManager.getInstance().getLoadingManager().deleteSomeObjects();
  37.         DatabaseManager.getInstance().closeConnection();
  38.     }
  39.  
  40.     @Override
  41.     public void start(Stage stage)
  42.     {
  43.         stage.setTitle("Loading Manager");
  44.         GridPane pane = new GridPane();
  45.         this.initContent(pane);
  46.  
  47.         Scene scene = new Scene(pane);
  48.         stage.setScene(scene);
  49.         stage.show();
  50.     }
  51.  
  52.     private void initContent(GridPane pane)
  53.     {
  54.         pane.setPadding(new Insets(15, 10, 15, 10));
  55.         pane.setHgap(10);
  56.         pane.setVgap(5);
  57.         pane.setGridLinesVisible(false);
  58.  
  59.         // --------------------------------------------------------------
  60.  
  61.         // fill the listView
  62. //        pane.add(lvTeams, 0, 0);
  63. //
  64. //        ChangeListener<Team> listenerBook = (ov, oldBook, newBook) -> controller
  65. //                .manageButtonsVisibility();
  66. //        lvTeams.getSelectionModel().selectedItemProperty().addListener(listenerBook);
  67. //
  68. //        btnAdd.setOnAction(event -> controller.addAction());
  69. //        btnEdit.setOnAction(event -> controller.editAction());
  70. //        btnRemove.setOnAction(event -> controller.removeAction());
  71. //
  72. //        VBox vBox = new VBox();
  73. //        vBox.setSpacing(10.0);
  74. //        vBox.getChildren().addAll(btnAdd, btnEdit, btnRemove);
  75. //        pane.add(vBox, 1, 0);
  76.  
  77.         // ------------- UPDATE OF CONTROLS -------------
  78.         // this.updateControls();
  79.     }
  80.  
  81. //    private void updateControls()
  82. //    {
  83. //        controller.updateControls();
  84. //    }
  85.  
  86.     // ---------------------------------------------------------
  87.  
  88.     private Controller controller = new Controller();
  89.  
  90.     private class Controller
  91.     {
  92. //        public void updateControls()
  93. //        {
  94. //            // update teams
  95. //            lvTeams.getItems()
  96. //                    .setAll(DatabaseManager.getInstance().getTeamsManager().getAllTeams());
  97. //
  98. //            // update buttons
  99. //            this.manageButtonsVisibility();
  100. //        }
  101.  
  102.         // ------------------------------------
  103.  
  104. //        public void addAction()
  105. //        {
  106. //            TeamDialog teamDialog = new TeamDialog("Create new team");
  107. //            teamDialog.showAndWait();
  108. //
  109. //            boolean isCreated = teamDialog.getResult();
  110. //            if (isCreated) {
  111. //                this.updateControls();
  112. //            }
  113. //        }
  114. //
  115. //        public void editAction()
  116. //        {
  117. //            Team selected = lvTeams.getSelectionModel().getSelectedItem();
  118. //
  119. //            TeamDialog teamDialog = new TeamDialog("Edit team");
  120. //            teamDialog.setTeam(selected);
  121. //            teamDialog.showAndWait();
  122. //
  123. //            boolean isCreated = teamDialog.getResult();
  124. //            if (isCreated) {
  125. //                this.updateControls();
  126. //            }
  127. //        }
  128. //
  129. //        public void removeAction()
  130. //        {
  131. //            Team selected = lvTeams.getSelectionModel().getSelectedItem();
  132. //            int id = selected.getId();
  133. //
  134. //            Alert alert = new Alert(AlertType.CONFIRMATION);
  135. //            alert.setTitle("Confirmation");
  136. //            alert.setHeaderText("Delete \"" + selected.getName() + "\"?");
  137. //            alert.setContentText("Deletion can't be undone");
  138. //
  139. //            Optional<ButtonType> result = alert.showAndWait();
  140. //
  141. //            if (result.isPresent() && result.get() == ButtonType.OK) {
  142. //                DatabaseManager.getInstance().getTeamsManager().deleteTeam(id);
  143. //                this.updateControls();
  144. //            }
  145. //        }
  146.  
  147.         // ------------------------------------
  148.  
  149. //            private void manageButtonsVisibility()
  150. //            {
  151. //                 Team selected = lvTeams.getSelectionModel().getSelectedItem();
  152. //
  153. //                if (selected == null) {
  154. //                    btnEdit.setDisable(true);
  155. //                    btnRemove.setDisable(true);
  156. //                } else {
  157. //                    btnEdit.setDisable(false);
  158. //                    btnRemove.setDisable(false);
  159. //                }
  160. //            }
  161.     }
  162. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement