feat(config): ajout de la persistance des positions des séparateurs

This commit is contained in:
Emi Boucly 2025-02-05 10:17:55 +01:00
parent 3bc5db868c
commit e18e4c3223
3 changed files with 12 additions and 8 deletions

View file

@ -9,10 +9,7 @@ import javafx.stage.Stage;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Locale;
import java.util.Objects;
import java.util.Properties;
import java.util.ResourceBundle;
import java.util.*;
import java.util.logging.Level;
import java.util.logging.LogManager;
import java.util.logging.Logger;
@ -53,8 +50,6 @@ public class ChatApplication extends Application {
if (!properties.getProperty("width").isEmpty() && !properties.getProperty("height").isEmpty()) {
stage.setWidth(Double.parseDouble(properties.getProperty("width")));
stage.setHeight(Double.parseDouble(properties.getProperty("height")));
}
if (properties.getProperty("posx").isEmpty() || properties.getProperty("height").isEmpty()) {
stage.centerOnScreen();
@ -77,7 +72,8 @@ public class ChatApplication extends Application {
properties.setProperty("posx", String.valueOf(stage.getX()));
properties.setProperty("posy", String.valueOf(stage.getY()));
properties.setProperty("split1", String.valueOf(controller.senderSplitPane.getDividerPositions()[0]));
properties.setProperty("split2", String.valueOf(controller.exchangeSplitPane.getDividerPositions()[0]));
LOGGER.finest(properties.toString());
properties.store(new FileOutputStream(getClass().getResource("config.properties").getPath()), null);
} catch (IOException e) {

View file

@ -69,6 +69,7 @@ public class ChatController implements Initializable {
public Label statusLabel;
public Label dateTimeLabel;
public Contact contact;
public SplitPane senderSplitPane;
private ContactMap contactMap = new ContactMap();
private ObservableList<Contact> contactObservableList = FXCollections.observableArrayList();
private ObservableList<Post> postsObservableList = FXCollections.observableArrayList();
@ -101,6 +102,13 @@ public class ChatController implements Initializable {
}
hostComboBox.setValue(!properties.getProperty("lasthost").isEmpty() ? properties.getProperty("lasthost") : hostComboBox.getItems().get(0));
loginTextField.setText(!properties.getProperty("login").isEmpty() ? properties.getProperty("login") : "");
if (!properties.getProperty("split2").isEmpty()) {
exchangeSplitPane.setDividerPositions(Double.parseDouble(properties.getProperty("split2")));
}
if (!properties.getProperty("split1").isEmpty()) {
exchangeSplitPane.setDividerPositions(Double.parseDouble(properties.getProperty("split2")));
}
} catch (IOException e) {
LOGGER.warning("Impossible de charger le fichier de configuration! Configuration par défaut chargée");
System.out.println(e.getMessage());