|
8 | 8 | import com.intellij.openapi.project.Project;
|
9 | 9 | import com.intellij.psi.PsiFile;
|
10 | 10 | import com.intellij.psi.xml.XmlTag;
|
| 11 | +import com.intellij.ui.DocumentAdapter; |
11 | 12 | import com.magento.idea.magento2plugin.actions.generation.InjectAViewModelAction;
|
12 | 13 | import com.magento.idea.magento2plugin.actions.generation.data.ViewModelFileData;
|
13 | 14 | import com.magento.idea.magento2plugin.actions.generation.dialog.validator.InjectAViewModelDialogValidator;
|
|
17 | 18 | import com.magento.idea.magento2plugin.bundles.CommonBundle;
|
18 | 19 | import com.magento.idea.magento2plugin.bundles.ValidatorBundle;
|
19 | 20 | import com.magento.idea.magento2plugin.magento.packages.XsiTypes;
|
| 21 | +import com.magento.idea.magento2plugin.util.FirstLetterToLowercaseUtil; |
20 | 22 | import com.magento.idea.magento2plugin.util.magento.GetModuleNameByDirectoryUtil;
|
21 | 23 | import java.awt.event.ActionEvent;
|
22 | 24 | import java.awt.event.ActionListener;
|
|
30 | 32 | import javax.swing.JPanel;
|
31 | 33 | import javax.swing.JTextField;
|
32 | 34 | import javax.swing.KeyStroke;
|
| 35 | +import javax.swing.event.DocumentEvent; |
33 | 36 | import org.jetbrains.annotations.NotNull;
|
34 | 37 |
|
35 | 38 | public class InjectAViewModelDialog extends AbstractDialog {
|
@@ -69,7 +72,12 @@ public InjectAViewModelDialog(
|
69 | 72 | this.validatorBundle = new ValidatorBundle();
|
70 | 73 | this.commonBundle = new CommonBundle();
|
71 | 74 |
|
72 |
| - this.viewModelArgumentName.setText("viewModel"); |
| 75 | + this.viewModelClassName.getDocument().addDocumentListener(new DocumentAdapter() { |
| 76 | + @Override |
| 77 | + protected void textChanged(final @NotNull DocumentEvent event) { |
| 78 | + updateArgumentText(); |
| 79 | + } |
| 80 | + }); |
73 | 81 | this.viewModelDirectory.setText("ViewModel");
|
74 | 82 |
|
75 | 83 | setContentPane(contentPane);
|
@@ -107,6 +115,13 @@ public void actionPerformed(final ActionEvent event) {
|
107 | 115 | JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
|
108 | 116 | }
|
109 | 117 |
|
| 118 | + protected void updateArgumentText() { |
| 119 | + final String classNameText = this.viewModelClassName.getText(); |
| 120 | + this.viewModelArgumentName.setText( |
| 121 | + FirstLetterToLowercaseUtil.convert(classNameText) |
| 122 | + ); |
| 123 | + } |
| 124 | + |
110 | 125 | protected void onOK() {
|
111 | 126 | if (!validator.validate(project)) {
|
112 | 127 | return;
|
|
0 commit comments