Package com.cloud.clientpak
Class Controller
java.lang.Object
com.cloud.clientpak.Controller
- All Implemented Interfaces:
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
FieldsModifier and TypeFieldDescription(package private) javafx.scene.control.TextFieldLogin input field on the authorization panel.(package private) javafx.scene.control.LabelA text label on the authorization panel.(package private) javafx.scene.layout.GridPaneAuthorization panel.(package private) javafx.scene.control.PasswordFieldPassword entry field on the authorization panel.(package private) javafx.scene.layout.VBoxstatic final longStorage capacity.(package private) javafx.scene.layout.VBoxThe main storage panel.private static Connectionprivate javafx.stage.FileChooserDialog for selecting a file from the current operating system.List of files in the cloud.(package private) javafx.scene.control.LabelA text label for displaying the downloaded file.(package private) javafx.scene.control.LabelThe text label shows the numerical equivalent of the cloud load.private FileWorkerПеременная классаFileWorker.(package private) javafx.scene.layout.VBoxCloud load bar's.(package private) javafx.scene.control.ProgressBarThe progress bar of the file upload progress.(package private) javafx.scene.control.TextFieldLogin input field during registration.(package private) javafx.scene.control.LabelThe label on the registration panel.(package private) javafx.scene.control.TextFieldThe field for entering the user name during registration.(package private) javafx.scene.layout.GridPaneRegistration panel.(package private) javafx.scene.control.PasswordFieldPassword input field during registration.(package private) javafx.scene.control.PasswordFieldThe password re-entry field during registration.(package private) javafx.scene.control.TableView<FileInfo>Table view for showing files. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidchangeLoadBar(double sizeFiles) Changes the size of the load bar of the cloud file storage.voidchangeProgressBar(double percent) Sets the size of the progress bar.voidMakes the authorization panel visible, hides the rest of the panels.voidMakes the main panel of the cloud visible and hides the rest.voidMakes the registration panel visible, puts the rest of the panels in an invisible state.voidChanges the panel to the Authorization panel and closes the network connection.voidCalled when the user clicks on the add file button.voidIt 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.voidSends a request to the server to receive the selected file.voidPrepares the presentation of the table, for its subsequent filling with data.voidIt is called by clicking the log in to the cloud button.voidexitApp()It is called by clicking on the "Exit the program" item in the upper menu.static Connectionvoidinitialize(URL location, ResourceBundle resources) When the application starts, it shows the user authorization panel.voidregister()It is called when the user clicks on the register button.voidreloadFxFilesList(List<FileInfo> fileList) Reloads the table view based on the list of files.voidsetVisibleLoadInfoFile(boolean check) Makes visible a label showing the name of the file being transferred.
-
Field Details
-
connection
-
fileList
List of files in the cloud. -
fileChooser
private javafx.stage.FileChooser fileChooserDialog for selecting a file from the current operating system.- See Also:
-
FileChooser
-
CAPACITY_CLOUD_IN_GB
public static final long CAPACITY_CLOUD_IN_GBStorage capacity.- See Also:
-
fileWorker
Переменная классаFileWorker. -
cloudPane
javafx.scene.layout.VBox cloudPaneThe main storage panel. -
tableView
javafx.scene.control.TableView<FileInfo> tableViewTable view for showing files. -
regPane
javafx.scene.layout.GridPane regPaneRegistration panel. -
regLogin
javafx.scene.control.TextField regLoginLogin input field during registration. -
regPassword
javafx.scene.control.PasswordField regPasswordPassword input field during registration. -
regPasswordRep
javafx.scene.control.PasswordField regPasswordRepThe password re-entry field during registration. -
regName
javafx.scene.control.TextField regNameThe field for entering the user name during registration. -
regMessage
javafx.scene.control.Label regMessageThe label on the registration panel. -
authLogin
javafx.scene.control.TextField authLoginLogin input field on the authorization panel. -
authPassword
javafx.scene.control.PasswordField authPasswordPassword entry field on the authorization panel. -
authPane
javafx.scene.layout.GridPane authPaneAuthorization panel. -
authMessage
javafx.scene.control.Label authMessageA text label on the authorization panel. -
progressBar
javafx.scene.control.ProgressBar progressBarThe progress bar of the file upload progress. -
fileNameMessage
javafx.scene.control.Label fileNameMessageA text label for displaying the downloaded file. -
load_bar
javafx.scene.layout.VBox load_barCloud load bar's. -
bar
javafx.scene.layout.VBox bar -
fileSizeLabel
javafx.scene.control.Label fileSizeLabelThe text label shows the numerical equivalent of the cloud load.
-
-
Constructor Details
-
Controller
public Controller()
-
-
Method Details
-
initialize
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:
initializein interfacejavafx.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 OSFileChooser. Passes the path to the selected file to the file management serviceFileWorker. -
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
Reloads the table view based on the list of files.- Parameters:
fileList- List of files.
-
enterCloud
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
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
-