本文整理汇总了Java中com.intellij.ide.util.DirectoryChooserUtil类的典型用法代码示例。如果您正苦于以下问题:Java DirectoryChooserUtil类的具体用法?Java DirectoryChooserUtil怎么用?Java DirectoryChooserUtil使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DirectoryChooserUtil类属于com.intellij.ide.util包,在下文中一共展示了DirectoryChooserUtil类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: chooseSourceRoot
import com.intellij.ide.util.DirectoryChooserUtil; //导入依赖的package包/类
public static VirtualFile chooseSourceRoot(final PackageWrapper targetPackage,
final List<VirtualFile> contentSourceRoots,
final PsiDirectory initialDirectory) {
Project project = targetPackage.getManager().getProject();
//ensure that there would be no duplicates: e.g. when one content root is subfolder of another root (configured via excluded roots)
LinkedHashSet<PsiDirectory> targetDirectories = new LinkedHashSet<PsiDirectory>();
Map<PsiDirectory, String> relativePathsToCreate = new HashMap<PsiDirectory,String>();
buildDirectoryList(targetPackage, contentSourceRoots, targetDirectories, relativePathsToCreate);
final PsiDirectory selectedDirectory = DirectoryChooserUtil.chooseDirectory(
targetDirectories.toArray(new PsiDirectory[targetDirectories.size()]),
initialDirectory,
project,
relativePathsToCreate
);
if (selectedDirectory == null) return null;
final VirtualFile virt = selectedDirectory.getVirtualFile();
final VirtualFile sourceRootForFile = ProjectRootManager.getInstance(project).getFileIndex().getSourceRootForFile(virt);
LOG.assertTrue(sourceRootForFile != null);
return sourceRootForFile;
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:MoveClassesOrPackagesUtil.java
示例2: getTargetClass
import com.intellij.ide.util.DirectoryChooserUtil; //导入依赖的package包/类
@Nullable
public PsiClass getTargetClass() {
if (myTargetClass != null) return myTargetClass;
final String packageName = StringUtil.getPackageName(myQualifiedName);
final String shortName = StringUtil.getShortName(myQualifiedName);
if (Comparing.strEqual(myParentClass.getQualifiedName(), packageName)) {
myTargetClass = (PsiClass)myParentClass.add(JavaPsiFacade.getElementFactory(myProject).createClass(shortName));
return myTargetClass;
}
PsiPackage psiPackage = JavaPsiFacade.getInstance(myProject).findPackage(packageName);
final PsiDirectory psiDirectory;
if (psiPackage != null) {
final PsiDirectory[] directories = psiPackage.getDirectories(GlobalSearchScope.allScope(myProject));
psiDirectory = directories.length > 1 ? DirectoryChooserUtil.chooseDirectory(directories, null, myProject, new HashMap<PsiDirectory, String>()) : directories[0];
} else {
psiDirectory = PackageUtil.findOrCreateDirectoryForPackage(myProject, packageName, myParentClass.getContainingFile().getContainingDirectory(), false);
}
myTargetClass = psiDirectory != null ? JavaDirectoryService.getInstance().createClass(psiDirectory, shortName) : null;
return myTargetClass;
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:BaseExpressionToFieldHandler.java
示例3: actionPerformed
import com.intellij.ide.util.DirectoryChooserUtil; //导入依赖的package包/类
@Override
public void actionPerformed(AnActionEvent e) {
IdeView view = e.getData(LangDataKeys.IDE_VIEW);
Project project = e.getData(CommonDataKeys.PROJECT);
if (view == null || project == null) {
return;
}
PsiDirectory directory = DirectoryChooserUtil.getOrChooseDirectory(view);
if (directory == null) return;
boolean isDirectory = !PsiDirectoryFactory.getInstance(project).isPackage(directory);
CreateDirectoryOrPackageHandler validator = new CreateDirectoryOrPackageHandler(project, directory, isDirectory,
isDirectory ? "\\/" : ".");
Messages.showInputDialog(project, isDirectory
? IdeBundle.message("prompt.enter.new.directory.name")
: IdeBundle.message("prompt.enter.new.package.name"),
isDirectory ? IdeBundle.message("title.new.directory") : IdeBundle.message("title.new.package"),
Messages.getQuestionIcon(), "", validator);
final PsiElement result = validator.getCreatedElement();
if (result != null) {
view.selectElement(result);
}
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:27,代码来源:CreateDirectoryOrPackageAction.java
示例4: resolveToDirectory
import com.intellij.ide.util.DirectoryChooserUtil; //导入依赖的package包/类
@Nullable
public static PsiDirectory resolveToDirectory(final Project project, final PsiElement element) {
if (!(element instanceof PsiDirectoryContainer)) {
return (PsiDirectory)element;
}
PsiDirectory[] directories = ((PsiDirectoryContainer)element).getDirectories();
switch (directories.length) {
case 0:
return null;
case 1:
return directories[0];
default:
return DirectoryChooserUtil.chooseDirectory(directories, directories[0], project, new HashMap<PsiDirectory, String>());
}
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:MoveFilesOrDirectoriesUtil.java
示例5: actionPerformed
import com.intellij.ide.util.DirectoryChooserUtil; //导入依赖的package包/类
@Override
public void actionPerformed(AnActionEvent e) {
final IdeView view = e.getData(LangDataKeys.IDE_VIEW);
final Project project = e.getData(CommonDataKeys.PROJECT);
if (view == null || project == null) {
return;
}
final PsiDirectory directory = DirectoryChooserUtil.getOrChooseDirectory(view);
if (directory == null) return;
final CCProjectService service = CCProjectService.getInstance(project);
final Course course = service.getCourse();
if (course == null) {
return;
}
createItem(view, project, directory, course);
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:CCCreateStudyItemActionBase.java
示例6: update
import com.intellij.ide.util.DirectoryChooserUtil; //导入依赖的package包/类
@Override
public void update(@NotNull AnActionEvent e) {
e.getPresentation().setEnabledAndVisible(false);
final IdeView view = e.getData(LangDataKeys.IDE_VIEW);
final Project project = e.getData(CommonDataKeys.PROJECT);
if (view == null || project == null) {
return;
}
final Course course = CCProjectService.getInstance(project).getCourse();
if (course == null) {
return;
}
PsiDirectory lessonDir = DirectoryChooserUtil.getOrChooseDirectory(view);
if (lessonDir == null || !lessonDir.getName().contains("lesson")) {
return;
}
final Lesson lesson = course.getLesson(lessonDir.getName());
if (lesson != null && lesson.id > 0) {
e.getPresentation().setEnabledAndVisible(true);
}
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:CCPushLesson.java
示例7: actionPerformed
import com.intellij.ide.util.DirectoryChooserUtil; //导入依赖的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 Course course = CCProjectService.getInstance(project).getCourse();
if (course == null) {
return;
}
PsiDirectory lessonDir = DirectoryChooserUtil.getOrChooseDirectory(view);
if (lessonDir == null || !lessonDir.getName().contains("lesson")) {
return;
}
final Lesson lesson = course.getLesson(lessonDir.getName());
if (lesson == null) {
return;
}
ProgressManager.getInstance().run(new Task.Modal(project, "Uploading Lesson", true) {
@Override
public void run(@NotNull ProgressIndicator indicator) {
indicator.setText("Uploading lesson to http://stepic.org");
EduStepicConnector.updateLesson(project, lesson, indicator);
}});
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:27,代码来源:CCPushLesson.java
示例8: obtainDirectoryRootForPackage
import com.intellij.ide.util.DirectoryChooserUtil; //导入依赖的package包/类
@Nullable
public static PsiDirectory obtainDirectoryRootForPackage(final Module module, final String packageName) {
final Project project = module.getProject();
GlobalSearchScope scope = GlobalSearchScope.moduleWithDependenciesAndLibrariesScope(module);
final PsiPackage aPackage = JavaPsiFacade.getInstance(project).findPackage(packageName);
if (aPackage != null) {
PsiDirectory[] directories = aPackage.getDirectories(scope);
if (directories.length == 1) return getSourceRootDirectory(directories[0]);
}
final VirtualFile[] sourceRoots = ModuleRootManager.getInstance(module).getSourceRoots();
List<PsiDirectory> directoryList = new ArrayList<PsiDirectory>();
for (VirtualFile sourceRoot : sourceRoots) {
final PsiDirectory directory = PsiManager.getInstance(project).findDirectory(sourceRoot);
directoryList.add(directory);
}
PsiDirectory[] sourceDirectories = directoryList.toArray(new PsiDirectory[directoryList.size()]);
return DirectoryChooserUtil.selectDirectory(project, sourceDirectories, null, File.separatorChar + packageName.replace('.', File.separatorChar));
}
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:21,代码来源:CreateClassUtil.java
示例9: chooseSourceRoot
import com.intellij.ide.util.DirectoryChooserUtil; //导入依赖的package包/类
public static VirtualFile chooseSourceRoot(final PackageWrapper targetPackage,
final VirtualFile[] contentSourceRoots,
final PsiDirectory initialDirectory) {
Project project = targetPackage.getManager().getProject();
//ensure that there would be no duplicates: e.g. when one content root is subfolder of another root (configured via excluded roots)
LinkedHashSet<PsiDirectory> targetDirectories = new LinkedHashSet<PsiDirectory>();
Map<PsiDirectory, String> relativePathsToCreate = new HashMap<PsiDirectory,String>();
buildDirectoryList(targetPackage, contentSourceRoots, targetDirectories, relativePathsToCreate);
final PsiDirectory selectedDirectory = DirectoryChooserUtil.chooseDirectory(
targetDirectories.toArray(new PsiDirectory[targetDirectories.size()]),
initialDirectory,
project,
relativePathsToCreate
);
if (selectedDirectory == null) return null;
final VirtualFile virt = selectedDirectory.getVirtualFile();
final VirtualFile sourceRootForFile = ProjectRootManager.getInstance(project).getFileIndex().getSourceRootForFile(virt);
LOG.assertTrue(sourceRootForFile != null);
return sourceRootForFile;
}
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:23,代码来源:MoveClassesOrPackagesUtil.java
示例10: actionPerformed
import com.intellij.ide.util.DirectoryChooserUtil; //导入依赖的package包/类
@Override
public void actionPerformed(AnActionEvent e) {
IdeView view = e.getData(LangDataKeys.IDE_VIEW);
Project project = e.getData(PlatformDataKeys.PROJECT);
if (view == null || project == null) {
return;
}
PsiDirectory directory = DirectoryChooserUtil.getOrChooseDirectory(view);
if (directory == null) return;
boolean isDirectory = !PsiDirectoryFactory.getInstance(project).isPackage(directory);
CreateDirectoryOrPackageHandler validator = new CreateDirectoryOrPackageHandler(project, directory, isDirectory,
isDirectory ? "\\/" : ".");
Messages.showInputDialog(project, isDirectory
? IdeBundle.message("prompt.enter.new.directory.name")
: IdeBundle.message("prompt.enter.new.package.name"),
isDirectory ? IdeBundle.message("title.new.directory") : IdeBundle.message("title.new.package"),
Messages.getQuestionIcon(), "", validator);
final PsiElement result = validator.getCreatedElement();
if (result != null) {
view.selectElement(result);
}
}
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:27,代码来源:CreateDirectoryOrPackageAction.java
示例11: resolveToDirectory
import com.intellij.ide.util.DirectoryChooserUtil; //导入依赖的package包/类
@Nullable
public static PsiDirectory resolveToDirectory(final Project project, final PsiElement element) {
if (!(element instanceof PsiDirectoryContainer)) {
return (PsiDirectory)element;
}
PsiDirectory[] directories = ((PsiDirectoryContainer)element).getDirectories();
switch (directories.length) {
case 0:
return null;
case 1:
return directories[0];
default:
return DirectoryChooserUtil.chooseDirectory(directories, directories[0], project, new HashMap<>());
}
}
开发者ID:consulo,项目名称:consulo,代码行数:18,代码来源:MoveFilesOrDirectoriesUtil.java
示例12: getTargetClass
import com.intellij.ide.util.DirectoryChooserUtil; //导入依赖的package包/类
@Nullable
public PsiClass getTargetClass() {
if (myTargetClass != null) return myTargetClass;
final String packageName = StringUtil.getPackageName(myQualifiedName);
final String shortName = StringUtil.getShortName(myQualifiedName);
if (Comparing.strEqual(myParentClass.getQualifiedName(), packageName)) {
myTargetClass = (PsiClass)myParentClass.add(JavaPsiFacade.getElementFactory(myProject).createClass(shortName));
return myTargetClass;
}
PsiJavaPackage psiPackage = JavaPsiFacade.getInstance(myProject).findPackage(packageName);
final PsiDirectory psiDirectory;
if (psiPackage != null) {
final PsiDirectory[] directories = psiPackage.getDirectories(GlobalSearchScope.allScope(myProject));
psiDirectory = directories.length > 1 ? DirectoryChooserUtil.chooseDirectory(directories, null, myProject, new HashMap<PsiDirectory, String>()) : directories[0];
} else {
psiDirectory = PackageUtil.findOrCreateDirectoryForPackage(myProject, packageName, myParentClass.getContainingFile().getContainingDirectory(), false);
}
myTargetClass = psiDirectory != null ? JavaDirectoryService.getInstance().createClass(psiDirectory, shortName) : null;
return myTargetClass;
}
开发者ID:consulo,项目名称:consulo-java,代码行数:21,代码来源:BaseExpressionToFieldHandler.java
示例13: actionPerformed
import com.intellij.ide.util.DirectoryChooserUtil; //导入依赖的package包/类
@Override
public void actionPerformed(@NotNull AnActionEvent e) {
final IdeView view = e.getData(LangDataKeys.IDE_VIEW);
if (view == null) {
return;
}
final Project project = e.getData(CommonDataKeys.PROJECT);
final PsiDirectory directory = DirectoryChooserUtil.getOrChooseDirectory(view);
if (directory == null)
return;
String name = Messages.showInputDialog(project, CatberryBundle.message("new.cat.store.prompt"),
CatberryBundle.message("new.cat.store"), CatberryIcons.LOGO_16, "Store", null);
if (name == null)
return;
name = StringUtil.toCamelCase(name, "-");
final String path = directory.getVirtualFile().getPath();
if (!createCatberryStore(path, name, e.getProject()))
return;
LocalFileSystem.getInstance().refreshWithoutFileWatcher(false);
PsiFile storeFile = directory.findFile(name + ".js");
if (storeFile == null)
return;
view.selectElement(storeFile);
}
开发者ID:catberry,项目名称:catberry-idea-plugin,代码行数:29,代码来源:CreateCatberryStoreAction.java
示例14: actionPerformed
import com.intellij.ide.util.DirectoryChooserUtil; //导入依赖的package包/类
@Override
public void actionPerformed(AnActionEvent e) {
final IdeView view = e.getData(LangDataKeys.IDE_VIEW);
if (view == null) {
return;
}
final Project project = e.getData(CommonDataKeys.PROJECT);
final PsiDirectory directory = DirectoryChooserUtil.getOrChooseDirectory(view);
if (directory == null) return;
CreateDirectoryOrPackageHandler validator = new CreateDirectoryOrPackageHandler(project, directory, false, ".") {
@Override
protected void createDirectories(String subDirName) {
super.createDirectories(subDirName);
PsiFileSystemItem element = getCreatedElement();
if (element instanceof PsiDirectory) {
createInitPyInHierarchy((PsiDirectory)element, directory);
}
}
};
Messages.showInputDialog(project, IdeBundle.message("prompt.enter.new.package.name"),
IdeBundle.message("title.new.package"),
Messages.getQuestionIcon(), "", validator);
final PsiFileSystemItem result = validator.getCreatedElement();
if (result != null) {
view.selectElement(result);
}
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:29,代码来源:CreatePackageAction.java
示例15: update
import com.intellij.ide.util.DirectoryChooserUtil; //导入依赖的package包/类
@Override
public void update(@NotNull AnActionEvent event) {
if (!CCProjectService.setCCActionAvailable(event)) {
return;
}
final Presentation presentation = event.getPresentation();
final Project project = event.getData(CommonDataKeys.PROJECT);
if (project == null) {
presentation.setVisible(false);
presentation.setEnabled(false);
return;
}
final IdeView view = event.getData(LangDataKeys.IDE_VIEW);
if (view == null) {
presentation.setVisible(false);
presentation.setEnabled(false);
return;
}
final PsiDirectory[] directories = view.getDirectories();
if (directories.length == 0) {
presentation.setVisible(false);
presentation.setEnabled(false);
return;
}
final PsiDirectory directory = DirectoryChooserUtil.getOrChooseDirectory(view);
final CCProjectService service = CCProjectService.getInstance(project);
final Course course = service.getCourse();
if (course != null && directory != null && !directory.getName().contains(EduNames.TASK)) {
presentation.setVisible(false);
presentation.setEnabled(false);
return;
}
presentation.setVisible(true);
presentation.setEnabled(true);
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:38,代码来源:CCCreateTaskFile.java
示例16: update
import com.intellij.ide.util.DirectoryChooserUtil; //导入依赖的package包/类
@Override
public void update(@NotNull AnActionEvent event) {
if (!CCProjectService.setCCActionAvailable(event)) {
return;
}
final Presentation presentation = event.getPresentation();
final Project project = event.getData(CommonDataKeys.PROJECT);
final IdeView view = event.getData(LangDataKeys.IDE_VIEW);
if (project == null || view == null) {
presentation.setEnabledAndVisible(false);
return;
}
final PsiDirectory[] directories = view.getDirectories();
if (directories.length == 0) {
presentation.setEnabledAndVisible(false);
return;
}
final PsiDirectory sourceDirectory = DirectoryChooserUtil.getOrChooseDirectory(view);
final CCProjectService service = CCProjectService.getInstance(project);
final Course course = service.getCourse();
if (course == null || sourceDirectory == null) {
presentation.setEnabledAndVisible(false);
return;
}
if (!isAddedAsLast(sourceDirectory, project, course) &&
getThresholdItem(course, sourceDirectory) == null) {
presentation.setEnabledAndVisible(false);
}
if (CommonDataKeys.PSI_FILE.getData(event.getDataContext()) != null) {
presentation.setEnabledAndVisible(false);
}
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:33,代码来源:CCCreateStudyItemActionBase.java
示例17: update
import com.intellij.ide.util.DirectoryChooserUtil; //导入依赖的package包/类
@Override
public void update(@NotNull AnActionEvent event) {
if (!CCProjectService.setCCActionAvailable(event)) {
return;
}
final Presentation presentation = event.getPresentation();
presentation.setVisible(false);
presentation.setEnabled(false);
final Project project = event.getData(CommonDataKeys.PROJECT);
if (project == null) {
return;
}
final IdeView view = event.getData(LangDataKeys.IDE_VIEW);
if (view == null) {
return;
}
final PsiDirectory[] directories = view.getDirectories();
if (directories.length == 0) {
return;
}
final PsiDirectory directory = DirectoryChooserUtil.getOrChooseDirectory(view);
if (directory != null && !project.getBaseDir().equals(directory.getVirtualFile())) {
return;
}
presentation.setVisible(true);
presentation.setEnabled(true);
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:29,代码来源:CCChangeCourseInfo.java
示例18: actionPerformed
import com.intellij.ide.util.DirectoryChooserUtil; //导入依赖的package包/类
@Override
public void actionPerformed(@NotNull AnActionEvent e) {
if (!CCProjectService.setCCActionAvailable(e)) {
return;
}
final Project project = e.getProject();
if (project == null) {
return;
}
Course course = CCProjectService.getInstance(project).getCourse();
if (course == null) {
return;
}
final IdeView view = e.getData(LangDataKeys.IDE_VIEW);
if (view == null) {
return;
}
final PsiDirectory[] directories = view.getDirectories();
if (directories.length == 0) {
return;
}
final PsiDirectory directory = DirectoryChooserUtil.getOrChooseDirectory(view);
if (directory != null && !project.getBaseDir().equals(directory.getVirtualFile())) {
return;
}
CCNewProjectPanel panel = new CCNewProjectPanel(course.getName(), Course.getAuthorsString(course.getAuthors()), course.getDescription());
ChangeCourseInfoDialog changeCourseInfoDialog =
new ChangeCourseInfoDialog(project, panel);
changeCourseInfoDialog.show();
if (changeCourseInfoDialog.getExitCode() == DialogWrapper.OK_EXIT_CODE) {
course.setAuthors(panel.getAuthors());
course.setName(panel.getName());
course.setDescription(panel.getDescription());
ProjectView.getInstance(project).refresh();
}
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:37,代码来源:CCChangeCourseInfo.java
示例19: canMove
import com.intellij.ide.util.DirectoryChooserUtil; //导入依赖的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;
}
PsiDirectory sourceDirectory = DirectoryChooserUtil.getOrChooseDirectory(view);
return CCUtils.isLessonDir(sourceDirectory);
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:13,代码来源:CCLessonMoveHandlerDelegate.java
示例20: canMove
import com.intellij.ide.util.DirectoryChooserUtil; //导入依赖的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;
}
PsiDirectory sourceDirectory = DirectoryChooserUtil.getOrChooseDirectory(view);
return isTaskDir(sourceDirectory);
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:13,代码来源:CCTaskMoveHandlerDelegate.java
注:本文中的com.intellij.ide.util.DirectoryChooserUtil类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论