We have done this quite a few times. But just because we are moving from a Swing application to an Eclipse RCP application is not because we like to mess with things. This project will really let you know if you separated your controller / model code from your view code.
One suggestion is not to try to convert everything all at once. You will get a bunch of mixed code that doesn't work at all. You can start by converting portals. I would consider a portal anything in Tab, Dialog or Window, essentially autonomous. If you have a window that opens, create the window in SWT, but make it the contents of the existing AWT / Swing. This should be pretty straight forward and allow you to get used to (I really hope they weren't drunk and had good reason for this), a way to create and map parent / child controls.
One of them can happen with transparent components. Swing, with the exception of the "window" class, is all displayed in Java. This makes it easy to visualize things the way you want them to. There are some limitations in SWT:
- Borders. If you use SWT.BORDER, you are stuck in any color that uses its own component. It is best to use a PaintListener and display your own borders if you want them to be in a different style or color.
- Transparent labels, progress indicators. I could not get shortcuts or progress bars to get a transparent background. If you want them to take the parent color or pattern, you will need to display the text and other controls yourself.
- Controls SWT has composites and controls. Think of the controls as the main built-in controls that make all API calls. They cannot be subclasses, which makes work difficult.
- Tables will provide you the most trouble. Make sure everything is stable before trying to convert JTable to Table or TableViewer. You will spend some time on them, especially if you have custom editors and viewers.
I have not investigated why SWT was designed the way it was. I guess that was a good reason. It would be great if someone had a blog or protection, so I don't need to look for it. As soon as it is published, I will delete these lines, since they are not relevant to the issue.
Adding
I want to add that since you have an existing product, I assume that it works. The best advice I can give you is to never allow your code to enter a state that it cannot compile and run. If you work on the conversion and everything you check is always up and running (despite the visual differences between SWT / AWT / Swing), you will save yourself a lot of headaches in the long run. The worst thing you can do is try to solve all this at once and get the code in an unstable state for several weeks.
source share