[grails] delegate hasFrameworkStructure() to MvcFramework

This commit is contained in:
Daniil Ovchinnikov
2015-09-25 15:07:15 +03:00
parent ac3ee3b425
commit d22cd9120d
3 changed files with 11 additions and 14 deletions
@@ -17,7 +17,6 @@ package org.jetbrains.plugins.groovy.mvc;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.roots.ui.configuration.libraries.AddCustomLibraryDialog;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.ui.EditorNotificationPanel;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.plugins.groovy.annotator.GroovyFrameworkConfigNotification;
@@ -36,10 +35,7 @@ public class MvcConfigureNotification extends GroovyFrameworkConfigNotification
@Override
public boolean hasFrameworkStructure(@NotNull Module module) {
VirtualFile appDir = framework.findAppDirectory(module);
if (appDir == null) return false;
return appDir.findChild("controllers") != null && appDir.findChild("conf") != null;
return framework.hasFrameworkStructure(module);
}
@Override
@@ -59,7 +55,7 @@ public class MvcConfigureNotification extends GroovyFrameworkConfigNotification
@Override
public EditorNotificationPanel createConfigureNotificationPanel(@NotNull final Module module) {
final EditorNotificationPanel panel = new EditorNotificationPanel();
panel.setText(framework.getFrameworkName() + " SDK is not configured for module '"+ module.getName() + '\'');
panel.setText(framework.getFrameworkName() + " SDK is not configured for module '" + module.getName() + '\'');
panel.createActionLabel("Configure " + framework.getFrameworkName() + " SDK", new Runnable() {
@Override
public void run() {
@@ -69,5 +65,4 @@ public class MvcConfigureNotification extends GroovyFrameworkConfigNotification
return panel;
}
}
@@ -90,6 +90,13 @@ public abstract class MvcFramework {
return new GroovyLibraryDescription(getSdkHomePropertyName(), getLibraryKind(), getDisplayName());
}
public boolean hasFrameworkStructure(@NotNull Module module) {
VirtualFile appDir = findAppDirectory(module);
if (appDir == null) return false;
return appDir.findChild("controllers") != null && appDir.findChild("conf") != null;
}
public boolean hasFrameworkJar(@NotNull Module module) {
GlobalSearchScope scope = GlobalSearchScope.moduleWithDependenciesAndLibrariesScope(module, false);
return JavaPsiFacade.getInstance(module.getProject()).findClass(getSomeFrameworkClass(), scope) != null;
@@ -641,5 +648,4 @@ public abstract class MvcFramework {
}
return null;
}
}
@@ -27,7 +27,6 @@ import com.intellij.openapi.project.DumbAware;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.startup.StartupActivity;
import com.intellij.openapi.util.Pair;
import com.intellij.openapi.vfs.VirtualFile;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -82,11 +81,8 @@ public class MvcProjectWithoutLibraryNotificator implements StartupActivity, Dum
for (Module module : ModuleManager.getInstance(project).getModules()) {
for (MvcFramework framework : frameworks) {
VirtualFile appRoot = framework.findAppRoot(module);
if (appRoot != null && appRoot.findChild("application.properties") != null) {
if (!framework.hasFrameworkJar(module)) {
return Pair.create(module, framework);
}
if (framework.hasFrameworkStructure(module) && !framework.hasFrameworkJar(module)) {
return Pair.create(module, framework);
}
}
}