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.
18 * @author Vladimir Kondratyev
20 package com
.intellij
.ide
.actions
;
22 import com
.intellij
.codeInsight
.daemon
.DaemonCodeAnalyzer
;
23 import com
.intellij
.openapi
.actionSystem
.AnAction
;
24 import com
.intellij
.openapi
.actionSystem
.AnActionEvent
;
25 import com
.intellij
.openapi
.actionSystem
.DataContext
;
26 import com
.intellij
.openapi
.actionSystem
.PlatformDataKeys
;
27 import com
.intellij
.openapi
.diagnostic
.Logger
;
28 import com
.intellij
.openapi
.fileEditor
.FileEditorManager
;
29 import com
.intellij
.openapi
.project
.Project
;
30 import com
.intellij
.openapi
.vfs
.VirtualFile
;
31 import com
.intellij
.profile
.codeInspection
.InspectionProjectProfileManager
;
32 import com
.intellij
.psi
.PsiFile
;
33 import com
.intellij
.psi
.PsiManager
;
35 public class TogglePopupHintsAction
extends AnAction
{
36 private static final Logger LOG
=Logger
.getInstance("#com.intellij.ide.actions.TogglePopupHintsAction");
38 private static PsiFile
getTargetFile(DataContext dataContext
){
39 Project project
= PlatformDataKeys
.PROJECT
.getData(dataContext
);
43 VirtualFile
[] files
=FileEditorManager
.getInstance(project
).getSelectedFiles();
47 PsiFile psiFile
=PsiManager
.getInstance(project
).findFile(files
[0]);
48 LOG
.assertTrue(psiFile
!=null);
52 public void update(AnActionEvent e
){
53 PsiFile psiFile
=getTargetFile(e
.getDataContext());
54 e
.getPresentation().setEnabled(psiFile
!=null);
57 public void actionPerformed(AnActionEvent e
){
58 PsiFile psiFile
=getTargetFile(e
.getDataContext());
59 LOG
.assertTrue(psiFile
!=null);
60 Project project
= PlatformDataKeys
.PROJECT
.getData(e
.getDataContext());
61 LOG
.assertTrue(project
!=null);
62 DaemonCodeAnalyzer codeAnalyzer
= DaemonCodeAnalyzer
.getInstance(project
);
63 codeAnalyzer
.setImportHintsEnabled(psiFile
,!codeAnalyzer
.isImportHintsEnabled(psiFile
));
64 InspectionProjectProfileManager
.getInstance(project
).updateStatusBar();