当前位置: 首页>>代码示例>>Java>>正文


Java FileTypeChooser.getKnownFileTypeOrAssociate方法代码示例

本文整理汇总了Java中com.intellij.openapi.fileTypes.ex.FileTypeChooser.getKnownFileTypeOrAssociate方法的典型用法代码示例。如果您正苦于以下问题:Java FileTypeChooser.getKnownFileTypeOrAssociate方法的具体用法?Java FileTypeChooser.getKnownFileTypeOrAssociate怎么用?Java FileTypeChooser.getKnownFileTypeOrAssociate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.intellij.openapi.fileTypes.ex.FileTypeChooser的用法示例。


在下文中一共展示了FileTypeChooser.getKnownFileTypeOrAssociate方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: doOKAction

import com.intellij.openapi.fileTypes.ex.FileTypeChooser; //导入方法依赖的package包/类
@Override
protected void doOKAction() {
  final Project project = myCurrentDirectory.getProject();

  final String directoryName = myTargetDirectoryField.getText().replace(File.separatorChar, '/');
  final String targetFileName = getTargetFileName();

  if (isFileExist(directoryName, targetFileName)) {
    Messages.showErrorDialog(project, RefactoringBundle.message("file.already.exist", targetFileName), RefactoringBundle.message("file.already.exist.title"));
    return;
  }

  final FileType type = FileTypeChooser.getKnownFileTypeOrAssociate(targetFileName);
  if (type == null) {
    return;
  }

  CommandProcessor.getInstance().executeCommand(project, new Runnable() {
    @Override
    public void run() {
      final Runnable action = new Runnable() {
        @Override
        public void run() {
          try {
            PsiDirectory targetDirectory = DirectoryUtil.mkdirs(PsiManager.getInstance(project), directoryName);
            targetDirectory.checkCreateFile(targetFileName);
            final String webPath = PsiFileSystemItemUtil.getRelativePath(myCurrentDirectory, targetDirectory);
            myTargetDirectory = webPath == null ? null : targetDirectory;
          }
          catch (IncorrectOperationException e) {
            CommonRefactoringUtil.showErrorMessage(REFACTORING_NAME, e.getMessage(), null, project);
          }
        }
      };
      ApplicationManager.getApplication().runWriteAction(action);
    }
  }, RefactoringBundle.message("create.directory"), null);
  if (myTargetDirectory == null) return;
  super.doOKAction();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:41,代码来源:ExtractIncludeDialog.java

示例2: doOpenFile

import com.intellij.openapi.fileTypes.ex.FileTypeChooser; //导入方法依赖的package包/类
private static void doOpenFile(@Nullable final Project project,
                               @NotNull final List<VirtualFile> result) {
  for (final VirtualFile file : result) {
    if (file.isDirectory()) {
      Project openedProject;
      if (ProjectAttachProcessor.canAttachToProject()) {
        openedProject = PlatformProjectOpenProcessor.doOpenProject(file, project, false, -1, null, false);
      }
      else {
        openedProject = ProjectUtil.openOrImport(file.getPath(), project, false);
      }
      FileChooserUtil.setLastOpenedFile(openedProject, file);
      return;
    }

    if (OpenProjectFileChooserDescriptor.isProjectFile(file)) {
      int answer = Messages.showYesNoDialog(project,
                                            IdeBundle.message("message.open.file.is.project", file.getName()),
                                            IdeBundle.message("title.open.project"),
                                            Messages.getQuestionIcon());
      if (answer == 0) {
        FileChooserUtil.setLastOpenedFile(ProjectUtil.openOrImport(file.getPath(), project, false), file);
        return;
      }
    }

    FileType type = FileTypeChooser.getKnownFileTypeOrAssociate(file, project);
    if (type == null) return;

    if (project != null) {
      openFile(file, project);
    }
    else {
      PlatformProjectOpenProcessor processor = PlatformProjectOpenProcessor.getInstanceIfItExists();
      if (processor != null) {
        processor.doOpenProject(file, null, false);
      }
    }
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:41,代码来源:OpenFileAction.java

示例3: canClose

import com.intellij.openapi.fileTypes.ex.FileTypeChooser; //导入方法依赖的package包/类
@Override
public boolean canClose(String inputString) {
  if (inputString.length() == 0) {
    return super.canClose(inputString);
  }

  final PsiDirectory psiDirectory = getDirectory();

  final FileType type = FileTypeChooser.getKnownFileTypeOrAssociate(new FakeVirtualFile(psiDirectory.getVirtualFile(), getFileName(inputString)),
                                                                    psiDirectory.getProject());
  return type != null && super.canClose(getFileName(inputString));
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:13,代码来源:CreateFileAction.java

示例4: doOpenFile

import com.intellij.openapi.fileTypes.ex.FileTypeChooser; //导入方法依赖的package包/类
private static void doOpenFile(@Nullable final Project project,
                               @Nonnull final List<VirtualFile> result) {
  for (final VirtualFile file : result) {
    if (file.isDirectory()) {
      Project openedProject = ProjectUtil.open(file.getPath(), project, false);
      FileChooserUtil.setLastOpenedFile(openedProject, file);
      return;
    }

    if (OpenProjectFileChooserDescriptor.canOpen(file)) {
      int answer = Messages.showYesNoDialog(project,
                                            IdeBundle.message("message.open.file.is.project", file.getName()),
                                            IdeBundle.message("title.open.project"),
                                            Messages.getQuestionIcon());
      if (answer == 0) {
        FileChooserUtil.setLastOpenedFile(ProjectUtil.open(file.getPath(), project, false), file);
        return;
      }
    }

    FileType type = FileTypeChooser.getKnownFileTypeOrAssociate(file, project);
    if (type == null) return;

    if (project != null) {
      openFile(file, project);
    }
    else {
      PlatformProjectOpenProcessor processor = PlatformProjectOpenProcessor.getInstance();
      processor.doOpenProject(file, null, false);
    }
  }
}
 
开发者ID:consulo,项目名称:consulo,代码行数:33,代码来源:OpenFileAction.java

示例5: canClose

import com.intellij.openapi.fileTypes.ex.FileTypeChooser; //导入方法依赖的package包/类
@RequiredDispatchThread
@Override
public boolean canClose(final String inputString) {
  if (inputString.length() == 0) {
    return super.canClose(inputString);
  }

  final PsiDirectory psiDirectory = getDirectory();

  final Project project = psiDirectory.getProject();
  final boolean[] result = {false};
  FileTypeChooser.getKnownFileTypeOrAssociate(psiDirectory.getVirtualFile(), getFileName(inputString), project);
  result[0] = super.canClose(getFileName(inputString));
  return result[0];
}
 
开发者ID:consulo,项目名称:consulo,代码行数:16,代码来源:CreateFileAction.java


注:本文中的com.intellij.openapi.fileTypes.ex.FileTypeChooser.getKnownFileTypeOrAssociate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。