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


Java FileTypeChooser类代码示例

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


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

示例1: getComponent

import com.intellij.openapi.fileTypes.ex.FileTypeChooser; //导入依赖的package包/类
@NotNull
@Override
public JComponent getComponent(@NotNull final DiffContext context) {
  final SimpleColoredComponent label = new SimpleColoredComponent();
  label.append("Can't show diff for unknown file type. ",
               new SimpleTextAttributes(SimpleTextAttributes.STYLE_PLAIN, UIUtil.getInactiveTextColor()));
  if (myFileName != null) {
    label.append("Associate", SimpleTextAttributes.LINK_ATTRIBUTES, new Runnable() {
      @Override
      public void run() {
        DumbService.allowStartingDumbModeInside(DumbModePermission.MAY_START_BACKGROUND, new Runnable() {
          @Override
          public void run() {
            FileType type = FileTypeChooser.associateFileType(myFileName);
            if (type != null) onSuccess(context);
          }
        });
      }
    });
    LinkMouseListenerBase.installSingleTagOn(label);
  }
  return DiffUtil.createMessagePanel(label);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:UnknownFileTypeDiffRequest.java

示例2: checkAssociate

import com.intellij.openapi.fileTypes.ex.FileTypeChooser; //导入依赖的package包/类
public static boolean checkAssociate(final Project project, String fileName, DiffChainContext context) {
  final String pattern = FileUtilRt.getExtension(fileName).toLowerCase();
  if (context.contains(pattern)) return false;
  int rc = Messages.showOkCancelDialog(project,
                               VcsBundle.message("diff.unknown.file.type.prompt", fileName),
                               VcsBundle.message("diff.unknown.file.type.title"),
                                 VcsBundle.message("diff.unknown.file.type.associate"),
                                 CommonBundle.getCancelButtonText(),
                               Messages.getQuestionIcon());
  if (rc == Messages.OK) {
    FileType fileType = FileTypeChooser.associateFileType(fileName);
    return fileType != null && !fileType.isBinary();
  } else {
    context.add(pattern);
  }
  return false;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:ChangeDiffRequestPresentable.java

示例3: fileTypesAreOk

import com.intellij.openapi.fileTypes.ex.FileTypeChooser; //导入依赖的package包/类
private boolean fileTypesAreOk(final List<Pair<VirtualFile, ApplyTextFilePatch>> textPatches) {
  for (Pair<VirtualFile, ApplyTextFilePatch> textPatch : textPatches) {
    final VirtualFile file = textPatch.getFirst();
    if (! file.isDirectory()) {
      FileType fileType = file.getFileType();
      if (fileType == FileTypes.UNKNOWN) {
        fileType = FileTypeChooser.associateFileType(file.getName());
        if (fileType == null) {
          showError(myProject, "Cannot apply patch. File " + file.getPresentableName() + " type not defined.", true);
          return false;
        }
      }
    }
  }
  return true;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:PatchApplier.java

示例4: canClose

import com.intellij.openapi.fileTypes.ex.FileTypeChooser; //导入依赖的package包/类
@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};
  DumbService.allowStartingDumbModeInside(DumbModePermission.MAY_START_BACKGROUND, new Runnable() {
    @Override
    public void run() {
      final FileType type = FileTypeChooser.getKnownFileTypeOrAssociate(new FakeVirtualFile(psiDirectory.getVirtualFile(), getFileName(inputString)),
                                                                        project);
      result[0] = type != null && MyValidator.super.canClose(getFileName(inputString));
    }
  });
  return result[0];
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:CreateFileAction.java

示例5: apply

import com.intellij.openapi.fileTypes.ex.FileTypeChooser; //导入依赖的package包/类
@Override
public void apply() throws ConfigurationException {
  if (myTemplate != null) {
    myTemplate.setText(myTemplateEditor.getDocument().getText());
    String name = myNameField.getText();
    String extension = myExtensionField.getText();
    String filename = name + "." + extension;
    if (name.length() == 0 || !isValidFilename(filename)) {
      throw new ConfigurationException(IdeBundle.message("error.invalid.template.file.name.or.extension"));
    }
    FileType fileType = FileTypeManager.getInstance().getFileTypeByFileName(filename);
    if (fileType == UnknownFileType.INSTANCE) {
      FileTypeChooser.associateFileType(filename);
    }
    myTemplate.setName(name);
    myTemplate.setExtension(extension);
    myTemplate.setReformatCode(myAdjustBox.isSelected());
    myTemplate.setLiveTemplateEnabled(myLiveTemplateBox.isSelected());
  }
  myModified = false;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:FileTemplateConfigurable.java

示例6: checkAssociate

import com.intellij.openapi.fileTypes.ex.FileTypeChooser; //导入依赖的package包/类
public static boolean checkAssociate(final Project project, final FilePath file, DiffChainContext context) {
  final String pattern = FileUtilRt.getExtension(file.getName()).toLowerCase();
  if (context.contains(pattern)) return false;
  int rc = Messages.showOkCancelDialog(project,
                               VcsBundle.message("diff.unknown.file.type.prompt", file.getName()),
                               VcsBundle.message("diff.unknown.file.type.title"),
                                 VcsBundle.message("diff.unknown.file.type.associate"),
                                 CommonBundle.getCancelButtonText(),
                               Messages.getQuestionIcon());
  if (rc == 0) {
    FileType fileType = FileTypeChooser.associateFileType(file.getName());
    return fileType != null && !fileType.isBinary();
  } else {
    context.add(pattern);
  }
  return false;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:18,代码来源:ChangeDiffRequestPresentable.java

示例7: fileTypesAreOk

import com.intellij.openapi.fileTypes.ex.FileTypeChooser; //导入依赖的package包/类
private boolean fileTypesAreOk(final List<Pair<VirtualFile, ApplyTextFilePatch>> textPatches) {
  for (Pair<VirtualFile, ApplyTextFilePatch> textPatch : textPatches) {
    final VirtualFile file = textPatch.getFirst();
    if (! file.isDirectory()) {
      FileType fileType = file.getFileType();
      if (fileType == FileTypes.UNKNOWN) {
        fileType = FileTypeChooser.associateFileType(file.getPresentableName());
        if (fileType == null) {
          showError(myProject, "Cannot apply patch. File " + file.getPresentableName() + " type not defined.", true);
          return false;
        }
      }
    }
  }
  return true;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:17,代码来源:PatchApplier.java

示例8: getComponent

import com.intellij.openapi.fileTypes.ex.FileTypeChooser; //导入依赖的package包/类
@Nonnull
@Override
public JComponent getComponent(@Nonnull final DiffContext context) {
  final SimpleColoredComponent label = new SimpleColoredComponent();
  label.setTextAlign(SwingConstants.CENTER);
  label.append("Can't show diff for unknown file type. ",
               new SimpleTextAttributes(SimpleTextAttributes.STYLE_PLAIN, UIUtil.getInactiveTextColor()));
  if (myFileName != null) {
    label.append("Associate", SimpleTextAttributes.LINK_ATTRIBUTES, new Runnable() {
      @Override
      public void run() {
        FileType type = FileTypeChooser.associateFileType(myFileName);
        if (type != null) onSuccess(context);
      }
    });
    LinkMouseListenerBase.installSingleTagOn(label);
  }
  return JBUI.Panels.simplePanel(label).withBorder(JBUI.Borders.empty(5));
}
 
开发者ID:consulo,项目名称:consulo,代码行数:20,代码来源:UnknownFileTypeDiffRequest.java

示例9: checkAssociate

import com.intellij.openapi.fileTypes.ex.FileTypeChooser; //导入依赖的package包/类
public static boolean checkAssociate(final Project project, String fileName, DiffChainContext context) {
  final String pattern = FileUtilRt.getExtension(fileName).toLowerCase();
  if (context.contains(pattern)) return false;
  int rc = Messages.showOkCancelDialog(project,
                                       VcsBundle.message("diff.unknown.file.type.prompt", fileName),
                                       VcsBundle.message("diff.unknown.file.type.title"),
                                       VcsBundle.message("diff.unknown.file.type.associate"),
                                       CommonBundle.getCancelButtonText(),
                                       Messages.getQuestionIcon());
  if (rc == Messages.OK) {
    FileType fileType = FileTypeChooser.associateFileType(fileName);
    return fileType != null && !fileType.isBinary();
  } else {
    context.add(pattern);
  }
  return false;
}
 
开发者ID:consulo,项目名称:consulo,代码行数:18,代码来源:ChangeDiffRequestPresentable.java

示例10: isFileTypeOk

import com.intellij.openapi.fileTypes.ex.FileTypeChooser; //导入依赖的package包/类
private boolean isFileTypeOk(@Nonnull VirtualFile file) {
  FileType fileType = file.getFileType();
  if (fileType == UnknownFileType.INSTANCE) {
    fileType = FileTypeChooser.associateFileType(file.getName());
    if (fileType == null) {
      PatchApplier
              .showError(myProject, "Cannot apply content for " + file.getPresentableName() + " file from patch because its type not defined.",
                         true);
      return false;
    }
  }
  if (fileType.isBinary()) {
    PatchApplier.showError(myProject, "Cannot apply file " + file.getPresentableName() + " from patch because it is binary.", true);
    return false;
  }
  return true;
}
 
开发者ID:consulo,项目名称:consulo,代码行数:18,代码来源:PathsVerifier.java

示例11: apply

import com.intellij.openapi.fileTypes.ex.FileTypeChooser; //导入依赖的package包/类
@RequiredDispatchThread
@Override
public void apply() throws ConfigurationException {
  if (myTemplate != null) {
    myTemplate.setText(myTemplateEditor.getDocument().getText());
    String name = myNameField.getText();
    String extension = myExtensionField.getText();
    String filename = name + "." + extension;
    if (name.length() == 0 || !isValidFilename(filename)) {
      throw new ConfigurationException(IdeBundle.message("error.invalid.template.file.name.or.extension"));
    }
    FileType fileType = FileTypeManager.getInstance().getFileTypeByFileName(filename);
    if (fileType == UnknownFileType.INSTANCE) {
      FileTypeChooser.associateFileType(filename);
    }
    myTemplate.setName(name);
    myTemplate.setExtension(extension);
    myTemplate.setReformatCode(myAdjustBox.isSelected());
    myTemplate.setLiveTemplateEnabled(myLiveTemplateBox.isSelected());
  }
  myModified = false;
}
 
开发者ID:consulo,项目名称:consulo,代码行数:23,代码来源:FileTemplateConfigurable.java

示例12: 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

示例13: 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

示例14: 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

示例15: 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


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