Skip to content

Commit 11606af

Browse files
committed
1023: Added additional fields for UCT configuration dialog
1 parent 9b11abb commit 11606af

File tree

3 files changed

+138
-22
lines changed

3 files changed

+138
-22
lines changed

src/com/magento/idea/magento2uct/settings/UctSettingsService.java

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,12 @@ public class UctSettingsService implements PersistentStateComponent<UctSettingsS
4242
@Property
4343
private Boolean ignoreCurrentVersion;
4444

45+
@Property
46+
private Boolean hasAdditionalPath;
47+
48+
@Property
49+
private String additionalPath;
50+
4551
@SuppressWarnings("PMD.UncommentedEmptyConstructor")
4652
public UctSettingsService() {
4753
}
@@ -249,4 +255,40 @@ public void setIgnoreCurrentVersion(final boolean ignoreCurrentVersion) {
249255
public @Nullable Boolean shouldIgnoreCurrentVersion() {
250256
return ignoreCurrentVersion;
251257
}
258+
259+
/**
260+
* Set if show additional path
261+
*
262+
* @param hasAdditionalPath boolean
263+
*/
264+
public void setHasAdditionalPath(final boolean hasAdditionalPath) {
265+
this.hasAdditionalPath = hasAdditionalPath;
266+
}
267+
268+
/**
269+
* Check if show additional path
270+
*
271+
* @return boolean
272+
*/
273+
public @Nullable Boolean getHasAdditionalPath() {
274+
return hasAdditionalPath;
275+
}
276+
277+
/**
278+
* Set path to analyse.
279+
*
280+
* @param additionalPath String
281+
*/
282+
public void setAdditionalPath(final @NotNull String additionalPath) {
283+
this.additionalPath = additionalPath;
284+
}
285+
286+
/**
287+
* Get target module path (path to analyse).
288+
*
289+
* @return String
290+
*/
291+
public @Nullable String getAdditionalPath() {
292+
return additionalPath;
293+
}
252294
}

src/com/magento/idea/magento2uct/ui/ConfigurationDialog.form

