1
- /**
1
+ /*
2
2
* Copyright © Magento, Inc. All rights reserved.
3
3
* See COPYING.txt for license details.
4
4
*/
12
12
import com .intellij .openapi .ui .ComponentWithBrowseButton ;
13
13
import com .intellij .openapi .ui .TextComponentAccessor ;
14
14
import com .intellij .openapi .ui .TextFieldWithBrowseButton ;
15
+ import com .intellij .openapi .util .Pair ;
15
16
import com .intellij .openapi .vfs .VirtualFile ;
16
17
import com .jetbrains .php .frameworks .PhpFrameworkConfigurable ;
17
18
import com .magento .idea .magento2plugin .indexes .IndexManager ;
38
39
"PMD.TooManyMethods"
39
40
})
40
41
public class SettingsForm implements PhpFrameworkConfigurable {
42
+
43
+ private static final String DEFAULT_MAGENTO_EDITION_LABEL = "Platform Version:" ;
44
+
41
45
private final Project project ;
42
46
private JCheckBox pluginEnabled ;
43
47
private JButton buttonReindex ;
@@ -48,6 +52,7 @@ public class SettingsForm implements PhpFrameworkConfigurable {
48
52
private JCheckBox mftfSupportEnabled ;
49
53
private TextFieldWithBrowseButton magentoPath ;
50
54
private final SettingsFormValidator validator = new SettingsFormValidator (this );
55
+ private String magentoEdition ;
51
56
private JLabel magentoVersionLabel ;//NOPMD
52
57
private JLabel magentoPathLabel ;//NOPMD
53
58
@@ -95,6 +100,12 @@ public void mouseClicked(final MouseEvent event) {
95
100
addPathListener ();
96
101
addMagentoVersionListener ();
97
102
103
+ final String storedMagentoEdition = getSettings ().magentoEdition ;
104
+
105
+ magentoVersionLabel .setText (
106
+ storedMagentoEdition == null ? DEFAULT_MAGENTO_EDITION_LABEL : storedMagentoEdition
107
+ );
108
+
98
109
return (JComponent ) panel ;
99
110
}
100
111
@@ -159,6 +170,7 @@ private void saveSettings() {
159
170
getSettings ().mftfSupportEnabled = mftfSupportEnabled .isSelected ();
160
171
getSettings ().magentoPath = getMagentoPath ();
161
172
getSettings ().magentoVersion = getMagentoVersion ();
173
+ getSettings ().magentoEdition = getMagentoEdition ();
162
174
buttonReindex .setEnabled (getSettings ().pluginEnabled );
163
175
regenerateUrnMapButton .setEnabled (getSettings ().pluginEnabled );
164
176
}
@@ -168,6 +180,10 @@ public String getMagentoVersion() {
168
180
return magentoVersion .getText ().trim ();
169
181
}
170
182
183
+ public @ NotNull String getMagentoEdition () {
184
+ return magentoEdition == null ? DEFAULT_MAGENTO_EDITION_LABEL : magentoEdition ;
185
+ }
186
+
171
187
@ NotNull
172
188
public String getMagentoPath () {
173
189
return magentoPath .getTextField ().getText ().trim ();
@@ -233,8 +249,19 @@ public void changedUpdate(final DocumentEvent documentEvent) {
233
249
*/
234
250
public void updateMagentoVersion () {
235
251
final String magentoPathValue = this .magentoPath .getTextField ().getText ();
236
- final String resolvedVersion = MagentoVersionUtil .get (project , magentoPathValue );
252
+ final Pair <String , String > version = MagentoVersionUtil .getVersionData (
253
+ project ,
254
+ magentoPathValue
255
+ );
256
+ final String resolvedVersion = version .getFirst ();
257
+ final String resolvedEdition = version .getSecond () == null
258
+ ? DEFAULT_MAGENTO_EDITION_LABEL
259
+ : version .getSecond ();
237
260
magentoVersion .setText (resolvedVersion );
261
+ magentoVersionLabel .setText (resolvedEdition );
262
+
263
+ magentoEdition = resolvedEdition ;
264
+ getSettings ().magentoEdition = getMagentoEdition ();
238
265
}
239
266
240
267
@ Override
0 commit comments