2 * Copyright 2000-2015 JetBrains s.r.o.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 package com.intellij.debugger.actions;
18 import com.intellij.debugger.DebuggerBundle;
19 import com.intellij.debugger.engine.DebugProcessImpl;
20 import com.intellij.debugger.engine.events.SuspendContextCommandImpl;
21 import com.intellij.debugger.impl.DebuggerContextImpl;
22 import com.intellij.debugger.jdi.ThreadReferenceProxyImpl;
23 import com.intellij.debugger.ui.impl.watch.DebuggerTreeNodeImpl;
24 import com.intellij.debugger.ui.impl.watch.NodeDescriptorImpl;
25 import com.intellij.debugger.ui.impl.watch.ThreadDescriptorImpl;
26 import com.intellij.openapi.actionSystem.AnActionEvent;
27 import com.intellij.openapi.actionSystem.Presentation;
28 import com.sun.jdi.request.EventRequest;
35 public class ResumeThreadAction extends DebuggerAction{
36 public void actionPerformed(final AnActionEvent e) {
37 DebuggerTreeNodeImpl[] selectedNode = getSelectedNodes(e.getDataContext());
38 final DebuggerContextImpl debuggerContext = getDebuggerContext(e.getDataContext());
39 final DebugProcessImpl debugProcess = debuggerContext.getDebugProcess();
41 //noinspection ConstantConditions
42 for (final DebuggerTreeNodeImpl debuggerTreeNode : selectedNode) {
43 final ThreadDescriptorImpl threadDescriptor = ((ThreadDescriptorImpl)debuggerTreeNode.getDescriptor());
45 if (threadDescriptor.isSuspended()) {
46 final ThreadReferenceProxyImpl thread = threadDescriptor.getThreadReference();
47 debugProcess.getManagerThread().schedule(new SuspendContextCommandImpl(debuggerContext.getSuspendContext()) {
48 public void contextAction() throws Exception {
49 debugProcess.createResumeThreadCommand(getSuspendContext(), thread).run();
50 debuggerTreeNode.calcValue();
57 public void update(AnActionEvent e) {
58 DebuggerTreeNodeImpl[] selectedNodes = getSelectedNodes(e.getDataContext());
60 boolean visible = false;
61 boolean enabled = false;
62 String text = DebuggerBundle.message("action.resume.thread.text.resume");
64 if(selectedNodes != null && selectedNodes.length > 0){
67 for (DebuggerTreeNodeImpl selectedNode : selectedNodes) {
68 final NodeDescriptorImpl threadDescriptor = selectedNode.getDescriptor();
69 if (!(threadDescriptor instanceof ThreadDescriptorImpl) || !((ThreadDescriptorImpl)threadDescriptor).isSuspended()) {
75 for (DebuggerTreeNodeImpl selectedNode : selectedNodes) {
76 final ThreadDescriptorImpl threadDescriptor = (ThreadDescriptorImpl)selectedNode.getDescriptor();
77 if (threadDescriptor.getSuspendContext().getSuspendPolicy() == EventRequest.SUSPEND_ALL && !threadDescriptor.isFrozen()) {
82 // if (threadDescriptor.isFrozen()) {
83 // text = DebuggerBundle.message("action.resume.thread.text.unfreeze");
89 final Presentation presentation = e.getPresentation();
90 presentation.setText(text);
91 presentation.setVisible(visible);
92 presentation.setEnabled(enabled);