Eclipse 实用方法

//获得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);
				}
			}
		});


  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值