Search in sources :

Example 26 with IdeView

use of com.intellij.ide.IdeView in project android by JetBrains.

the class CreateTypedResourceFileAction method invokeDialog.

@NotNull
@Override
protected PsiElement[] invokeDialog(@NotNull Project project, @NotNull DataContext dataContext) {
    final IdeView view = LangDataKeys.IDE_VIEW.getData(dataContext);
    if (view != null) {
        // If you're in the Android View, we want to ask you not just the filename but also let you
        // create other resource folder configurations
        AbstractProjectViewPane pane = ProjectView.getInstance(project).getCurrentProjectViewPane();
        if (pane instanceof AndroidProjectViewPane) {
            return CreateResourceFileAction.getInstance().invokeDialog(project, dataContext);
        }
        final PsiDirectory directory = view.getOrChooseDirectory();
        if (directory != null) {
            InputValidator validator = createValidator(project, directory);
            Messages.showInputDialog(project, AndroidBundle.message("new.file.dialog.text"), AndroidBundle.message("new.typed.resource.dialog.title", myResourcePresentableName), Messages.getQuestionIcon(), "", validator);
        }
    }
    return PsiElement.EMPTY_ARRAY;
}
Also used : AndroidProjectViewPane(com.android.tools.idea.navigator.AndroidProjectViewPane) InputValidator(com.intellij.openapi.ui.InputValidator) PsiDirectory(com.intellij.psi.PsiDirectory) IdeView(com.intellij.ide.IdeView) AbstractProjectViewPane(com.intellij.ide.projectView.impl.AbstractProjectViewPane) NotNull(org.jetbrains.annotations.NotNull)

Example 27 with IdeView

use of com.intellij.ide.IdeView in project android by JetBrains.

the class CreateMultiRootResourceFileAction method invokeDialog.

@NotNull
@Override
protected PsiElement[] invokeDialog(@NotNull Project project, @NotNull DataContext dataContext) {
    final IdeView view = LangDataKeys.IDE_VIEW.getData(dataContext);
    if (view != null) {
        // If you're in the Android View, we want to ask you not just the filename but also let you
        // create other resource folder configurations
        AbstractProjectViewPane pane = ProjectView.getInstance(project).getCurrentProjectViewPane();
        if (pane instanceof AndroidProjectViewPane) {
            return CreateResourceFileAction.getInstance().invokeDialog(project, dataContext);
        }
        final PsiDirectory directory = view.getOrChooseDirectory();
        if (directory != null) {
            InputValidator validator = createValidator(project, directory);
            final AndroidFacet facet = AndroidFacet.getInstance(directory);
            if (facet != null) {
                final MyDialog dialog = new MyDialog(facet, validator);
                dialog.show();
                return PsiElement.EMPTY_ARRAY;
            }
        }
    }
    return PsiElement.EMPTY_ARRAY;
}
Also used : AndroidProjectViewPane(com.android.tools.idea.navigator.AndroidProjectViewPane) InputValidator(com.intellij.openapi.ui.InputValidator) PsiDirectory(com.intellij.psi.PsiDirectory) IdeView(com.intellij.ide.IdeView) AbstractProjectViewPane(com.intellij.ide.projectView.impl.AbstractProjectViewPane) AndroidFacet(org.jetbrains.android.facet.AndroidFacet) NotNull(org.jetbrains.annotations.NotNull)

Example 28 with IdeView

use of com.intellij.ide.IdeView in project intellij-plugins by JetBrains.

the class NewActionScriptClassAction method isAvailable.

private boolean isAvailable(DataContext dataContext) {
    final Project project = CommonDataKeys.PROJECT.getData(dataContext);
    final IdeView view = LangDataKeys.IDE_VIEW.getData(dataContext);
    if (project == null || project.isDisposed() || view == null)
        return false;
    ProjectFileIndex projectFileIndex = ProjectRootManager.getInstance(project).getFileIndex();
    for (PsiDirectory dir : view.getDirectories()) {
        if (projectFileIndex.isInSourceContent(dir.getVirtualFile()) && DirectoryIndex.getInstance(dir.getProject()).getPackageName(dir.getVirtualFile()) != null) {
            Module module = ModuleUtilCore.findModuleForPsiElement(dir);
            if (module != null && isAvailableIn(module)) {
                return true;
            }
        }
    }
    return false;
}
Also used : Project(com.intellij.openapi.project.Project) ProjectFileIndex(com.intellij.openapi.roots.ProjectFileIndex) PsiDirectory(com.intellij.psi.PsiDirectory) IdeView(com.intellij.ide.IdeView) Module(com.intellij.openapi.module.Module)

