mirror of https://gitee.com/makejava/EasyCode.git
parent
7e65744ef2
commit
ecb0b88f41
|
@ -4,6 +4,8 @@ import com.google.common.collect.Lists;
|
|||
import com.intellij.openapi.actionSystem.AnAction;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.actionSystem.CommonDataKeys;
|
||||
import com.intellij.openapi.actionSystem.LangDataKeys;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.PsiClass;
|
||||
|
@ -74,5 +76,23 @@ public class EasyCodeEntityAction extends AnAction {
|
|||
return psiClassList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(@NotNull AnActionEvent event) {
|
||||
// 不存在模块不展示:选择多个模块
|
||||
Project project = event.getData(CommonDataKeys.PROJECT);
|
||||
Module module = event.getData(LangDataKeys.MODULE);
|
||||
if (project == null || module == null) {
|
||||
event.getPresentation().setVisible(false);
|
||||
return;
|
||||
}
|
||||
|
||||
// 非java的文件不显示
|
||||
VirtualFile file = event.getDataContext().getData(CommonDataKeys.VIRTUAL_FILE);
|
||||
if (file != null && !file.isDirectory() && !"java".equals(file.getExtension())) {
|
||||
event.getPresentation().setVisible(false);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue