1
1
package de .php_perfect .intellij .ddev .settings ;
2
2
3
+ import com .intellij .icons .AllIcons ;
3
4
import com .intellij .openapi .fileChooser .FileChooserDescriptor ;
4
5
import com .intellij .openapi .project .Project ;
5
6
import com .intellij .openapi .ui .TextFieldWithBrowseButton ;
8
9
import com .intellij .ui .components .JBLabel ;
9
10
import com .intellij .util .ui .FormBuilder ;
10
11
import com .intellij .util .ui .JBUI ;
12
+ import com .intellij .util .ui .UIUtil ;
11
13
import de .php_perfect .intellij .ddev .DdevIntegrationBundle ;
14
+ import de .php_perfect .intellij .ddev .util .FeatureRequiredPlugins ;
15
+ import de .php_perfect .intellij .ddev .util .PluginChecker ;
12
16
import org .jetbrains .annotations .NotNull ;
13
17
14
18
import javax .swing .*;
19
+ import javax .swing .BoxLayout ;
15
20
import java .awt .*;
21
+ import java .util .List ;
16
22
17
23
public final class DdevSettingsComponent {
18
24
private final @ NotNull JPanel jPanel ;
@@ -32,7 +38,7 @@ public DdevSettingsComponent(Project project) {
32
38
checkForUpdatesComment .setForeground (UIManager .getColor ("Component.infoForeground" ));
33
39
checkForUpdatesComment .setBorder (JBUI .Borders .emptyLeft (24 ));
34
40
checkForUpdatesPanel .add (checkForUpdatesComment , BorderLayout .CENTER );
35
-
41
+
36
42
JPanel watchDdevPanel = new JPanel (new BorderLayout ());
37
43
watchDdevPanel .add (this .watchDdevCheckbox , BorderLayout .NORTH );
38
44
JLabel watchDdevComment = new JLabel (DdevIntegrationBundle .message ("settings.watchDdev.description" ));
@@ -41,13 +47,35 @@ public DdevSettingsComponent(Project project) {
41
47
watchDdevComment .setBorder (JBUI .Borders .emptyLeft (24 ));
42
48
watchDdevPanel .add (watchDdevComment , BorderLayout .CENTER );
43
49
50
+ // Set up warning indicators and tooltips
51
+ @ NotNull JPanel autoConfigureDataSourcePanel = new JPanel (new BorderLayout ());
52
+ @ NotNull JLabel dataSourceWarningLabel = new JLabel (AllIcons .General .Warning );
53
+ @ NotNull JLabel dataSourceWarningText = new JLabel ();
54
+ setupWarningIndicator (autoConfigureDataSourcePanel , this .autoConfigureDataSource , dataSourceWarningLabel ,
55
+ dataSourceWarningText , FeatureRequiredPlugins .DATABASE , "database auto-registration" );
56
+
57
+ @ NotNull JPanel autoConfigurePhpInterpreterPanel = new JPanel (new BorderLayout ());
58
+ @ NotNull JLabel phpWarningLabel = new JLabel (AllIcons .General .Warning );
59
+ @ NotNull JLabel phpWarningText = new JLabel ();
60
+ setupWarningIndicator (autoConfigurePhpInterpreterPanel , this .autoConfigurePhpInterpreter , phpWarningLabel ,
61
+ phpWarningText , FeatureRequiredPlugins .PHP_INTERPRETER , "PHP interpreter auto-registration" );
62
+
63
+ @ NotNull JPanel autoConfigureNodeJsInterpreterPanel = new JPanel (new BorderLayout ());
64
+ @ NotNull JLabel nodeWarningLabel = new JLabel (AllIcons .General .Warning );
65
+ @ NotNull JLabel nodeWarningText = new JLabel ();
66
+ setupWarningIndicator (autoConfigureNodeJsInterpreterPanel , this .autoConfigureNodeJsInterpreter , nodeWarningLabel ,
67
+ nodeWarningText , FeatureRequiredPlugins .NODE_INTERPRETER , "Node.js interpreter auto-registration" );
68
+
44
69
final JPanel panel = new JPanel ();
45
70
panel .setBorder (IdeBorderFactory .createTitledBorder (DdevIntegrationBundle .message ("settings.automaticConfiguration" ), true ));
46
- panel .setLayout (new GridBagLayout ());
47
- final GridBagConstraints gc = new GridBagConstraints (0 , GridBagConstraints .RELATIVE , 1 , 1 , 1 , 0 , GridBagConstraints .NORTHWEST , GridBagConstraints .BOTH , JBUI .emptyInsets (), 0 , 0 );
48
- panel .add (this .autoConfigureDataSource , gc );
49
- panel .add (this .autoConfigurePhpInterpreter , gc );
50
- panel .add (this .autoConfigureNodeJsInterpreter , gc );
71
+ panel .setLayout (new BoxLayout (panel , BoxLayout .Y_AXIS ));
72
+
73
+ // Add feature panels with some vertical spacing
74
+ panel .add (autoConfigureDataSourcePanel );
75
+ panel .add (Box .createVerticalStrut (5 ));
76
+ panel .add (autoConfigurePhpInterpreterPanel );
77
+ panel .add (Box .createVerticalStrut (5 ));
78
+ panel .add (autoConfigureNodeJsInterpreterPanel );
51
79
52
80
this .ddevBinary .addBrowseFolderListener (
53
81
project ,
@@ -65,6 +93,52 @@ public DdevSettingsComponent(Project project) {
65
93
.getPanel ();
66
94
}
67
95
96
+ /**
97
+ * Sets up a warning indicator for a feature that requires plugins.
98
+ *
99
+ * @param panel The panel to add the components to
100
+ * @param checkbox The checkbox for the feature
101
+ * @param warningLabel The warning icon to show if plugins are missing
102
+ * @param warningText The label to display the warning text
103
+ * @param requiredPlugins The list of required plugin IDs
104
+ * @param featureName The name of the feature for the message
105
+ */
106
+ private void setupWarningIndicator (@ NotNull JPanel panel , @ NotNull JBCheckBox checkbox , @ NotNull JLabel warningLabel ,
107
+ @ NotNull JLabel warningText , @ NotNull List <String > requiredPlugins , @ NotNull String featureName ) {
108
+ // Set up panel with vertical layout
109
+ panel .setLayout (new BoxLayout (panel , BoxLayout .Y_AXIS ));
110
+
111
+ // Add checkbox to panel
112
+ JPanel checkboxPanel = new JPanel (new BorderLayout ());
113
+ checkboxPanel .add (checkbox , BorderLayout .WEST );
114
+ panel .add (checkboxPanel );
115
+
116
+ // Check if any required plugins are missing
117
+ List <String > missingPlugins = PluginChecker .getMissingPlugins (requiredPlugins );
118
+
119
+ if (missingPlugins .isEmpty ()) {
120
+ // No missing plugins, hide warning
121
+ warningLabel .setVisible (false );
122
+ warningText .setVisible (false );
123
+ } else {
124
+ // Create warning message
125
+ String warningMessage = DdevIntegrationBundle .message ("settings.warning.missingPlugins" , String .join (", " , missingPlugins ));
126
+
127
+ // Set up warning text
128
+ warningText .setText (" " + warningMessage );
129
+ warningText .setForeground (UIUtil .getErrorForeground ());
130
+
131
+ // Create warning panel with left alignment and indentation
132
+ JPanel warningPanel = new JPanel (new FlowLayout (FlowLayout .LEFT , 0 , 0 ));
133
+ warningPanel .setBorder (JBUI .Borders .emptyLeft (24 ));
134
+ warningPanel .add (warningLabel );
135
+ warningPanel .add (warningText );
136
+
137
+ // Add warning panel below the checkbox
138
+ panel .add (warningPanel );
139
+ }
140
+ }
141
+
68
142
public @ NotNull JPanel getPanel () {
69
143
return this .jPanel ;
70
144
}
0 commit comments