11package fr .adrienbrault .idea .symfony2plugin ;
22
3- import com .intellij .notification .Notification ;
4- import com .intellij .notification .NotificationType ;
5- import com .intellij .notification .Notifications ;
6- import com .intellij .openapi .components .ProjectComponent ;
3+ import com .intellij .openapi .Disposable ;
74import com .intellij .openapi .diagnostic .Logger ;
85import com .intellij .openapi .extensions .ExtensionPointName ;
96import com .intellij .openapi .project .Project ;
2825/**
2926 * @author Adrien Brault <adrien.brault@gmail.com>
3027 */
31- public class Symfony2ProjectComponent implements ProjectComponent {
28+ public class Symfony2ProjectComponent {
29+ public static class PostStartupActivity implements com .intellij .openapi .startup .StartupActivity {
30+ @ Override
31+ public void runActivity (@ NotNull Project project ) {
32+ checkProject (project );
3233
33- public static String HELP_URL = "http://symfony2-plugin.espend.de/" ;
34- final private static Logger LOG = Logger .getInstance ("Symfony-Plugin" );
35- private static final ExtensionPointName <ServiceContainerLoader > SERVICE_CONTAINER_POINT_NAME = new ExtensionPointName <>("fr.adrienbrault.idea.symfony2plugin.extension.ServiceContainerLoader" );
36- public static final ExtensionPointName <PluginConfigurationExtension > PLUGIN_CONFIGURATION_EXTENSION = new ExtensionPointName <>("fr.adrienbrault.idea.symfony2plugin.extension.PluginConfigurationExtension" );
37-
38- private final Project project ;
39-
40- public Symfony2ProjectComponent (Project project ) {
41- this .project = project ;
42- }
43-
44- @ NotNull
45- public String getComponentName () {
46- return "Symfony2ProjectComponent" ;
34+ }
4735 }
4836
49- public void projectOpened () {
50- this .checkProject ();
51- }
37+ public static class ProjectCloseService implements Disposable {
38+ private final Project project ;
5239
53- public void projectClosed () {
54- ServiceXmlParserFactory .cleanInstance (project );
40+ public ProjectCloseService (@ NotNull Project project ) {
41+ this .project = project ;
42+ }
5543
56- // clean routing
57- if (RouteHelper .COMPILED_CACHE .containsKey (project )) {
44+ @ Override
45+ public void dispose () {
46+ ServiceXmlParserFactory .cleanInstance (this .project );
47+ // clean routing
5848 RouteHelper .COMPILED_CACHE .remove (project );
5949 }
6050 }
6151
52+ public static String HELP_URL = "http://symfony2-plugin.espend.de/" ;
53+ final private static Logger LOG = Logger .getInstance ("Symfony-Plugin" );
54+ private static final ExtensionPointName <ServiceContainerLoader > SERVICE_CONTAINER_POINT_NAME = new ExtensionPointName <>("fr.adrienbrault.idea.symfony2plugin.extension.ServiceContainerLoader" );
55+ public static final ExtensionPointName <PluginConfigurationExtension > PLUGIN_CONFIGURATION_EXTENSION = new ExtensionPointName <>("fr.adrienbrault.idea.symfony2plugin.extension.PluginConfigurationExtension" );
56+
6257 public static Logger getLogger () {
6358 return LOG ;
6459 }
6560
66- public void showInfoNotification (String content ) {
67- Notification errorNotification = new Notification ("Symfony Plugin" , "Symfony Plugin" , content , NotificationType .INFORMATION );
68- Notifications .Bus .notify (errorNotification , this .project );
69- }
70-
71- private boolean isEnabled () {
72- return Settings .getInstance (project ).pluginEnabled ;
73- }
74-
75- public Collection <File > getContainerFiles () {
61+ public static Collection <File > getContainerFiles (@ NotNull Project project ) {
7662 Collection <ContainerFile > containerFiles = new ArrayList <>();
7763
7864 ServiceContainerLoaderParameter containerLoaderExtensionParameter = new ServiceContainerLoaderParameter (project , containerFiles );
@@ -88,25 +74,25 @@ public Collection<File> getContainerFiles() {
8874
8975 Collection <File > validFiles = new ArrayList <>();
9076 for (ContainerFile containerFile : containerFiles ) {
91- if (containerFile .exists (this . project )) {
92- validFiles .add (containerFile .getFile (this . project ));
77+ if (containerFile .exists (project )) {
78+ validFiles .add (containerFile .getFile (project ));
9379 }
9480 }
9581
9682 return validFiles ;
9783 }
9884
99- private void checkProject () {
100- if (!this . isEnabled ()
85+ private static void checkProject (@ NotNull Project project ) {
86+ if (!isEnabled (project )
10187 && !Settings .getInstance (project ).dismissEnableNotification
102- && VfsUtil .findRelativeFile (ProjectUtil .getProjectDir (this . project ), "vendor" , "symfony" ) != null
88+ && VfsUtil .findRelativeFile (ProjectUtil .getProjectDir (project ), "vendor" , "symfony" ) != null
10389 ) {
10490
10591 IdeHelper .notifyEnableMessage (project );
10692 return ;
10793 }
10894
109- if (this . getContainerFiles ().size () == 0 ) {
95+ if (getContainerFiles (project ).size () == 0 ) {
11096 Symfony2ProjectComponent .getLogger ().warn ("missing at least one container file" );
11197 }
11298 }
0 commit comments