5.1. Continuing from the ShellChapter 4, "The Hyperbola Application," gave you a good idea of all the classes and files needed for the skeleton Hyperbola application. Let's critique the skeleton as shown in Figure 5-2 and see how we can improve. Figure 5-2. Hyperbola skeleton
Let's fix the resize and position bug and address the other issues in the next few chapters. 5.1.1. Saving Window Location and SizeOne of the problems with the skeleton code is that when the window was resized or moved and the application re-run, the window's size and position was reset. This is annoying. The good news is that it's really easy to fixthe Workbench contains code that saves settings for open windows. It's disabled by default as saving and restoring window state can be expensive, and for some applications, not even necessary. To enable it, first override the WorkbenchAdvisor.initialize() method from within ApplicationWorkbenchAdvisor, as shown in the snippet below. A trick is to open the ApplicationWorkbenchAdvisor class and type "ini", then "Ctrl+Space". A pop-up appears, listing the possible methods that can be overridden. Simply select the initialize() method to get a skeleton. This method is called by Eclipse to mark the beginning of the advisor's lifecycle. This hooks in at the earliest possible point to enable save and restore. org.eclipsercp.hyperbola/ApplicationWorkbenchAdvisor
public void initialize(IWorkbenchConfigurer configurer) {
configurer.setSaveAndRestore(true);
} |