Class Controller

java.lang.Object
com.cloud.clientpak.Controller
All Implemented Interfaces:
javafx.fxml.Initializable

public class Controller extends Object implements javafx.fxml.Initializable
The application controller class. Binds all application methods that are executed from user actions in the application UI. Contains a link to the current network connection to the server.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    (package private) javafx.scene.control.TextField
    Login input field on the authorization panel.
    (package private) javafx.scene.control.Label
    A text label on the authorization panel.
    (package private) javafx.scene.layout.GridPane
    Authorization panel.
    (package private) javafx.scene.control.PasswordField
    Password entry field on the authorization panel.
    (package private) javafx.scene.layout.VBox
     
    static final long
    Storage capacity.
    (package private) javafx.scene.layout.VBox
    The main storage panel.
    private static Connection
    private javafx.stage.FileChooser
    Dialog for selecting a file from the current operating system.
    private List<FileInfo>
    List of files in the cloud.
    (package private) javafx.scene.control.Label
    A text label for displaying the downloaded file.
    (package private) javafx.scene.control.Label
    The text label shows the numerical equivalent of the cloud load.
    private FileWorker
    Переменная класса FileWorker.
    (package private) javafx.scene.layout.VBox
    Cloud load bar's.
    (package private) javafx.scene.control.ProgressBar
    The progress bar of the file upload progress.
    (package private) javafx.scene.control.TextField
    Login input field during registration.
    (package private) javafx.scene.control.Label
    The label on the registration panel.
    (package private) javafx.scene.control.TextField
    The field for entering the user name during registration.
    (package private) javafx.scene.layout.GridPane
    Registration panel.
    (package private) javafx.scene.control.PasswordField
    Password input field during registration.
    (package private) javafx.scene.control.PasswordField
    The password re-entry field during registration.
    (package private) javafx.scene.control.TableView<FileInfo>
    Table view for showing files.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    changeLoadBar(double sizeFiles)
    Changes the size of the load bar of the cloud file storage.
    void
    changeProgressBar(double percent)
    Sets the size of the progress bar.
    void
    Makes the authorization panel visible, hides the rest of the panels.
    void
    Makes the main panel of the cloud visible and hides the rest.
    void
    Makes the registration panel visible, puts the rest of the panels in an invisible state.
    void
    Changes the panel to the Authorization panel and closes the network connection.
    void
    Called when the user clicks on the add file button.
    void
    It is called when clicking on the "Delete" button, selects an entry with the current focus from the table model and takes out the file name from it that needs to be deleted.
    void
    Sends a request to the server to receive the selected file.
    void
    Prepares the presentation of the table, for its subsequent filling with data.
    void
    It is called by clicking the log in to the cloud button.
    void
    It is called by clicking on the "Exit the program" item in the upper menu.
    static Connection
     
    void
    initialize(URL location, ResourceBundle resources)
    When the application starts, it shows the user authorization panel.
    void
    It is called when the user clicks on the register button.
    void
    Reloads the table view based on the list of files.
    void
    setVisibleLoadInfoFile(boolean check)
    Makes visible a label showing the name of the file being transferred.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • connection

      private static Connection connection
    • fileList

      private List<FileInfo> fileList
      List of files in the cloud.
    • fileChooser

      private javafx.stage.FileChooser fileChooser
      Dialog for selecting a file from the current operating system.
      See Also:
      • FileChooser
    • CAPACITY_CLOUD_IN_GB

      public static final long CAPACITY_CLOUD_IN_GB
      Storage capacity.
      See Also:
    • fileWorker

      private FileWorker fileWorker
      Переменная класса FileWorker.
    • cloudPane

      javafx.scene.layout.VBox cloudPane
      The main storage panel.
    • tableView

      javafx.scene.control.TableView<FileInfo> tableView
      Table view for showing files.
    • regPane

      javafx.scene.layout.GridPane regPane
      Registration panel.
    • regLogin

      javafx.scene.control.TextField regLogin
      Login input field during registration.
    • regPassword

      javafx.scene.control.PasswordField regPassword
      Password input field during registration.
    • regPasswordRep

      javafx.scene.control.PasswordField regPasswordRep
      The password re-entry field during registration.
    • regName

      javafx.scene.control.TextField regName
      The field for entering the user name during registration.
    • regMessage

      javafx.scene.control.Label regMessage
      The label on the registration panel.
    • authLogin

      javafx.scene.control.TextField authLogin
      Login input field on the authorization panel.
    • authPassword

      javafx.scene.control.PasswordField authPassword
      Password entry field on the authorization panel.
    • authPane

      javafx.scene.layout.GridPane authPane
      Authorization panel.
    • authMessage

      javafx.scene.control.Label authMessage
      A text label on the authorization panel.
    • progressBar

      javafx.scene.control.ProgressBar progressBar
      The progress bar of the file upload progress.
    • fileNameMessage

      javafx.scene.control.Label fileNameMessage
      A text label for displaying the downloaded file.
    • load_bar

      javafx.scene.layout.VBox load_bar
      Cloud load bar's.
    • bar

      javafx.scene.layout.VBox bar
    • fileSizeLabel

      javafx.scene.control.Label fileSizeLabel
      The text label shows the numerical equivalent of the cloud load.
  • Constructor Details

    • Controller

      public Controller()
  • Method Details

    • initialize

      public void initialize(URL location, ResourceBundle resources)
      When the application starts, it shows the user authorization panel. Creates an empty list of files, creates a dialog for selecting files, creates a file management service, prepares a table model for displaying files.
      Specified by:
      initialize in interface javafx.fxml.Initializable
      Parameters:
      location - an unused parameter from an inherited interface.
      resources - an unused parameter from an inherited interface.
    • clickAddFile

      public void clickAddFile()
      Called when the user clicks on the add file button. Opens the dialog for selecting the file of the current OS FileChooser. Passes the path to the selected file to the file management service FileWorker.
    • setVisibleLoadInfoFile

      public void setVisibleLoadInfoFile(boolean check)
      Makes visible a label showing the name of the file being transferred.
      Parameters:
      check - true while the file is being transferred.
    • changeProgressBar

      public void changeProgressBar(double percent)
      Sets the size of the progress bar.
      Parameters:
      percent - Percentage of filling.
    • clickDeleteButton

      public void clickDeleteButton()
      It is called when clicking on the "Delete" button, selects an entry with the current focus from the table model and takes out the file name from it that needs to be deleted. Deletes the entry with focus from the table. Generates and sends a message to the server about the need to delete the file.
    • clickGetButton

      public void clickGetButton()
      Sends a request to the server to receive the selected file.
    • changeStageToAuth

      public void changeStageToAuth()
      Makes the authorization panel visible, hides the rest of the panels.
    • changeStageToCloud

      public void changeStageToCloud()
      Makes the main panel of the cloud visible and hides the rest.
    • changeStageToReg

      public void changeStageToReg()
      Makes the registration panel visible, puts the rest of the panels in an invisible state.
    • exitApp

      public void exitApp()
      It is called by clicking on the "Exit the program" item in the upper menu.
    • reloadFxFilesList

      public void reloadFxFilesList(List<FileInfo> fileList)
      Reloads the table view based on the list of files.
      Parameters:
      fileList - List of files.
    • enterCloud

      public void enterCloud() throws InterruptedException
      It is called by clicking the log in to the cloud button. Before logging in, it is checked whether the user has entered the data - login and password. If no data is entered, it displays a message in the text label. Starts a network connection to the server.
      Throws:
      InterruptedException - it may occur if another thread tries to interrupt the waiting for a connection to the server, but in this program this is unlikely.
    • register

      public void register() throws InterruptedException
      It is called when the user clicks on the register button. Checks whether all data is entered for registration. If everything is in order, it opens a network connection with the server and sends a service message about registering a new user.
      Throws:
      InterruptedException - it may occur if another thread tries to interrupt the waiting for a connection to the server, but in this program this is unlikely.
    • changeUser

      public void changeUser()
      Changes the panel to the Authorization panel and closes the network connection.
    • createTableView

      public void createTableView()
      Prepares the presentation of the table, for its subsequent filling with data.
    • changeLoadBar

      public void changeLoadBar(double sizeFiles)
      Changes the size of the load bar of the cloud file storage. The length in the load bar is 1% depending on the size of the bar in the viewport in pixels calculation example: I got the method 4 gb -> (10 gb / 4 gb) = 2.5 (this is 1/4 of 10 gb) we calculate how much in % of 100 will be ( 1/4 ) 100 / 2.5 = 40 % should be The Bar is filled. We take the calculated 1% in pixels of the length of the Bar and multiply by the % by which it should be filled.
      Parameters:
      sizeFiles - File size in bytes.
    • getConnection

      public static Connection getConnection()