I am working on eclipse RCP/RAP single sourcing.
i need to execute some code in resotreState()
and saveState()
method of ApplicationWorkbenchAdvisor
class that is needed only for RCP but not for RAP. What is the best way to implement this?
Asked
Active
Viewed 70 times
1

Sharif
- 1,488
- 17
- 21
1 Answers
0
If the code that should only execute in RCP compiles on both platforms then you can query SWT#getPlatform()
like this:
if( !SWT.getPlatform().startsWith( "rap" ) ) {
// execute RCP code
}
If the RCP code uses API that is not available on both platforms, then I recommend to extract the code into a fragment and only deploy that fragment with the RCP applications. Search for 'rap single sourcing' for more on that.

Rüdiger Herrmann
- 20,512
- 11
- 62
- 79
-
Please see the following code : `@Override` `public IStatus saveState(IMemento memento) {` `TerminalCompatibility.saveState(memento);` `ServerStorageController.getInstance().saveState(memento);` `return super.saveState(memento);` `} ` -- this code is dependent on IMemento . Is it posible i can move this code to a RCP specific fragment. i do not want to write empty compatibility classes. – Sharif Jan 28 '15 at 10:46
-
`IMemento` is available on both platforms so that you can use the first approach and guard the code that saves state with an if condition. – Rüdiger Herrmann Jan 28 '15 at 14:26