Example 29 with IdeView

use of com.intellij.ide.IdeView in project intellij-plugins by JetBrains.

the class NewActionScriptClassAction method actionPerformed.

public void actionPerformed(final AnActionEvent e) {
    final DataContext dataContext = e.getDataContext();
    final IdeView view = LangDataKeys.IDE_VIEW.getData(dataContext);
    if (view == null) {
        return;
    }
    final Project project = CommonDataKeys.PROJECT.getData(dataContext);
    final PsiDirectory dir = view.getOrChooseDirectory();
    if (dir == null || project == null)
        return;
    CommandProcessor.getInstance().executeCommand(project, () -> createAction(dir).execute(), getCommandName(), null);
}
Also used : Project(com.intellij.openapi.project.Project) PsiDirectory(com.intellij.psi.PsiDirectory) IdeView(com.intellij.ide.IdeView)

Example 30 with IdeView

use of com.intellij.ide.IdeView in project qi4j-sdk by Qi4j.

the class Qi4jCreateActionGroup method shouldActionGroupVisible.

private boolean shouldActionGroupVisible(AnActionEvent e) {
    Module module = e.getData(LangDataKeys.MODULE);
    if (module == null) {
        return false;
    }
    // TODO: Enable this once Qi4jFacet can be automatically added/removed
    //        if( Qi4jFacet.getInstance( module ) == null )
    //        {
    //            return false;
    //        }
    // Are we on IDE View and under project source folder?
    Project project = e.getData(PlatformDataKeys.PROJECT);
    IdeView view = e.getData(LangDataKeys.IDE_VIEW);
    if (view != null && project != null) {
        ProjectFileIndex projectFileIndex = ProjectRootManager.getInstance(project).getFileIndex();
        PsiDirectory[] dirs = view.getDirectories();
        for (PsiDirectory dir : dirs) {
            if (projectFileIndex.isInSourceContent(dir.getVirtualFile()) && JavaDirectoryService.getInstance().getPackage(dir) != null) {
                return true;
            }
        }
    }
    return false;
}
Also used : Project(com.intellij.openapi.project.Project) ProjectFileIndex(com.intellij.openapi.roots.ProjectFileIndex) PsiDirectory(com.intellij.psi.PsiDirectory) Module(com.intellij.openapi.module.Module) IdeView(com.intellij.ide.IdeView)

Aggregations

IdeView (com.intellij.ide.IdeView)47 Project (com.intellij.openapi.project.Project)35 PsiDirectory (com.intellij.psi.PsiDirectory)30 Module (com.intellij.openapi.module.Module)10 ProjectFileIndex (com.intellij.openapi.roots.ProjectFileIndex)10 Course (com.jetbrains.edu.learning.courseFormat.Course)7 AndroidFacet (org.jetbrains.android.facet.AndroidFacet)6 Presentation (com.intellij.openapi.actionSystem.Presentation)5 PsiElement (com.intellij.psi.PsiElement)5 Lesson (com.jetbrains.edu.learning.courseFormat.Lesson)5 ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)4 NotNull (org.jetbrains.annotations.NotNull)4 DataContext (com.intellij.openapi.actionSystem.DataContext)3 Task (com.intellij.openapi.progress.Task)3 VirtualFile (com.intellij.openapi.vfs.VirtualFile)3 JavaDirectoryService (com.intellij.psi.JavaDirectoryService)3 AndroidProjectViewPane (com.android.tools.idea.navigator.AndroidProjectViewPane)2 StudioWizardDialogBuilder (com.android.tools.idea.ui.wizard.StudioWizardDialogBuilder)2 ModelWizard (com.android.tools.idea.wizard.model.ModelWizard)2 AbstractProjectViewPane (com.intellij.ide.projectView.impl.AbstractProjectViewPane)2