Thursday, March 5, 2009

Add Nested Menu Items to an Eclipse RCP Application

This article shows how to add nested menu items to a menu in an Eclipse RCP application and builds off of a clean Hello World Eclipse RCP Application. As shown in the article Add a Menu to an Eclipse RCP Application, it is very easy to add a File menu containing the Exit action. Here the Exit action as well as About and Preferences are added to a submenu called Expand in the File menu to demonstrate nested menu items.

Step 0: Create a HelloWorld RCP application.

Step 1: Add the nested menu actions. Open up the ApplicationActionBarAdvisor class and add the three About, Preferences, and Exit actions as private fields. In makeactions(), define the actions and register them. In the fillMenuBar() method, create two instances of MenuManager, one for the File and one for Expand. Add the three actions to the Expand MenuManager. A Separator is added before the Exit action for the sake of demonstrating this nice menu organizing feature. Next add the Expand MenuManager to the File MenuManager. Finally add the File MenuManager to the menubar.

package com.blogspot.obscuredclarity.nestedmenu;

import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.MenuManager;
import org.eclipse.jface.action.Separator;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.actions.ActionFactory;
import org.eclipse.ui.actions.ActionFactory.IWorkbenchAction;
import org.eclipse.ui.application.ActionBarAdvisor;
import org.eclipse.ui.application.IActionBarConfigurer;

public class ApplicationActionBarAdvisor extends ActionBarAdvisor {

private IWorkbenchAction aboutAction;
private IWorkbenchAction preferencesAction;
private IWorkbenchAction exitAction;

public ApplicationActionBarAdvisor(IActionBarConfigurer configurer) {
super(configurer);
}

protected void makeActions(IWorkbenchWindow window) {

//ActionFactory Actions, the ActionFactory defines a set of common actions and can be used in our application.
aboutAction = ActionFactory.ABOUT.create(window);
register(aboutAction); //register the action so it is deleted when the Workbench window is closed
preferencesAction = ActionFactory.PREFERENCES.create(window);
register(preferencesAction);
exitAction = ActionFactory.QUIT.create(window);
register(exitAction);
}

protected void fillMenuBar(IMenuManager menuBar) {

MenuManager fileMenu = new MenuManager("&File", "file"); //create a menuManager to take care of all submenus in "File"

MenuManager expandingMenu = new MenuManager("&Expand", "expand");
expandingMenu.add(aboutAction); //Add the "about" action
expandingMenu.add(preferencesAction); //Add the "preferences" action
expandingMenu.add(new Separator()); //Add a horizontal separator
expandingMenu.add(exitAction); //Add the "exit" action

fileMenu.add(expandingMenu); //Add the expanding menu to the "File" menu
menuBar.add(fileMenu); //Add the "File" menu to the menuBar
}

}



Step 2: Run the application and test if everything worked. Your application should now have a new menu containing a group of actions nested in a parent menu:



Piece of cake!


<--- Previous - Verify User Intent Before Closing an Eclipse RCP Application
---> Next - Add a Custom Menu Action to an Eclipse RCP Application

Also see: Eclipse RCP Tutorial Table of Contents

Wednesday, March 4, 2009

11 Spectacular Bird Photos by David Hemmings

All the bird photos in this post are copyright David Hemmings found on Photo.net. I just wanted to share these amazing bird photos that I discovered a while back as well as promote David's phenomenal work. These are just a small sampling from all his work, so be sure to check out the rest of his work. Thanks for the amazing shots and the inspiration, David! Click on the images below for higher resolution versions.















See also: Bar-headed Goose - Streifengans

Submit Photos to Shutterstock and make $$$!


Fibonacci Sequence

The Fibonacci Sequence: 0 1 1 2 3 5 8 13 21 34 55 89 144 233 377...

Check it out:





The Fibonacci Sequence can be found in the song Laterus by Tool.



See also: Statistics Not Calculus

Tuesday, February 17, 2009

