| 
What this is
 Other links
 The source code
Code snippets for the exercises
===============================
Exercise 2 (Adding Summary view):
// Comment for the SummaryView:
/**
 * A view that shows a summary of the current adventure package.
 */
	/**
	 * Updates the summary by setting the viewer's input 
	 * to be the Cart from the active editor, or null if none.
	 */
	private void updateSummary() {
		IEditorPart editor = getSite().getPage().getActiveEditor();
		Cart cart = null;
		if (editor instanceof CartEditor) {
			CartEditor cartEditor = (CartEditor) editor;
			cart = cartEditor.getCart();
		}
		viewer.setInput(cart);
	}
Exercise 4 (Tracking part lifecycle events):
	// part listener for tracking the active editor	
	private IPartListener partListener = new IPartListener() {
		public void partActivated(IWorkbenchPart part) {
			// a cart editor may have been activated
			updateSummary();
		}
		public void partBroughtToTop(IWorkbenchPart part) {
			// a cart editor may have been brought to top (without being activated)
			updateSummary();
		}
		public void partClosed(IWorkbenchPart part) {
			// a cart editor may have been closed
			updateSummary();
		}
		public void partDeactivated(IWorkbenchPart part) {
			// no need to track deactivation
		}
		public void partOpened(IWorkbenchPart part) {
			// a cart editor may have been opened 
			updateSummary();
		}
	};
 | 
| ... this post is sponsored by my books ... | |
         
           #1 New Release!  | 
      
         
           FP Best Seller  | 
  
Copyright 1998-2024 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse 
URI on this website is
paid back to open source projects.