Skip to content

Commit

Permalink
Merge pull request #13 from Filmaluco/ClientBranch-TableViewColumns
Browse files Browse the repository at this point in the history
Added: Initial Columns for File and Transfer Views Updated: Settings View
  • Loading branch information
Vascoide authored Nov 21, 2018
2 parents dbce812 + 44c7952 commit 2f3ed56
Show file tree
Hide file tree
Showing 12 changed files with 258 additions and 46 deletions.
20 changes: 19 additions & 1 deletion Client/src/Controllers/View/BrowseController.java
Original file line number Diff line number Diff line change
@@ -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<File> ttvBrowse;

@Override
public void initialize(URL location, ResourceBundle resources) {

}
}
62 changes: 61 additions & 1 deletion Client/src/Controllers/View/FileController.java
Original file line number Diff line number Diff line change
@@ -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<File> ttvFiles;

public ObservableList<File> files = FXCollections.observableArrayList();

@Override
public void initialize(URL location, ResourceBundle resources) {
ttvFiles.getStyleClass().add("noheader");

//Setting up columns
JFXTreeTableColumn<File, String> filename = new JFXTreeTableColumn<>("Filename");
filename.setPrefWidth(400);
filename.setCellValueFactory(new Callback<TreeTableColumn.CellDataFeatures<File, String>, ObservableValue<String>>() {
@Override
public ObservableValue<String> call(TreeTableColumn.CellDataFeatures<File, String> param) {
return param.getValue().getValue().filenameProperty();
}
});


JFXTreeTableColumn<File, String> fileSize = new JFXTreeTableColumn<>("FileSize");
fileSize.setPrefWidth(400);
fileSize.setCellValueFactory(new Callback<TreeTableColumn.CellDataFeatures<File, String>, ObservableValue<String>>() {
@Override
public ObservableValue<String> call(TreeTableColumn.CellDataFeatures<File, String> param) {
return param.getValue().getValue().sizeProperty();
}
});

//Adding files to observable array
//files.add(new File("Test","1GB", "JohnDoe", "21/11/2018"));

final TreeItem<File> root = new RecursiveTreeItem<File>(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
}
}
23 changes: 20 additions & 3 deletions Client/src/Controllers/View/LoginController.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,27 @@
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;
import javafx.fxml.Initializable;
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;
Expand All @@ -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<String> 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();
}
Expand All @@ -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);
}
}
75 changes: 74 additions & 1 deletion Client/src/Controllers/View/TransferController.java
Original file line number Diff line number Diff line change
@@ -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<File> ttvTransfers;

public ObservableList<File> transfers = FXCollections.observableArrayList();


@Override
public void initialize(URL location, ResourceBundle resources) {
ttvTransfers.getStyleClass().add("noheader");

//Setting up columns
JFXTreeTableColumn<File, String> filename = new JFXTreeTableColumn<>("Filename");
filename.setPrefWidth(170);
filename.setCellValueFactory(new Callback<TreeTableColumn.CellDataFeatures<File, String>, ObservableValue<String>>() {
@Override
public ObservableValue<String> call(TreeTableColumn.CellDataFeatures<File, String> param) {
return param.getValue().getValue().filenameProperty();
}
});


JFXTreeTableColumn<File, String> fileSize = new JFXTreeTableColumn<>("FileSize");
fileSize.setPrefWidth(170);
fileSize.setCellValueFactory(new Callback<TreeTableColumn.CellDataFeatures<File, String>, ObservableValue<String>>() {
@Override
public ObservableValue<String> call(TreeTableColumn.CellDataFeatures<File, String> param) {
return param.getValue().getValue().sizeProperty();
}
});

JFXTreeTableColumn<File, String> downloadedFrom = new JFXTreeTableColumn<>("DownloadedFrom");
downloadedFrom.setPrefWidth(170);
downloadedFrom.setCellValueFactory(new Callback<TreeTableColumn.CellDataFeatures<File, String>, ObservableValue<String>>() {
@Override
public ObservableValue<String> call(TreeTableColumn.CellDataFeatures<File, String> param) {
return param.getValue().getValue().downloadedFromProperty();
}
});

JFXTreeTableColumn<File, String> downloadedDate = new JFXTreeTableColumn<>("DownloadedDate");
downloadedDate.setPrefWidth(170);
downloadedDate.setCellValueFactory(new Callback<TreeTableColumn.CellDataFeatures<File, String>, ObservableValue<String>>() {
@Override
public ObservableValue<String> call(TreeTableColumn.CellDataFeatures<File, String> param) {
return param.getValue().getValue().downloadDateProperty();
}
});

//Adding files to observable array
//transfers.add(new File("Test","1GB", "JohnDoe", "21/11/2018"));

final TreeItem<File> root = new RecursiveTreeItem<File>(transfers, RecursiveTreeObject::getChildren);
ttvTransfers.getColumns().setAll(filename, fileSize, downloadedFrom, downloadedDate);
ttvTransfers.setRoot(root);
ttvTransfers.setShowRoot(false);
}
}
4 changes: 3 additions & 1 deletion Client/src/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,21 @@
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);

