Tuesday, October 27, 2009

Section 7.3.  Checkpoint










7.3. Checkpoint


Now is a good time to run Hyperbola. Select a contact in the Contacts view and run the Chat action. A chat editor should open as shown in Figure 7-1. Notice that the chat editor is rather narrow. Even if you make the window bigger, the chat editor stays skinny. Remember all the way back to Chapter 5, when you defined the Hyperbola perspective? There we were not concerned about the editor area, and we wanted the Contacts view to take the whole window.


To fix this, first increase the default size of the Hyperbola windowwe need more room now. Go to the ApplicationWorkbenchWindowAdvisor's method preWindowOpen() and change the initial size of the window. The user can ultimately decide on the size of the window and all the views and editors, but it's always good to provide a good default layout.


Next, go to the Perspective class and change it to show the editor area. While you are there, shrink the relative size of the Contacts view by changing the ratio to .50f. These changes are shown below:


org.eclipsercp.hyperbola/Perspective
public void createInitialLayout(IPageLayout layout) {
layout.setEditorAreaVisible(false);
layout.setEditorAreaVisible(true);
layout.addStandaloneView(ContactsView.ID, false,
IPageLayout.LEFT, .50f, layout.getEditorArea());
}


The result of these changes is shown in Figure 7-5. The editor area is empty, but shown, and the Contacts view takes 50% of the page width.



Figure 7-5. Hyperbola with the editor area shown







If you want to get fancy, you can show and hide the editor area automatically by adding an action that uses IPartListeners to listen for editors closing and then hides the area when the last editor is closed using IWorkbenchPage.setEditorAreaVisible(boolean).












No comments:

Post a Comment