Search in sources :

Example 31 with FileType

use of com.intellij.openapi.fileTypes.FileType in project intellij-community by JetBrains.

the class CorruptedProjectFilesDialog method showNextFileInfo.

private void showNextFileInfo() {
    VirtualFile currentVirtualFile = getCurrentVirtualFile();
    FileType fileType = currentVirtualFile.getFileType();
    myMessageLabel.setText(com.intellij.CvsBundle.message("label.project.files.cannot.be.merged.without.conflict", fileType.getDescription(), currentVirtualFile.getPresentableUrl()));
    setTitle(com.intellij.CvsBundle.message("dialog.title.file.cannot.be.merged.without.conflicts", fileType.getDescription(), currentVirtualFile.getName()));
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) FileType(com.intellij.openapi.fileTypes.FileType)

Example 32 with FileType

use of com.intellij.openapi.fileTypes.FileType in project intellij-community by JetBrains.

the class VirtualFilePresentation method getIconImpl.

public static Icon getIconImpl(@NotNull VirtualFile vFile) {
    Icon icon = TypePresentationService.getService().getIcon(vFile);
    if (icon != null) {
        return icon;
    }
    FileType fileType = vFile.getFileType();
    if (vFile.isDirectory() && vFile.isInLocalFileSystem() && !(fileType instanceof DirectoryFileType)) {
        return PlatformIcons.FOLDER_ICON;
    }
    return fileType.getIcon();
}
Also used : DirectoryFileType(com.intellij.openapi.fileTypes.DirectoryFileType) FileType(com.intellij.openapi.fileTypes.FileType) DirectoryFileType(com.intellij.openapi.fileTypes.DirectoryFileType)

Example 33 with FileType

use of com.intellij.openapi.fileTypes.FileType in project intellij-community by JetBrains.

the class LightVirtualFile method setLanguage.

public void setLanguage(@NotNull Language language) {
    myLanguage = language;
    FileType type = language.getAssociatedFileType();
    if (type == null) {
        type = FileTypeRegistry.getInstance().getFileTypeByFileName(getName());
    }
    setFileType(type);
}
Also used : FileType(com.intellij.openapi.fileTypes.FileType)

Example 34 with FileType

use of com.intellij.openapi.fileTypes.FileType in project intellij-community by JetBrains.

the class UnknownFileTypeDiffRequest method getComponent.

@NotNull
@Override
public JComponent getComponent(@NotNull 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 new DiffUtil.CenteredPanel(label, JBUI.Borders.empty(5));
}
Also used : FileType(com.intellij.openapi.fileTypes.FileType) UnknownFileType(com.intellij.openapi.fileTypes.UnknownFileType) SimpleTextAttributes(com.intellij.ui.SimpleTextAttributes) SimpleColoredComponent(com.intellij.ui.SimpleColoredComponent) NotNull(org.jetbrains.annotations.NotNull)

Example 35 with FileType

use of com.intellij.openapi.fileTypes.FileType in project intellij-community by JetBrains.

the class LangDiffIgnoredRangeProvider method getLanguage.

@Nullable
private static Language getLanguage(@NotNull Project project, @NotNull DiffContent content) {
    Language language = content.getUserData(DiffUserDataKeys.LANGUAGE);
    if (language != null)
        return language;
    FileType type = content.getContentType();
    if (type instanceof LanguageFileType)
        language = ((LanguageFileType) type).getLanguage();
    if (language != null && content instanceof DocumentContent) {
        VirtualFile highlightFile = ((DocumentContent) content).getHighlightFile();
        if (highlightFile != null)
            language = LanguageSubstitutors.INSTANCE.substituteLanguage(language, highlightFile, project);
    }
    return language;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) LanguageFileType(com.intellij.openapi.fileTypes.LanguageFileType) Language(com.intellij.lang.Language) FileType(com.intellij.openapi.fileTypes.FileType) LanguageFileType(com.intellij.openapi.fileTypes.LanguageFileType) DocumentContent(com.intellij.diff.contents.DocumentContent) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

FileType (com.intellij.openapi.fileTypes.FileType)198 VirtualFile (com.intellij.openapi.vfs.VirtualFile)60 NotNull (org.jetbrains.annotations.NotNull)38 Language (com.intellij.lang.Language)31 PsiFile (com.intellij.psi.PsiFile)31 LanguageFileType (com.intellij.openapi.fileTypes.LanguageFileType)30 Nullable (org.jetbrains.annotations.Nullable)28 Project (com.intellij.openapi.project.Project)27 Document (com.intellij.openapi.editor.Document)20 IncorrectOperationException (com.intellij.util.IncorrectOperationException)13 ArrayList (java.util.ArrayList)12 IOException (java.io.IOException)11 Editor (com.intellij.openapi.editor.Editor)10 HighlighterIterator (com.intellij.openapi.editor.highlighter.HighlighterIterator)10 CustomSyntaxTableFileType (com.intellij.openapi.fileTypes.impl.CustomSyntaxTableFileType)10 PlainTextFileType (com.intellij.openapi.fileTypes.PlainTextFileType)9 UnknownFileType (com.intellij.openapi.fileTypes.UnknownFileType)9 BraceMatcher (com.intellij.codeInsight.highlighting.BraceMatcher)8 AbstractFileType (com.intellij.openapi.fileTypes.impl.AbstractFileType)8 PsiElement (com.intellij.psi.PsiElement)8