use of com.intellij.openapi.file.exclude.EnforcedPlainTextFileTypeManager in project intellij-community by JetBrains.
the class EnforcedPlaintTextFileTypeManagerTest method testMarkAsPlainText.
public void testMarkAsPlainText() {
EnforcedPlainTextFileTypeManager manager = EnforcedPlainTextFileTypeManager.getInstance();
VirtualFile file = myFixture.getTempDirFixture().createFile("test.java");
FileType originalType = file.getFileType();
assertEquals("JAVA", originalType.getName());
manager.markAsPlainText(getProject(), file);
// reparseFiles in invokeLater
UIUtil.dispatchAllInvocationEvents();
FileType changedType = file.getFileType();
assertEquals(EnforcedPlainTextFileTypeFactory.ENFORCED_PLAIN_TEXT, changedType.getName());
manager.resetOriginalFileType(getProject(), file);
FileType revertedType = file.getFileType();
assertEquals(originalType, revertedType);
}
use of com.intellij.openapi.file.exclude.EnforcedPlainTextFileTypeManager in project intellij-community by JetBrains.
the class MarkAsOriginalTypeAction method actionPerformed.
@Override
public void actionPerformed(AnActionEvent e) {
Project project = e.getProject();
EnforcedPlainTextFileTypeManager typeManager = EnforcedPlainTextFileTypeManager.getInstance();
if (project == null || typeManager == null)
return;
JBIterable<VirtualFile> selectedFiles = JBIterable.of(e.getData(CommonDataKeys.VIRTUAL_FILE_ARRAY)).filter(file -> !file.isDirectory() && typeManager.isMarkedAsPlainText(file));
typeManager.resetOriginalFileType(project, VfsUtilCore.toVirtualFileArray(selectedFiles.toList()));
}
use of com.intellij.openapi.file.exclude.EnforcedPlainTextFileTypeManager in project intellij-community by JetBrains.
the class MarkAsPlainTextAction method actionPerformed.
@Override
public void actionPerformed(AnActionEvent e) {
Project project = e.getProject();
EnforcedPlainTextFileTypeManager typeManager = EnforcedPlainTextFileTypeManager.getInstance();
if (project == null || typeManager == null)
return;
JBIterable<VirtualFile> selectedFiles = JBIterable.of(e.getData(CommonDataKeys.VIRTUAL_FILE_ARRAY)).filter(file -> EnforcedPlainTextFileTypeManager.isApplicableFor(file) && !typeManager.isMarkedAsPlainText(file));
typeManager.markAsPlainText(project, VfsUtilCore.toVirtualFileArray(selectedFiles.toList()));
}
use of com.intellij.openapi.file.exclude.EnforcedPlainTextFileTypeManager in project intellij-community by JetBrains.
the class MarkAsPlainTextAction method update.
@Override
public void update(AnActionEvent e) {
EnforcedPlainTextFileTypeManager typeManager = EnforcedPlainTextFileTypeManager.getInstance();
JBIterable<VirtualFile> selectedFiles = typeManager == null ? JBIterable.empty() : JBIterable.of(e.getData(CommonDataKeys.VIRTUAL_FILE_ARRAY)).filter(file -> EnforcedPlainTextFileTypeManager.isApplicableFor(file) && !typeManager.isMarkedAsPlainText(file));
boolean enabled = e.getProject() != null && !selectedFiles.isEmpty();
e.getPresentation().setEnabledAndVisible(enabled);
e.getPresentation().setIcon(EnforcedPlainTextFileTypeFactory.ENFORCED_PLAIN_TEXT_ICON);
}
use of com.intellij.openapi.file.exclude.EnforcedPlainTextFileTypeManager in project intellij-community by JetBrains.
the class MarkAsOriginalTypeAction method update.
@Override
public void update(AnActionEvent e) {
EnforcedPlainTextFileTypeManager typeManager = EnforcedPlainTextFileTypeManager.getInstance();
JBIterable<VirtualFile> selectedFiles = JBIterable.of(e.getData(CommonDataKeys.VIRTUAL_FILE_ARRAY)).filter(file -> !file.isDirectory() && typeManager.isMarkedAsPlainText(file));
FileTypeManager fileTypeManager = FileTypeManager.getInstance();
boolean enabled = e.getProject() != null && !selectedFiles.isEmpty();
Set<FileType> fileTypes = selectedFiles.map(file -> fileTypeManager.getFileTypeByFileName(file.getName())).toSet();
if (fileTypes.size() == 1) {
FileType original = fileTypes.iterator().next();
String originalName = original.getName();
String text = ActionsBundle.actionText("MarkAsOriginalTypeAction").replace("Original File Type", originalName);
e.getPresentation().setText(text);
e.getPresentation().setIcon(original.getIcon());
}
e.getPresentation().setEnabledAndVisible(enabled);
}
Aggregations