[英]How to programmatically check whether eclipse console build or GUI build is launched?
I am writing CDT plug-in for Eclipse IDE. 我正在为Eclipse IDE编写CDT插件。 I want to show a warning dialog to user if GUI Eclipse instance is launched, otherwise if console build is launched just write to stderr.
如果启动了GUI Eclipse实例,我想向用户显示一个警告对话框,否则如果启动了控制台构建,则只需写入stderr。 How can I determine programmatically which of GUI and console Eclipse is launched?
如何以编程方式确定启动哪个GUI和控制台Eclipse?
UPDATE: This code works properly only if a corresponding system property is set. 更新:此代码仅在设置了相应的系统属性时才能正常工作。
boolean isHeadless = System.getProperty("eclipse.application")
.equals("org.eclipse.cdt.managedbuilder.core.headlessbuild");
This code checks an argument passed as an "application", it is "org.eclipse.cdt.managedbuilder.core.headlessbuild" in case of a headless eclipse launch. 此代码检查作为“应用程序”传递的参数,如果是无头eclipse启动,则为“org.eclipse.cdt.managedbuilder.core.headlessbuild”。
You could also check SWT plugin's state: 您还可以检查SWT插件的状态:
Bundle swtBunble = Platform.getBundle("org.eclipse.swt");
boolean isHeadless = (swtBunble==null || swtBunble.getState() != Bundle.ACTIVE);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.