blob: 82c9cac636b54b2b46f990d1d52b901f9093a303 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
/*******************************************************************************
* Copyright (c) 2007, 2010 Wind River Systems, Inc. and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Wind River Systems - initial API and implementation
*******************************************************************************/
package org.eclipse.tcf.internal.debug.ui.commands;
import org.eclipse.core.runtime.Status;
import org.eclipse.debug.core.commands.IDebugCommandRequest;
import org.eclipse.debug.core.commands.IDisconnectHandler;
import org.eclipse.debug.core.commands.IEnabledStateRequest;
import org.eclipse.tcf.internal.debug.model.TCFError;
import org.eclipse.tcf.internal.debug.ui.model.TCFModel;
import org.eclipse.tcf.internal.debug.ui.model.TCFRunnable;
public class DisconnectCommand implements IDisconnectHandler {
private final TCFModel model;
public DisconnectCommand(TCFModel model) {
this.model = model;
}
public void canExecute(final IEnabledStateRequest monitor) {
new TCFRunnable(monitor) {
public void run() {
monitor.setEnabled(model.getLaunch().canDisconnect());
monitor.setStatus(Status.OK_STATUS);
done();
}
};
}
public boolean execute(final IDebugCommandRequest monitor) {
new TCFRunnable(monitor) {
public void run() {
try {
model.getLaunch().closeChannel();
monitor.setStatus(Status.OK_STATUS);
}
catch (Throwable x) {
monitor.setStatus(new TCFError(x).getStatus());
}
done();
}
};
return false;
}
}
|