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();
}
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();
}
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());
}
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);
}
}
Aggregations