diff --git a/java/java-impl/src/com/intellij/refactoring/actions/RenameFileActionImpl.java b/java/java-impl/src/com/intellij/refactoring/actions/RenameFileActionImpl.java new file mode 100644 index 000000000000..95e7b3bfd292 --- /dev/null +++ b/java/java-impl/src/com/intellij/refactoring/actions/RenameFileActionImpl.java @@ -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; + } +} diff --git a/java/java-impl/src/com/intellij/refactoring/actions/RenameFileAction.java b/platform/lang-impl/src/com/intellij/refactoring/actions/RenameFileAction.java similarity index 86% rename from java/java-impl/src/com/intellij/refactoring/actions/RenameFileAction.java rename to platform/lang-impl/src/com/intellij/refactoring/actions/RenameFileAction.java index 56d07e1985a5..c7c04f4d0ae9 100644 --- a/java/java-impl/src/com/intellij/refactoring/actions/RenameFileAction.java +++ b/platform/lang-impl/src/com/intellij/refactoring/actions/RenameFileAction.java @@ -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; + } } diff --git a/resources/src/idea/JavaActions.xml b/resources/src/idea/JavaActions.xml index 676ef3dbc23f..d212692e1d9e 100644 --- a/resources/src/idea/JavaActions.xml +++ b/resources/src/idea/JavaActions.xml @@ -83,7 +83,7 @@ - +