1- package com .cedricziel .idea .typo3 ;
1+ package com .cedricziel .idea .typo3 . listener ;
22
3+ import com .cedricziel .idea .typo3 .IdeHelper ;
4+ import com .cedricziel .idea .typo3 .TYPO3CMSProjectSettings ;
5+ import com .cedricziel .idea .typo3 .TYPO3CMSSettings ;
36import com .cedricziel .idea .typo3 .index .*;
47import com .cedricziel .idea .typo3 .index .extbase .ControllerActionIndex ;
58import com .cedricziel .idea .typo3 .index .extensionScanner .MethodArgumentDroppedIndex ;
69import com .cedricziel .idea .typo3 .index .php .LegacyClassesForIDEIndex ;
710import com .intellij .ide .plugins .IdeaPluginDescriptor ;
811import com .intellij .ide .plugins .PluginManager ;
9- import com .intellij .notification .Notification ;
10- import com .intellij .notification .NotificationType ;
11- import com .intellij .notification .Notifications ;
12- import com .intellij .openapi .components .ProjectComponent ;
13- import com .intellij .openapi .diagnostic .Logger ;
1412import com .intellij .openapi .extensions .PluginId ;
1513import com .intellij .openapi .project .Project ;
14+ import com .intellij .openapi .project .ProjectManagerListener ;
1615import com .intellij .openapi .vfs .VfsUtil ;
1716import com .intellij .psi .search .FilenameIndex ;
1817import com .intellij .psi .search .GlobalSearchScope ;
1918import com .intellij .util .indexing .FileBasedIndex ;
2019import org .jetbrains .annotations .NotNull ;
2120import org .jetbrains .annotations .Nullable ;
2221
23- public class TYPO3CMSProjectComponent implements ProjectComponent {
24-
25- private static final Logger LOG = Logger .getInstance ("TYPO3-CMS-Plugin" );
26-
27- private Project project ;
28-
29- public TYPO3CMSProjectComponent (Project project ) {
30- this .project = project ;
31- }
32-
33- public static Logger getLogger () {
34- return LOG ;
35- }
36-
37- @ Override
38- public void initComponent () {
39- }
40-
41- @ Override
42- public void disposeComponent () {
43- }
44-
45- @ Override
46- @ NotNull
47- public String getComponentName () {
48- return "com.cedricziel.idea.typo3.TYPO3CMSProjectComponent" ;
49- }
50-
22+ public class TYPO3DetectionListener implements ProjectManagerListener {
5123 @ Override
52- public void projectOpened () {
53- this .checkProject ();
24+ public void projectOpened (@ NotNull Project project ) {
25+ this .checkProject (project );
5426
5527 TYPO3CMSSettings instance = TYPO3CMSSettings .getInstance (project );
5628 IdeaPluginDescriptor plugin = PluginManager .getPlugin (PluginId .getId ("com.cedricziel.idea.typo3" ));
@@ -75,34 +47,24 @@ public void projectOpened() {
7547 }
7648 }
7749
78- @ Override
79- public void projectClosed () {
80- }
81-
82- public void showInfoNotification (String content ) {
83- Notification notification = new Notification ("TYPO3 CMS Plugin" , "TYPO3 CMS Plugin" , content , NotificationType .INFORMATION );
84-
85- Notifications .Bus .notify (notification , this .project );
86- }
87-
8850 public boolean isEnabled (@ Nullable Project project ) {
8951
9052 return project != null && TYPO3CMSProjectSettings .getInstance (project ).pluginEnabled ;
9153 }
9254
93- private void checkProject () {
94- if (!this .isEnabled (project ) && !notificationIsDismissed () && containsPluginRelatedFiles ()) {
55+ private void checkProject (@ NotNull Project project ) {
56+ if (!this .isEnabled (project ) && !notificationIsDismissed (project ) && containsPluginRelatedFiles (project )) {
9557 IdeHelper .notifyEnableMessage (project );
9658 }
9759 }
9860
99- private boolean notificationIsDismissed () {
61+ private boolean notificationIsDismissed (@ NotNull Project project ) {
10062
10163 return TYPO3CMSProjectSettings .getInstance (project ).dismissEnableNotification ;
10264 }
10365
104- private boolean containsPluginRelatedFiles () {
105- return (VfsUtil .findRelativeFile (this . project .getBaseDir (), "vendor" , "typo3" ) != null )
66+ private boolean containsPluginRelatedFiles (@ NotNull Project project ) {
67+ return (VfsUtil .findRelativeFile (project .getBaseDir (), "vendor" , "typo3" ) != null )
10668 || FilenameIndex .getFilesByName (project , "ext_emconf.php" , GlobalSearchScope .allScope (project )).length > 0 ;
10769 }
10870}
0 commit comments