public void actionPerformed(java.awt.event.ActionEvent e) {
boolean suspend = false;
VirtualMachineManager vmm = Bootstrap.virtualMachineManager();
if (DebugTab.this.launchVM.isSelected()) {
// Launch
LaunchingConnector connector = vmm.defaultConnector();
Map<String, Argument> args = connector.defaultArguments();
//Project project = OpenProjects.getInstance().getCurrentProject();
String mainClass = DebugTab.this.mainClassField.getText();
args.get("options").setValue("-cp \"" + project.getFileSet().getClasspath(mainClass) + "\"" + DebugTab.this.classpathField.getText());
args.get("suspend").setValue("true");
suspend = DebugTab.this.suspend.isSelected();
args.get("main").setValue(mainClass);
try {
DebugTab.this.vm = connector.launch(args);
StreamRedirector srErr = new StreamRedirector(vm.process().getErrorStream(), System.err);
new Thread(srErr).start();
StreamRedirector srOut = new StreamRedirector(vm.process().getInputStream(), System.out);
new Thread(srOut).start();
} catch (Exception ex) {
SystemFacade.getInstance().handleException(ex);
return;
}
} else {
// Attach
AttachingConnector connector = null;
for (AttachingConnector ac : vmm.attachingConnectors()) {
if (ac.transport().name().equals(DebugTab.this.methodCombo.getSelectedItem())) {
connector = ac;
break;
}
}
if (connector == null) {
SystemFacade.getInstance().setStatus("Attaching connector (" + DebugTab.this.methodCombo.getSelectedItem() + ") not available.");
return;
}
Map<String, Argument> args = connector.defaultArguments();
args.get("timeout").setValue("30000");
String hostname = DebugTab.this.hostField.getText();
if (connector.transport().name().equals("dt_socket")) {
if (hostname.length() == 0) {
args.get("hostname").setValue("127.0.0.1");
} else {
args.get("hostname").setValue(hostname);
}
args.get("port").setValue(DebugTab.this.portField.getText());
} else {
args.get("name").setValue(hostname);
}
try {
DebugTab.this.vm = connector.attach(args);
DebugTab.this.vm.suspend();
} catch (Exception ex) {
SystemFacade.getInstance().handleException(ex);
return;
}