Eurasian Coot - Blässhuhn

The Eurasian Coot (Blässhuhn) is mostly black with a white beak and "forehead shield". If you hear someone say "bald as a coot" they're referring to that shield. They have very unique foot webbing and beautiful red eyes. Coot are also referred to as water chickens. Click on the images below for higher resolution versions.








See also: Mandarin Duck - Mandarinente

Submit Photos to Shutterstock and make $$$!


Friday, February 13, 2009

Crayon Physics Deluxe



The object of this game is to make the red ball touch the star by drawing objects and trying to get physics to work in your favor. The objects in the game follow the laws of gravity, kinetic energy, and momentum, etc. and you have to cleverly draw your way to the solution!

Number Patterns



Monday, February 9, 2009

Add an HTML Footer to Every Post of Your Blogger Blog

Have you ever wanted to add some text or a link to the end of every post of your Blogger blog? If you're reading this, I'm assuming you do, and I'll be showing you exactly how to accomplish that. If you are like me, you might have thought it would have been quite easy using the Page Elements tool in Blogger to add the footer to every blog post, but it turns out it's not possible. The trick is to edit the blog template instead and add the desired text or HTML code to the correct location. Here's how...



Step 1: Log into Blogger and go to the Layout tab and click the "Edit HTML" sub-tab.


Step 2: Backup your template. Click "Download Full Template" and save it somewhere on your hard drive in case you ever royally mess up your template and need to start over fresh with a known-to-function template.


Step 3: Click the "Edit Template Widgets" check box. This lets you see all the template code you'll be adding your HTML code to.


Step 4: Search for "data:post.body" in the template using your browser. That bit of text signifies the end of the body of a post in your template. You'll be putting your HTML code directly after that.


Step 5: Add your HTML code right after that line. In my case, I wanted to add a link for people to be able to subscribe to my RSS feed. I added two single line breaks, my link, and another line break. The em tags make the link italicized.


Step 6: Click "Preview" and make sure it worked as expected. When you're satisfied with your footer and there are no HTML errors click "Save Template".

Piece of Cake!!

See also: How to Add an Amazon Widget to Your Blog to Make Some Extra Cash

Thursday, February 5, 2009

An error occurred while trying to save your photo library

An error occurred on my MacBook running Mac OS X 10.5 Leopard the other day while I was importing pictures into iPhoto. About halfway through the image import, a dialog box popped up saying "An error occurred while trying to save your photo library. Some recent changes may be lost. Make sure your hard disk has enough space and that iPhoto is able to access the iPhoto Library."
My disk definitely wasn't full because I just upgraded the hard drive to 500GB following the instructions found here: 500GB MacBook Harddrive Upgrade for Under $100. In fact I checked just to make sure and there was still 285 GB of free space. I was worried that my iPhoto library was messed up despite not doing anything unordinary. A day later I got another system error when adding some other files to a folder in my home folder. It dawned on me then that there might be perhaps some upper limit per user account, and I might have reached it.

Solution: While the HD still had plenty of room, the user account had reached some limit set by the operating system. I created a new folder on the root directory of the HD and transferred several large files out of my home account into the new folder thereby freeing up space for the photos I wanted to import into iPhoto. Another solution would be to somehow change the allotted HD space per user account. Maybe it has something to do with FileVault as well??

Tuesday, February 3, 2009

Greylag Goose - Graugans

The GreyLag Goose (Graugans) is a fun bird to observe due to its boisterously verbal and animated social behavior. The most distinct feature of these birds in my opinion is their rivuletted neck feathers. These photos were taken in the heart of Munich in the English Garden. Click on the images below for higher resolution versions.

A regal pair.



"Rivuletted" neck feathers

Incoming with landing gear deployed!

Touchdown.

Bath time.

Rinsing off.

Drying off.

"Hey, you're entering my territory!"

"I warned you!"

Gosling


See also: Eurasian Coot - Blässhuhn


Submit Photos to Shutterstock and make $$$!