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


Java FileTypeChooser.associateFileType方法代码示例

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


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

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

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

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

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

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

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

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

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

示例9: actionPerformed

import com.intellij.openapi.fileTypes.ex.FileTypeChooser; //导入方法依赖的package包/类
@Override
public void actionPerformed(AnActionEvent e) {
  VirtualFile file = e.getRequiredData(CommonDataKeys.VIRTUAL_FILE);
  FileTypeChooser.associateFileType(file.getName());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:6,代码来源:AssociateFileTypeAction.java

示例10: actionPerformed

import com.intellij.openapi.fileTypes.ex.FileTypeChooser; //导入方法依赖的package包/类
public void actionPerformed(AnActionEvent e) {
  VirtualFile file = e.getData(PlatformDataKeys.VIRTUAL_FILE);
  FileTypeChooser.associateFileType(file.getName());
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:5,代码来源:AssociateFileType.java

示例11: actionPerformed

import com.intellij.openapi.fileTypes.ex.FileTypeChooser; //导入方法依赖的package包/类
@Override
public void actionPerformed(AnActionEvent e) {
  VirtualFile file = e.getData(PlatformDataKeys.VIRTUAL_FILE);
  FileTypeChooser.associateFileType(file.getName());
}
 
开发者ID:consulo,项目名称:consulo,代码行数:6,代码来源:AssociateFileType.java


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