unused class removed
[fedora-idea.git] / plugins / images / src / org / intellij / images / thumbnail / actions / EnterAction.java
blobb608b82f97c76b05a7fff59405426869d694db16
1 /*
2 * Copyright 2000-2009 JetBrains s.r.o.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 package org.intellij.images.thumbnail.actions;
18 import com.intellij.openapi.actionSystem.AnAction;
19 import com.intellij.openapi.actionSystem.AnActionEvent;
20 import com.intellij.openapi.actionSystem.Presentation;
21 import com.intellij.openapi.vfs.VirtualFile;
22 import com.intellij.openapi.fileEditor.FileEditorManager;
23 import org.intellij.images.thumbnail.ThumbnailView;
24 import org.intellij.images.thumbnail.actionSystem.ThumbnailViewActionUtil;
25 import org.intellij.images.fileTypes.ImageFileTypeManager;
27 /**
28 * Level up to browse images.
30 * @author <a href="mailto:aefimov.box@gmail.com">Alexey Efimov</a>
32 public final class EnterAction extends AnAction {
33 public void actionPerformed(AnActionEvent e) {
34 ThumbnailView view = ThumbnailViewActionUtil.getVisibleThumbnailView(e);
35 if (view != null) {
36 VirtualFile[] selection = view.getSelection();
37 if (selection.length == 1 && selection[0].isDirectory()) {
38 view.setRoot(selection[0]);
39 } else if (selection.length > 0) {
40 FileEditorManager fileEditorManager = FileEditorManager.getInstance(view.getProject());
41 ImageFileTypeManager typeManager = ImageFileTypeManager.getInstance();
42 for (VirtualFile file : selection) {
43 if (typeManager.isImage(file)) {
44 fileEditorManager.openFile(file, false);
51 public void update(AnActionEvent e) {
52 super.update(e);
53 if (ThumbnailViewActionUtil.setEnabled(e)) {
54 Presentation presentation = e.getPresentation();
55 ThumbnailView view = ThumbnailViewActionUtil.getVisibleThumbnailView(e);
56 VirtualFile[] selection = view.getSelection();
57 if (selection.length > 0) {
58 if (selection.length == 1 && selection[0].isDirectory()) {
59 presentation.setVisible(true);
60 } else if (selection.length > 0) {
61 boolean notImages = false;
62 ImageFileTypeManager typeManager = ImageFileTypeManager.getInstance();
63 for (VirtualFile file : selection) {
64 notImages |= !typeManager.isImage(file);
66 presentation.setEnabled(!notImages);
67 presentation.setVisible(false);
68 } else {
69 presentation.setVisible(false);
70 presentation.setEnabled(false);
72 } else {
73 presentation.setVisible(false);
74 presentation.setEnabled(false);