use of org.intellij.images.fileTypes.ImageFileTypeManager in project intellij-community by JetBrains.
the class EditExternallyAction method actionPerformed.
public void actionPerformed(AnActionEvent e) {
Project project = e.getData(CommonDataKeys.PROJECT);
VirtualFile[] files = e.getData(CommonDataKeys.VIRTUAL_FILE_ARRAY);
Options options = OptionsManager.getInstance().getOptions();
String executablePath = options.getExternalEditorOptions().getExecutablePath();
if (StringUtil.isEmpty(executablePath)) {
Messages.showErrorDialog(project, ImagesBundle.message("error.empty.external.editor.path"), ImagesBundle.message("error.title.empty.external.editor.path"));
ImagesConfigurable.show(project);
} else {
if (files != null) {
Map<String, String> env = EnvironmentUtil.getEnvironmentMap();
for (String varName : env.keySet()) {
if (SystemInfo.isWindows) {
executablePath = StringUtil.replace(executablePath, "%" + varName + "%", env.get(varName), true);
} else {
executablePath = StringUtil.replace(executablePath, "${" + varName + "}", env.get(varName), false);
}
}
executablePath = FileUtil.toSystemDependentName(executablePath);
File executable = new File(executablePath);
GeneralCommandLine commandLine = new GeneralCommandLine();
final String path = executable.exists() ? executable.getAbsolutePath() : executablePath;
if (SystemInfo.isMac) {
commandLine.setExePath(ExecUtil.getOpenCommandPath());
commandLine.addParameter("-a");
commandLine.addParameter(path);
} else {
commandLine.setExePath(path);
}
ImageFileTypeManager typeManager = ImageFileTypeManager.getInstance();
for (VirtualFile file : files) {
if (file.isInLocalFileSystem() && typeManager.isImage(file)) {
commandLine.addParameter(VfsUtilCore.virtualToIoFile(file).getAbsolutePath());
}
}
commandLine.setWorkDirectory(new File(executablePath).getParentFile());
try {
commandLine.createProcess();
} catch (ExecutionException ex) {
Messages.showErrorDialog(project, ex.getLocalizedMessage(), ImagesBundle.message("error.title.launching.external.editor"));
ImagesConfigurable.show(project);
}
}
}
}
use of org.intellij.images.fileTypes.ImageFileTypeManager in project intellij-community by JetBrains.
the class ThumbnailViewUI method isImagesInDirectory.
private boolean isImagesInDirectory(VirtualFile dir) {
ImageFileTypeManager typeManager = ImageFileTypeManager.getInstance();
VirtualFile[] files = dir.getChildren();
for (VirtualFile file : files) {
if (file.isDirectory()) {
// We can be sure for fast searching
return true;
}
if (typeManager.isImage(file)) {
return true;
}
}
return false;
}
use of org.intellij.images.fileTypes.ImageFileTypeManager in project intellij-community by JetBrains.
the class ThumbnailViewUI method findFiles.
private Set<VirtualFile> findFiles(VirtualFile file) {
Set<VirtualFile> files = new HashSet<>(0);
Project project = thumbnailView.getProject();
if (!project.isDisposed()) {
ProjectRootManager rootManager = ProjectRootManager.getInstance(project);
boolean projectIgnored = rootManager.getFileIndex().isExcluded(file);
if (!projectIgnored && !FileTypeManager.getInstance().isFileIgnored(file)) {
ImageFileTypeManager typeManager = ImageFileTypeManager.getInstance();
if (file.isDirectory()) {
if (thumbnailView.isRecursive()) {
files.addAll(findFiles(file.getChildren()));
} else if (isImagesInDirectory(file)) {
files.add(file);
}
} else if (typeManager.isImage(file)) {
files.add(file);
}
}
}
return files;
}
use of org.intellij.images.fileTypes.ImageFileTypeManager in project intellij-community by JetBrains.
the class EnterAction method update.
public void update(AnActionEvent e) {
super.update(e);
if (ThumbnailViewActionUtil.setEnabled(e)) {
Presentation presentation = e.getPresentation();
ThumbnailView view = ThumbnailViewActionUtil.getVisibleThumbnailView(e);
VirtualFile[] selection = view.getSelection();
if (selection.length > 0) {
if (selection.length == 1 && selection[0].isDirectory()) {
presentation.setVisible(true);
} else {
boolean notImages = false;
ImageFileTypeManager typeManager = ImageFileTypeManager.getInstance();
for (VirtualFile file : selection) {
notImages |= !typeManager.isImage(file);
}
presentation.setEnabled(!notImages);
presentation.setVisible(false);
}
} else {
presentation.setVisible(false);
presentation.setEnabled(false);
}
}
}
use of org.intellij.images.fileTypes.ImageFileTypeManager in project intellij-community by JetBrains.
the class EditExternallyAction method isImages.
private static boolean isImages(VirtualFile[] files) {
boolean isImagesFound = false;
if (files != null) {
ImageFileTypeManager typeManager = ImageFileTypeManager.getInstance();
for (VirtualFile file : files) {
boolean isImage = typeManager.isImage(file);
isImagesFound |= isImage;
if (!file.isInLocalFileSystem() || !isImage) {
return false;
}
}
}
return isImagesFound;
}
Aggregations