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);
}
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);
}
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);
}
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);
}
}
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);
}
}
Aggregations