001    /*
002     * Copyright 2010-2015 JetBrains s.r.o.
003     *
004     * Licensed under the Apache License, Version 2.0 (the "License");
005     * you may not use this file except in compliance with the License.
006     * You may obtain a copy of the License at
007     *
008     * http://www.apache.org/licenses/LICENSE-2.0
009     *
010     * Unless required by applicable law or agreed to in writing, software
011     * distributed under the License is distributed on an "AS IS" BASIS,
012     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013     * See the License for the specific language governing permissions and
014     * limitations under the License.
015     */
016    
017    package org.jetbrains.kotlin.idea;
018    
019    import com.intellij.openapi.fileTypes.FileType;
020    import com.intellij.openapi.fileTypes.LanguageFileType;
021    import com.intellij.openapi.util.IconLoader;
022    import com.intellij.openapi.util.NotNullLazyValue;
023    import com.intellij.openapi.vfs.VirtualFile;
024    import org.jetbrains.annotations.NotNull;
025    import org.jetbrains.annotations.Nullable;
026    
027    import javax.swing.*;
028    
029    public class KotlinModuleFileType implements FileType {
030        public static final String EXTENSION = "kotlin_module";
031        public static final KotlinModuleFileType INSTANCE = new KotlinModuleFileType();
032    
033        private final NotNullLazyValue<Icon> myIcon = new NotNullLazyValue<Icon>() {
034            @NotNull
035            @Override
036            protected Icon compute() {
037                return IconLoader.getIcon("/org/jetbrains/kotlin/idea/icons/kotlin_file.png");
038            }
039        };
040    
041        private KotlinModuleFileType() {}
042    
043        @Override
044        @NotNull
045        public String getName() {
046            return EXTENSION;
047        }
048    
049        @Override
050        @NotNull
051        public String getDescription() {
052            return "Kotlin module info: contains package part mappings";
053        }
054    
055        @Override
056        @NotNull
057        public String getDefaultExtension() {
058            return EXTENSION;
059        }
060    
061        @Override
062        public Icon getIcon() {
063            return myIcon.getValue();
064        }
065    
066        @Override
067        public boolean isBinary() {
068            return true;
069        }
070    
071        @Override
072        public boolean isReadOnly() {
073            return true;
074        }
075    
076        @Nullable
077        @Override
078        public String getCharset(@NotNull VirtualFile file, @NotNull byte[] content) {
079            return null;
080        }
081    }