Lines changed: 52 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,16 @@
33
<grid id="27dc6" binding="contentPanel" layout-manager="GridLayoutManager" row-count="3" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
44
<margin top="10" left="10" bottom="10" right="10"/>
55
<constraints>
6-
<xy x="20" y="20" width="688" height="400"/>
6+
<xy x="20" y="20" width="719" height="500"/>
77
</constraints>
88
<properties>
9-
<preferredSize width="580" height="300"/>
9+
<minimumSize width="559" height="300"/>
10+
<preferredSize width="580" height="380"/>
11+
<requestFocusEnabled value="true"/>
1012
</properties>
1113
<border type="none"/>
1214
<children>
13-
<grid id="d41a9" layout-manager="GridLayoutManager" row-count="9" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
15+
<grid id="d41a9" layout-manager="GridLayoutManager" row-count="12" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
1416
<margin top="0" left="0" bottom="0" right="0"/>
1517
<constraints>
1618
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
@@ -20,15 +22,15 @@
2022
<children>
2123
<component id="28e30" class="javax.swing.JCheckBox" binding="enable">
2224
<constraints>
23-
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
25+
<grid row="0" column="1" row-span="1" col-span="2" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
2426
</constraints>
2527
<properties>
2628
<text value="Enable the built-in Upgrade Compatibility Tool"/>
2729
</properties>
2830
</component>
2931
<component id="dda21" class="javax.swing.JComboBox" binding="currentVersion" custom-create="true">
3032
<constraints>
31-
<grid row="3" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="8" fill="1" indent="0" use-parent-layout="false"/>
33+
<grid row="3" column="1" row-span="1" col-span="2" vsize-policy="0" hsize-policy="2" anchor="8" fill="1" indent="0" use-parent-layout="false"/>
3234
</constraints>
3335
<properties/>
3436
</component>
@@ -43,7 +45,7 @@
4345
</component>
4446
<component id="dede1" class="javax.swing.JComboBox" binding="targetVersion" custom-create="true">
4547
<constraints>
46-
<grid row="4" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="8" fill="1" indent="0" use-parent-layout="false"/>
48+
<grid row="4" column="1" row-span="1" col-span="2" vsize-policy="0" hsize-policy="2" anchor="8" fill="1" indent="0" use-parent-layout="false"/>
4749
</constraints>
4850
<properties/>
4951
</component>
@@ -58,11 +60,13 @@
5860
</component>
5961
<component id="d5e0b" class="com.intellij.openapi.ui.LabeledComponent" binding="modulePath" custom-create="true">
6062
<constraints>
61-
<grid row="5" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
63+
<grid row="5" column="1" row-span="1" col-span="2" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
6264
<preferred-size width="150" height="-1"/>
6365
</grid>
6466
</constraints>
65-
<properties/>
67+
<properties>
68+
<enabled value="true"/>
69+
</properties>
6670
</component>
6771
<component id="f4311" class="javax.swing.JLabel" binding="modulePathLabel">
6872
<constraints>
@@ -74,13 +78,13 @@
7478
</component>
7579
<component id="70b2b" class="javax.swing.JComboBox" binding="issueSeverityLevel" custom-create="true">
7680
<constraints>
77-
<grid row="7" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="8" fill="1" indent="0" use-parent-layout="false"/>
81+
<grid row="10" column="1" row-span="1" col-span="2" vsize-policy="0" hsize-policy="2" anchor="8" fill="1" indent="0" use-parent-layout="false"/>
7882
</constraints>
7983
<properties/>
8084
</component>
8185
<component id="bd4f" class="javax.swing.JLabel" binding="issueSeverityLevelLabel">
8286
<constraints>
83-
<grid row="7" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
87+
<grid row="10" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
8488
</constraints>
8589
<properties>
8690
<labelFor value="70b2b"/>
@@ -89,23 +93,23 @@
8993
</component>
9094
<component id="3c2d0" class="javax.swing.JCheckBox" binding="ignoreCurrentVersion">
9195
<constraints>
92-
<grid row="8" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
96+
<grid row="11" column="1" row-span="1" col-span="2" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
9397
</constraints>
9498
<properties>
9599
<text value="Ignore current version compatibility issues"/>
96100
</properties>
97101
</component>
98102
<component id="2d9d9" class="javax.swing.JLabel" binding="modulePathError">
99103
<constraints>
100-
<grid row="6" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
104+
<grid row="6" column="1" row-span="1" col-span="2" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
101105
</constraints>
102106
<properties>
103107
<text value="Label"/>
104108
</properties>
105109
</component>
106110
<component id="6f213" class="javax.swing.JLabel" binding="enableComment">
107111
<constraints>
108-
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
112+
<grid row="1" column="1" row-span="1" col-span="2" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
109113
</constraints>
110114
<properties>
111115
<enabled value="true"/>
@@ -116,14 +120,48 @@
116120
</component>
117121
<component id="1b278" class="javax.swing.JLabel" binding="enableCommentPath">
118122
<constraints>
119-
<grid row="2" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
123+
<grid row="2" column="1" row-span="1" col-span="2" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
120124
</constraints>
121125
<properties>
122126
<enabled value="true"/>
123127
<font size="12"/>
124128
<text value="Preferences -&gt; Editor -&gt; Inspections -&gt; UCT"/>
125129
</properties>
126130
</component>
131+
<component id="3b634" class="javax.swing.JLabel" binding="additionalPathLabel">
132+
<constraints>
133+
<grid row="8" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
134+
</constraints>
135+
<properties>
136+
<text value="Path To Analyse"/>
137+
</properties>
138+
</component>
139+
<component id="ab5bd" class="com.intellij.openapi.ui.LabeledComponent" binding="additionalPath" custom-create="true">
140+
<constraints>
141+
<grid row="8" column="1" row-span="1" col-span="2" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
142+
<preferred-size width="150" height="-1"/>
143+
</grid>
144+
</constraints>
145+
<properties>
146+
<enabled value="true"/>
147+
</properties>
148+
</component>
149+
<component id="c2187" class="javax.swing.JCheckBox" binding="hasAdditionalPath">
150+
<constraints>
151+
<grid row="7" column="1" row-span="1" col-span="2" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
152+
</constraints>
153+
<properties>
154+
<text value="Add additional path to analyse"/>
155+
</properties>
156+
</component>
157+
<component id="9ba03" class="javax.swing.JLabel" binding="additionalPathError">
158+
<constraints>
159+
<grid row="9" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
160+
</constraints>
161+
<properties>
162+
<text value="Label"/>
163+
</properties>
164+
</component>
127165
</children>
128166
</grid>
129167
<vspacer id="9089b">

src/com/magento/idea/magento2uct/ui/ConfigurationDialog.java

Lines changed: 44 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,7 @@
2727
import java.awt.event.WindowAdapter;
2828
import java.awt.event.WindowEvent;
2929
import java.util.Objects;
30-
import javax.swing.JButton;
31-
import javax.swing.JCheckBox;
32-
import javax.swing.JComboBox;
33-
import javax.swing.JComponent;
34-
import javax.swing.JLabel;
35-
import javax.swing.JPanel;
36-
import javax.swing.KeyStroke;
30+
import javax.swing.*;
3731
import org.jetbrains.annotations.NotNull;
3832

