Me n My Programming

If Only I Have TIme

Marama Code 110 ~ How to get current shell

I was thinking to create a list box where you can choose from template (Java/C++) to generate concrete test. So got two option, either using awt or swt. The awt example can be found here:

Link1 (to create listbox)

Link2 (to create button)

If you like to you eclipse swt , then you need to know the shell that is running (running workspace shell). How do you get it? Well, there is (I just notice) that you can use a class called EclipseHelper. I’m not sure who create this (either eclipse or someone from the group) but I think this should do the trick.

Shell sh = EclipseHelper.getWorkingWindowShell(); // get current shell

Shell s = new Shell (sh); // this will create a new shell to display

String items[] = { “Java”, “C++”, “C” };

String title = “Template Option”;

new ComboBoxSWT(dialog, title, items);

Why do we need to create new shell? Well, if you don’t create a new one, it will only invoke you running workspace. You dont want that to happen. Cheers.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Information

This entry was posted on August 26, 2010 by in Uncategorized.
%d bloggers like this: