Search in sources :

Example 36 with IdeView

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

the class CreateFromTemplateGroup method canCreateFromTemplate.

static boolean canCreateFromTemplate(AnActionEvent e, FileTemplate template) {
    if (e == null)
        return false;
    DataContext dataContext = e.getDataContext();
    IdeView view = LangDataKeys.IDE_VIEW.getData(dataContext);
    if (view == null)
        return false;
    PsiDirectory[] dirs = view.getDirectories();
    if (dirs.length == 0)
        return false;
    return FileTemplateUtil.canCreateFromTemplate(dirs, template);
}
Also used : PsiDirectory(com.intellij.psi.PsiDirectory) IdeView(com.intellij.ide.IdeView)

Example 37 with IdeView

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

the class CCLessonMoveHandlerDelegate method canMove.

@Override
public boolean canMove(DataContext dataContext) {
    if (CommonDataKeys.PSI_FILE.getData(dataContext) != null) {
        return false;
    }
    IdeView view = LangDataKeys.IDE_VIEW.getData(dataContext);
    if (view == null) {
        return false;
    }
    PsiDirectory sourceDirectory = DirectoryChooserUtil.getOrChooseDirectory(view);
    return CCUtils.isLessonDir(sourceDirectory);
}
Also used : PsiDirectory(com.intellij.psi.PsiDirectory) IdeView(com.intellij.ide.IdeView)

Example 38 with IdeView

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

the class NewGroovyClassAction method update.

@Override
public void update(AnActionEvent e) {
    super.update(e);
    Presentation presentation = e.getPresentation();
    if (!presentation.isVisible())
        return;
    IdeView view = LangDataKeys.IDE_VIEW.getData(e.getDataContext());
    if (view == null)
        return;
    Project project = e.getProject();
    if (project == null)
        return;
    ProjectFileIndex projectFileIndex = ProjectRootManager.getInstance(project).getFileIndex();
    for (PsiDirectory dir : view.getDirectories()) {
        if (projectFileIndex.isInSourceContent(dir.getVirtualFile()) && checkPackageExists(dir)) {
            for (GroovySourceFolderDetector detector : GroovySourceFolderDetector.EP_NAME.getExtensions()) {
                if (detector.isGroovySourceFolder(dir)) {
                    presentation.setWeight(Presentation.HIGHER_WEIGHT);
                    break;
                }
            }
            return;
        }
    }
}
Also used : Project(com.intellij.openapi.project.Project) ProjectFileIndex(com.intellij.openapi.roots.ProjectFileIndex) PsiDirectory(com.intellij.psi.PsiDirectory) Presentation(com.intellij.openapi.actionSystem.Presentation) IdeView(com.intellij.ide.IdeView)

Example 39 with IdeView

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

the class CreateSnapShotAction method update.

@Override
public void update(AnActionEvent e) {
    final Project project = e.getData(CommonDataKeys.PROJECT);
    final IdeView view = e.getData(LangDataKeys.IDE_VIEW);
    e.getPresentation().setVisible(project != null && view != null && hasDirectoryInPackage(project, view));
}
Also used : Project(com.intellij.openapi.project.Project) IdeView(com.intellij.ide.IdeView)

Example 40 with IdeView

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

the class CCGetCourseFromStepic method actionPerformed.

@Override
public void actionPerformed(@NotNull AnActionEvent e) {
    final IdeView view = e.getData(LangDataKeys.IDE_VIEW);
    final Project project = e.getData(CommonDataKeys.PROJECT);
    if (view == null || project == null) {
        return;
    }
    final String courseId = Messages.showInputDialog("Please, enter course id", "Get Course From Stepik", null);
    if (StringUtil.isNotEmpty(courseId)) {
        ProgressManager.getInstance().run(new com.intellij.openapi.progress.Task.Modal(project, "Creating Course", true) {

            @Override
            public void run(@NotNull final ProgressIndicator indicator) {
                createCourse(project, courseId);
            }
        });
    }
}
Also used : Project(com.intellij.openapi.project.Project) Task(com.jetbrains.edu.learning.courseFormat.Task) ProgressIndicator(com.intellij.openapi.progress.ProgressIndicator) 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