provide refactoring quick list (IDEA-75821)

This commit is contained in:
anna
2011-10-27 15:19:17 +02:00
parent b8ddbbc704
commit c6b40735aa
6 changed files with 89 additions and 9 deletions
@@ -0,0 +1,72 @@
/*
* Copyright 2000-2011 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.refactoring.actions;
import com.intellij.ide.actions.QuickSwitchSchemeAction;
import com.intellij.openapi.actionSystem.*;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.popup.ListPopup;
import org.jetbrains.annotations.Nullable;
public class RefactoringQuickListPopupAction extends QuickSwitchSchemeAction {
protected void fillActions(@Nullable final Project project,
final DefaultActionGroup group,
final DataContext dataContext) {
if (project == null) {
return;
}
final ActionManager actionManager = ActionManager.getInstance();
final AnAction action = actionManager.getAction(IdeActions.GROUP_REFACTOR);
if (action instanceof DefaultActionGroup) {
final AnAction[] children = ((DefaultActionGroup)action).getChildren(null);
for (AnAction child : children) {
if (child instanceof Separator) {
group.add(child);
}
else if (child instanceof BaseRefactoringAction && ((BaseRefactoringAction)child).getHandler(dataContext) != null) {
final Presentation presentation = new Presentation();
final AnActionEvent event = new AnActionEvent(null, dataContext, ActionPlaces.UNKNOWN, presentation, actionManager, 0);
child.update(event);
if (presentation.isEnabled() && presentation.isVisible()) {
group.add(child);
}
}
}
}
}
@Override
protected void showPopup(AnActionEvent e, ListPopup popup) {
final Editor editor = e.getData(PlatformDataKeys.EDITOR);
if (editor != null) {
popup.showInBestPositionFor(editor);
} else {
super.showPopup(e, popup);
}
}
protected boolean isEnabled() {
return true;
}
protected String getPopupTitle(AnActionEvent e) {
return "Refactor This";
}
}
@@ -63,6 +63,10 @@ public abstract class QuickSwitchSchemeAction extends AnAction implements DumbAw
e.getDataContext(), getAidMethod(),
true, myActionPlace);
showPopup(e, popup);
}
protected void showPopup(AnActionEvent e, ListPopup popup) {
popup.showCenteredInCurrentWindow(e.getData(PlatformDataKeys.PROJECT));
}
@@ -252,4 +252,5 @@ public interface IdeActions {
String ACTION_UNDO = "$Undo";
String ACTION_REDO = "$Redo";
String GROUP_REFACTOR = "RefactoringMenu";
}
@@ -934,5 +934,8 @@
<action id="Jdbc.RunSqlScript"><keyboard-shortcut first-keystroke="control shift F10"/></action>
<action id="Console.Execute"><keyboard-shortcut first-keystroke="ENTER"/></action>
<action id ="Refactorings.QuickListPopupAction">
<keyboard-shortcut first-keystroke="control alt shift T"/>
</action>
</keymap>
</component>
@@ -250,6 +250,9 @@
<!-- Refactor -->
<group id="RefactoringMenu" popup="true">
<action id="Refactorings.QuickListPopupAction"
class = "com.intellij.refactoring.actions.RefactoringQuickListPopupAction"
text = "Refactor This..." description="Context aware popup with list of refactoring actions"/>
<action id="RenameElement" class="com.intellij.refactoring.actions.RenameElementAction"/>
<action id="ChangeSignature" class="com.intellij.refactoring.actions.ChangeSignatureAction"/>
<separator/>
@@ -258,21 +261,21 @@
<action id="CloneElement" class="com.intellij.ide.actions.CloneElementAction"/>
<action id="SafeDelete" class="com.intellij.refactoring.actions.SafeDeleteAction"/>
<separator/>
<action id="ExtractMethod" class="com.intellij.refactoring.actions.ExtractMethodAction"/>
<action id="ExtractClass" class="com.intellij.refactoring.actions.ExtractClassAction"/>
<action id="IntroduceVariable" class="com.intellij.refactoring.actions.IntroduceVariableAction"/>
<action id="IntroduceConstant" class="com.intellij.refactoring.actions.IntroduceConstantAction"/>
<action id="IntroduceField" class="com.intellij.refactoring.actions.IntroduceFieldAction"/>
<action id="IntroduceParameter" class="com.intellij.refactoring.actions.IntroduceParameterAction"/>
<action id="Inline" class="com.intellij.refactoring.actions.InlineAction"/>
<action id="ExtractMethod" class="com.intellij.refactoring.actions.ExtractMethodAction"/>
<action id="ExtractClass" class="com.intellij.refactoring.actions.ExtractClassAction"/>
<separator/>
<action id="MembersPullUp" class="com.intellij.refactoring.actions.PullUpAction"/>
<action id="MemberPushDown" class="com.intellij.refactoring.actions.PushDownAction"/>
<separator/>
<action id="ExtractInclude" class="com.intellij.refactoring.actions.ExtractIncludeAction"/>
<action id="ExtractInterface" class="com.intellij.refactoring.actions.ExtractInterfaceAction"/>
<action id="ExtractModule" class="com.intellij.refactoring.actions.ExtractModuleAction"/>
<action id="ExtractSuperclass" class="com.intellij.refactoring.actions.ExtractSuperclassAction"/>
<action id="ExtractModule" class="com.intellij.refactoring.actions.ExtractModuleAction"/>
<add-to-group group-id="MainMenu" anchor="after" relative-to-action="CodeMenu"/>
</group>
+3 -6
View File
@@ -59,9 +59,10 @@
<group id="RefactoringMenu2">
<action id="MethodDuplicates" class="com.intellij.refactoring.actions.MethodDuplicatesAction"/>
<action id="InvertBoolean" class="com.intellij.refactoring.actions.InvertBooleanAction"/>
<action id="ReplaceMethodWithMethodObject" class="com.intellij.refactoring.actions.ReplaceMethodWithMethodObjectAction"/>
<action id="IntroduceParameterObject" class="com.intellij.refactoring.actions.IntroduceParameterObjectAction"/>
<add-to-group group-id="RefactoringMenu" anchor="before" relative-to-action="IntroduceVariable"/>
<action id="InvertBoolean" class="com.intellij.refactoring.actions.InvertBooleanAction"/>
<add-to-group group-id="RefactoringMenu" anchor="after" relative-to-action="ExtractMethod"/>
</group>
<group id="RefactoringMenu4">
@@ -83,10 +84,6 @@
<add-to-group group-id="RefactoringMenu" anchor="after" relative-to-action="MemberPushDown"/>
</group>
<action id="ReplaceMethodWithMethodObject" class="com.intellij.refactoring.actions.ReplaceMethodWithMethodObjectAction">
<add-to-group group-id="RefactoringMenu" anchor="after" relative-to-action="ExtractMethod"/>
</action>
<action id="Hotswap" class="com.intellij.debugger.actions.HotSwapAction">
<add-to-group group-id="DebugMainMenu" anchor="before" relative-to-action="StepOver"/>
</action>