Search in sources :

Example 1 with MvcFramework

use of org.jetbrains.plugins.groovy.mvc.MvcFramework in project intellij-community by JetBrains.

the class GriffonDefaultImportContributor method appendImplicitlyImportedPackages.

@NotNull
@Override
public List<String> appendImplicitlyImportedPackages(@NotNull GroovyFile file) {
    Module module = ModuleUtilCore.findModuleForPsiElement(file);
    MvcFramework framework = MvcFramework.getInstance(module);
    if (framework instanceof GriffonFramework) {
        ArrayList<String> result = new ArrayList<>();
        result.add("griffon.core");
        result.add("griffon.util");
        VirtualFile griffonApp = framework.findAppDirectory(file);
        if (griffonApp != null) {
            VirtualFile models = griffonApp.findChild("models");
            VirtualFile views = griffonApp.findChild("views");
            VirtualFile vFile = file.getOriginalFile().getVirtualFile();
            assert vFile != null;
            assert module != null;
            if (models != null && VfsUtilCore.isAncestor(models, vFile, true)) {
                result.addAll(getDefaultImports(module).first);
            } else if (views != null && VfsUtilCore.isAncestor(views, vFile, true)) {
                result.addAll(getDefaultImports(module).second);
            }
        }
        return result;
    }
    return Collections.emptyList();
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) ArrayList(java.util.ArrayList) MvcFramework(org.jetbrains.plugins.groovy.mvc.MvcFramework) Module(com.intellij.openapi.module.Module) NotNull(org.jetbrains.annotations.NotNull)

Example 2 with MvcFramework

use of org.jetbrains.plugins.groovy.mvc.MvcFramework in project intellij-community by JetBrains.

the class MvcProjectViewSelectInTarget method selectIn.

@Override
public void selectIn(SelectInContext context, final boolean requestFocus) {
    final Project project = context.getProject();
    final VirtualFile file = context.getVirtualFile();
    final MvcFramework framework = MvcFramework.getInstance(ModuleUtilCore.findModuleForFile(file, project));
    if (framework == null) {
        return;
    }
    final Runnable select = () -> {
        final MvcProjectViewPane view = MvcProjectViewPane.getView(project, framework);
        if (view != null) {
            view.selectFile(file, requestFocus);
        }
    };
    if (requestFocus) {
        ToolWindowManager.getInstance(project).getToolWindow(MvcToolWindowDescriptor.getToolWindowId(framework)).activate(select, false);
    } else {
        select.run();
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Project(com.intellij.openapi.project.Project) MvcFramework(org.jetbrains.plugins.groovy.mvc.MvcFramework)

Example 3 with MvcFramework

use of org.jetbrains.plugins.groovy.mvc.MvcFramework in project intellij-community by JetBrains.

the class MvcProjectViewSelectInTarget method canSelect.

@Override
public boolean canSelect(SelectInContext context) {
    final Project project = context.getProject();
    final VirtualFile file = context.getVirtualFile();
    final MvcFramework framework = MvcFramework.getInstance(ModuleUtilCore.findModuleForFile(file, project));
    if (framework == null) {
        return false;
    }
    return MvcProjectViewPane.canSelectFile(project, framework, file);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Project(com.intellij.openapi.project.Project) MvcFramework(org.jetbrains.plugins.groovy.mvc.MvcFramework)

Example 4 with MvcFramework

use of org.jetbrains.plugins.groovy.mvc.MvcFramework in project intellij-community by JetBrains.

the class MvcTargetDialogCompletionUtils method getAllTargetNamesInternal.

public static Set<String> getAllTargetNamesInternal(@NotNull Module module) {
    final Set<String> result = new HashSet<>();
    MvcFramework.addAvailableSystemScripts(result, module);
    MvcFramework framework = MvcFramework.getInstance(module);
    if (framework != null) {
        final VirtualFile root = framework.findAppRoot(module);
        if (root != null) {
            MvcFramework.addAvailableScripts(result, root);
        }
        for (VirtualFile pluginRoot : framework.getAllPluginRoots(module, false)) {
            MvcFramework.addAvailableScripts(result, pluginRoot);
        }
    }
    collectScriptsFromUserHome(result);
    return result;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) MvcFramework(org.jetbrains.plugins.groovy.mvc.MvcFramework)

Aggregations

VirtualFile (com.intellij.openapi.vfs.VirtualFile)4 MvcFramework (org.jetbrains.plugins.groovy.mvc.MvcFramework)4 Project (com.intellij.openapi.project.Project)2 Module (com.intellij.openapi.module.Module)1 ArrayList (java.util.ArrayList)1 NotNull (org.jetbrains.annotations.NotNull)1