2 * Copyright 2004-2005 Alexey Efimov
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
.actions
;
18 import com
.intellij
.openapi
.actionSystem
.ActionPlaces
;
19 import com
.intellij
.openapi
.actionSystem
.AnAction
;
20 import com
.intellij
.openapi
.actionSystem
.AnActionEvent
;
21 import com
.intellij
.openapi
.actionSystem
.PlatformDataKeys
;
22 import com
.intellij
.openapi
.project
.Project
;
23 import com
.intellij
.openapi
.vfs
.VirtualFile
;
24 import org
.intellij
.images
.thumbnail
.ThumbnailManager
;
25 import org
.intellij
.images
.thumbnail
.ThumbnailView
;
28 * Show thumbnail for directory.
30 * @author <a href="mailto:aefimov.box@gmail.com">Alexey Efimov</a>
32 public final class ShowThumbnailsAction
extends AnAction
{
33 public void actionPerformed(AnActionEvent e
) {
34 Project project
= e
.getData(PlatformDataKeys
.PROJECT
);
35 VirtualFile file
= e
.getData(PlatformDataKeys
.VIRTUAL_FILE
);
36 if (project
!= null && file
!= null && file
.isDirectory()) {
37 ThumbnailManager thumbnailManager
= ThumbnailManager
.getManager(project
);
38 ThumbnailView thumbnailView
= thumbnailManager
.getThumbnailView();
39 thumbnailView
.setRoot(file
);
40 thumbnailView
.setVisible(true);
41 thumbnailView
.activate();
45 public void update(AnActionEvent e
) {
47 VirtualFile file
= e
.getData(PlatformDataKeys
.VIRTUAL_FILE
);
48 final boolean isEnabled
= file
!= null && file
.isDirectory();
49 if (e
.getPlace().equals(ActionPlaces
.PROJECT_VIEW_POPUP
)) {
50 e
.getPresentation().setVisible(isEnabled
);
53 e
.getPresentation().setEnabled(isEnabled
);