primaryStage.setTitle("Mega PD");
primaryStage.setScene(login);
primaryStage.setResizable(false);
primaryStage.show();

}
}
58 changes: 58 additions & 0 deletions Client/src/Models/View/File.java
Original file line number Diff line number Diff line change
@@ -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<File> {
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;
}
}
2 changes: 1 addition & 1 deletion Client/src/Views/Layouts/browse.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
</AnchorPane>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="160.0" prefWidth="100.0">
<children>
<JFXTreeTableView layoutX="-7.0" layoutY="5.0" prefHeight="450.0" prefWidth="603.0" />
<JFXTreeTableView fx:id="ttvBrowse" layoutX="-7.0" layoutY="5.0" prefHeight="450.0" prefWidth="603.0" />
</children>
</AnchorPane>
</items>
Expand Down
18 changes: 6 additions & 12 deletions Client/src/Views/Layouts/file.fxml
Original file line number Diff line number Diff line change
@@ -1,20 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>

<?import java.lang.*?>
<?import java.util.*?>

<?import javafx.scene.layout.*?>

<?import com.jfoenix.controls.JFXButton?>
<?import com.jfoenix.controls.JFXTreeTableView?>
<?import de.jensd.fx.glyphs.fontawesome.FontAwesomeIconView?>
<?import javafx.geometry.Insets?>
<?import com.jfoenix.controls.JFXTreeTableView?>
<AnchorPane xmlns="http://javafx.com/javafx"
xmlns:fx="http://javafx.com/fxml"
fx:controller="Controllers.View.FileController"
prefHeight="460.0" prefWidth="683.0">
<?import javafx.scene.layout.AnchorPane?>

<AnchorPane prefHeight="460.0" prefWidth="683.0" xmlns="http://javafx.com/javafx/8.0.171" xmlns:fx="http://javafx.com/fxml/1" fx:controller="Controllers.View.FileController">
<children>
<JFXButton id="fileButton" layoutX="683.0" layoutY="460.0" prefHeight="33.0" prefWidth="103.0" text="File">
<JFXButton id="bntFile" fx:id="btnFile" onAction="#addFile" layoutX="683.0" layoutY="460.0" prefHeight="33.0" prefWidth="103.0" text="File">
<graphic>
<FontAwesomeIconView glyphName="FILE" size="15" />
</graphic>
Expand All @@ -25,6 +19,6 @@
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
</padding>
</JFXButton>
<JFXTreeTableView prefHeight="450.0" prefWidth="800.0" />
<JFXTreeTableView fx:id="ttvFiles" prefHeight="450.0" prefWidth="800.0" />
</children>
</AnchorPane>
1 change: 1 addition & 0 deletions Client/src/Views/Layouts/login.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,6 @@
<Image url="@../../Resources/Images/FullLogo.png" />
</image>
</ImageView>
<Label id="lbWarning" fx:id="lbWarning" alignment="CENTER" layoutX="14.0" layoutY="14.0" prefHeight="17.0" prefWidth="575.0" textAlignment="CENTER" textFill="#d00000" wrapText="true" />
</children>
</AnchorPane>
7 changes: 7 additions & 0 deletions Client/src/Views/Layouts/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Loading

0 comments on commit 2f3ed56

Please sign in to comment.