7
7
import javax .swing .JTextField ;
8
8
import javax .swing .event .DocumentEvent ;
9
9
import javax .swing .event .DocumentListener ;
10
- import tools .sctrade .companion .domain .user .Setting ;
11
- import tools .sctrade .companion .domain .user .SettingRepository ;
10
+ import tools .sctrade .companion .domain .gamelog .GameLogPathSubject ;
11
+ import tools .sctrade .companion .domain .setting .Setting ;
12
+ import tools .sctrade .companion .domain .setting .SettingRepository ;
12
13
import tools .sctrade .companion .domain .user .UserService ;
13
14
import tools .sctrade .companion .utils .LocalizationUtil ;
14
15
15
16
public class SettingsTab extends JPanel {
16
17
private static final long serialVersionUID = -3532718267415423680L ;
17
18
18
- public SettingsTab (UserService userService , SettingRepository settings ) {
19
+ public SettingsTab (UserService userService , GameLogPathSubject gameLogService ,
20
+ SettingRepository settings ) {
19
21
super ();
20
22
setLayout (new GridBagLayout ());
21
23
22
24
buildUsernameField (userService );
25
+ buildStarCitizenLivePathField (gameLogService );
23
26
buildDataPathField (settings .get (Setting .MY_DATA_PATH ).toString ());
24
27
buildImagesPathField (settings .get (Setting .MY_IMAGES_PATH ).toString ());
25
28
}
@@ -34,20 +37,20 @@ private void buildUsernameField(UserService userService) {
34
37
usernameField .getDocument ().addDocumentListener (new DocumentListener () {
35
38
@ Override
36
39
public void insertUpdate (DocumentEvent e ) {
37
- updateUserLabel ();
40
+ updateUsername ();
38
41
}
39
42
40
43
@ Override
41
44
public void removeUpdate (DocumentEvent e ) {
42
- updateUserLabel ();
45
+ updateUsername ();
43
46
}
44
47
45
48
@ Override
46
49
public void changedUpdate (DocumentEvent e ) {
47
- updateUserLabel ();
50
+ updateUsername ();
48
51
}
49
52
50
- private void updateUserLabel () {
53
+ private void updateUsername () {
51
54
userService .updateUsername (usernameField .getText ());
52
55
}
53
56
});
@@ -58,16 +61,50 @@ private void updateUserLabel() {
58
61
buildLabel (2 , " " );
59
62
}
60
63
64
+ private void buildStarCitizenLivePathField (GameLogPathSubject gameLogService ) {
65
+ var starCitizenLivePathLabel = buildLabel (3 , LocalizationUtil .get ("labelStarCitizenLivePath" ));
66
+ var starCitizenLivePathField = buildTextField (3 , gameLogService .getStarCitizenLivePath ().get ());
67
+ starCitizenLivePathField .putClientProperty ("JTextField.placeholderText" ,
68
+ LocalizationUtil .get ("textFieldStarCitizenLivePathPlaceholder" ));
69
+ starCitizenLivePathLabel .setLabelFor (starCitizenLivePathField );
70
+
71
+ starCitizenLivePathField .getDocument ().addDocumentListener (new DocumentListener () {
72
+ @ Override
73
+ public void insertUpdate (DocumentEvent e ) {
74
+ updateStarCitizenLivePath ();
75
+ }
76
+
77
+ @ Override
78
+ public void removeUpdate (DocumentEvent e ) {
79
+ updateStarCitizenLivePath ();
80
+ }
81
+
82
+ @ Override
83
+ public void changedUpdate (DocumentEvent e ) {
84
+ updateStarCitizenLivePath ();
85
+ }
86
+
87
+ private void updateStarCitizenLivePath () {
88
+ gameLogService .setStarCitizenLivePath (starCitizenLivePathField .getText ());
89
+ }
90
+ });
91
+
92
+ var tooltip = buildLabel (4 , LocalizationUtil .get ("tooltipStarCitizenLivePath" ));
93
+ tooltip .putClientProperty ("FlatLaf.styleClass" , "small" );
94
+ tooltip .setEnabled (false );
95
+ buildLabel (5 , " " );
96
+ }
97
+
61
98
private void buildDataPathField (String dataPath ) {
62
- var dataPathLabel = buildLabel (3 , LocalizationUtil .get ("labelMyData" ));
63
- var dataPathField = buildTextField (3 , dataPath );
99
+ var dataPathLabel = buildLabel (6 , LocalizationUtil .get ("labelMyData" ));
100
+ var dataPathField = buildTextField (6 , dataPath );
64
101
dataPathField .setEditable (false );
65
102
dataPathLabel .setLabelFor (dataPathField );
66
103
}
67
104
68
105
private void buildImagesPathField (String imagesPath ) {
69
- var imagesPathLabel = buildLabel (4 , LocalizationUtil .get ("labelMyImages" ));
70
- var imagesPathField = buildTextField (4 , imagesPath );
106
+ var imagesPathLabel = buildLabel (7 , LocalizationUtil .get ("labelMyImages" ));
107
+ var imagesPathField = buildTextField (7 , imagesPath );
71
108
imagesPathField .setEditable (false );
72
109
imagesPathLabel .setLabelFor (imagesPathField );
73
110
}
0 commit comments