Search in sources :

Example 6 with ThumbnailView

use of org.intellij.images.thumbnail.ThumbnailView 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);
        }
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) ImageFileTypeManager(org.intellij.images.fileTypes.ImageFileTypeManager) ThumbnailView(org.intellij.images.thumbnail.ThumbnailView) Presentation(com.intellij.openapi.actionSystem.Presentation)

Aggregations

ThumbnailView (org.intellij.images.thumbnail.ThumbnailView)6 VirtualFile (com.intellij.openapi.vfs.VirtualFile)4 Project (com.intellij.openapi.project.Project)3 Presentation (com.intellij.openapi.actionSystem.Presentation)2 ImageFileTypeManager (org.intellij.images.fileTypes.ImageFileTypeManager)1 ThumbnailManager (org.intellij.images.thumbnail.ThumbnailManager)1