revive NewElementSamePlace action

This commit is contained in:
Gregory.Shrago
2014-02-01 04:48:41 +04:00
parent 32b9577e20
commit 3287d5d260
2 changed files with 21 additions and 9 deletions
@@ -84,23 +84,28 @@ public class NewElementAction extends AnAction implements DumbAware, PopupActio
@Override
public void update(AnActionEvent e){
final Presentation presentation = e.getPresentation();
final DataContext context = e.getDataContext();
final Project project = CommonDataKeys.PROJECT.getData(context);
Presentation presentation = e.getPresentation();
Project project = CommonDataKeys.PROJECT.getData(e.getDataContext());
if (project == null) {
presentation.setEnabled(false);
return;
}
if (Boolean.TRUE.equals(LangDataKeys.NO_NEW_ACTION.getData(context))) {
presentation.setEnabled(false);
return;
}
if (PlatformDataKeys.FILE_EDITOR.getData(context) != null) {
if (!isEnabled(e)) {
presentation.setEnabled(false);
return;
}
presentation.setEnabled(!ActionGroupUtil.isGroupEmpty(getGroup(context), e));
presentation.setEnabled(!ActionGroupUtil.isGroupEmpty(getGroup(e.getDataContext()), e));
}
protected boolean isEnabled(AnActionEvent e) {
if (Boolean.TRUE.equals(LangDataKeys.NO_NEW_ACTION.getData(e.getDataContext()))) {
return false;
}
if (PlatformDataKeys.FILE_EDITOR.getData(e.getDataContext()) != null) {
return false;
}
return true;
}
protected ActionGroup getGroup(DataContext dataContext) {
@@ -17,10 +17,17 @@
package com.intellij.ide.actions;
import com.intellij.ide.IdeBundle;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.LangDataKeys;
public class NewElementSamePlaceAction extends NewElementAction {
@Override
protected String getPopupTitle() {
return IdeBundle.message("title.popup.new.element.same.place");
}
@Override
protected boolean isEnabled(AnActionEvent e) {
return LangDataKeys.IDE_VIEW.getData(e.getDataContext()) != null;
}
}