IDEA-CR-22016 RUBY-19336 add 'Rename file' action on the editor tab context menu onto PhpStorm, RubyMine, WebStorm

This commit is contained in:
Dmitry.Krasilschikov
2017-06-30 13:35:00 +03:00
parent 7b7498be2c
commit 27768a33a8
3 changed files with 36 additions and 5 deletions
@@ -0,0 +1,27 @@
/*
* Copyright 2000-2017 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.psi.PsiClassOwner;
import com.intellij.psi.PsiFile;
import org.jetbrains.annotations.NotNull;
public class RenameFileActionImpl extends RenameFileAction {
@Override
protected boolean enabledInProjectView(@NotNull PsiFile file) {
return file instanceof PsiClassOwner;
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2017 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.
@@ -19,9 +19,9 @@ import com.intellij.openapi.actionSystem.*;
import com.intellij.openapi.project.DumbAware;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.PsiClassOwner;
import com.intellij.psi.PsiFile;
import com.intellij.refactoring.rename.PsiElementRenameHandler;
import org.jetbrains.annotations.NotNull;
/**
* @author ven
@@ -48,8 +48,8 @@ public class RenameFileAction extends AnAction implements DumbAware {
PsiFile file = e.getData(CommonDataKeys.PSI_FILE);
Presentation presentation = e.getPresentation();
String place = e.getPlace();
boolean enabled = file != null &&
(file instanceof PsiClassOwner || !ActionPlaces.PROJECT_VIEW_POPUP.equals(place)) &&
boolean enabled = file != null &&
(enabledInProjectView(file) || !ActionPlaces.PROJECT_VIEW_POPUP.equals(place)) &&
place != ActionPlaces.EDITOR_POPUP && e.getData(CommonDataKeys.PROJECT) != null;
presentation.setEnabled(enabled);
presentation.setVisible(enabled);
@@ -58,4 +58,8 @@ public class RenameFileAction extends AnAction implements DumbAware {
presentation.setDescription("Rename selected file");
}
}
protected boolean enabledInProjectView(@NotNull PsiFile file) {
return true;
}
}
+1 -1
View File
@@ -83,7 +83,7 @@
<add-to-group group-id="IntroduceActionsGroup" anchor="after" relative-to-action="IntroduceFunctionalParameter"/>
</action>
<action id="RenameFile" class="com.intellij.refactoring.actions.RenameFileAction">
<action id="RenameFile" class="com.intellij.refactoring.actions.RenameFileActionImpl">
<add-to-group group-id="RefactoringMenu" anchor="after" relative-to-action="RenameElement"/>
<add-to-group group-id="EditorTabPopupMenuEx" anchor="after" relative-to-action="AddAllToFavorites"/>
</action>