//获得Debug视图中的lauch个数
ILaunch[] launchs = DebugPlugin.getDefault().getLaunchManager().getLaunches();
DebugPlugin.getDefault().getLaunchManager().removeLaunch(templaunch); //移除某个Launch
//获得所有的断点
IBreakpoint[] breakpoints = DebugPlugin.getDefault().getBreakpointManager().getBreakpoints();
for (int i = 0; i < breakpoints.length; i++) {
System.out.println("breakpoint : " + breakpoints[i]);
}
//获得所有的Console,并获得Console的名称及执行结果
IConsole[] consoles = ConsolePlugin.getDefault().getConsoleManager().getConsoles();
System.out.println("Console 长度:" + consoles.length);
for(IConsole con: consoles){
if(con instanceof ProcessConsole){
ProcessConsole proc = ((ProcessConsole)con);
System.out.println( "信息:" + proc.getName() + " :" + proc.getProcess().getStreamsProxy().getOutputStreamMonitor().getContents());
System.out.println("结果: " +proc.getDocument().get());//获得到控制台输出的内容
}
}
//获得当前激活的编辑器
IEditorPart editor = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
//Launch 中移除process
IProcess[] process = launch.getProcesses();
System.out.println("process长度:" + process.length);
for(IProcess pro:process){
launch.removeProcess(pro);
}
//Launch 中移除DebugTarget
IDebugTarget[] iDebugTargets = launch.getDebugTargets();
System.out.println("IDebugTarget长度:" + iDebugTargets.length);
for(IDebugTarget iTarget:iDebugTargets){
launch.removeDebugTarget(iTarget);
}
//将透视图切换至Debug视图
PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {
public void run() {
IWorkbench workbench = Activator.getDefault().getWorkbench();
IPerspectiveRegistry perspReg = workbench
.getPerspectiveRegistry();
IPerspectiveDescriptor perspDesc = perspReg
.findPerspectiveWithId("org.eclipse.debug.ui.DebugPerspective");
IWorkbenchWindow dwindow = PlatformUI.getWorkbench()
.getActiveWorkbenchWindow();
IWorkbenchPage page = dwindow.getActivePage();
if (page != null) {
page.setPerspective(perspDesc);
}
}
});