don't show "update copyright" action in context menu if there are no copyright profiles configured (IDEA-81700)

This commit is contained in:
Dmitry Jemerov
2012-02-23 16:07:16 +01:00
parent 093196d7db
commit 0ac6d8208e
2 changed files with 10 additions and 2 deletions
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2012 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -228,6 +228,10 @@ public class CopyrightManager extends AbstractProjectComponent implements JDOMEx
return myCopyrights.values();
}
public boolean hasAnyCopyrights() {
return myDefaultCopyright != null || !myModule2Copyrights.isEmpty();
}
@Nullable
public CopyrightProfile getCopyrightOptions(@NotNull PsiFile file) {
final VirtualFile virtualFile = file.getVirtualFile();
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2012 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -23,6 +23,7 @@ import com.intellij.openapi.project.Project;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.*;
import com.intellij.psi.util.PsiUtilCore;
import com.maddyhome.idea.copyright.CopyrightManager;
import com.maddyhome.idea.copyright.pattern.FileUtil;
import com.maddyhome.idea.copyright.util.FileTypeUtil;
@@ -45,6 +46,9 @@ public class UpdateCopyrightAction extends AnAction {
return false;
}
if (!CopyrightManager.getInstance(project).hasAnyCopyrights()) {
return false;
}
final VirtualFile[] files = PlatformDataKeys.VIRTUAL_FILE_ARRAY.getData(context);
final Editor editor = PlatformDataKeys.EDITOR.getData(context);
if (editor != null) {