mirror of
https://github.com/Akomry/sae302_applicom.git
synced 2025-12-06 08:43:54 +00:00
Merge branch 'dev-layout' into 'dev'
Environnement graphique JavaFX See merge request iut_rt/but2/sae302-applicom/bouclyma!1
This commit is contained in:
commit
e75e5485ff
7 changed files with 239 additions and 17 deletions
|
|
@ -1,6 +1,7 @@
|
|||
module rtgre.chat {
|
||||
requires javafx.controls;
|
||||
requires javafx.fxml;
|
||||
requires java.logging;
|
||||
|
||||
|
||||
opens rtgre.chat to javafx.fxml;
|
||||
|
|
|
|||
|
|
@ -3,16 +3,40 @@ package rtgre.chat;
|
|||
import javafx.application.Application;
|
||||
import javafx.fxml.FXMLLoader;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.scene.image.Image;
|
||||
import javafx.stage.Stage;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.Objects;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.LogManager;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class ChatApplication extends Application {
|
||||
public static final Logger LOGGER = Logger.getLogger(ChatApplication.class.getCanonicalName());
|
||||
public class EssaiLogger {
|
||||
/* . . . */
|
||||
static {
|
||||
try {
|
||||
InputStream is = EssaiLogger.class.getClassLoader()
|
||||
.getResource("logging.properties").openStream();
|
||||
LogManager.getLogManager().readConfiguration(is);
|
||||
} catch (Exception e) {
|
||||
LOGGER.log(Level.INFO, "Cannot read configuration file", e);
|
||||
}
|
||||
}
|
||||
/* . . . */
|
||||
}
|
||||
@Override
|
||||
public void start(Stage stage) throws IOException {
|
||||
FXMLLoader fxmlLoader = new FXMLLoader(ChatApplication.class.getResource("chat-view.fxml"));
|
||||
Scene scene = new Scene(fxmlLoader.load(), 320, 240);
|
||||
Scene scene = new Scene(fxmlLoader.load(), 600, 400);
|
||||
stage.setTitle("Chat @BOUCLY_Emi (B2GA)");
|
||||
|
||||
stage.getIcons().add(new Image(Objects.requireNonNull(ChatApplication.class.getResourceAsStream("rt.png"))));
|
||||
stage.setMinWidth(600);
|
||||
stage.setMinHeight(400);
|
||||
stage.setScene(scene);
|
||||
stage.show();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,14 +1,79 @@
|
|||
package rtgre.chat;
|
||||
|
||||
import javafx.application.Platform;
|
||||
import javafx.beans.Observable;
|
||||
import javafx.event.Event;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.fxml.Initializable;
|
||||
import javafx.scene.control.*;
|
||||
import javafx.scene.image.Image;
|
||||
import javafx.scene.image.ImageView;
|
||||
|
||||
public class ChatController {
|
||||
@FXML
|
||||
private Label welcomeText;
|
||||
import java.net.URL;
|
||||
import java.util.Date;
|
||||
import java.util.Objects;
|
||||
import java.util.ResourceBundle;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import static rtgre.chat.ChatApplication.LOGGER;
|
||||
public class ChatController implements Initializable {
|
||||
|
||||
public MenuItem hostAddMenuItem;
|
||||
public MenuItem avatarMenuItem;
|
||||
public MenuItem aboutMenuItem;
|
||||
public ComboBox hostComboBox;
|
||||
public TextField loginTextField;
|
||||
public ToggleButton connectionButton;
|
||||
public ImageView avatarImageView;
|
||||
public SplitPane exchangeSplitPane;
|
||||
public ListView postListView;
|
||||
public ListView roomsListView;
|
||||
public ListView contactListView;
|
||||
public TextField messageTextField;
|
||||
public Button sendButton;
|
||||
public Label statusLabel;
|
||||
public Label dateTimeLabel;
|
||||
|
||||
|
||||
@Override
|
||||
public void initialize(URL url, ResourceBundle resourceBundle) {
|
||||
LOGGER.info("Initialisation de l'interface graphique");
|
||||
|
||||
Image image = new Image(Objects.requireNonNull(ChatController.class.getResourceAsStream("anonymous.png")));
|
||||
this.avatarImageView.setImage(image);
|
||||
|
||||
Thread dateTimeLoop = new Thread(this::dateTimeLoop);
|
||||
dateTimeLoop.setDaemon(true);
|
||||
dateTimeLoop.start();
|
||||
|
||||
hostComboBox.getItems().addAll("localhost:2024");
|
||||
hostComboBox.getItems().addAll("localhost:2025");
|
||||
hostComboBox.setValue("localhost:2024");
|
||||
hostComboBox.setOnAction(this::statusNameUpdate);
|
||||
|
||||
statusLabel.setText("not connected to " + hostComboBox.getValue());
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void statusNameUpdate(Event event) {
|
||||
statusLabel.setText("not connected to " + hostComboBox.getValue());
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void dateTimeLoop() {
|
||||
while (true) {
|
||||
try {
|
||||
String datetime = "%1$ta %1$te %1$tb %1$tY - %1$tH:%1$tM".formatted(new Date());
|
||||
// System.out.println(datetime);
|
||||
Platform.runLater(() -> dateTimeLabel.setText(datetime));
|
||||
Thread.sleep(60000);
|
||||
} catch (Exception e) {
|
||||
System.out.println(e);
|
||||
}
|
||||
}
|
||||
|
||||
@FXML
|
||||
protected void onHelloButtonClick() {
|
||||
welcomeText.setText("Welcome to JavaFX Application!");
|
||||
}
|
||||
}
|
||||
BIN
chat/src/main/resources/rtgre/chat/anonymous.png
Normal file
BIN
chat/src/main/resources/rtgre/chat/anonymous.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 5.9 KiB |
|
|
@ -1,16 +1,123 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import javafx.geometry.Insets?>
|
||||
<?import javafx.scene.control.Button?>
|
||||
<?import javafx.scene.control.ComboBox?>
|
||||
<?import javafx.scene.control.Label?>
|
||||
<?import javafx.scene.control.ListView?>
|
||||
<?import javafx.scene.control.Menu?>
|
||||
<?import javafx.scene.control.MenuBar?>
|
||||
<?import javafx.scene.control.MenuItem?>
|
||||
<?import javafx.scene.control.Separator?>
|
||||
<?import javafx.scene.control.SplitPane?>
|
||||
<?import javafx.scene.control.TextField?>
|
||||
<?import javafx.scene.control.ToggleButton?>
|
||||
<?import javafx.scene.image.ImageView?>
|
||||
<?import javafx.scene.layout.ColumnConstraints?>
|
||||
<?import javafx.scene.layout.GridPane?>
|
||||
<?import javafx.scene.layout.HBox?>
|
||||
<?import javafx.scene.layout.RowConstraints?>
|
||||
<?import javafx.scene.layout.VBox?>
|
||||
|
||||
<?import javafx.scene.control.Button?>
|
||||
<VBox alignment="CENTER" spacing="20.0" xmlns:fx="http://javafx.com/fxml"
|
||||
fx:controller="rtgre.chat.ChatController">
|
||||
<padding>
|
||||
<Insets bottom="20.0" left="20.0" right="20.0" top="20.0"/>
|
||||
</padding>
|
||||
|
||||
<Label fx:id="welcomeText"/>
|
||||
<Button text="Hello!" onAction="#onHelloButtonClick"/>
|
||||
<VBox alignment="CENTER" minHeight="400.0" minWidth="600.0" prefHeight="500.0" prefWidth="800.0" xmlns="http://javafx.com/javafx/18" xmlns:fx="http://javafx.com/fxml/1" fx:controller="rtgre.chat.ChatController">
|
||||
<children>
|
||||
<MenuBar>
|
||||
<menus>
|
||||
<Menu mnemonicParsing="false" text="Edit">
|
||||
<items>
|
||||
<MenuItem fx:id="hostAddMenuItem" mnemonicParsing="false" text="Add host" />
|
||||
<MenuItem fx:id="avatarMenuItem" mnemonicParsing="false" text="Change avatar" />
|
||||
</items>
|
||||
</Menu>
|
||||
<Menu mnemonicParsing="false" text="Help">
|
||||
<items>
|
||||
<MenuItem fx:id="aboutMenuItem" mnemonicParsing="false" text="About" />
|
||||
</items>
|
||||
</Menu>
|
||||
</menus>
|
||||
</MenuBar>
|
||||
<GridPane maxWidth="1.7976931348623157E308">
|
||||
<columnConstraints>
|
||||
<ColumnConstraints hgrow="NEVER" maxWidth="107.0" minWidth="10.0" prefWidth="62.0" />
|
||||
<ColumnConstraints hgrow="NEVER" maxWidth="286.0" minWidth="0.0" prefWidth="34.0" />
|
||||
<ColumnConstraints hgrow="ALWAYS" minWidth="10.0" prefWidth="400.0" />
|
||||
<ColumnConstraints halignment="RIGHT" hgrow="NEVER" maxWidth="131.0" minWidth="10.0" prefWidth="106.0" />
|
||||
</columnConstraints>
|
||||
<rowConstraints>
|
||||
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
||||
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
||||
</rowConstraints>
|
||||
<children>
|
||||
<Label text="Server :" GridPane.hgrow="NEVER" />
|
||||
<Label text="Login :" GridPane.hgrow="NEVER" GridPane.rowIndex="1" />
|
||||
<ComboBox fx:id="hostComboBox" maxWidth="1.7976931348623157E308" promptText="Choose host..." GridPane.columnIndex="2" GridPane.hgrow="ALWAYS">
|
||||
<GridPane.margin>
|
||||
<Insets bottom="5.0" top="5.0" />
|
||||
</GridPane.margin>
|
||||
</ComboBox>
|
||||
<TextField fx:id="loginTextField" maxWidth="1.7976931348623157E308" GridPane.columnIndex="2" GridPane.hgrow="ALWAYS" GridPane.rowIndex="1">
|
||||
<GridPane.margin>
|
||||
<Insets bottom="5.0" top="5.0" />
|
||||
</GridPane.margin>
|
||||
</TextField>
|
||||
<ToggleButton fx:id="connectionButton" maxHeight="1.7976931348623157E308" mnemonicParsing="false" prefWidth="100.0" text="Connection" GridPane.columnIndex="3" GridPane.halignment="RIGHT" GridPane.hgrow="NEVER" GridPane.rowSpan="2">
|
||||
<GridPane.margin>
|
||||
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
|
||||
</GridPane.margin>
|
||||
</ToggleButton>
|
||||
<ImageView fx:id="avatarImageView" fitHeight="24.0" fitWidth="24.0" pickOnBounds="true" preserveRatio="true" GridPane.columnIndex="1" GridPane.halignment="LEFT" GridPane.hgrow="NEVER" GridPane.rowIndex="1" />
|
||||
</children>
|
||||
<VBox.margin>
|
||||
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
|
||||
</VBox.margin>
|
||||
</GridPane>
|
||||
<SplitPane fx:id="exchangeSplitPane" dividerPositions="0.9" prefHeight="200.0" prefWidth="200.0" VBox.vgrow="ALWAYS">
|
||||
<items>
|
||||
<ListView fx:id="postListView" prefHeight="200.0" prefWidth="348.0" />
|
||||
<SplitPane dividerPositions="0.1" orientation="VERTICAL" prefHeight="200.0" prefWidth="160.0">
|
||||
<items>
|
||||
<ListView fx:id="roomsListView" prefHeight="200.0" prefWidth="200.0" />
|
||||
<ListView fx:id="contactListView" prefHeight="200.0" prefWidth="200.0" />
|
||||
</items>
|
||||
</SplitPane>
|
||||
</items>
|
||||
</SplitPane>
|
||||
<HBox>
|
||||
<children>
|
||||
<Label text="Message :">
|
||||
<padding>
|
||||
<Insets bottom="5.0" left="5.0" top="5.0" />
|
||||
</padding>
|
||||
<HBox.margin>
|
||||
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
|
||||
</HBox.margin>
|
||||
</Label>
|
||||
<TextField fx:id="messageTextField" HBox.hgrow="ALWAYS">
|
||||
<padding>
|
||||
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
|
||||
</padding>
|
||||
<HBox.margin>
|
||||
<Insets bottom="5.0" right="5.0" top="5.0" />
|
||||
</HBox.margin>
|
||||
</TextField>
|
||||
<Button fx:id="sendButton" mnemonicParsing="false" text="Send">
|
||||
<padding>
|
||||
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
|
||||
</padding>
|
||||
<HBox.margin>
|
||||
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
|
||||
</HBox.margin>
|
||||
</Button>
|
||||
</children>
|
||||
</HBox>
|
||||
<Separator prefWidth="200.0" />
|
||||
<HBox>
|
||||
<children>
|
||||
<Label text="Status : " />
|
||||
<Label fx:id="statusLabel" text="Not connected"/>
|
||||
<Separator maxWidth="1.7976931348623157E308" orientation="VERTICAL" HBox.hgrow="ALWAYS" />
|
||||
<Label fx:id="dateTimeLabel" text="Today" />
|
||||
</children>
|
||||
</HBox>
|
||||
</children>
|
||||
</VBox>
|
||||
|
|
|
|||
25
chat/src/main/resources/rtgre/chat/logging.properties
Normal file
25
chat/src/main/resources/rtgre/chat/logging.properties
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
# Les logs sont envoyés sur la console *et* dans un fichier
|
||||
handlers=java.util.logging.ConsoleHandler, java.util.logging.FileHandler
|
||||
|
||||
# Configuration par défaut pour ConsoleHandler
|
||||
# java.util.logging.ConsoleHandler.formatter=java.util.logging.SimpleFormatter
|
||||
|
||||
# Configuration de FileHandler. Par défaut,
|
||||
# java.util.logging.FileHandler.formatter=java.util.logging.XMLFormater
|
||||
java.util.logging.FileHandler.formatter=java.util.logging.SimpleFormatter
|
||||
|
||||
# Nom du fichier de logs
|
||||
java.util.logging.FileHandler.pattern=../out/java%u.log
|
||||
|
||||
# Format de logs plus compact sur 1 seule ligne
|
||||
java.util.logging.SimpleFormatter.format=%1$tF %1$tT.%1$tL | %4$-7s | %2$s | %5$s %6$s%n
|
||||
|
||||
# niveaux : OFF / SEVERE / WARNING / INFO / CONFIG / FINE / FINER / FINEST / ALL
|
||||
# Niveau global minimum pour les logs
|
||||
.level=ALL
|
||||
|
||||
# Niveau minimum pour les logs sur la console
|
||||
java.util.logging.ConsoleHandler.level=FINE
|
||||
|
||||
# Niveau minimum pour les logs dans le fichier
|
||||
java.util.logging.FileHandler.level=ALL
|
||||
BIN
chat/src/main/resources/rtgre/chat/rt.png
Normal file
BIN
chat/src/main/resources/rtgre/chat/rt.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.6 KiB |
Loading…
Add table
Add a link
Reference in a new issue