This commit is contained in:
Konstantin Bulenkov
2014-04-29 22:48:43 +04:00
parent b02b4c1912
commit 577cef9f18
4 changed files with 16 additions and 23 deletions
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
* Copyright 2000-2014 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.
@@ -25,8 +25,8 @@ import com.intellij.openapi.editor.actionSystem.DocCommandGroupId;
import com.intellij.openapi.project.Project;
import com.intellij.psi.PsiFile;
import com.intellij.psi.util.PsiUtilBase;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
* @author Dmitry Avdeev
@@ -34,10 +34,9 @@ import org.jetbrains.annotations.NotNull;
public abstract class CodeInsightAction extends AnAction {
@Override
public void actionPerformed(AnActionEvent e) {
DataContext dataContext = e.getDataContext();
Project project = CommonDataKeys.PROJECT.getData(dataContext);
Project project = e.getProject();
if (project != null) {
Editor editor = getEditor(dataContext, project);
Editor editor = getEditor(e.getDataContext(), project);
actionPerformedImpl(project, editor);
}
}
@@ -74,17 +73,16 @@ public abstract class CodeInsightAction extends AnAction {
}
@Override
public void update(AnActionEvent event) {
Presentation presentation = event.getPresentation();
DataContext dataContext = event.getDataContext();
public void update(AnActionEvent e) {
Presentation presentation = e.getPresentation();
Project project = CommonDataKeys.PROJECT.getData(dataContext);
Project project = e.getProject();
if (project == null) {
presentation.setEnabled(false);
return;
}
Editor editor = getEditor(dataContext, project);
Editor editor = getEditor(e.getDataContext(), project);
if (editor == null) {
presentation.setEnabled(false);
return;
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2014 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.
@@ -23,7 +23,6 @@ import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.InputValidator;
import com.intellij.psi.PsiDirectory;
import com.intellij.psi.PsiElement;
import com.intellij.util.IncorrectOperationException;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
@@ -63,14 +62,12 @@ public abstract class CreateElementActionBase extends AnAction {
@Override
public final void actionPerformed(final AnActionEvent e) {
final DataContext dataContext = e.getDataContext();
final IdeView view = LangDataKeys.IDE_VIEW.getData(dataContext);
final IdeView view = e.getData(LangDataKeys.IDE_VIEW);
if (view == null) {
return;
}
final Project project = CommonDataKeys.PROJECT.getData(dataContext);
final Project project = e.getProject();
final PsiDirectory dir = view.getOrChooseDirectory();
if (dir == null) return;
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2012 JetBrains s.r.o.
* Copyright 2000-2014 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.
@@ -58,7 +58,7 @@ public abstract class BaseAnalysisAction extends AnAction {
public void update(AnActionEvent event) {
Presentation presentation = event.getPresentation();
final DataContext dataContext = event.getDataContext();
final Project project = CommonDataKeys.PROJECT.getData(dataContext);
final Project project = event.getProject();
final boolean dumbMode = project == null || DumbService.getInstance(project).isDumb();
presentation.setEnabled(!dumbMode && getInspectionScope(dataContext) != null);
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2012 JetBrains s.r.o.
* Copyright 2000-2014 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.
@@ -18,8 +18,6 @@ package com.intellij.application.options.codeStyle.arrangement.action;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.CommonDataKeys;
import com.intellij.openapi.actionSystem.LangDataKeys;
import com.intellij.openapi.actionSystem.PlatformDataKeys;
import com.intellij.openapi.command.CommandProcessor;
import com.intellij.openapi.components.ServiceManager;
import com.intellij.openapi.editor.Document;
@@ -52,12 +50,12 @@ public class RearrangeCodeAction extends AnAction {
@Override
public void actionPerformed(AnActionEvent e) {
final Project project = CommonDataKeys.PROJECT.getData(e.getDataContext());
final Project project = e.getProject();
if (project == null) {
return;
}
final Editor editor = CommonDataKeys.EDITOR.getData(e.getDataContext());
final Editor editor = e.getData(CommonDataKeys.EDITOR);
if (editor == null) {
return;
}