Skip to content

Commit 6095eb7

Browse files
committed
make window dimensions customizable
1 parent c9fcc6f commit 6095eb7

File tree

5 files changed

+20
-2
lines changed

5 files changed

+20
-2
lines changed

extern/config.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
{
22
"legacyMode": false,
33
"legacyProfile": "WS",
4+
"windowWidth" : 680,
5+
"windowHeight" : 960,
6+
"keyColumnWidth": 150,
47
"profiles": {
58
"WS": {
69
"target": "data/teilnehmer.xls",

src/main/java/com/damgem/DataImporter/Controller/MainController.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
import javafx.scene.control.Tooltip;
2424
import javafx.scene.effect.ColorInput;
2525
import javafx.scene.image.Image;
26+
import javafx.scene.layout.AnchorPane;
27+
import javafx.scene.layout.ColumnConstraints;
2628
import javafx.scene.layout.GridPane;
2729
import javafx.scene.paint.Color;
2830
import javafx.scene.paint.Paint;
@@ -41,6 +43,8 @@ public class MainController implements Initializable {
4143
public Button buttonConfirm;
4244
public Label targetLabel;
4345
public Label subTargetLabel;
46+
public AnchorPane anchor;
47+
public ColumnConstraints keyColumn;
4448

4549
private List<Field> fields;
4650
private final Property<Boolean> disabled = new SimpleBooleanProperty(false);
@@ -148,6 +152,12 @@ public void errorDialog(String errorTitle, String errorDescription) {
148152
stage.showAndWait();
149153
}
150154

155+
public void setDimensions(Integer width, Integer height, Integer keyColumnWidth) {
156+
if(width != null) this.anchor.setPrefWidth(width);
157+
if(height != null) this.anchor.setPrefHeight(height);
158+
if(keyColumnWidth != null) this.keyColumn.setPrefWidth(keyColumnWidth);
159+
}
160+
151161
private class FieldName extends Label {
152162
FieldName(Field field) {
153163
super(field.name);

src/main/java/com/damgem/DataImporter/Data/ConfigurationData.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,8 @@
66
public class ConfigurationData {
77
public Boolean legacyMode;
88
public String legacyProfile;
9+
public Integer windowWidth;
10+
public Integer windowHeight;
11+
public Integer keyColumnWidth;
912
public Map<String, Profile> profiles;
1013
}

src/main/java/com/damgem/DataImporter/Main.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ private void start_unsafe(Stage primaryStage) throws DataImporterError {
9797

9898
// Init Main Controller
9999
MainController controller = loader.getController();
100+
controller.setDimensions(configurationData.windowWidth, configurationData.windowHeight, configurationData.keyColumnWidth);
100101
controller.setFields(new FieldMatcher(profile.mapping).match(parameterData.values));
101102
controller.setTarget(Objects.requireNonNullElse(profile.target, ""),
102103
Objects.requireNonNullElse(profile.subTarget, ""));

src/main/resources/Main.fxml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
prefWidth="600.0"
1515
xmlns="http://javafx.com/javafx"
1616
xmlns:fx="http://javafx.com/fxml"
17-
fx:controller="com.damgem.DataImporter.Controller.MainController">
17+
fx:controller="com.damgem.DataImporter.Controller.MainController"
18+
fx:id="anchor">
1819
<VBox AnchorPane.rightAnchor="0"
1920
AnchorPane.leftAnchor="0"
2021
AnchorPane.topAnchor="0"
@@ -29,7 +30,7 @@
2930
</padding>
3031
<GridPane fx:id="grid" hgap="16" vgap="4">
3132
<columnConstraints>
32-
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" halignment="RIGHT"/>
33+
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" halignment="RIGHT" fx:id="keyColumn"/>
3334
<ColumnConstraints hgrow="ALWAYS" minWidth="10.0" prefWidth="150.0"/>
3435
</columnConstraints>
3536
<padding>

0 commit comments

Comments
 (0)