3933
@SuppressWarnings({"PMD.TooManyFields", "PMD.ExcessiveImports"})
@@ -44,6 +38,7 @@ public class ConfigurationDialog extends AbstractDialog {
4438

4539
private JCheckBox enable;
4640
private LabeledComponent<TextFieldWithBrowseButton> modulePath;
41+
private LabeledComponent<TextFieldWithBrowseButton> additionalPath;
4742
private JCheckBox ignoreCurrentVersion;
4843
private JComboBox<ComboBoxItemData> currentVersion;
4944
private JComboBox<ComboBoxItemData> targetVersion;
@@ -59,6 +54,9 @@ public class ConfigurationDialog extends AbstractDialog {
5954
private JLabel modulePathError;//NOPMD
6055
private JLabel enableComment;//NOPMD
6156
private JLabel enableCommentPath;//NOPMD
57+
private JCheckBox hasAdditionalPath;
58+
private JLabel additionalPathLabel;//NOPMD
59+
private JLabel additionalPathError;//NOPMD
6260

6361
/**
6462
* Configuration dialog.
@@ -76,6 +74,7 @@ public ConfigurationDialog(final @NotNull Project project) {
7674
setTitle(ConfigureUctAction.ACTION_NAME);
7775
getRootPane().setDefaultButton(buttonOk);
7876

77+
hasAdditionalPath.addActionListener(event -> refreshAdditionalFields(hasAdditionalPath.isSelected()));
7978
buttonOk.addActionListener(event -> onOK());
8079
buttonCancel.addActionListener(event -> onCancel());
8180

@@ -98,6 +97,9 @@ public void windowClosing(final WindowEvent event) {
9897
modulePathError.setText("");
9998
modulePathError.setFont(UIUtil.getLabelFont(UIUtil.FontSize.SMALL));
10099
modulePathError.setForeground(new Color(252, 119, 83));
100+
additionalPathError.setText("");
101+
additionalPathError.setFont(UIUtil.getLabelFont(UIUtil.FontSize.SMALL));
102+
additionalPathError.setForeground(new Color(252, 119, 83));
101103
enableComment.setForeground(JBColor.blue);
102104
enableCommentPath.setForeground(JBColor.blue);
103105
setDefaultValues();
@@ -120,12 +122,18 @@ public static void open(final @NotNull Project project) {
120122
*/
121123
private void onOK() {
122124
modulePathError.setText("");
125+
additionalPathError.setText("");
123126

124127
if (modulePath.getComponent().getText().isEmpty()
125128
|| !UctModulePathValidatorUtil.validate(modulePath.getComponent().getText())) {
126129
modulePathError.setText("The `Path To Analyse` field is empty or invalid");
127130
return;
128131
}
132+
if (additionalPath.getComponent().getText().isEmpty()
133+
|| !UctModulePathValidatorUtil.validate(additionalPath.getComponent().getText())) {
134+
additionalPathError.setText("The `Path To Analyse` field is empty or invalid");
135+
return;
136+
}
129137
settingsService.setEnabled(enable.isSelected());
130138

131139
final ComboBoxItemData currentVersionItemData =
@@ -155,7 +163,8 @@ private void onOK() {
155163
)
156164
);
157165
settingsService.setIgnoreCurrentVersion(ignoreCurrentVersion.isSelected());
158-
166+
settingsService.setHasAdditionalPath(hasAdditionalPath.isSelected());
167+
settingsService.setAdditionalPath(additionalPath.getComponent().getText());
159168
exit();
160169
}
161170

@@ -221,6 +230,21 @@ private void setDefaultValues() {
221230
}
222231
final Boolean shouldIgnore = settingsService.shouldIgnoreCurrentVersion();
223232
ignoreCurrentVersion.setSelected(Objects.requireNonNullElse(shouldIgnore, false));
233+
234+
final Boolean isShowAdditionalPath = settingsService.getHasAdditionalPath();
235+
additionalPath.setEnabled(
236+
Objects.requireNonNullElse(isShowAdditionalPath, false)
237+
);
238+
239+
if (settingsService.getAdditionalPath() == null) {
240+
final String basePath = Settings.getMagentoPath(project);
241+
242+
if (basePath != null) {
243+
additionalPath.getComponent().setText(basePath);
244+
}
245+
} else {
246+
additionalPath.getComponent().setText(settingsService.getAdditionalPath());
247+
}
224248
}
225249

226250
/**
@@ -271,5 +295,17 @@ private void createUIComponents() {
271295
new FileChooserDescriptor(false, true, false, false, false, false)
272296
)
273297
);
298+
299+
additionalPath = new LabeledComponent<>();
300+
additionalPath.setComponent(new TextFieldWithBrowseButton());
301+
additionalPath.getComponent().addBrowseFolderListener(
302+
new TextBrowseFolderListener(
303+
new FileChooserDescriptor(false, true, false, false, false, false)
304+
)
305+
);
306+
}
307+
308+
private void refreshAdditionalFields(final boolean isEnabled) {
309+
additionalPath.setEnabled(isEnabled);
274310
}
275311
}

0 commit comments

Comments
 (0)