diff --git a/Client/src/Controllers/View/BrowseController.java b/Client/src/Controllers/View/BrowseController.java index f1c8cd9..139ed4f 100755 --- a/Client/src/Controllers/View/BrowseController.java +++ b/Client/src/Controllers/View/BrowseController.java @@ -1,4 +1,22 @@ package Controllers.View; -public class BrowseController { +import Models.View.File; +import com.jfoenix.controls.JFXTreeTableView; +import javafx.collections.FXCollections; +import javafx.collections.ObservableList; +import javafx.fxml.FXML; +import javafx.fxml.Initializable; + +import java.net.URL; +import java.util.ResourceBundle; + +public class BrowseController implements Initializable { + + @FXML + private JFXTreeTableView ttvBrowse; + + @Override + public void initialize(URL location, ResourceBundle resources) { + + } } diff --git a/Client/src/Controllers/View/FileController.java b/Client/src/Controllers/View/FileController.java index b1c044f..5849222 100755 --- a/Client/src/Controllers/View/FileController.java +++ b/Client/src/Controllers/View/FileController.java @@ -1,4 +1,64 @@ package Controllers.View; -public class FileController { +import Models.View.File; +import com.jfoenix.controls.JFXTreeTableColumn; +import com.jfoenix.controls.JFXTreeTableView; +import com.jfoenix.controls.RecursiveTreeItem; +import com.jfoenix.controls.datamodels.treetable.RecursiveTreeObject; +import javafx.beans.value.ObservableValue; +import javafx.collections.FXCollections; +import javafx.collections.ObservableList; +import javafx.event.ActionEvent; +import javafx.fxml.FXML; +import javafx.fxml.Initializable; +import javafx.scene.control.TreeItem; +import javafx.scene.control.TreeTableColumn; +import javafx.util.Callback; + +import java.net.URL; +import java.util.ResourceBundle; + +public class FileController implements Initializable { + + @FXML + private JFXTreeTableView ttvFiles; + + public ObservableList files = FXCollections.observableArrayList(); + + @Override + public void initialize(URL location, ResourceBundle resources) { + ttvFiles.getStyleClass().add("noheader"); + + //Setting up columns + JFXTreeTableColumn filename = new JFXTreeTableColumn<>("Filename"); + filename.setPrefWidth(400); + filename.setCellValueFactory(new Callback, ObservableValue>() { + @Override + public ObservableValue call(TreeTableColumn.CellDataFeatures param) { + return param.getValue().getValue().filenameProperty(); + } + }); + + + JFXTreeTableColumn fileSize = new JFXTreeTableColumn<>("FileSize"); + fileSize.setPrefWidth(400); + fileSize.setCellValueFactory(new Callback, ObservableValue>() { + @Override + public ObservableValue call(TreeTableColumn.CellDataFeatures param) { + return param.getValue().getValue().sizeProperty(); + } + }); + + //Adding files to observable array + //files.add(new File("Test","1GB", "JohnDoe", "21/11/2018")); + + final TreeItem root = new RecursiveTreeItem(files, RecursiveTreeObject::getChildren); + ttvFiles.getColumns().setAll(filename, fileSize); + ttvFiles.setRoot(root); + ttvFiles.setShowRoot(false); + } + + public void addFile(ActionEvent event) { + //TODO: Show file chooser and get the file to send + } } diff --git a/Client/src/Controllers/View/LoginController.java b/Client/src/Controllers/View/LoginController.java index 781deb7..ca418c8 100644 --- a/Client/src/Controllers/View/LoginController.java +++ b/Client/src/Controllers/View/LoginController.java @@ -3,6 +3,8 @@ import com.jfoenix.controls.JFXButton; import com.jfoenix.controls.JFXPasswordField; import com.jfoenix.controls.JFXTextField; +import javafx.collections.FXCollections; +import javafx.collections.ObservableList; import javafx.event.ActionEvent; import javafx.fxml.FXML; import javafx.fxml.FXMLLoader; @@ -10,12 +12,18 @@ import javafx.scene.Parent; import javafx.scene.Scene; import javafx.stage.Stage; +import javafx.scene.control.Label; import javafx.stage.StageStyle; +import sun.applet.Main; +import java.awt.*; +import java.awt.image.SampleModel; import java.io.IOException; import java.net.URL; import java.util.ResourceBundle; +import static javafx.collections.FXCollections.observableArrayList; + public class LoginController implements Initializable { @FXML private JFXTextField usernameField; @@ -29,19 +37,24 @@ public class LoginController implements Initializable { @FXML private JFXButton btnGuestLogin; + @FXML + private Label lbWarning; @Override public void initialize(URL location, ResourceBundle resources) { //TODO: Update visual changes + //setWarning(); + ObservableList list = FXCollections.observableArrayList(); } @FXML - public void userLogin(ActionEvent event) { + private void userLogin(ActionEvent event) { String username = usernameField.getText(); String password = passwordField.getText(); //TODO: Implement real authentication - if (username.equals("MegaPD") && password.equals("PD2018")){ + + if (true){ closeStage(); loadMain(); } @@ -64,7 +77,11 @@ void loadMain(){ } @FXML - public void guestLogin(ActionEvent event) { + private void guestLogin(ActionEvent event) { //TODO: Implement } + + public void setWarning(String warning){ + lbWarning.setText(warning); + } } diff --git a/Client/src/Controllers/View/TransferController.java b/Client/src/Controllers/View/TransferController.java index 4aa08be..cf3706d 100755 --- a/Client/src/Controllers/View/TransferController.java +++ b/Client/src/Controllers/View/TransferController.java @@ -1,4 +1,77 @@ package Controllers.View; -public class TransferController { +import Models.View.File; +import com.jfoenix.controls.JFXTreeTableColumn; +import com.jfoenix.controls.JFXTreeTableView; +import com.jfoenix.controls.RecursiveTreeItem; +import com.jfoenix.controls.datamodels.treetable.RecursiveTreeObject; +import javafx.beans.value.ObservableValue; +import javafx.collections.FXCollections; +import javafx.collections.ObservableList; +import javafx.fxml.FXML; +import javafx.fxml.Initializable; +import javafx.scene.control.TreeItem; +import javafx.scene.control.TreeTableColumn; +import javafx.util.Callback; + +import java.net.URL; +import java.util.ResourceBundle; + +public class TransferController implements Initializable { + @FXML + private JFXTreeTableView ttvTransfers; + + public ObservableList transfers = FXCollections.observableArrayList(); + + + @Override + public void initialize(URL location, ResourceBundle resources) { + ttvTransfers.getStyleClass().add("noheader"); + + //Setting up columns + JFXTreeTableColumn filename = new JFXTreeTableColumn<>("Filename"); + filename.setPrefWidth(170); + filename.setCellValueFactory(new Callback, ObservableValue>() { + @Override + public ObservableValue call(TreeTableColumn.CellDataFeatures param) { + return param.getValue().getValue().filenameProperty(); + } + }); + + + JFXTreeTableColumn fileSize = new JFXTreeTableColumn<>("FileSize"); + fileSize.setPrefWidth(170); + fileSize.setCellValueFactory(new Callback, ObservableValue>() { + @Override + public ObservableValue call(TreeTableColumn.CellDataFeatures param) { + return param.getValue().getValue().sizeProperty(); + } + }); + + JFXTreeTableColumn downloadedFrom = new JFXTreeTableColumn<>("DownloadedFrom"); + downloadedFrom.setPrefWidth(170); + downloadedFrom.setCellValueFactory(new Callback, ObservableValue>() { + @Override + public ObservableValue call(TreeTableColumn.CellDataFeatures param) { + return param.getValue().getValue().downloadedFromProperty(); + } + }); + + JFXTreeTableColumn downloadedDate = new JFXTreeTableColumn<>("DownloadedDate"); + downloadedDate.setPrefWidth(170); + downloadedDate.setCellValueFactory(new Callback, ObservableValue>() { + @Override + public ObservableValue call(TreeTableColumn.CellDataFeatures param) { + return param.getValue().getValue().downloadDateProperty(); + } + }); + + //Adding files to observable array + //transfers.add(new File("Test","1GB", "JohnDoe", "21/11/2018")); + + final TreeItem root = new RecursiveTreeItem(transfers, RecursiveTreeObject::getChildren); + ttvTransfers.getColumns().setAll(filename, fileSize, downloadedFrom, downloadedDate); + ttvTransfers.setRoot(root); + ttvTransfers.setShowRoot(false); + } } diff --git a/Client/src/Main.java b/Client/src/Main.java index 1a6708c..15c5caf 100644 --- a/Client/src/Main.java +++ b/Client/src/Main.java @@ -4,13 +4,14 @@ import javafx.scene.Scene; import javafx.stage.Stage; -public class Main extends Application { +public class Main extends Application { public static void main(String[] args) { launch(args); } @Override public void start(Stage primaryStage) throws Exception { Parent root = FXMLLoader.load(getClass().getResource("Views/Layouts/login.fxml")); + //Parent root = FXMLLoader.load(getClass().getResource("Views/Layouts/main.fxml")); Scene login = new Scene(root); @@ -18,5 +19,6 @@ public void start(Stage primaryStage) throws Exception { primaryStage.setScene(login); primaryStage.setResizable(false); primaryStage.show(); + } } diff --git a/Client/src/Models/View/File.java b/Client/src/Models/View/File.java new file mode 100644 index 0000000..33b86ec --- /dev/null +++ b/Client/src/Models/View/File.java @@ -0,0 +1,58 @@ +package Models.View; + +import com.jfoenix.controls.datamodels.treetable.RecursiveTreeObject; +import javafx.beans.property.SimpleStringProperty; +import javafx.beans.property.StringProperty; + +public class File extends RecursiveTreeObject { + StringProperty filename; + StringProperty size; + StringProperty downloadedFrom; + StringProperty downloadDate; + + + public File(String filename, String size, String downloadedFrom, String downloadDate) { + this.filename = new SimpleStringProperty(filename); + this.size = new SimpleStringProperty(size); + this.downloadedFrom = new SimpleStringProperty(downloadedFrom); + this.downloadDate = new SimpleStringProperty(downloadDate); + } + + public File(String filename, String size) { + this.filename = new SimpleStringProperty(filename); + this.size = new SimpleStringProperty(size); + } + + + public String getFilename() { + return filename.get(); + } + + public StringProperty filenameProperty() { + return filename; + } + + public String getSize() { + return size.get(); + } + + public StringProperty sizeProperty() { + return size; + } + + public String getDownloadedFrom() { + return downloadedFrom.get(); + } + + public StringProperty downloadedFromProperty() { + return downloadedFrom; + } + + public String getDownloadDate() { + return downloadDate.get(); + } + + public StringProperty downloadDateProperty() { + return downloadDate; + } +} diff --git a/Client/src/Views/Layouts/browse.fxml b/Client/src/Views/Layouts/browse.fxml index e584dbf..43c7586 100644 --- a/Client/src/Views/Layouts/browse.fxml +++ b/Client/src/Views/Layouts/browse.fxml @@ -36,7 +36,7 @@ - + diff --git a/Client/src/Views/Layouts/file.fxml b/Client/src/Views/Layouts/file.fxml index 656b2df..38fdd62 100644 --- a/Client/src/Views/Layouts/file.fxml +++ b/Client/src/Views/Layouts/file.fxml @@ -1,20 +1,14 @@ - - - - - + - - + + + - + @@ -25,6 +19,6 @@ - + diff --git a/Client/src/Views/Layouts/login.fxml b/Client/src/Views/Layouts/login.fxml index 861899c..75f8ca7 100644 --- a/Client/src/Views/Layouts/login.fxml +++ b/Client/src/Views/Layouts/login.fxml @@ -41,5 +41,6 @@ + diff --git a/Client/src/Views/Layouts/main.css b/Client/src/Views/Layouts/main.css index a7ed813..009fee4 100755 --- a/Client/src/Views/Layouts/main.css +++ b/Client/src/Views/Layouts/main.css @@ -70,3 +70,10 @@ { -fx-background-color: WHITE; /*Yellow - bottom bar*/ } + +/* Tree Table View Remover Header Style Class */ +.noheader .column-header-background { + -fx-max-height: 0; + -fx-pref-height: 0; + -fx-min-height: 0; +} diff --git a/Client/src/Views/Layouts/settings.fxml b/Client/src/Views/Layouts/settings.fxml index f040aa2..bde3e5d 100644 --- a/Client/src/Views/Layouts/settings.fxml +++ b/Client/src/Views/Layouts/settings.fxml @@ -10,46 +10,28 @@ - diff --git a/Client/src/Views/Layouts/transfer.fxml b/Client/src/Views/Layouts/transfer.fxml index e8e6601..c62810e 100644 --- a/Client/src/Views/Layouts/transfer.fxml +++ b/Client/src/Views/Layouts/transfer.fxml @@ -12,6 +12,6 @@ fx:controller="Controllers.View.TransferController" prefHeight="400.0" prefWidth="600.0"> - +