Search in sources :

Example 1 with IdeView

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

the class CCChangeCourseInfo method update.

@Override
public void update(@NotNull AnActionEvent event) {
    final Project project = event.getProject();
    final Presentation presentation = event.getPresentation();
    if (project == null) {
        return;
    }
    presentation.setEnabledAndVisible(false);
    if (!CCUtils.isCourseCreator(project)) {
        return;
    }
    final IdeView view = event.getData(LangDataKeys.IDE_VIEW);
    if (view == null) {
        return;
    }
    final PsiDirectory[] directories = view.getDirectories();
    if (directories.length == 0) {
        return;
    }
    presentation.setEnabledAndVisible(true);
}
Also used : Project(com.intellij.openapi.project.Project) PsiDirectory(com.intellij.psi.PsiDirectory) Presentation(com.intellij.openapi.actionSystem.Presentation) IdeView(com.intellij.ide.IdeView)

Example 2 with IdeView

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

the class CCCreateStudyItemActionBase method update.

@Override
public void update(@NotNull AnActionEvent event) {
    final Presentation presentation = event.getPresentation();
    presentation.setEnabledAndVisible(false);
    final Project project = event.getData(CommonDataKeys.PROJECT);
    final IdeView view = event.getData(LangDataKeys.IDE_VIEW);
    if (project == null || view == null) {
        return;
    }
    if (!StudyUtils.isStudyProject(project) || !CCUtils.isCourseCreator(project)) {
        return;
    }
    final PsiDirectory[] directories = view.getDirectories();
    if (directories.length == 0) {
        return;
    }
    final PsiDirectory sourceDirectory = DirectoryChooserUtil.getOrChooseDirectory(view);
    final Course course = StudyTaskManager.getInstance(project).getCourse();
    if (course == null || sourceDirectory == null) {
        return;
    }
    if (!isAddedAsLast(sourceDirectory, project, course) && getThresholdItem(course, sourceDirectory) == null) {
        return;
    }
    if (CommonDataKeys.PSI_FILE.getData(event.getDataContext()) != null) {
        return;
    }
    presentation.setEnabledAndVisible(true);
}
Also used : Project(com.intellij.openapi.project.Project) PsiDirectory(com.intellij.psi.PsiDirectory) Presentation(com.intellij.openapi.actionSystem.Presentation) IdeView(com.intellij.ide.IdeView) Course(com.jetbrains.edu.learning.courseFormat.Course)

Example 3 with IdeView

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

the class CCCreateStudyItemActionBase method actionPerformed.

@Override
public void actionPerformed(AnActionEvent e) {
    final IdeView view = e.getData(LangDataKeys.IDE_VIEW);
    final Project project = e.getProject();
    if (view == null || project == null) {
        return;
    }
    final PsiDirectory directory = DirectoryChooserUtil.getOrChooseDirectory(view);
    if (directory == null)
        return;
    final Course course = StudyTaskManager.getInstance(project).getCourse();
    if (course == null) {
        return;
    }
    createItem(view, project, directory, course);
}
Also used : Project(com.intellij.openapi.project.Project) PsiDirectory(com.intellij.psi.PsiDirectory) IdeView(com.intellij.ide.IdeView) Course(com.jetbrains.edu.learning.courseFormat.Course)

Example 4 with IdeView

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

the class MvcFramework method createApplicationIfNeeded.

public void createApplicationIfNeeded(@NotNull final Module module) {
    if (findAppRoot(module) == null && module.getUserData(CREATE_APP_STRUCTURE) == Boolean.TRUE) {
        while (ModuleRootManager.getInstance(module).getSdk() == null) {
            if (Messages.showYesNoDialog(module.getProject(), "Cannot generate " + getDisplayName() + " project structure because JDK is not specified for module \"" + module.getName() + "\".\n" + getDisplayName() + " project will not be created if you don't specify JDK.\nDo you want to specify JDK?", "Error", Messages.getErrorIcon()) == Messages.NO) {
                return;
            }
            ProjectSettingsService.getInstance(module.getProject()).showModuleConfigurationDialog(module.getName(), ClasspathEditor.NAME);
        }
        module.putUserData(CREATE_APP_STRUCTURE, null);
        final GeneralCommandLine commandLine = getCreationCommandLine(module);
        if (commandLine == null)
            return;
        MvcConsole.executeProcess(module, commandLine, () -> {
            VirtualFile root = findAppRoot(module);
            if (root == null)
                return;
            PsiDirectory psiDir = PsiManager.getInstance(module.getProject()).findDirectory(root);
            IdeView ide = LangDataKeys.IDE_VIEW.getData(DataManager.getInstance().getDataContext());
            if (ide != null)
                ide.selectElement(psiDir);
        //also here comes fileCreated(application.properties) which manages roots and run configuration
        }, true);
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) IdeView(com.intellij.ide.IdeView)

Example 5 with IdeView

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

the class AbstractCreateFormAction method update.

public void update(final AnActionEvent e) {
    super.update(e);
    final Project project = e.getData(CommonDataKeys.PROJECT);
    final Presentation presentation = e.getPresentation();
    if (presentation.isEnabled()) {
        final IdeView view = e.getData(LangDataKeys.IDE_VIEW);
        if (view != null) {
            final ProjectFileIndex projectFileIndex = ProjectRootManager.getInstance(project).getFileIndex();
            final PsiDirectory[] dirs = view.getDirectories();
            for (final PsiDirectory dir : dirs) {
                if (projectFileIndex.isUnderSourceRootOfType(dir.getVirtualFile(), JavaModuleSourceRootTypes.SOURCES) && JavaDirectoryService.getInstance().getPackage(dir) != null) {
                    return;
                }
            }
        }
        presentation.setEnabled(false);
        presentation.setVisible(false);
    }
}
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)

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