From f1a1706698699fb310f6ee2dadc1b5ac0a9fd85b Mon Sep 17 00:00:00 2001 From: Alexey Kudravtsev Date: Wed, 25 Dec 2013 14:06:19 +0400 Subject: [PATCH] already disposed --- .../MvcProjectWithoutLibraryNotificator.java | 70 +++++++++++-------- 1 file changed, 41 insertions(+), 29 deletions(-) diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/mvc/MvcProjectWithoutLibraryNotificator.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/mvc/MvcProjectWithoutLibraryNotificator.java index 744518893a90..bcef2c84c5aa 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/mvc/MvcProjectWithoutLibraryNotificator.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/mvc/MvcProjectWithoutLibraryNotificator.java @@ -1,9 +1,23 @@ +/* + * Copyright 2000-2013 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.jetbrains.plugins.groovy.mvc; import com.intellij.notification.Notification; import com.intellij.notification.NotificationListener; import com.intellij.notification.NotificationType; -import com.intellij.openapi.application.AccessToken; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.module.Module; import com.intellij.openapi.module.ModuleManager; @@ -24,44 +38,42 @@ import javax.swing.event.HyperlinkEvent; * @author Sergey Evdokimov */ public class MvcProjectWithoutLibraryNotificator implements StartupActivity, DumbAware { - @Override public void runActivity(@NotNull final Project project) { ApplicationManager.getApplication().executeOnPooledThread(new Runnable() { @Override public void run() { - AccessToken accessToken = ApplicationManager.getApplication().acquireReadActionLock(); + ApplicationManager.getApplication().runReadAction(new Runnable() { + @Override + public void run() { + if (project.isDisposed() || JavaPsiFacade.getInstance(project).findClass(CommonClassNames.JAVA_LANG_OBJECT, GlobalSearchScope.allScope(project)) == null) { + return; // If indexes is corrupted JavaPsiFacade.findClass() can't find classes during StartupActivity (may be it's a bug). + // So we can't determine whether exists Grails library or not. + } - try { - if (JavaPsiFacade.getInstance(project).findClass(CommonClassNames.JAVA_LANG_OBJECT, GlobalSearchScope.allScope(project)) == null) { - return; // If indexes is corrupted JavaPsiFacade.findClass() can't find classes during StartupActivity (may be it's a bug). - // So we can't determine whether exists Grails library or not. - } + Pair pair = findModuleWithoutLibrary(project); - Pair pair = findModuleWithoutLibrary(project); + if (pair != null) { + final MvcFramework framework = pair.second; + final Module module = pair.first; - if (pair != null) { - final MvcFramework framework = pair.second; - final Module module = pair.first; - - new Notification(framework.getFrameworkName() + ".Configure", - framework.getFrameworkName() + " SDK not found.", - "Module '" + - module.getName() + - "' has no " + - framework.getFrameworkName() + - " SDK. Configure SDK", NotificationType.INFORMATION, - new NotificationListener.Adapter() { - @Override - protected void hyperlinkActivated(@NotNull Notification notification, @NotNull HyperlinkEvent e) { - MvcConfigureNotification.configure(framework, module); + new Notification(framework.getFrameworkName() + ".Configure", + framework.getFrameworkName() + " SDK not found.", + "Module '" + + module.getName() + + "' has no " + + framework.getFrameworkName() + + " SDK. Configure SDK", NotificationType.INFORMATION, + new NotificationListener.Adapter() { + @Override + protected void hyperlinkActivated(@NotNull Notification notification, @NotNull HyperlinkEvent e) { + MvcConfigureNotification.configure(framework, module); + } } - }).notify(project); + ).notify(project); + } } - } - finally { - accessToken.finish(); - } + }); } }); }