本文整理汇总了Java中com.intellij.ide.IdeView类的典型用法代码示例。如果您正苦于以下问题:Java IdeView类的具体用法?Java IdeView怎么用?Java IdeView使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IdeView类属于com.intellij.ide包,在下文中一共展示了IdeView类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: invokeDialog
import com.intellij.ide.IdeView; //导入依赖的package包/类
@NotNull
@Override
protected void invokeDialog(AnActionEvent e,Project project, PsiDirectory dir) {
BaseDialog dialog = new BaseDialog("请输入基类前缀:",project);
dialog.show();
if (dialog.getExitCode() == DialogWrapper.OK_EXIT_CODE) {
String prefix = dialog.getClassNamePrefix();
if(prefix != null && !prefix.isEmpty()){
Application application = ApplicationManager.getApplication();
application.runWriteAction(() -> {
PsiElement createdElement = createProjectDir(dir,prefix);
final IdeView view = e.getData(LangDataKeys.IDE_VIEW);
if(view != null&&createdElement != null){
view.selectElement(createdElement);
}
});
}
}
}
示例2: getExtensionDirectory
import com.intellij.ide.IdeView; //导入依赖的package包/类
public static PsiDirectory getExtensionDirectory(@NotNull AnActionEvent event) {
Project project = event.getData(PlatformDataKeys.PROJECT);
if (project == null) {
return null;
}
DataContext dataContext = event.getDataContext();
IdeView view = LangDataKeys.IDE_VIEW.getData(dataContext);
if (view == null) {
return null;
}
PsiDirectory[] directories = view.getDirectories();
if (directories.length == 0) {
return null;
}
return FilesystemUtil.findParentExtensionDirectory(directories[0]);
}
示例3: isAvailable
import com.intellij.ide.IdeView; //导入依赖的package包/类
@CheckReturnValue
@VisibleForTesting
@SuppressWarnings("WeakerAccess")
static boolean isAvailable(@Nonnull AnActionEvent event) {
final Project project = event.getProject();
if (project == null) {
return false;
}
final IdeView view = event.getData(LangDataKeys.IDE_VIEW);
if (view == null) {
return false;
}
final ProjectRootManager rootManager = ProjectRootManager.getInstance(project);
final ProjectFileIndex fileIndex = rootManager.getFileIndex();
final Optional<PsiDirectory> sourceDirectory = Stream.of(view.getDirectories())
.filter(directory -> {
final VirtualFile virtualFile = directory.getVirtualFile();
return fileIndex.isUnderSourceRootOfType(virtualFile, JavaModuleSourceRootTypes.SOURCES);
})
.findFirst();
return sourceDirectory.isPresent();
}
示例4: createTaskContent
import com.intellij.ide.IdeView; //导入依赖的package包/类
@Override
public PsiDirectory createTaskContent(@NotNull Project project,
@NotNull Task task,
@Nullable IdeView view,
@NotNull PsiDirectory parentDirectory,
@NotNull Course course) {
final Ref<PsiDirectory> taskDirectory = new Ref<>();
ApplicationManager.getApplication().runWriteAction(() -> {
String taskDirName = EduNames.TASK + task.getIndex();
taskDirectory.set(DirectoryUtil.createSubdirectories(taskDirName, parentDirectory, "\\/"));
if (taskDirectory.isNull()) return;
if (course.isAdaptive() && !task.getTaskFiles().isEmpty()) {
createTaskFilesFromText(task, taskDirectory.get());
}
else {
createFilesFromTemplates(project, view, taskDirectory.get());
}
});
return taskDirectory.get();
}
示例5: createFromTemplate
import com.intellij.ide.IdeView; //导入依赖的package包/类
public static void createFromTemplate(@NotNull Project project,
@NotNull PsiDirectory taskDirectory,
@NotNull String name,
@Nullable IdeView view,
boolean open) {
FileTemplate template = FileTemplateManager.getInstance(project).getInternalTemplate(name);
if (template == null) {
LOG.info("Template " + name + " wasn't found");
return;
}
try {
final PsiElement file = FileTemplateUtil.createFromTemplate(template, name, null, taskDirectory);
if (view != null && open) {
EditorHelper.openInEditor(file, false);
view.selectElement(file);
}
}
catch (Exception e) {
LOG.error(e);
}
}
示例6: createLessonContent
import com.intellij.ide.IdeView; //导入依赖的package包/类
@Override
public PsiDirectory createLessonContent(@NotNull Project project, @NotNull Lesson lesson, @Nullable IdeView view, @NotNull PsiDirectory parentDirectory) {
NewModuleAction newModuleAction = new NewModuleAction();
String courseDirPath = parentDirectory.getVirtualFile().getPath();
Module utilModule = ModuleManager.getInstance(project).findModuleByName(EduIntelliJNames.UTIL);
if (utilModule == null) {
return null;
}
newModuleAction.createModuleFromWizard(project, null, new AbstractProjectWizard("", project, "") {
@Override
public StepSequence getSequence() {
return null;
}
@Override
public ProjectBuilder getProjectBuilder() {
return new EduLessonModuleBuilder(courseDirPath, lesson, utilModule);
}
});
return parentDirectory.findSubdirectory(EduNames.LESSON + lesson.getIndex());
}
示例7: createLessonContent
import com.intellij.ide.IdeView; //导入依赖的package包/类
/**
* Creates content (including its directory or module) of new lesson in project
*
* @param project Parameter is used in Java and Kotlin plugins
* @param lesson Lesson to create content for. It's already properly initialized and added to course.
* @return PsiDirectory of created lesson
*/
default PsiDirectory createLessonContent(@NotNull Project project,
@NotNull Lesson lesson,
@Nullable IdeView view,
@NotNull PsiDirectory parentDirectory) {
final PsiDirectory[] lessonDirectory = new PsiDirectory[1];
ApplicationManager.getApplication().runWriteAction(() -> {
String lessonDirName = EduNames.LESSON + lesson.getIndex();
lessonDirectory[0] = DirectoryUtil.createSubdirectories(lessonDirName, parentDirectory, "\\/");
});
if (lessonDirectory[0] != null) {
if (view != null) {
view.selectElement(lessonDirectory[0]);
}
}
return lessonDirectory[0];
}
示例8: actionPerformed
import com.intellij.ide.IdeView; //导入依赖的package包/类
@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 Task.Modal(project, "Creating Course", true) {
@Override
public void run(@NotNull final ProgressIndicator indicator) {
createCourse(project, courseId);
}
});
}
}
示例9: actionPerformed
import com.intellij.ide.IdeView; //导入依赖的package包/类
@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[] directories = view.getDirectories();
if (directories.length == 0 || directories.length > 1) {
return;
}
final PsiDirectory directory = directories[0];
if (directory == null) return;
final Course course = StudyTaskManager.getInstance(project).getCourse();
if (course == null) {
return;
}
createItem(view, project, directory, course);
}
示例10: createItem
import com.intellij.ide.IdeView; //导入依赖的package包/类
@Nullable
public PsiDirectory createItem(@Nullable final IdeView view, @NotNull final Project project,
@NotNull final PsiDirectory sourceDirectory, @NotNull final Course course) {
StudyItem parentItem = getParentItem(course, sourceDirectory);
final StudyItem item = getItem(sourceDirectory, project, course, view, parentItem);
if (item == null) {
return null;
}
final PsiDirectory parentDir = getParentDir(project, course, sourceDirectory);
if (parentDir == null) {
return null;
}
CCUtils.updateHigherElements(parentDir.getVirtualFile().getChildren(), getStudyOrderable(item),
item.getIndex() - 1, getItemName(), 1);
addItem(course, item);
sortSiblings(course, parentItem);
return createItemDir(project, item, view, parentDir, course);
}
示例11: update
import com.intellij.ide.IdeView; //导入依赖的package包/类
@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);
}
示例12: canMove
import com.intellij.ide.IdeView; //导入依赖的package包/类
@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;
}
final PsiDirectory[] directories = view.getDirectories();
if (directories.length == 0 || directories.length > 1) {
return false;
}
final PsiDirectory sourceDirectory = directories[0];
return CCUtils.isLessonDir(sourceDirectory);
}
示例13: canMove
import com.intellij.ide.IdeView; //导入依赖的package包/类
@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;
}
final PsiDirectory[] directories = view.getDirectories();
if (directories.length == 0 || directories.length > 1) {
return false;
}
final PsiDirectory sourceDirectory = directories[0];
return isTaskDir(sourceDirectory);
}
示例14: isAvailable
import com.intellij.ide.IdeView; //导入依赖的package包/类
/**
* Checked whether or not this action can be enabled.
*
* <p>Requirements to be enabled: * User must be in a Java source folder.
*
* @param dataContext to figure out where the user is.
* @return {@code true} when the action is available, {@code false} when the action is not
* available.
*/
private boolean isAvailable(DataContext dataContext) {
final Project project = CommonDataKeys.PROJECT.getData(dataContext);
if (project == null) {
return false;
}
final IdeView view = LangDataKeys.IDE_VIEW.getData(dataContext);
if (view == null || view.getDirectories().length == 0) {
return false;
}
ProjectFileIndex projectFileIndex = ProjectRootManager.getInstance(project).getFileIndex();
for (PsiDirectory dir : view.getDirectories()) {
if (projectFileIndex.isUnderSourceRootOfType(
dir.getVirtualFile(), JavaModuleSourceRootTypes.SOURCES)
&& checkPackageExists(dir)) {
return true;
}
}
return false;
}
示例15: actionPerformed
import com.intellij.ide.IdeView; //导入依赖的package包/类
@Override
public void actionPerformed(AnActionEvent e) {
final DataContext dataContext = e.getDataContext();
final Project project = CommonDataKeys.PROJECT.getData(dataContext);
final Module module = LangDataKeys.MODULE.getData(dataContext);
final IdeView view = LangDataKeys.IDE_VIEW.getData(dataContext);
if (view == null) {
return;
}
CreateNewThemeDialog dialog = new CreateNewThemeDialog(project);
dialog.show();
if (dialog.getExitCode() == 0) {
themeData = dialog.getThemeData();
createTheme(project, module);
}
}