|
8 | 8 | import com.intellij.openapi.project.Project;
|
9 | 9 | import com.intellij.psi.PsiDirectory;
|
10 | 10 | import com.intellij.psi.PsiFile;
|
| 11 | +import com.intellij.util.indexing.FileBasedIndex; |
11 | 12 | import com.jetbrains.php.lang.psi.elements.PhpClass;
|
12 | 13 | import com.magento.idea.magento2plugin.actions.generation.NewUiComponentFormAction;
|
13 | 14 | import com.magento.idea.magento2plugin.actions.generation.NewUiComponentGridAction;
|
|
24 | 25 | import com.magento.idea.magento2plugin.actions.generation.generator.UiComponentDataProviderGenerator;
|
25 | 26 | import com.magento.idea.magento2plugin.actions.generation.generator.UiComponentGridXmlGenerator;
|
26 | 27 | import com.magento.idea.magento2plugin.actions.generation.generator.util.NamespaceBuilder;
|
| 28 | +import com.magento.idea.magento2plugin.indexes.ModuleIndex; |
27 | 29 | import com.magento.idea.magento2plugin.magento.files.ControllerBackendPhp;
|
28 | 30 | import com.magento.idea.magento2plugin.magento.files.UiComponentDataProviderPhp;
|
29 | 31 | import com.magento.idea.magento2plugin.magento.packages.Areas;
|
30 | 32 | import com.magento.idea.magento2plugin.magento.packages.File;
|
31 | 33 | import com.magento.idea.magento2plugin.magento.packages.HttpMethod;
|
32 | 34 | import com.magento.idea.magento2plugin.magento.packages.Package;
|
| 35 | +import com.magento.idea.magento2plugin.stubs.indexes.xml.MenuIndex; |
33 | 36 | import com.magento.idea.magento2plugin.ui.FilteredComboBox;
|
34 | 37 | import com.magento.idea.magento2plugin.util.magento.GetModuleNameByDirectoryUtil;
|
35 | 38 | import com.magento.idea.magento2plugin.util.magento.GetResourceCollections;
|
| 39 | +import org.jetbrains.annotations.NotNull; |
| 40 | + |
36 | 41 | import java.awt.event.KeyEvent;
|
37 | 42 | import java.awt.event.WindowAdapter;
|
38 | 43 | import java.awt.event.WindowEvent;
|
39 | 44 | import java.util.ArrayList;
|
40 | 45 | import java.util.Arrays;
|
| 46 | +import java.util.Collection; |
| 47 | +import java.util.Collections; |
41 | 48 | import java.util.List;
|
42 | 49 | import javax.swing.*;
|
43 | 50 |
|
@@ -71,14 +78,14 @@ public class NewUiComponentGridDialog extends AbstractDialog {
|
71 | 78 | private JTextField route;
|
72 | 79 | private JTextField controllerName;
|
73 | 80 | private JTextField actionName;
|
74 |
| - private JComboBox parentMenuItem; |
75 | 81 | private JLabel parentMenuItemLabel;
|
76 | 82 | private JTextField sortOrder;
|
77 | 83 | private JTextField menuIdentifier;
|
78 | 84 | private JLabel sortOrderLabel;
|
79 | 85 | private JLabel menuIdentifierLabel;
|
80 | 86 | private JTextField menuTitle;
|
81 | 87 | private JLabel menuTitleLabel;
|
| 88 | + private FilteredComboBox parentMenu; |
82 | 89 | private JLabel collectionLabel;
|
83 | 90 |
|
84 | 91 | /**
|
@@ -118,6 +125,7 @@ public void windowClosing(final WindowEvent event) {
|
118 | 125 | KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0),
|
119 | 126 | JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT
|
120 | 127 | );
|
| 128 | + menuIdentifier.setText(getModuleName() + "::listing"); |
121 | 129 | }
|
122 | 130 |
|
123 | 131 | /**
|
@@ -297,6 +305,16 @@ private void createUIComponents() {
|
297 | 305 | this.collection = new FilteredComboBox(getCollectionOptions());
|
298 | 306 | this.dataProviderType = new FilteredComboBox(getProviderTypeOptions());
|
299 | 307 | this.areaSelect = new FilteredComboBox(getAreaOptions());
|
| 308 | + this.parentMenu = new FilteredComboBox(getMenuReferences()); |
| 309 | + } |
| 310 | + |
| 311 | + @NotNull |
| 312 | + private ArrayList<String> getMenuReferences() { |
| 313 | + final Collection<String> menuReferences |
| 314 | + = FileBasedIndex.getInstance().getAllKeys(MenuIndex.KEY, project); |
| 315 | + ArrayList<String> menuReferencesList = new ArrayList<>(menuReferences); |
| 316 | + Collections.sort(menuReferencesList); |
| 317 | + return menuReferencesList; |
300 | 318 | }
|
301 | 319 |
|
302 | 320 | private List<String> getCollectionOptions() {
|
@@ -445,7 +463,7 @@ public String getRoute() {
|
445 | 463 | }
|
446 | 464 |
|
447 | 465 | private String getParentMenuItem() {
|
448 |
| - return parentMenuItem.getSelectedItem().toString(); |
| 466 | + return parentMenu.getSelectedItem().toString(); |
449 | 467 | }
|
450 | 468 |
|
451 | 469 | public String getSortOrder() {
|
|
0 commit comments