simplify getting project from AnActionEvent

This commit is contained in:
Konstantin Bulenkov
2016-05-24 01:52:46 +02:00
parent 4a328a3dc4
commit 557ded7990
5 changed files with 21 additions and 29 deletions
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2015 JetBrains s.r.o.
* Copyright 2000-2016 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.
@@ -22,7 +22,6 @@ import com.intellij.debugger.settings.NodeRendererSettings;
import com.intellij.idea.ActionsBundle;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.CommonDataKeys;
import com.intellij.openapi.options.Configurable;
import com.intellij.openapi.options.ConfigurationException;
import com.intellij.openapi.options.TabbedConfigurable;
@@ -49,7 +48,7 @@ public class CustomizeContextViewAction extends XDebuggerTreeActionBase {
@Override
protected void perform(XValueNodeImpl node, @NotNull String nodeName, AnActionEvent e) {
final Project project = CommonDataKeys.PROJECT.getData(e.getDataContext());
final Project project = e.getProject();
Disposable disposable = Disposer.newDisposable();
final MyTabbedConfigurable configurable = new MyTabbedConfigurable(disposable);
SingleConfigurableEditor editor = new SingleConfigurableEditor(project, configurable) {
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2015 JetBrains s.r.o.
* Copyright 2000-2016 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.
@@ -26,14 +26,17 @@ import com.intellij.debugger.impl.DebuggerSession;
import com.intellij.debugger.ui.impl.watch.DebuggerTreeNodeImpl;
import com.intellij.debugger.ui.impl.watch.NodeDescriptorImpl;
import com.intellij.debugger.ui.impl.watch.WatchItemDescriptor;
import com.intellij.openapi.actionSystem.*;
import com.intellij.openapi.actionSystem.ActionManager;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.IdeActions;
import com.intellij.openapi.actionSystem.Presentation;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Computable;
public class EditSourceAction extends DebuggerAction{
public void actionPerformed(AnActionEvent e) {
final Project project = CommonDataKeys.PROJECT.getData(e.getDataContext());
final Project project = e.getProject();
if(project == null) {
return;
@@ -89,7 +92,7 @@ public class EditSourceAction extends DebuggerAction{
}
public void update(AnActionEvent e) {
final Project project = CommonDataKeys.PROJECT.getData(e.getDataContext());
final Project project = e.getProject();
final DebuggerContextImpl debuggerContext = getDebuggerContext(e.getDataContext());
final DebuggerTreeNodeImpl node = getSelectedNode(e.getDataContext());
@@ -24,7 +24,6 @@ import com.intellij.debugger.impl.DebuggerSession;
import com.intellij.ide.actions.ExportToTextFileAction;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.CommonDataKeys;
import com.intellij.openapi.actionSystem.Presentation;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.application.ModalityState;
@@ -36,7 +35,7 @@ import java.util.List;
public class ExportThreadsAction extends AnAction implements AnAction.TransparentUpdate {
public void actionPerformed(AnActionEvent e) {
final Project project = CommonDataKeys.PROJECT.getData(e.getDataContext());
final Project project = e.getProject();
if (project == null) {
return;
}
@@ -58,9 +57,9 @@ public class ExportThreadsAction extends AnAction implements AnAction.Transparen
}
}
public void update(AnActionEvent event){
Presentation presentation = event.getPresentation();
Project project = CommonDataKeys.PROJECT.getData(event.getDataContext());
public void update(AnActionEvent e){
Presentation presentation = e.getPresentation();
Project project = e.getProject();
if (project == null) {
presentation.setEnabled(false);
return;
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2015 JetBrains s.r.o.
* Copyright 2000-2016 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.
@@ -22,8 +22,6 @@ import com.intellij.debugger.ui.HotSwapUI;
import com.intellij.debugger.ui.HotSwapUIImpl;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.CommonDataKeys;
import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.project.Project;
/**
@@ -32,12 +30,7 @@ import com.intellij.openapi.project.Project;
public class HotSwapAction extends AnAction{
public void actionPerformed(AnActionEvent e) {
DataContext dataContext = e.getDataContext();
Project project = CommonDataKeys.PROJECT.getData(dataContext);
if(project == null) {
return;
}
Project project = e.getProject();
DebuggerManagerEx debuggerManager = DebuggerManagerEx.getInstanceEx(project);
DebuggerSession session = debuggerManager.getContext().getDebuggerSession();
@@ -47,9 +40,8 @@ public class HotSwapAction extends AnAction{
}
public void update(AnActionEvent e) {
DataContext dataContext = e.getDataContext();
Project project = CommonDataKeys.PROJECT.getData(dataContext);
if(project == null) {
Project project = e.getProject();
if (project == null) {
e.getPresentation().setEnabled(false);
return;
}
@@ -26,7 +26,6 @@ import com.intellij.debugger.impl.DebuggerUtilsEx;
import com.intellij.debugger.jdi.VirtualMachineProxyImpl;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.CommonDataKeys;
import com.intellij.openapi.actionSystem.Presentation;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.application.ModalityState;
@@ -46,7 +45,7 @@ import java.util.Map;
public class ThreadDumpAction extends AnAction implements AnAction.TransparentUpdate {
public void actionPerformed(AnActionEvent e) {
final Project project = CommonDataKeys.PROJECT.getData(e.getDataContext());
final Project project = e.getProject();
if (project == null) {
return;
}
@@ -321,9 +320,9 @@ public class ThreadDumpAction extends AnAction implements AnAction.TransparentUp
}
public void update(AnActionEvent event){
Presentation presentation = event.getPresentation();
Project project = CommonDataKeys.PROJECT.getData(event.getDataContext());
public void update(AnActionEvent e){
Presentation presentation = e.getPresentation();
Project project = e.getProject();
if (project == null) {
presentation.setEnabled(false);
return;