设置属性以在eclipse中启动配置

时间:2013-04-05 10:35:38

标签: eclipse configuration attributes launch

eclispe3.7中的一个应用程序,我想在每次启动时为启动配置设置一个属性。 Iam使用以下命令设置属性,但在获取attribte时,它仅显示默认属性值。

launch.getLaunchConfiguration().getWorkingCopy().setAttribute(IGDBLaunchConfigurationConstants.ATTR_PORT, value);

在另一个类中,从第一个类开始使用以下代码:

launch.getLaunchConfiguration()..getWorkingCopy().getAttributes();

为什么无法设置属性?请帮帮我......

2 个答案:

答案 0 :(得分:0)

我怀疑问题是你每次调用getWorkingCopy()都会得到不同的工作副本。如果在调试器中检查工作副本对象的Java ID,那么您将能够确定。

希望这有帮助,  托马斯

答案 1 :(得分:0)

当你使用getWorkingCopy()时,你会得到原始状态的副本,但你需要使用doSave()。

ILaunchConfigurationWorkingCopy launchCopy = launch.getWorkingCopy();
launchCopy.setAttribute(IGDBLaunchConfigurationConstants.ATTR_PORT, value);
launch = launchCopy.doSave();

您可以阅读,这是如何运作的:http://comments.gmane.org/gmane.comp.ide.eclipse.platform.debug.devel/240

相关问题