make it possible to provide custom name for Delete action via TitledHandler interface (IDEA-63434)

This commit is contained in:
Dmitry Jemerov
2011-10-13 15:06:37 +02:00
parent ce869dba84
commit 66b2b6b7a4
9 changed files with 20 additions and 11 deletions
@@ -14,13 +14,11 @@
* limitations under the License.
*/
package com.intellij.refactoring.lang;
import com.intellij.refactoring.RefactoringActionHandler;
package com.intellij.ide;
/**
* @author yole
*/
public interface TitledHandler extends RefactoringActionHandler {
public interface TitledHandler {
String getActionTitle();
}
@@ -17,6 +17,7 @@
package com.intellij.ide.projectView.impl;
import com.intellij.ide.IdeBundle;
import com.intellij.ide.TitledHandler;
import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.actionSystem.LangDataKeys;
import com.intellij.openapi.application.ApplicationManager;
@@ -34,7 +35,6 @@ import com.intellij.openapi.util.Ref;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
import com.intellij.refactoring.RefactoringBundle;
import com.intellij.refactoring.lang.TitledHandler;
import com.intellij.refactoring.rename.RenameHandler;
import org.jetbrains.annotations.NotNull;
@@ -17,6 +17,7 @@
package com.intellij.openapi.roots.ui.configuration.actions;
import com.intellij.ide.DeleteProvider;
import com.intellij.ide.TitledHandler;
import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.actionSystem.LangDataKeys;
import com.intellij.openapi.actionSystem.PlatformDataKeys;
@@ -40,7 +41,7 @@ import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
public class ModuleDeleteProvider implements DeleteProvider {
public class ModuleDeleteProvider implements DeleteProvider, TitledHandler {
public boolean canDeleteElement(DataContext dataContext) {
return LangDataKeys.MODULE_CONTEXT_ARRAY.getData(dataContext) != null;
}
@@ -84,6 +85,11 @@ public class ModuleDeleteProvider implements DeleteProvider {
}, ProjectBundle.message("module.remove.command"), null);
}
@Override
public String getActionTitle() {
return "Remove Module";
}
public static void removeModule(@NotNull final Module moduleToRemove,
@Nullable ModifiableRootModel modifiableRootModelToRemove,
@NotNull Collection<ModifiableRootModel> otherModuleRootModels,
@@ -16,6 +16,7 @@
package com.intellij.refactoring.actions;
import com.intellij.ide.TitledHandler;
import com.intellij.lang.Language;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.DataContext;
@@ -23,7 +24,6 @@ import com.intellij.openapi.actionSystem.LangDataKeys;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
import com.intellij.refactoring.RefactoringActionHandler;
import com.intellij.refactoring.lang.TitledHandler;
import com.intellij.refactoring.lang.LanguageExtractInclude;
/**
@@ -19,6 +19,7 @@ package com.intellij.refactoring.lang;
import com.intellij.codeInsight.PsiEquivalenceUtil;
import com.intellij.codeInsight.highlighting.HighlightManager;
import com.intellij.find.FindManager;
import com.intellij.ide.TitledHandler;
import com.intellij.lang.Language;
import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.application.ApplicationManager;
@@ -16,6 +16,7 @@
package com.intellij.refactoring.rename;
import com.intellij.CommonBundle;
import com.intellij.ide.TitledHandler;
import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.actionSystem.LangDataKeys;
import com.intellij.openapi.actionSystem.PlatformDataKeys;
@@ -37,7 +38,6 @@ import com.intellij.psi.PsiFile;
import com.intellij.psi.search.GlobalSearchScope;
import com.intellij.refactoring.BaseRefactoringProcessor;
import com.intellij.refactoring.RefactoringBundle;
import com.intellij.refactoring.lang.TitledHandler;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -16,6 +16,7 @@
package com.intellij.refactoring.rename;
import com.intellij.ide.TitledHandler;
import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.actionSystem.PlatformDataKeys;
import com.intellij.openapi.application.ApplicationManager;
@@ -25,7 +26,6 @@ import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.DialogWrapper;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.refactoring.RefactoringBundle;
import com.intellij.refactoring.lang.TitledHandler;
import com.intellij.refactoring.util.RadioUpDownListener;
import com.intellij.util.ArrayUtil;
import com.intellij.util.containers.HashSet;
@@ -18,10 +18,11 @@ package com.intellij.ide.actions;
import com.intellij.ide.DeleteProvider;
import com.intellij.ide.IdeBundle;
import com.intellij.ide.TitledHandler;
import com.intellij.openapi.actionSystem.*;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.project.DumbAware;
import com.intellij.openapi.project.Project;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
@@ -69,6 +70,9 @@ public class DeleteAction extends AnAction implements DumbAware {
Object component = PlatformDataKeys.CONTEXT_COMPONENT.getData(dataContext);
if (component instanceof JTextComponent) provider = null; // Do not override text deletion
}
if (provider instanceof TitledHandler) {
presentation.setText(((TitledHandler)provider).getActionTitle());
}
final boolean canDelete = provider != null && provider.canDeleteElement(dataContext);
if (ActionPlaces.isPopupPlace(event.getPlace())) {
presentation.setVisible(canDelete);
@@ -15,6 +15,7 @@
*/
package org.jetbrains.plugins.groovy.refactoring.rename;
import com.intellij.ide.TitledHandler;
import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.actionSystem.LangDataKeys;
import com.intellij.openapi.actionSystem.PlatformDataKeys;
@@ -25,7 +26,6 @@ import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
import com.intellij.psi.PsiMember;
import com.intellij.psi.PsiMethod;
import com.intellij.refactoring.lang.TitledHandler;
import com.intellij.refactoring.rename.PsiElementRenameHandler;
import com.intellij.refactoring.rename.RenameHandler;
import org.jetbrains.annotations.NotNull;