mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
EDU-121 Forbid renaming
This commit is contained in:
@@ -61,6 +61,9 @@
|
||||
description="Show hint for answer placeholder"/>
|
||||
<action id="StudyRunAction" class="com.jetbrains.edu.learning.actions.StudyRunAction" text="Run File With Tests"
|
||||
description="Run your code with tests"/>
|
||||
<action overrides="true" id="RenameElement" class="com.jetbrains.edu.learning.actions.StudyRenameTaskFileAction"
|
||||
text="Rename..."
|
||||
/>
|
||||
|
||||
</actions>
|
||||
|
||||
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
package com.jetbrains.edu.learning.actions;
|
||||
|
||||
import com.intellij.openapi.actionSystem.CommonDataKeys;
|
||||
import com.intellij.openapi.actionSystem.DataContext;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.refactoring.actions.RenameElementAction;
|
||||
import com.jetbrains.edu.learning.StudyUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class StudyRenameTaskFileAction extends RenameElementAction {
|
||||
@Override
|
||||
protected boolean isEnabledOnDataContext(DataContext dataContext) {
|
||||
PsiElement element = CommonDataKeys.PSI_ELEMENT.getData(dataContext);
|
||||
return super.isEnabledOnDataContext(dataContext) && !isTaskFile(element);
|
||||
}
|
||||
|
||||
private static boolean isTaskFile(PsiElement element) {
|
||||
return element != null && StudyUtils.getTaskFile(element.getProject(),
|
||||
element.getContainingFile().getVirtualFile()) != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabledOnElements(@NotNull PsiElement[] elements){
|
||||
return !super.isEnabledOnElements(elements) && !isTaskFile(elements[0]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user