Package com.intellij.openapi.fileTypes

Examples of com.intellij.openapi.fileTypes.FileTypeManager


   public void registerExtensions() {
       new WriteActionRunner() {
           public void run() {
               if (!isDisposed()) {
                   FileTypeManager.getInstance().removeFileTypeListener(DDLFileManager.this);
                   FileTypeManager fileTypeManager = FileTypeManager.getInstance();
                   List<DDLFileType> ddlFileTypeList = getExtensionSettings().getDDLFileTypes();
                   for (DDLFileType ddlFileType : ddlFileTypeList) {
                       for (String extension : ddlFileType.getExtensions()) {
                           fileTypeManager.associateExtension(ddlFileType.getLanguageFileType(), extension);
                       }
                   }
                   FileTypeManager.getInstance().addFileTypeListener(DDLFileManager.this);
               }
           }
View Full Code Here


    }

    public void fileTypesChanged(FileTypeEvent event) {
        StringBuilder restoredAssociations = null;
        FileTypeManager fileTypeManager = FileTypeManager.getInstance();
        List<DDLFileType> ddlFileTypeList = getExtensionSettings().getDDLFileTypes();
        for (DDLFileType ddlFileType : ddlFileTypeList) {
            DBLanguageFileType fileType = ddlFileType.getLanguageFileType();
            List<FileNameMatcher> associations = fileTypeManager.getAssociations(fileType);
            List<String> registeredExtension = new ArrayList<String>();
            for (FileNameMatcher association : associations) {
                if (association instanceof ExtensionFileNameMatcher) {
                    ExtensionFileNameMatcher extensionMatcher = (ExtensionFileNameMatcher) association;
                    registeredExtension.add(extensionMatcher.getExtension());
                }
            }

            for (String extension : ddlFileType.getExtensions()) {
                if (!registeredExtension.contains(extension)) {
                    fileTypeManager.associateExtension(fileType, extension);
                    if (restoredAssociations == null) {
                        restoredAssociations = new StringBuilder();
                    } else {
                        restoredAssociations.append(", ");
                    }
View Full Code Here

        this.contentType = contentType;
    }

    public void setExtension(String extension) {
        if (!this.extension.equals(extension)) {
            FileTypeManager fileTypeManager = FileTypeManager.getInstance();
            fileTypeManager.removeAssociatedExtension(this, this.extension);
            this.extension = extension;
            fileTypeManager.registerFileType(this, extension);
        }
    }
View Full Code Here

    public String getComponentName() {
        return "NativeNeighbourhoodPlugin";
    }

    private void registerFileType() {
        FileTypeManager fileTypeManager = FileTypeManager.getInstance();
        // already registered?
        FileType[] filetypeArray = fileTypeManager.getRegisteredFileTypes();
        boolean alreadyRegistered = false;
        for (FileType tType : filetypeArray) {
            //            if (tType.getName().equals(NATIVE_FILE_TYPE_NAME)) {
            if (tType instanceof NativeFileType) {
                alreadyRegistered = true;
                nativeFileType = (NativeFileType) tType;
                break;
            }
        }
        if (!alreadyRegistered) {
            nativeFileType = new NativeFileType();
            nativeFileType.setName(NATIVE_FILE_TYPE_NAME);
            nativeFileType.setDescription(NATIVE_FILE_TYPE_DESCRIPTION);
            String tExtensions = getNativeExtensions();
            List<String> tList = new ArrayList<String>();
            StringTokenizer tTokenizer = new StringTokenizer(tExtensions, ",;:/ ");
            while (tTokenizer.hasMoreTokens()) {
                String tExtension = tTokenizer.nextToken().trim();
                tList.add(tExtension);
            }
            String[] tArray = tList.toArray(new String[tList.size()]);
          fileTypeManager.registerFileType(nativeFileType, tArray);
        }
        nativeFileType.setIcon(Util.loadIconFromDir("nativefiletype.gif", getIconsDir()));
    }
View Full Code Here

    }

    /** updateNativeExtensions */
    protected void updateConfigPriorWrite() {
        // updateNativeExtensions
        FileTypeManager fileTypeManager = FileTypeManager.getInstance();
        String[] tArray = fileTypeManager.getAssociatedExtensions(nativeFileType);
        StringBuilder tExtensions = new StringBuilder(140);
        for (int i = 0; i < tArray.length; i++) {
            String tExt = tArray[i];
            if (i > 0) {
                tExtensions.append(",");
View Full Code Here

    {
        FileTemplateGroupDescriptor group = new FileTemplateGroupDescriptor(
            message( "qi4j.file.template.group.title" ), null
        );

        FileTypeManager fileTypeManager = FileTypeManager.getInstance();
        for( @NonNls String template : FILE_TEMPLATES )
        {
            Icon icon = fileTypeManager.getFileTypeByFileName( template ).getIcon();
            group.addTemplate( new FileTemplateDescriptor( template, icon ) );
        }

        return group;
    }
View Full Code Here

    static final String NAME_TEMPLATE_PROPERTY = "NAME";
    static final String LOW_CASE_NAME_TEMPLATE_PROPERTY = "lowCaseName";

    public FileTemplateGroupDescriptor getFileTemplatesDescriptor() {
        final FileTemplateGroupDescriptor group = new FileTemplateGroupDescriptor("Spock", GroovyIcons.getInstance().getGroovy16Icon());
        final FileTypeManager fileTypeManager = FileTypeManager.getInstance();
        group.addTemplate(new FileTemplateDescriptor(SpockTemplates.SPOCK_SPEC, fileTypeManager.getFileTypeByFileName(SpockTemplates.SPOCK_SPEC).getIcon()));

        // register custom templates
        for (String template : getInstance().getCustomTemplates()) {
            group.addTemplate(new FileTemplateDescriptor(template, fileTypeManager.getFileTypeByFileName(template).getIcon()));
        }
        return group;
    }
View Full Code Here

  public static void collectFiles(VirtualFile dir, List files, boolean recursive, boolean addDirectories) {
    if (!dir.isDirectory()) {
      throw new IllegalArgumentException(VcsBundle.message("exception.text.file.should.be.directory", dir.getPresentableUrl()));
    }

    FileTypeManager fileTypeManager = FileTypeManager.getInstance();
    VirtualFile[] children = dir.getChildren();
    for (VirtualFile child : children) {
      if (!child.isDirectory() && (fileTypeManager == null || fileTypeManager.getFileTypeByFile(child) != StdFileTypes.UNKNOWN)) {
        files.add(child);
      }
      else if (recursive && child.isDirectory()) {
        if (addDirectories) {
          files.add(child);
View Full Code Here

TOP

Related Classes of com.intellij.openapi.fileTypes.FileTypeManager

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.