本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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());
}
示例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());
}
示例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());
}