fix resume action available in debugger toolbar if session is stopped
[fedora-idea.git] / platform / xdebugger-impl / src / com / intellij / xdebugger / impl / actions / ResumeAction.java
bloba7812e746ebebb8d1c32b8c9199a57c7462bb718
1 package com.intellij.xdebugger.impl.actions;
3 import com.intellij.execution.actions.ChooseDebugConfigurationAction;
4 import com.intellij.openapi.actionSystem.AnActionEvent;
5 import com.intellij.openapi.actionSystem.PlatformDataKeys;
6 import com.intellij.openapi.actionSystem.ActionPlaces;
7 import com.intellij.openapi.project.Project;
8 import com.intellij.xdebugger.impl.DebuggerSupport;
9 import com.intellij.xdebugger.AbstractDebuggerSession;
10 import org.jetbrains.annotations.NotNull;
12 /**
13 * @author nik
15 public class ResumeAction extends XDebuggerActionBase {
16 @Override
17 protected boolean isEnabled(AnActionEvent e) {
18 Project project = e.getData(PlatformDataKeys.PROJECT);
19 if (project == null) return false;
21 boolean haveCurrentSession = false;
22 for (DebuggerSupport support : DebuggerSupport.getDebuggerSupports()) {
23 final AbstractDebuggerSession session = support.getCurrentSession(project);
24 if (session != null && !session.isStopped()) {
25 haveCurrentSession = true;
26 if (session.isPaused()) {
27 return true;
31 return !ActionPlaces.DEBUGGER_TOOLBAR.equals(e.getPlace()) && !haveCurrentSession;
34 @Override
35 public void actionPerformed(AnActionEvent e) {
36 if (!performWithHandler(e)) {
37 new ChooseDebugConfigurationAction().actionPerformed(e);
41 @NotNull
42 protected DebuggerActionHandler getHandler(@NotNull final DebuggerSupport debuggerSupport) {
43 return debuggerSupport.getResumeActionHandler();