Commit c1d984ce authored by Peining Li's avatar Peining Li
Browse files

Merge branch 'IHM-Main/secondinteg' into 'develop'

Ihm main/secondinteg

See merge request !133
parents fdd09fa9 299b8aa7
......@@ -251,7 +251,6 @@ public class GameListController extends AbstractController{
try {
while(isLoading){
Thread.sleep(500);
connectionImpossible();
}
} catch (Exception e){
e.printStackTrace();
......
......@@ -14,6 +14,8 @@ import java.time.ZoneId;
import java.util.Date;
import java.util.logging.Level;
import java.util.logging.Logger;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.concurrent.Task;
import javafx.concurrent.WorkerStateEvent;
import javafx.event.ActionEvent;
......@@ -24,6 +26,7 @@ import javafx.scene.Cursor;
import javafx.scene.Node;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.chart.PieChart;
import javafx.scene.control.Button;
import javafx.scene.control.DatePicker;
import javafx.scene.control.Label;
......@@ -33,6 +36,7 @@ import javafx.scene.image.ImageView;
import javafx.scene.input.KeyCode;
import javafx.scene.input.KeyEvent;
import javafx.scene.layout.Pane;
import javafx.scene.paint.Color;
import javafx.stage.FileChooser;
import javafx.stage.Stage;
......@@ -57,14 +61,32 @@ public class PlayerProfileController extends AbstractController{
private TextField description;
@FXML
private ImageView image;
@FXML
private PieChart allMode;
@FXML
private PieChart classical;
@FXML
private PieChart belge;
@FXML
private Button PlayerName;
@FXML
private Button FirstName;
@FXML
private Button LastName;
@FXML
private Button Birthday;
@FXML
private Button Password;
@FXML
private Button Avatar;
@FXML
private Button Description;
private PublicUser me;
private PublicUser other;
private boolean isLoading = false;
private boolean isOther = false;
private String attribut;
private Image avatarImage;
private PopupController control;
@FXML
@Override
......@@ -99,34 +121,12 @@ public class PlayerProfileController extends AbstractController{
}
@FXML
private void editPlayerName(ActionEvent event) throws IOException{
attribut="PlayerName";
popup(attribut);
}
@FXML
private void editFirstName(ActionEvent event) throws IOException{
attribut="FirstName";
popup(attribut);
}
@FXML
private void editLastName(ActionEvent event) throws IOException{
attribut="LastName";
popup(attribut);
}
@FXML
private void editBirthday(ActionEvent event) throws IOException{
attribut="Birthday";
popup(attribut);
}
@FXML
private void editPassword(ActionEvent event) throws IOException{
attribut="Password";
private void edit(ActionEvent event) throws IOException{
attribut = ((Button)event.getSource()).getId();
System.out.println(attribut);
popup(attribut);
}
@FXML
private void editAvatar(ActionEvent event) throws IOException, DataException{
String avatarPath;
......@@ -148,10 +148,11 @@ public class PlayerProfileController extends AbstractController{
* @param attribut:name of info that user would like to modify
*/
private void popup(String attribut) throws IOException{
System.out.println("Popup: "+attribut);
final Stage primaryStage = getIhmmain().primaryStage;
Stage popup = new Stage();
popup.initOwner(primaryStage);
if(attribut == "Birthday"){
if("Birthday".equals(attribut)){
final DatePicker date = new DatePicker();
Button back = new Button();
Button submit = new Button();
......@@ -217,7 +218,6 @@ public class PlayerProfileController extends AbstractController{
other = player;
}
}
/**
* This method is for waiting the profile.
* As soon as receive the profile sent by Data, skip the loading and refresh the page.
......@@ -242,8 +242,7 @@ public class PlayerProfileController extends AbstractController{
);
Thread.sleep(500);
}
} catch (Exception e) {
e.printStackTrace();
} catch (InterruptedException e) {
}
return null;
}
......@@ -278,7 +277,8 @@ public class PlayerProfileController extends AbstractController{
}
}
/**
* Get user's avatar
* Get player's avatar
* @param player:user self or other player
*/
public void getAvatar(PublicUser player){
byte[] thumbnail = player.getLightPublicUser().getAvatarThumbnail();
......@@ -293,7 +293,25 @@ public class PlayerProfileController extends AbstractController{
}
}
@Override
public void drawPieChart(PieChart chart){
//to do: get data from interface Data
ObservableList<PieChart.Data> pieChartData = FXCollections.observableArrayList(
new PieChart.Data("Win", 15),
new PieChart.Data("Loss", 5),
new PieChart.Data("Abandonned", 0)
);
chart.setData(pieChartData);
}
public void disableButton(){
PlayerName.setDisable(true);
FirstName.setDisable(true);
LastName.setDisable(true);
Birthday.setDisable(true);
Password.setDisable(true);
Avatar.setDisable(true);
Description.setDisable(true);
}
/**
* Initializes all the info of profile.
*/
......@@ -307,8 +325,12 @@ public class PlayerProfileController extends AbstractController{
firstName.setText(me.getFirstName());
lastName.setText(me.getLastName());
birthday.setText(me.getBirthDate().toString());
drawPieChart(allMode);
drawPieChart(classical);
drawPieChart(belge);
}
catch(NullPointerException e){
e.printStackTrace();
Logger.getLogger(
PlayerProfileController.class.getName()).log(
Level.INFO,
......@@ -318,6 +340,7 @@ public class PlayerProfileController extends AbstractController{
}
else{
try{
disableButton();
getAvatar(other);
image.setImage(avatarImage);
userID.setText(other.getLightPublicUser().getPlayerName());
......
......@@ -27,7 +27,7 @@
</HBox>
<HBox alignment="CENTER_LEFT" prefHeight="100.0" prefWidth="200.0">
<children>
<Button mnemonicParsing="false" onAction="#editAvatar" text="Modify">
<Button fx:id="Avatar" mnemonicParsing="false" onAction="#editAvatar" text="Modify">
<opaqueInsets>
<Insets />
</opaqueInsets>
......@@ -51,11 +51,11 @@
<Label text="Birthday" GridPane.rowIndex="3" />
<Label fx:id="birthday" text="--" GridPane.columnIndex="1" GridPane.rowIndex="3" />
<Label text="Password" GridPane.rowIndex="4" />
<Button mnemonicParsing="false" onAction="#editPlayerName" text="edit" GridPane.columnIndex="2" />
<Button mnemonicParsing="false" onAction="#editFirstName" text="edit" GridPane.columnIndex="2" GridPane.rowIndex="1" />
<Button mnemonicParsing="false" onAction="#editLastName" text="edit" GridPane.columnIndex="2" GridPane.rowIndex="2" />
<Button mnemonicParsing="false" onAction="#editBirthday" text="edit" GridPane.columnIndex="2" GridPane.rowIndex="3" />
<Button mnemonicParsing="false" onAction="#editPassword" text="edit" GridPane.columnIndex="2" GridPane.rowIndex="4" />
<Button fx:id="PlayerName" mnemonicParsing="false" onAction="#edit" text="edit" GridPane.columnIndex="2" />
<Button fx:id="FirstName" mnemonicParsing="false" onAction="#edit" text="edit" GridPane.columnIndex="2" GridPane.rowIndex="1" />
<Button fx:id="LastName" mnemonicParsing="false" onAction="#edit" text="edit" GridPane.columnIndex="2" GridPane.rowIndex="2" />
<Button fx:id="Birthday" mnemonicParsing="false" onAction="#edit" text="edit" GridPane.columnIndex="2" GridPane.rowIndex="3" />
<Button fx:id="Password" mnemonicParsing="false" onAction="#edit" text="edit" GridPane.columnIndex="2" GridPane.rowIndex="4" />
<Label />
<Label text="Nickname" />
<Label fx:id="birthday1" text="********" GridPane.columnIndex="1" GridPane.rowIndex="4" />
......@@ -77,20 +77,29 @@
</VBox>
<VBox prefHeight="261.0" prefWidth="291.0">
<children>
<HBox alignment="CENTER_RIGHT" prefHeight="51.0" prefWidth="268.0">
<HBox alignment="CENTER_LEFT" prefHeight="51.0" prefWidth="268.0">
<children>
<Label alignment="CENTER" text="Description" />
<Label alignment="CENTER" contentDisplay="CENTER" text="Description">
<HBox.margin>
<Insets left="80.0" />
</HBox.margin></Label>
</children>
<VBox.margin>
<Insets />
</VBox.margin>
</HBox>
<HBox alignment="CENTER_RIGHT" prefHeight="165.0" prefWidth="268.0">
<children>
<TextField fx:id="description" editable="false" onKeyPressed="#closeEdit" prefHeight="144.0" prefWidth="219.0" text="Hello!" />
</children>
</HBox>
<HBox alignment="CENTER_RIGHT" prefHeight="29.0" prefWidth="268.0">
<HBox alignment="CENTER_LEFT" prefHeight="29.0" prefWidth="268.0">
<children>
<Button mnemonicParsing="false" onAction="#editDescription" text="edit" />
<Button fx:id="Description" mnemonicParsing="false" onAction="#editDescription" text="edit" />
</children>
<padding>
<Insets left="70.0" />
</padding>
</HBox>
</children></VBox>
</children>
......@@ -101,8 +110,8 @@
</columnConstraints>
<rowConstraints>
<RowConstraints maxHeight="143.0" minHeight="10.0" prefHeight="29.0" vgrow="SOMETIMES" />
<RowConstraints maxHeight="143.0" minHeight="6.0" prefHeight="14.0" vgrow="SOMETIMES" />
<RowConstraints maxHeight="280.0" minHeight="10.0" prefHeight="263.0" vgrow="SOMETIMES" />
<RowConstraints maxHeight="143.0" minHeight="0.0" prefHeight="0.0" vgrow="SOMETIMES" />
<RowConstraints maxHeight="280.0" minHeight="10.0" prefHeight="273.0" vgrow="SOMETIMES" />
</rowConstraints>
</GridPane>
<GridPane alignment="CENTER" GridPane.halignment="CENTER" GridPane.rowIndex="1" GridPane.valignment="CENTER">
......@@ -198,9 +207,9 @@
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
</rowConstraints>
<children>
<PieChart minHeight="-Infinity" minWidth="-Infinity" prefHeight="120.0" prefWidth="120.0" title="All Mode" titleSide="BOTTOM" />
<PieChart minHeight="-Infinity" minWidth="-Infinity" prefHeight="120.0" prefWidth="120.0" title="Classical" titleSide="BOTTOM" GridPane.columnIndex="1" />
<PieChart minHeight="-Infinity" minWidth="-Infinity" prefHeight="120.0" prefWidth="120.0" title="Belge" titleSide="BOTTOM" GridPane.columnIndex="2" />
<PieChart fx:id="allMode" minHeight="-Infinity" minWidth="-Infinity" prefHeight="120.0" prefWidth="120.0" title="All Mode" titleSide="BOTTOM" />
<PieChart fx:id="classical" minHeight="-Infinity" minWidth="-Infinity" prefHeight="120.0" prefWidth="120.0" title="Classical" titleSide="BOTTOM" GridPane.columnIndex="1" />
<PieChart fx:id="belge" minHeight="-Infinity" minWidth="-Infinity" prefHeight="120.0" prefWidth="120.0" title="Belge" titleSide="BOTTOM" GridPane.columnIndex="2" />
</children>
</GridPane>
</children>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment