Search in sources :

Example 1 with FileTypeManagerEx

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

the class IntentionDescriptionPanel method showUsages.

private static void showUsages(final JPanel panel, final TitledSeparator separator, final List<IntentionUsagePanel> usagePanels, @Nullable final TextDescriptor[] exampleUsages) throws IOException {
    GridBagConstraints gb = null;
    boolean reuse = exampleUsages != null && panel.getComponents().length == exampleUsages.length;
    if (!reuse) {
        disposeUsagePanels(usagePanels);
        panel.setLayout(new GridBagLayout());
        panel.removeAll();
        gb = new GridBagConstraints();
        gb.anchor = GridBagConstraints.NORTHWEST;
        gb.fill = GridBagConstraints.BOTH;
        gb.gridheight = GridBagConstraints.REMAINDER;
        gb.gridwidth = 1;
        gb.gridx = 0;
        gb.gridy = 0;
        gb.insets = new Insets(0, 0, 0, 0);
        gb.ipadx = 5;
        gb.ipady = 5;
        gb.weightx = 1;
        gb.weighty = 1;
    }
    if (exampleUsages != null) {
        for (int i = 0; i < exampleUsages.length; i++) {
            final TextDescriptor exampleUsage = exampleUsages[i];
            final String name = exampleUsage.getFileName();
            final FileTypeManagerEx fileTypeManager = FileTypeManagerEx.getInstanceEx();
            final String extension = fileTypeManager.getExtension(name);
            final FileType fileType = fileTypeManager.getFileTypeByExtension(extension);
            IntentionUsagePanel usagePanel;
            if (reuse) {
                usagePanel = (IntentionUsagePanel) panel.getComponent(i);
            } else {
                usagePanel = new IntentionUsagePanel();
                usagePanels.add(usagePanel);
            }
            usagePanel.reset(exampleUsage.getText(), fileType);
            if (!reuse) {
                if (i == exampleUsages.length) {
                    gb.gridwidth = GridBagConstraints.REMAINDER;
                }
                panel.add(usagePanel, gb);
                gb.gridx++;
            }
        }
    }
    panel.revalidate();
    panel.repaint();
}
Also used : FileTypeManagerEx(com.intellij.openapi.fileTypes.ex.FileTypeManagerEx) FileType(com.intellij.openapi.fileTypes.FileType) HintHint(com.intellij.ui.HintHint)

Example 2 with FileTypeManagerEx

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

the class PostfixDescriptionPanel method showUsages.

private static void showUsages(@NotNull JPanel panel, @Nullable TextDescriptor exampleUsage) {
    String text = "";
    FileType fileType = PlainTextFileType.INSTANCE;
    if (exampleUsage != null) {
        try {
            text = exampleUsage.getText();
            String name = exampleUsage.getFileName();
            FileTypeManagerEx fileTypeManager = FileTypeManagerEx.getInstanceEx();
            String extension = fileTypeManager.getExtension(name);
            fileType = fileTypeManager.getFileTypeByExtension(extension);
        } catch (IOException e) {
            LOG.error(e);
        }
    }
    ((ActionUsagePanel) panel.getComponent(0)).reset(text, fileType);
    panel.repaint();
}
Also used : FileTypeManagerEx(com.intellij.openapi.fileTypes.ex.FileTypeManagerEx) PlainTextFileType(com.intellij.openapi.fileTypes.PlainTextFileType) FileType(com.intellij.openapi.fileTypes.FileType) ActionUsagePanel(com.intellij.codeInsight.intention.impl.config.ActionUsagePanel) IOException(java.io.IOException)

Example 3 with FileTypeManagerEx

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

the class FileTypesTest method testIgnoreOrder.

public void testIgnoreOrder() {
    final FileTypeManagerEx manager = FileTypeManagerEx.getInstanceEx();
    ApplicationManager.getApplication().runWriteAction(() -> manager.setIgnoredFilesList("a;b;"));
    assertEquals("a;b;", manager.getIgnoredFilesList());
    ApplicationManager.getApplication().runWriteAction(() -> manager.setIgnoredFilesList("b;a;"));
    assertEquals("b;a;", manager.getIgnoredFilesList());
}
Also used : FileTypeManagerEx(com.intellij.openapi.fileTypes.ex.FileTypeManagerEx)

Example 4 with FileTypeManagerEx

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

the class DirectoryIndexTest method testChangeIgnoreList.

public void testChangeIgnoreList() {
    VirtualFile newDir = createChildDirectory(myModule1Dir, "newDir");
    assertInProject(newDir);
    final FileTypeManagerEx fileTypeManager = (FileTypeManagerEx) FileTypeManager.getInstance();
    final String list = fileTypeManager.getIgnoredFilesList();
    final String list1 = list + ";" + "newDir";
    try {
        ApplicationManager.getApplication().runWriteAction(() -> fileTypeManager.setIgnoredFilesList(list1));
        assertNotInProject(newDir);
    } finally {
        ApplicationManager.getApplication().runWriteAction(() -> fileTypeManager.setIgnoredFilesList(list));
        assertInProject(newDir);
    }
}
Also used : FileTypeManagerEx(com.intellij.openapi.fileTypes.ex.FileTypeManagerEx)

Aggregations

FileTypeManagerEx (com.intellij.openapi.fileTypes.ex.FileTypeManagerEx)4 FileType (com.intellij.openapi.fileTypes.FileType)2 ActionUsagePanel (com.intellij.codeInsight.intention.impl.config.ActionUsagePanel)1 PlainTextFileType (com.intellij.openapi.fileTypes.PlainTextFileType)1 HintHint (com.intellij.ui.HintHint)1 IOException (java.io.IOException)1