1
1
package com .magento .idea .magento2plugin ;
2
2
3
3
import com .intellij .javaee .ExternalResourceManager ;
4
+ import com .intellij .javaee .ExternalResourceManagerEx ;
4
5
import com .intellij .openapi .application .ApplicationManager ;
5
6
import com .intellij .openapi .options .Configurable ;
6
7
import com .intellij .openapi .options .ConfigurationException ;
@@ -59,8 +60,7 @@ public JComponent createComponent() {
59
60
new MouseAdapter () {
60
61
@ Override
61
62
public void mouseClicked (MouseEvent e ) {
62
- IndexUtil .manualReindex ();
63
- MagentoComponentManager .getInstance (project ).flushModules ();
63
+ reindex ();
64
64
super .mouseClicked (e );
65
65
}
66
66
}
@@ -75,6 +75,11 @@ public void mouseClicked(MouseEvent e) {
75
75
return (JComponent ) panel1 ;
76
76
}
77
77
78
+ private void reindex () {
79
+ IndexUtil .manualReindex ();
80
+ MagentoComponentManager .getInstance (project ).flushModules ();
81
+ }
82
+
78
83
@ Override
79
84
public boolean isModified () {
80
85
return !pluginEnabled .isSelected () == getSettings ().pluginEnabled ;
@@ -85,6 +90,11 @@ public void apply() throws ConfigurationException {
85
90
getSettings ().pluginEnabled = pluginEnabled .isSelected ();
86
91
buttonReindex .setEnabled (getSettings ().pluginEnabled );
87
92
regenerateUrnMapButton .setEnabled (getSettings ().pluginEnabled );
93
+
94
+ if (buttonReindex .isEnabled ()) {
95
+ reindex ();
96
+ }
97
+
88
98
}
89
99
90
100
@ Override
@@ -141,7 +151,15 @@ public void run() {
141
151
continue ;
142
152
}
143
153
144
- externalResourceManager .addResource (urnKey , virtualFile .getCanonicalPath ());
154
+ // we need to attach resource to a project scope
155
+ // but with ExternalResourceManager itself it's not possible unfortunately
156
+ if (externalResourceManager instanceof ExternalResourceManagerEx ) {
157
+ ((ExternalResourceManagerEx )externalResourceManager ).addResource (
158
+ urnKey , virtualFile .getCanonicalPath (), project
159
+ );
160
+ } else {
161
+ externalResourceManager .addResource (urnKey , virtualFile .getCanonicalPath ());
162
+ }
145
163
}
146
164
}
147
165
}
0 commit comments