mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-06 03:21:12 +07:00
MvcProjectWithoutLibraryNotificator should be DumbAware and work under read action.
This commit is contained in:
@@ -3,8 +3,11 @@ 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;
|
||||
import com.intellij.openapi.project.DumbAware;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.startup.StartupActivity;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
@@ -20,35 +23,42 @@ import javax.swing.event.HyperlinkEvent;
|
||||
/**
|
||||
* @author Sergey Evdokimov
|
||||
*/
|
||||
public class MvcProjectWithoutLibraryNotificator implements StartupActivity {
|
||||
public class MvcProjectWithoutLibraryNotificator implements StartupActivity, DumbAware {
|
||||
|
||||
@Override
|
||||
public void runActivity(final Project project) {
|
||||
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 determinate whether exists Grails library or not.
|
||||
AccessToken accessToken = ApplicationManager.getApplication().acquireReadActionLock();
|
||||
|
||||
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<Module, MvcFramework> pair = findModuleWithoutLibrary(project);
|
||||
|
||||
if (pair != null) {
|
||||
final MvcFramework framework = pair.second;
|
||||
final Module module = pair.first;
|
||||
|
||||
new Notification(framework.getFrameworkName() + ".Configure",
|
||||
framework.getFrameworkName() + " SDK not found.",
|
||||
"<html><body>Module '" +
|
||||
module.getName() +
|
||||
"' has no " +
|
||||
framework.getFrameworkName() +
|
||||
" SDK. <a href='create'>Configure SDK</a></body></html>", NotificationType.INFORMATION,
|
||||
new NotificationListener() {
|
||||
@Override
|
||||
public void hyperlinkUpdate(@NotNull Notification notification,
|
||||
@NotNull HyperlinkEvent event) {
|
||||
MvcConfigureNotification.configure(framework, module);
|
||||
}
|
||||
}).notify(project);
|
||||
}
|
||||
}
|
||||
|
||||
Pair<Module, MvcFramework> pair = findModuleWithoutLibrary(project);
|
||||
|
||||
if (pair != null) {
|
||||
final MvcFramework framework = pair.second;
|
||||
final Module module = pair.first;
|
||||
|
||||
new Notification(framework.getFrameworkName() + ".Configure",
|
||||
framework.getFrameworkName() + " SDK not found.",
|
||||
"<html><body>Module '" +
|
||||
module.getName() +
|
||||
"' has no " +
|
||||
framework.getFrameworkName() +
|
||||
" SDK. <a href='create'>Configure SDK</a></body></html>", NotificationType.INFORMATION,
|
||||
new NotificationListener() {
|
||||
@Override
|
||||
public void hyperlinkUpdate(@NotNull Notification notification,
|
||||
@NotNull HyperlinkEvent event) {
|
||||
MvcConfigureNotification.configure(framework, module);
|
||||
}
|
||||
}).notify(project);
|
||||
finally {
|
||||
accessToken.finish();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user