Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/fortran/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Eclipse rcp 我只需要为RCP而不是RAP执行一些代码,我怎么能这样做呢_Eclipse Rcp_Eclipse Rap - Fatal编程技术网

Eclipse rcp 我只需要为RCP而不是RAP执行一些代码,我怎么能这样做呢

Eclipse rcp 我只需要为RCP而不是RAP执行一些代码,我怎么能这样做呢,eclipse-rcp,eclipse-rap,Eclipse Rcp,Eclipse Rap,我正在从事EclipseRCP/RAP单一采购。 我需要在applicationworkbenchhadvisor类的resotreState()和saveState()方法中执行一些代码,这些代码仅用于RCP,而不用于RAP。实现这一点的最佳方法是什么?如果只应在RCP中执行的代码在两种平台上都编译,那么您可以像这样查询SWT#getPlatform(): if(!SWT.getPlatform().startsWith(“rap”)){ //执行RCP代码 } 如果RCP代码使用的API在

我正在从事EclipseRCP/RAP单一采购。
我需要在
applicationworkbenchhadvisor
类的
resotreState()
saveState()
方法中执行一些代码,这些代码仅用于RCP,而不用于RAP。实现这一点的最佳方法是什么?

如果只应在RCP中执行的代码在两种平台上都编译,那么您可以像这样查询
SWT#getPlatform()

if(!SWT.getPlatform().startsWith(“rap”)){
//执行RCP代码
}

如果RCP代码使用的API在两个平台上都不可用,那么我建议将代码提取到片段中,并仅将该片段与RCP应用程序一起部署。搜索“rap single sourcing”了解更多信息。

请查看以下代码:
@Override
public-IStatus-saveState(IMemento-memento){
TerminalCompatibility.saveState(memento);
ServerStorageController.getInstance().saveState(memento);
返回super.saveState(memento);
}
--此代码依赖于IMemento。我能把这段代码移到一个RCP特定的片段吗。我不想编写空的兼容类。
IMemento
在两种平台上都可用,因此您可以使用第一种方法,并使用if条件保护保存状态的代码。