ComponentWithBrowseButton - optional remove listener on hide
[fedora-idea.git] / java / debugger / impl / src / com / intellij / debugger / engine / RemoteDebugProcessHandler.java
blob84e3032ed5797d89ca464a8b7fcdc871f95c1d09
1 /*
2 * Copyright 2000-2009 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.engine;
18 import com.intellij.debugger.DebuggerManager;
19 import com.intellij.execution.process.ProcessHandler;
20 import com.intellij.openapi.project.Project;
22 import java.io.OutputStream;
24 public class RemoteDebugProcessHandler extends ProcessHandler{
25 private final Project myProject;
27 public RemoteDebugProcessHandler(Project project) {
28 myProject = project;
31 public void startNotify() {
32 final DebugProcess debugProcess = DebuggerManager.getInstance(myProject).getDebugProcess(this);
33 final DebugProcessAdapter listener = new DebugProcessAdapter() {
34 //executed in manager thread
35 public void processDetached(DebugProcess process, boolean closedByUser) {
36 debugProcess.removeDebugProcessListener(this);
37 notifyProcessDetached();
40 debugProcess.addDebugProcessListener(listener);
41 try {
42 super.startNotify();
44 finally {
45 // in case we added our listener too late, we may have lost processDetached notification,
46 // so check here if process is detached
47 if (debugProcess.isDetached()) {
48 debugProcess.removeDebugProcessListener(listener);
49 notifyProcessDetached();
54 protected void destroyProcessImpl() {
55 DebugProcess debugProcess = DebuggerManager.getInstance(myProject).getDebugProcess(this);
56 if(debugProcess != null) {
57 debugProcess.stop(true);
61 protected void detachProcessImpl() {
62 DebugProcess debugProcess = DebuggerManager.getInstance(myProject).getDebugProcess(this);
63 if(debugProcess != null) {
64 debugProcess.stop(false);
68 public boolean detachIsDefault() {
69 return true;
72 public OutputStream getProcessInput() {
73 return null;