本文整理汇总了Java中com.intellij.ide.IdeView.getOrChooseDirectory方法的典型用法代码示例。如果您正苦于以下问题:Java IdeView.getOrChooseDirectory方法的具体用法?Java IdeView.getOrChooseDirectory怎么用?Java IdeView.getOrChooseDirectory使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.ide.IdeView
的用法示例。
在下文中一共展示了IdeView.getOrChooseDirectory方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isAvailable
import com.intellij.ide.IdeView; //导入方法依赖的package包/类
@Override
protected boolean isAvailable(DataContext dataContext) {
IdeView view = (IdeView) LangDataKeys.IDE_VIEW.getData(dataContext);
if (view == null) {
return false;
}
PsiDirectory dir = view.getOrChooseDirectory();
if (dir == null) {
return false;
}
return this.classTypeMatchesDir(dir);
}
示例2: actionPerformed
import com.intellij.ide.IdeView; //导入方法依赖的package包/类
@Override
public final void actionPerformed(final AnActionEvent e) {
final IdeView view = e.getData(LangDataKeys.IDE_VIEW);
if (view == null) {
return;
}
final Project project = e.getProject();
final PsiDirectory dir = view.getOrChooseDirectory();
if (dir == null) return;
final PsiElement[] createdElements = invokeDialog(project, dir);
for (PsiElement createdElement : createdElements) {
view.selectElement(createdElement);
}
}
示例3: invokeDialog
import com.intellij.ide.IdeView; //导入方法依赖的package包/类
@NotNull
@Override
protected PsiElement[] invokeDialog(@NotNull Project project, @NotNull DataContext dataContext) {
final IdeView view = LangDataKeys.IDE_VIEW.getData(dataContext);
if (view != null) {
// If you're in the Android View, we want to ask you not just the filename but also let you
// create other resource folder configurations
AbstractProjectViewPane pane = ProjectView.getInstance(project).getCurrentProjectViewPane();
if (pane instanceof AndroidProjectViewPane) {
return CreateResourceFileAction.getInstance().invokeDialog(project, dataContext);
}
final PsiDirectory directory = view.getOrChooseDirectory();
if (directory != null) {
InputValidator validator = createValidator(project, directory);
Messages.showInputDialog(project, AndroidBundle.message("new.file.dialog.text"),
AndroidBundle.message("new.typed.resource.dialog.title", myResourcePresentableName),
Messages.getQuestionIcon(), "", validator);
}
}
return PsiElement.EMPTY_ARRAY;
}
示例4: actionPerformed
import com.intellij.ide.IdeView; //导入方法依赖的package包/类
@Override
public void actionPerformed(@NotNull AnActionEvent anActionEvent) {
final DataContext dataContext = anActionEvent.getDataContext();
final IdeView view = LangDataKeys.IDE_VIEW.getData(dataContext);
if (view == null) {
return;
}
final Project project = CommonDataKeys.PROJECT.getData(dataContext);
final PsiDirectory dir = view.getOrChooseDirectory();
if (dir == null || project == null) {
return;
}
CreateFileDialog createFileDialog = new CreateFileDialog(project, dir);
createFileDialog.show();
}
示例5: actionPerformed
import com.intellij.ide.IdeView; //导入方法依赖的package包/类
@Override
public final void actionPerformed(final AnActionEvent e) {
final DataContext dataContext = e.getDataContext();
final IdeView view = LangDataKeys.IDE_VIEW.getData(dataContext);
if (view == null) {
return;
}
final Project project = PlatformDataKeys.PROJECT.getData(dataContext);
final PsiDirectory dir = view.getOrChooseDirectory();
if (dir == null) return;
final PsiElement[] createdElements = invokeDialog(project, dir);
for (PsiElement createdElement : createdElements) {
view.selectElement(createdElement);
}
}
示例6: actionPerformed
import com.intellij.ide.IdeView; //导入方法依赖的package包/类
@RequiredDispatchThread
@Override
public final void actionPerformed(@Nonnull final AnActionEvent e) {
final IdeView view = e.getData(LangDataKeys.IDE_VIEW);
if (view == null) {
return;
}
final Project project = e.getProject();
final PsiDirectory dir = view.getOrChooseDirectory();
if (dir == null) return;
final PsiElement[] createdElements = invokeDialog(project, dir);
for (PsiElement createdElement : createdElements) {
view.selectElement(createdElement);
}
}
示例7: update
import com.intellij.ide.IdeView; //导入方法依赖的package包/类
@Override
public void update( AnActionEvent e )
{
super.update( e );
boolean enabled;
final DataContext dataContext = e.getDataContext();
final IdeView view = LangDataKeys.IDE_VIEW.getData( dataContext );
if( view == null )
{
enabled = false;
}
else
{
final Project project = PlatformDataKeys.PROJECT.getData( dataContext );
final PsiDirectory dir = view.getOrChooseDirectory();
if( dir == null || project == null )
{
enabled = false;
}
else
{
PsiPackage pkg = JavaDirectoryService.getInstance().getPackage( dir );
ProjectFileIndex projectFileIndex = ProjectRootManager.getInstance( project).getFileIndex();
enabled = pkg != null && projectFileIndex.isUnderSourceRootOfType( dir.getVirtualFile(), JavaModuleSourceRootTypes.SOURCES );
}
}
e.getPresentation().setEnabled( enabled );
}
示例8: isAvailable
import com.intellij.ide.IdeView; //导入方法依赖的package包/类
@Override
protected boolean isAvailable(DataContext dataContext) {
IdeView view = (IdeView) LangDataKeys.IDE_VIEW.getData(dataContext);
if (view == null) {
return false;
}
PsiDirectory dir = view.getOrChooseDirectory();
if (dir == null) {
return false;
}
if (!dir.getName().equals(this.getApplicationName())) {
return false;
}
PsiDirectory projectDir = dir.getParent();
if (projectDir == null) {
return false;
}
PsiDirectory srcDir = projectDir.getParent();
return srcDir != null && srcDir.getName().equals("src");
}
示例9: actionPerformed
import com.intellij.ide.IdeView; //导入方法依赖的package包/类
@Override
public void actionPerformed(AnActionEvent e) {
List<PsiClass> modulesClasses = extractDagger2ModulesPsiClasses(e);
SelectModulesDialog dg = new SelectModulesDialog(e.getProject(), modulesClasses);
if (!dg.showAndGet()) {
return;
}
List<PsiClass> componentModules = new ArrayList<>();
List<TypeInfo> typeInfos = dg.getTypeInfos();
for (TypeInfo typeInfo : typeInfos) {
if (typeInfo.isChecked()) {
PsiClass typeObject = typeInfo.getTypeObject();
componentModules.add(typeObject);
}
}
final DataContext dataContext = e.getDataContext();
final IdeView view = LangDataKeys.IDE_VIEW.getData(dataContext);
if (view == null) {
return;
}
final Project project = CommonDataKeys.PROJECT.getData(dataContext);
final PsiDirectory dir = view.getOrChooseDirectory();
if (dir == null || project == null) return;
PsiClass createdComponentClass = (PsiClass) doCreate(dir, dg.getComponentName(), project, componentModules);
}
示例10: isAvailable
import com.intellij.ide.IdeView; //导入方法依赖的package包/类
@Override
protected boolean isAvailable(@NotNull final DataContext dataContext) {
final Project project = PlatformDataKeys.PROJECT.getData(dataContext);
if (project == null) {
return false;
}
if (DumbService.getInstance(project).isDumb() && !isDumbAware()) {
return false;
}
final IdeView view = LangDataKeys.IDE_VIEW.getData(dataContext);
if (view == null || view.getDirectories().length == 0) {
return false;
}
final PsiDirectory dir = view.getOrChooseDirectory();
if (dir == null) {
return false;
}
final VirtualFile virtualDir = dir.getVirtualFile();
final Module module = ModuleUtil.findModuleForFile(virtualDir, project);
//noinspection SimplifiableIfStatement
if (!OCamlModuleUtil.isOCamlModule(module)) {
return false;
}
return ModuleRootManager.getInstance(module).getFileIndex().isInSourceContent(virtualDir);
}
示例11: isAvailable
import com.intellij.ide.IdeView; //导入方法依赖的package包/类
@Override
@RequiredDispatchThread
protected boolean isAvailable(DataContext dataContext)
{
Module module = findModule(dataContext);
if(module != null)
{
DotNetModuleExtension extension = ModuleUtilCore.getExtension(module, DotNetModuleExtension.class);
if(extension != null && extension.isAllowSourceRoots())
{
final IdeView view = dataContext.getData(LangDataKeys.IDE_VIEW);
if(view == null)
{
return false;
}
PsiDirectory orChooseDirectory = view.getOrChooseDirectory();
if(orChooseDirectory == null)
{
return false;
}
PsiPackage aPackage = PsiPackageManager.getInstance(module.getProject()).findPackage(orChooseDirectory, DotNetModuleExtension.class);
if(aPackage == null)
{
return false;
}
}
}
return module != null && ModuleUtilCore.getExtension(module, CSharpSimpleModuleExtension.class) != null;
}
示例12: findModule
import com.intellij.ide.IdeView; //导入方法依赖的package包/类
@RequiredReadAction
private static Module findModule(DataContext dataContext)
{
Project project = dataContext.getData(CommonDataKeys.PROJECT);
if(project == null)
{
return null;
}
final IdeView view = dataContext.getData(LangDataKeys.IDE_VIEW);
if(view == null)
{
return null;
}
final PsiDirectory orChooseDirectory = view.getOrChooseDirectory();
if(orChooseDirectory == null)
{
return null;
}
Module resolve = CSharpCreateFromTemplateHandler.findModuleByPsiDirectory(orChooseDirectory);
if(resolve != null)
{
return resolve;
}
return dataContext.getData(LangDataKeys.MODULE);
}
示例13: actionPerformed
import com.intellij.ide.IdeView; //导入方法依赖的package包/类
@Override
public void actionPerformed(AnActionEvent e) {
final DataContext dataContext = e.getDataContext();
final IdeView view = LangDataKeys.IDE_VIEW.getData(dataContext);
if (view == null) {
return;
}
final Module module = LangDataKeys.MODULE.getData(dataContext);
if (module == null) {
return;
}
AndroidFacet facet = AndroidFacet.getInstance(module);
if (facet == null) {
return;
}
// If you're invoking the Asset Studio by right clicking in the Android Project view on a drawable or
// mipmap folder for example, the IDE will ask you to pick a specific folder from one of the many
// actual folders packed into the single resource directory.
//
// However, in this case we don't need those folders; we just want the corresponding source set, so
// asking the user to choose between "drawable-mdpi" and "drawable-hdpi" isn't helpful.
final PsiDirectory dir;
AbstractProjectViewPane pane = ProjectView.getInstance(module.getProject()).getCurrentProjectViewPane();
if (pane instanceof AndroidProjectViewPane) {
PsiDirectory[] directories = view.getDirectories();
if (directories.length == 0) {
return;
}
dir = directories[0];
} else {
dir = view.getOrChooseDirectory();
}
if (dir == null) {
return;
}
Project project = CommonDataKeys.PROJECT.getData(dataContext);
VirtualFile targetFile = CommonDataKeys.VIRTUAL_FILE.getData(dataContext);
showWizardAndCreateAsset(project, module, targetFile);
}
示例14: actionPerformed
import com.intellij.ide.IdeView; //导入方法依赖的package包/类
@Override
public void actionPerformed(@NotNull final AnActionEvent event) {
final DataContext dataContext = event.getDataContext();
final IdeView view = LangDataKeys.IDE_VIEW.getData(dataContext);
if(view == null) {
return;
}
final Project project = event.getProject();
if(project == null) {
return;
}
final DefracFacet facet = getFacet(event);
final DefracConfigOracle config = facet.getConfigOracle();
if(config == null) {
return;
}
final PsiDirectory dir = view.getOrChooseDirectory();
if(dir == null) {
return;
}
final MultiPlatformCreateDialog<T> dialog =
MultiPlatformCreateDialog.create(
event.getProject(),
ImmutableSet.copyOf(config.getTargets()),
createGeneric(),
createAndroid(), createIOS(),
createJVM(), createWeb());
updateDialog(project, facet, event, dialog);
final MultiPlatformCreateDialog.Result<T> result = dialog.getResult(project, dir);
if(result != null && result.generic != null) {
view.selectElement(result.generic);
}
}
示例15: actionPerformed
import com.intellij.ide.IdeView; //导入方法依赖的package包/类
/**
* Creates new Gitignore file if it does not exist or uses an existing one and opens {@link GeneratorDialog}.
*
* @param e action event
*/
@Override
public void actionPerformed(AnActionEvent e) {
final Project project = e.getRequiredData(CommonDataKeys.PROJECT);
final IdeView view = e.getRequiredData(LangDataKeys.IDE_VIEW);
VirtualFile fixedDirectory = fileType.getIgnoreLanguage().getFixedDirectory(project);
PsiDirectory directory;
if (fixedDirectory != null) {
directory = PsiManager.getInstance(project).findDirectory(fixedDirectory);
} else {
directory = view.getOrChooseDirectory();
}
if (directory == null) {
return;
}
GeneratorDialog dialog;
String filename = fileType.getIgnoreLanguage().getFilename();
PsiFile file = directory.findFile(filename);
VirtualFile virtualFile = file == null ? directory.getVirtualFile().findChild(filename) : file.getVirtualFile();
if (file == null && virtualFile == null) {
CreateFileCommandAction action = new CreateFileCommandAction(project, directory, fileType);
dialog = new GeneratorDialog(project, action);
} else {
Notifications.Bus.notify(new Notification(
fileType.getLanguageName(),
IgnoreBundle.message("action.newFile.exists", fileType.getLanguageName()),
IgnoreBundle.message("action.newFile.exists.in", virtualFile.getPath()),
NotificationType.INFORMATION
), project);
if (file == null) {
file = Utils.getPsiFile(project, virtualFile);
}
dialog = new GeneratorDialog(project, file);
}
dialog.show();
file = dialog.getFile();
if (file != null) {
Utils.openFile(project, file);
}
}