os eclipse ganymede pt1 pdf

74
Using Eclipse Ganymede to develop for the desktop, Web and mobile devices, Part 1: Developing for the Rich Client Platform, the Ganymede way Desktop applications with RCP, Subversion and p2 Skill Level: Intermediate Suresh Krishna Software Developer Freelance Developer Trebor Fenstermaker Software Consultant Sunnyside Avenue Software, LLC 02 Sep 2008 The Ganymede release of the Eclipse IDE includes 24 separate projects, covering a wide range of technologies. Many of these projects are mature, and this release provides incremental improvements to those. But Ganymede also includes a number of new projects that introduce new technologies to the Eclipse platform. In this three-part "Using Eclipse Ganymede to develop for the desktop, Web and mobile devices" tutorial series, we will cover the following new Ganymede features: RCP, RAP, and eRCP, which allow you to develop software for the desktop, Web, and mobile platforms, respectively, with one common code base; Subversion for version control; and p2 for update and installation. Here in Part 1, we will use the mature Rich Client Platform (RCP) to develop an application for the desktop using Subversion for source control, and we will package and distribute the application using p2. Section 1. Before you start Developing for the Rich Client Platform, the Ganymede way Trademarks © Copyright IBM Corporation 2008. All rights reserved. Page 1 of 74

Upload: andreea-iuliana

Post on 13-Apr-2015

30 views

Category:

Documents


4 download

TRANSCRIPT

Page 1: Os Eclipse Ganymede Pt1 PDF

Using Eclipse Ganymede to develop for thedesktop, Web and mobile devices, Part 1:Developing for the Rich Client Platform, theGanymede wayDesktop applications with RCP, Subversion and p2

Skill Level: Intermediate

Suresh KrishnaSoftware DeveloperFreelance Developer

Trebor FenstermakerSoftware ConsultantSunnyside Avenue Software, LLC

02 Sep 2008

The Ganymede release of the Eclipse IDE includes 24 separate projects, covering awide range of technologies. Many of these projects are mature, and this releaseprovides incremental improvements to those. But Ganymede also includes a numberof new projects that introduce new technologies to the Eclipse platform. In thisthree-part "Using Eclipse Ganymede to develop for the desktop, Web and mobiledevices" tutorial series, we will cover the following new Ganymede features: RCP,RAP, and eRCP, which allow you to develop software for the desktop, Web, andmobile platforms, respectively, with one common code base; Subversion for versioncontrol; and p2 for update and installation. Here in Part 1, we will use the mature RichClient Platform (RCP) to develop an application for the desktop using Subversion forsource control, and we will package and distribute the application using p2.

Section 1. Before you start

Developing for the Rich Client Platform, the Ganymede way Trademarks© Copyright IBM Corporation 2008. All rights reserved. Page 1 of 74

Page 2: Os Eclipse Ganymede Pt1 PDF

This tutorial is for any Eclipse developer who wants to learn about some of theexciting new features available in Ganymede and for anyone interested in usingthese features to develop applications that can be deployed on multiple platformswith common code base. You should have an understanding of how to program inthe Java programming language, and familiarity with the Eclipse platform and itsmodel of using plug-ins.

About this series

Part 1 ("Developing for the Rich Client Platform, the Ganymede Way") provides anintroduction to the new features of the RCP, the new Subversion Eclipse integration,and the p2 packaging and distribution system. Part 2 ("Take it to the Web")introduces the Rich Ajax Platform (RAP) to write applications for the Web. And Part3 ("Going Mobile") discusses how to use the embedded Rich Client Platform (eRCP)to develop an application for a mobile device.

About this tutorial

The RCP is an Eclipse architecture that allows a developer to pick and choose theEclipse plug-ins needed — and only those needed — to build a client desktopapplication. To demonstrate some of the new features of Ganymede, you willdevelop a simple RCP application (a personal organizer). In doing so, you will seesome of the changes to the RCP in Ganymede, and you will use this application toexplore the new Subversion source control and p2 packaging and distributionsystems.

Topics include:

• How to download and install the Ganymede packages.

• How to set up the Subversion client and store your source in Subversion.

• How to set up the target platform and switch from one operating system toanother (i.e., Mac OS X to Microsoft® Windows® Vista).

• How to create an application model and user plug-ins.

• How to create a product definition and package and distributing yourapplication using p2.

System requirements

You need the following technologies to follow along:

developerWorks® ibm.com/developerWorks

Developing for the Rich Client Platform, the Ganymede way Trademarks© Copyright IBM Corporation 2008. All rights reserved. Page 2 of 74

Page 3: Os Eclipse Ganymede Pt1 PDF

• Eclipse Ganymede is at the Eclipse Foundation.

• The Java 2 Standard Edition V5 or greater is available from SunMicrosystems.

Section 2. Getting started with Ganymede

Before you begin developing your personal-organizer application, you need todownload and install the Ganymede package of Eclipse. In this section, you'll seewhere to download it from and how to set it up to get you going.

Downloading Ganymede

The Ganymede package represents the next incremental release for Eclipse, and assuch, means a new installation of the Eclipse platform. As with all Eclipse releases,there are a number of packages to choose from, depending on your developmentneeds. The Eclipse Web site provides a comparison chart, which you can see inFigure 1.

Figure 1. Comparison of Eclipse packages

ibm.com/developerWorks developerWorks®

Developing for the Rich Client Platform, the Ganymede way Trademarks© Copyright IBM Corporation 2008. All rights reserved. Page 3 of 74

Page 4: Os Eclipse Ganymede Pt1 PDF

For the purposes of this series, you can download the RCP/plug-in version, as it haseverything you need to develop and deploy an RCP application (see Figure 2).Choose the version for your operating system, select an appropriate mirror, anddownload. (The file is quite large — close to 200 MB, depending on your platform —so be patient.)

developerWorks® ibm.com/developerWorks

Developing for the Rich Client Platform, the Ganymede way Trademarks© Copyright IBM Corporation 2008. All rights reserved. Page 4 of 74

Page 5: Os Eclipse Ganymede Pt1 PDF

Figure 2. Download page for RCP/plug-in package of Eclipse Ganymede

Installing and running

When the download is complete, unzip the package where you want Eclipse to be

ibm.com/developerWorks developerWorks®

Developing for the Rich Client Platform, the Ganymede way Trademarks© Copyright IBM Corporation 2008. All rights reserved. Page 5 of 74

Page 6: Os Eclipse Ganymede Pt1 PDF

installed, then double-click the Eclipse icon to run. Select a workspace, and Eclipsewill take you to the welcome page. From here, choose the Workbench icon (thearrow on the far right of the welcome screen, shown in Figure 3).

Figure 3. Welcome screen for Eclipse setup

So far, none of this is much different from previous releases of Eclipse, though in thenext section, you will see some incremental improvements to one of the corecomponents of Eclipse development: the Rich Client Platform.

You have now installed the Ganymede release. But, you may be surprised to learnyou haven't installed every package that is part of Ganymede. Next, when youexplore Subversion, you will have to separately download and install the relevantpackage. Although Subversion is considered part of the Ganymede release,licensing restrictions prevent it from being distributed automatically with the rest ofthe package, requiring you to perform a separate download from within Eclipse.

Section 3. Subversion control using the Subversive

developerWorks® ibm.com/developerWorks

Developing for the Rich Client Platform, the Ganymede way Trademarks© Copyright IBM Corporation 2008. All rights reserved. Page 6 of 74

Page 7: Os Eclipse Ganymede Pt1 PDF

plug-in

Source control is an essential part of any serious software development effort,especially one that supports development distributed across a geographicallydistributed team (this tutorial's co-authors, for example, are on opposite sides of acontinent). Such a system allows for uncoordinated changes to a code base, withoutfear of one programmer making changes that will adversely affect another — yetwithout a central authority governing the entire process or the need of close andcareful coordination between the programmers.

Subversion is an open source version-control system, similar to CVS, but widelyconsidered its eventual successor. Subversion support for Eclipse has beenavailable for many years using third-party plug-ins, the most popular of which wascalled Subversive. The Ganymede project took on development of Subversive andadded it as a core library of Eclipse. However, outstanding legal issues prevent itfrom being distributed with the rest of Ganymede, so, for now at least, you must stillseparately install the Subversive plug-in from within Ganymede.

Follow along to see how we set up Subversive and used it to manage the sourcecode for the personal-organizer application.

Install Subversive

Subversive consists of two parts, each of which must be separately installed. Thefirst is the Subversive plug-in itself, which provides the UI elements to integrateSubversion support into Eclipse. The second part is the connector libraries, andthese are separately developed and licensed. To install the Subversive plug-in fromwithin Eclipse, navigate to Help > Software Updates.

Figure 4. Software Updates from the Help menu

ibm.com/developerWorks developerWorks®

Developing for the Rich Client Platform, the Ganymede way Trademarks© Copyright IBM Corporation 2008. All rights reserved. Page 7 of 74

Page 8: Os Eclipse Ganymede Pt1 PDF

Choose the Available Software screen, then click Add Site. For the Location, enterhttp://download.eclipse.org/technology/subversive/0.7/update-site/and click OK.

Figure 5. Add Site for Subversive

This will add a list of related plug-ins, but before installing those, click Add Siteagain, and add the location for the Subversive connectors. Enterhttp://www.polarion.org/projects/subversive/download/eclipse/2.0/update-site/for the location and click OK.

Figure 6. Add site for Subversive connectors

developerWorks® ibm.com/developerWorks

Developing for the Rich Client Platform, the Ganymede way Trademarks© Copyright IBM Corporation 2008. All rights reserved. Page 8 of 74

Page 9: Os Eclipse Ganymede Pt1 PDF

You'll see that both update sites have added a number of different possible plug-ins.You can select them all, but the minimal required for now are the ones labeled SVNTeam Provider and the Subversive SVN Connectors. Select it from the list and clickInstall.

Figure 7. Subversive plug-ins

ibm.com/developerWorks developerWorks®

Developing for the Rich Client Platform, the Ganymede way Trademarks© Copyright IBM Corporation 2008. All rights reserved. Page 9 of 74

Page 10: Os Eclipse Ganymede Pt1 PDF

Eclipse will take you through a standard set of screens for installing the plug-ins,including a screen asking you to review and accept the licensing terms. Workthrough these screens, and, when promoted, restart your Eclipse workbench. TheSubversive plug-ins are now installed.

Set up a repository

Subversion, like CVS, is a server-based source-code repository, which makes it anexcellent choice for collaborative software development across distributed teams.

developerWorks® ibm.com/developerWorks

Developing for the Rich Client Platform, the Ganymede way Trademarks© Copyright IBM Corporation 2008. All rights reserved. Page 10 of 74

Page 11: Os Eclipse Ganymede Pt1 PDF

The server piece is not a part of Eclipse, and installing and setting up a Subversionserver is beyond the scope of this tutorial. However, there are a number of ways torun one, including using Apache (see Resources for more information).

Once you have a Subversion server you can use, you can set up your project tostore its source and configurations using the Subversive plug-in. Highlight the projectname in the Package Explorer and display its context menu. From there, chooseTeam > Share Projects. Eclipse will display a screen offering you a choice ofversioning systems: CVS, which has been available as a core feature of Eclipse forsome time; and SVN, which is the short-hand notation for Subversion, which wasenabled when you added Subclipse.

Figure 8. Sharing a project via SVN

Select SVN and choose Next. You'll be presented with a screen (shown in Figure 9)where you'll enter the server URL and credentials for your Subversion server. Enterthe information for your server. From here, you can accept the defaults for namingthe repository that are set on the next screens and click Finish.

Figure 9. Share Project wizard

ibm.com/developerWorks developerWorks®

Developing for the Rich Client Platform, the Ganymede way Trademarks© Copyright IBM Corporation 2008. All rights reserved. Page 11 of 74

Page 12: Os Eclipse Ganymede Pt1 PDF

developerWorks® ibm.com/developerWorks

Developing for the Rich Client Platform, the Ganymede way Trademarks© Copyright IBM Corporation 2008. All rights reserved. Page 12 of 74

Page 13: Os Eclipse Ganymede Pt1 PDF

Eclipse will present you with the commit screen for your project (see Figure 10). Allthe files that are part of our project will be selected by default, but you can choose tokeep some from being checked in at this time if you want. You will also be promotedfor an initial check-in comment. It's good practice to enter comments on everycheck-in. Enter your comment and click OK. For the organizer application code, wehave all of the files checked.

Figure 10. Subversion Check-in box

Eclipse has now added all of the files for our organizer to your Subversionrepository. If you are using a WebDAV version of Subversion, such as throughApache as we did, you can explore the repository's structure using your Webbrowser. Simply enter the same URL and credentials you used to set up therepository in Subversive and navigate through the directory tree by way of thehyperlinks on each file or directory.

Figure 11. A view of the Subversion repository through the Web

ibm.com/developerWorks developerWorks®

Developing for the Rich Client Platform, the Ganymede way Trademarks© Copyright IBM Corporation 2008. All rights reserved. Page 13 of 74

Page 14: Os Eclipse Ganymede Pt1 PDF

You can see that our project is now wired to Subversion in the Package Explorer.Each filed under Subversion control has a revision number next to it, and the projectitself has the name of the repository next to its name.

Figure 12. The Package Explorer after being shared through Subversion

developerWorks® ibm.com/developerWorks

Developing for the Rich Client Platform, the Ganymede way Trademarks© Copyright IBM Corporation 2008. All rights reserved. Page 14 of 74

Page 15: Os Eclipse Ganymede Pt1 PDF

ibm.com/developerWorks developerWorks®

Developing for the Rich Client Platform, the Ganymede way Trademarks© Copyright IBM Corporation 2008. All rights reserved. Page 15 of 74

Page 16: Os Eclipse Ganymede Pt1 PDF

Working with the code in the repository

Like CVS, we can now access the Subversion source-control functions from theTeam context menu. To select a file from the Package Explorer that we want toupdate in the repository, bring up its context menu and select Team. This nowshows all the Subversion features in this context menu.

Following is a list of the more common commands we'll use (see Figure 13):

CommitTo save your changes to the repository

UpdateTo refresh your local copy with the latest from the repository

RevertTo discard your changes and replace them with the latest in the repository

Add to Version ControlTo mark newly created local files in the repository (you must then Commit thefile to add it to the server).

Figure 13. The Subversion context menu

To delete a file from the repository, delete it from the Package Explorer as younormally would (the Delete item on that file's context menu). Then commit theparent directory of that file. Prior to executing any commit on the server, you willhave a chance to review all the changes; for a delete, you will see the name andlocation of the deleted file.

developerWorks® ibm.com/developerWorks

Developing for the Rich Client Platform, the Ganymede way Trademarks© Copyright IBM Corporation 2008. All rights reserved. Page 16 of 74

Page 17: Os Eclipse Ganymede Pt1 PDF

Subversion is also like CVS in that it uses optimistic locking — that is, rather thanchecking out a file for editing and locking it from others, code can be edited locally atwill and checked in when finished. At the time of check-in, any conflicts are thenresolved.

Section 4. Creating an RCP application in Ganymede

In this section, you will create the organizer application — a simple, one-view RCPapp — by using the Eclipse wizards to create the RCP framework, adding the codefor the logic and running it.

Creating an RCP application framework

Start by creating a new project by selecting File > New > Project. Eclipse willdisplay the New Project Wizard, as shown below.

Figure 14. The New Project wizard

ibm.com/developerWorks developerWorks®

Developing for the Rich Client Platform, the Ganymede way Trademarks© Copyright IBM Corporation 2008. All rights reserved. Page 17 of 74

Page 18: Os Eclipse Ganymede Pt1 PDF

Choose Plug-in Project and select Next. The next screen will allow you to enterdetails of the project. Because you'll be creating a personal-organizer application,name the project com.devworks.tutorial.po (for "personal organizer"). Use the defaultlocation for the project (Eclipse will create a folder under your workspace namedafter the project). Be sure the Create a Java Project checkbox in the ProjectSettings is selected, and keep the defaults of src and bin for the folder names. Forthe target platform, select the radio button for Eclipse version and choose 3.4 fromthe drop-down menu. Leave the checkbox for Add project to working sets emptyand select Next.

The New Plug-in Project wizard shown in Figure 15 will continue to the Plug-inContent screen, where you'll enter information about the plug-in that will be added tothe manifest file that describes the plug-in and allows you to set up options for yourplug-in.

developerWorks® ibm.com/developerWorks

Developing for the Rich Client Platform, the Ganymede way Trademarks© Copyright IBM Corporation 2008. All rights reserved. Page 18 of 74

Page 19: Os Eclipse Ganymede Pt1 PDF

Figure 15. New Plug-in Project wizard screen

For the plug-in ID, choose the project name you used earlier(com.devworks.tutorial.po). Since this is the first release of your plug-in, leave thevalue of the plug-in version the default of 1.0.0. Likewise, you can leave the default

ibm.com/developerWorks developerWorks®

Developing for the Rich Client Platform, the Ganymede way Trademarks© Copyright IBM Corporation 2008. All rights reserved. Page 19 of 74

Page 20: Os Eclipse Ganymede Pt1 PDF

values of Po Plug-in for the plug-in name and DEVWORKS for the plug-in provider.

The Execution Environment drop-down menu allows you to target a specificruntime environment for the plug-in, from a selection of environments know toEclipse. For this tutorial, select JavaSE-1.6.

The next section sets the plug-in options. Be sure the box is checked for Generatean activator, a Java class that controls the plug-in's life cycle and change thedefault Activator class name, com.devworks.tutorial.po.Activator, tocom.devworks.tutorial.po.Activator.

Because this plug-in will have a visual component, be sure to select the checkboxfor This plug-in will make contributions to the UI. Leave the checkbox for EnableAPI Analysis blank. This is beyond the scope of this tutorial (see Resources formore information). Finally, since this is going to be a RCP application, select the Yesradio button for the question, Would you like to create a rich client application?,then select Next to continue with the wizard.

Figure 16. Plug-in content screen in the New Plug-in Project wizard

developerWorks® ibm.com/developerWorks

Developing for the Rich Client Platform, the Ganymede way Trademarks© Copyright IBM Corporation 2008. All rights reserved. Page 20 of 74

Page 21: Os Eclipse Ganymede Pt1 PDF

Figure 17 asks what kind of RCP template you'd like to use. Because our project isgoing to have a visual component, select the RCP Application with a View, thenselect Next.

ibm.com/developerWorks developerWorks®

Developing for the Rich Client Platform, the Ganymede way Trademarks© Copyright IBM Corporation 2008. All rights reserved. Page 21 of 74

Page 22: Os Eclipse Ganymede Pt1 PDF

Figure 17. Templates screen of New Plug-in Project wizard

On the final screen of the wizard shown in Figure 18, The Single View RCPapplication, you'll have an opportunity to enter information relevant to the templateyou just chose. Give your application window title the name Personal

developerWorks® ibm.com/developerWorks

Developing for the Rich Client Platform, the Ganymede way Trademarks© Copyright IBM Corporation 2008. All rights reserved. Page 22 of 74

Page 23: Os Eclipse Ganymede Pt1 PDF

. Leave the Java™ package name the default of com.devworks.tutorial.po and namethe application class TaskOrganizerApplication. Finally, select the Addbranding tag, which will display a splash screen when your application starts. ClickFinish.

Figure 18. Single-view RCP properties screen in New Project wizard

ibm.com/developerWorks developerWorks®

Developing for the Rich Client Platform, the Ganymede way Trademarks© Copyright IBM Corporation 2008. All rights reserved. Page 23 of 74

Page 24: Os Eclipse Ganymede Pt1 PDF

Eclipse will ask if you want to switch your workbench view to the Plug-inDevelopment perspective. This perspective will contain view of everything we needto see for this effort, so say Yes. The wizard finishes by generating template filesrelated to a single-view RCP application in the project directory in your workspace,

developerWorks® ibm.com/developerWorks

Developing for the Rich Client Platform, the Ganymede way Trademarks© Copyright IBM Corporation 2008. All rights reserved. Page 24 of 74

Page 25: Os Eclipse Ganymede Pt1 PDF

as well as a standard directory structure useful for plug-in development. It thenpresents you with your workbench screen in the Plug-in Development perspective.

Figure 19. Plug-in perspective of workbench after finishing the New Projectwizard

The template files created by Eclipse are listed under src in the Package Explorer.Briefly, here are their functions:

ActivatorThe plug-in's launching point

TaskOrganizerApplicationThe Application Activator that implements Application and defines theapplication's life cycle

ApplicationActionBarAdvisorThe class responsible for managing the life cycle of actions added to windows

ApplicationWorkbenchAdvisorThe class that initializes the perspective

ibm.com/developerWorks developerWorks®

Developing for the Rich Client Platform, the Ganymede way Trademarks© Copyright IBM Corporation 2008. All rights reserved. Page 25 of 74

Page 26: Os Eclipse Ganymede Pt1 PDF

ApplicationWorkbenchWindowAdvisorThe class responsible for many of the visual aspects of windows (size,statusline, menubars, etc.)

PerspectiveThe Views and Editor that will be visible in the application

ViewA simple Table viewer with three elements

Also, the icons folder contains bitmap resources for icons associated with theapplication; and the splash.bpm is the graphic used for the application's splashscreen.

These template files are an excellent start on creating an RCP plug-in, and you willbuild on these to create the organizer. But they, in fact, form a complete applicationof their own (albeit not one that does much) that you can run right now.

To see these work together, go to the Package Explorer window and highlight theproject name, at the very top of the tree view, then bring up the context menu(right-click on Windows; control-click on Mac OS X, etc). Select Run As > EclipseApplication. You should shortly get a splash screen, followed by a tree view withthree elements.

Figure 20. Organizer default tree view from template

developerWorks® ibm.com/developerWorks

Developing for the Rich Client Platform, the Ganymede way Trademarks© Copyright IBM Corporation 2008. All rights reserved. Page 26 of 74

Page 27: Os Eclipse Ganymede Pt1 PDF

You have everything you need at this point to build out a simple organizer with asingle list view.

Coding the organizer application

From here, you're ready to start coding the organizer application. The organizer willfeature a single screen with a list of tasks. Each task will contain a description, apriority, an owner, and a place to record the percentage complete. There will bebuttons to add or delete these tasks, as well as a button to close the entireapplication. To ensure that we have something to work with right away, theapplication will pre-populate the task manager with ten sample tasks with a variety ofsettings. To keep this simple, the data you enter will not be stored anywherebetween sessions.

The details of this code aren't particularly interesting to what we're trying todemonstrate in this tutorial, so you are encouraged to download it. Many of the files,in fact, do not change from the template versions, but there are some changes you'llmake to the view.

Create a new package under the project called View. Under here, you'll create filesrelated to the visual elements of the application. Start by moving the currenttemplate-created View class under this new package and renaming it

ibm.com/developerWorks developerWorks®

Developing for the Rich Client Platform, the Ganymede way Trademarks© Copyright IBM Corporation 2008. All rights reserved. Page 27 of 74

Page 28: Os Eclipse Ganymede Pt1 PDF

PersonalTaskView.

Because you have changed the View class name, you'll have to change theplug-in's definition of its main View class. To do this, open theMETA-INF/MANIFEST.MF file in the editor and switch to the Extensions tab, asshown in Figure 21. Expand the org.eclipse.ui.views extension in the listview and highlight the View class. Eclipse will display the properties of that class onthe right side of the screen. Change the class to the new package and name:com.devworks.tutorial.po.view.PersonalTaskView. Change the name ofthe class to PersonalTaskView. Be sure to save your changes.

Figure 21. Changing the View class

Because the organizer is really a collection of tasks, the model object will be calledPersonalTaskModel (see Listing 1).

Listing 1. PersonalTaskModel class, representing a single task

package com.devworks.tutorial.po.view;import java.util.ArrayList;import java.util.HashSet;import java.util.Iterator;import java.util.List;

developerWorks® ibm.com/developerWorks

Developing for the Rich Client Platform, the Ganymede way Trademarks© Copyright IBM Corporation 2008. All rights reserved. Page 28 of 74

Page 29: Os Eclipse Ganymede Pt1 PDF

import java.util.Set;import java.util.Vector;

public class PersonalTaskModel {

private final int COUNT = 10;private List<PersonalTask> tasks = new ArrayList<PersonalTask>(COUNT);private Set changeListeners = new HashSet();

static final String[] OWNERS_ARRAY = { "-", "Bill", "Larry", "Jo", "Harry","Hulk" };

static final String[] PRIO_ARRAY = { "-", "Low", "Medium", "High" };

public PersonalTaskModel() {super();this.initData();

}

private void initData() {PersonalTask personalTask;for (int i = 0; i < COUNT; i++) {

personalTask = new PersonalTask("Sample Task " + (i+1));personalTask.setTaskOwner(OWNERS_ARRAY[i % 5]);personalTask.setTaskPrio(PRIO_ARRAY[i % 3]);tasks.add(personalTask);

}};

public String[] getOwners() {return OWNERS_ARRAY;

}

public String[] getPrios() {return PRIO_ARRAY;

}

public List<PersonalTask> getTasks() {return tasks;

}

public void addTask() {PersonalTask task = new PersonalTask("New Sample Task");tasks.add(tasks.size(), task);Iterator iterator = changeListeners.iterator();while (iterator.hasNext())

((IPersonalTaskViewer) iterator.next()).addTask(task);}

public void removeTask(PersonalTask task) {tasks.remove(task);Iterator iterator = changeListeners.iterator();while (iterator.hasNext())

((IPersonalTaskViewer) iterator.next()).removeTask(task);}

public void taskChanged(PersonalTask task) {Iterator iterator = changeListeners.iterator();while (iterator.hasNext())

((IPersonalTaskViewer) iterator.next()).updateTask(task);}

public void removeChangeListener(IPersonalTaskViewer viewer) {changeListeners.remove(viewer);

}

public void addChangeListener(IPersonalTaskViewer viewer) {changeListeners.add(viewer);

}

ibm.com/developerWorks developerWorks®

Developing for the Rich Client Platform, the Ganymede way Trademarks© Copyright IBM Corporation 2008. All rights reserved. Page 29 of 74

Page 30: Os Eclipse Ganymede Pt1 PDF

You can see that Listing 1 defines the structure of a task, as well as methods thatoperate on it. It also, in this case, defines the sample data with which it's initiallypopulated.

The PersonalTaskViewer class defines the TableViewer, which is the buildingblock to hold the list of tasks. Creating the PersonalTaskViewer involves creatingthe TableViewer, adding the Content and Label Provider, finally initializing thePersonalTaskModel and setting this model as input to the TableViewer.

Listing 2. addChildControls() method fragment from PersonalTaskViewer

tableViewer = new TableViewer(table);tableViewer.setUseHashlookup(true);tableViewer.setColumnProperties(columnNames);

// Create the cell editorsCellEditor[] editors = new CellEditor[columnNames.length];

// Column 1 : Completed (Checkbox)editors[0] = new CheckboxCellEditor(table);

// Column 2 : Description (Free text)TextCellEditor textEditor = new TextCellEditor(table);((Text) textEditor.getControl()).setTextLimit(60);editors[1] = textEditor;

// Column 3 : Priority (Combo Box)editors[2] = new ComboBoxCellEditor(table, taskList.getPrios(), SWT.READ_ONLY);

// Column 4 : Owner (Combo Box)editors[3] = new ComboBoxCellEditor(table, taskList.getOwners(), SWT.READ_ONLY);

// Column 5 : Percent complete (Text with digits only)textEditor = new TextCellEditor(table);((Text) textEditor.getControl()).addVerifyListener(

new VerifyListener() {public void verifyText(VerifyEvent e) {

e.doit = "0123456789".indexOf(e.text) >= 0 ;}

});editors[4] = textEditor;

// Assign the cell editors to the viewertableViewer.setCellEditors(editors);// Set the cell modifier for the viewertableViewer.setCellModifier(new TaskCellModifier(this));// Set the default sorter for the viewertableViewer.setSorter(new PersonalTaskSorter(PersonalTaskSorter.TASK_DESC));

// Create and setup the TableViewertableViewer.setContentProvider(new PersonalTaskContentProvider());tableViewer.setLabelProvider(new TaskLabelProvider());

// The input for the table viewer is the instance of PersonalTaskModeltaskList = new PersonalTaskModel();tableViewer.setInput(taskList);

PersonalTaskContentProvider class has methods that would return theelements to display in the TableViewer, when its input is set to the given element.This class also defines basic operations on the PersonalTask like addTask(),

developerWorks® ibm.com/developerWorks

Developing for the Rich Client Platform, the Ganymede way Trademarks© Copyright IBM Corporation 2008. All rights reserved. Page 30 of 74

Page 31: Os Eclipse Ganymede Pt1 PDF

removeTask(), and updateTask() from IPersonalTaskViewer.

PersonalTaskLabelProvider class provides labels and images for the table'scolumn data.

Listing 3. getColumnText() from PersonalTaskLabelProvider

public String getColumnText(Object element, int columnIndex) {String result = "";PersonalTask task = (PersonalTask) element;switch (columnIndex) {

case 0:break;

case 1 :result = task.getTaskDesc();break;

case 2 :result = task.getTaskPrio();break;

case 3 :result = task.getTaskOwner();break;

case 4 :result = task.getPercentComplete() + "";break;

default :break;

}return result;

}

TaskCellModifier is used as a cell modifier to access the data model from thecell editor in an abstract way. It offers methods to check if TaskModel element'sproperty can be edited, retrieve a value a TaskModel element's property and tostore a cell editor's value back into the model element's property.

PersonalTaskSorter class takes the elements provided by thePersonalTaskContentProvider and sorts them in the given order. compare()method sorts the elements depending on the SortType.

Listing 4. compare() from PersonalTaskSorter

public int compare(Viewer viewer, Object o1, Object o2) {PersonalTask task1 = (PersonalTask) o1;PersonalTask task2 = (PersonalTask) o2;switch (sortType) {

case TASK_DESC :return compareDescriptions(task1, task2);

case TASK_PRIO :return comparePrios(task1, task2);

case TASK_OWNER :return compareOwners(task1, task2);

case TASK_COMPLETE :return comparePercentComplete(task1, task2);

default:return 0;

}

ibm.com/developerWorks developerWorks®

Developing for the Rich Client Platform, the Ganymede way Trademarks© Copyright IBM Corporation 2008. All rights reserved. Page 31 of 74

Page 32: Os Eclipse Ganymede Pt1 PDF

}

PersonalTaskView is the View class that extends ViewPart.

Listing 5. createPartControl() from PersonalTaskView

public void createPartControl(Composite parent) {viewer = new PersonalTaskViewer(parent);viewer.getCloseButton().addSelectionListener(new SelectionAdapter() {

public void widgetSelected(SelectionEvent e) {handleDispose();

}});

}

PersonalTaskOrganizer Application's Perspective uses this View to display inthe perspective (see Listing 6). In doing this, you have established the connectionbetween the code templates generated by RCP application wizard and thePersonalTaskView.

Listing 6. createInitialLayout() from perspective

public void createInitialLayout(IPageLayout layout) {String editorArea = layout.getEditorArea();layout.setEditorAreaVisible(false);layout.setFixed(true);layout.addStandaloneView(PersonalTaskView.ID, false, IPageLayout.LEFT, 1.0f,

editorArea);

Run your application the way you did before, by selecting Run > EclipseApplication from the context menu of the project in the Package Explorer. After thesplash screen, you'll see the task manager, pre-populated with some sample tasks.

Figure 22. Organizer task manager view

developerWorks® ibm.com/developerWorks

Developing for the Rich Client Platform, the Ganymede way Trademarks© Copyright IBM Corporation 2008. All rights reserved. Page 32 of 74

Page 33: Os Eclipse Ganymede Pt1 PDF

Congratulations! You've created a simple RCP plug-in that can now be targeted torun on a desktop environment of your choice.

Section 5. Creating the product definition

In previous releases of the RCP in Eclipse, the plug-ins included in your applicationfor distribution were limited to those available in the target directory. WithGanymede, you now have the ability to specify exactly what plug-ins you need,resulting in a more precise distribution. In this section, you'll package yourapplication so it can be distributed in a tight package, containing only what's neededto run.

Setting up the target environment

To set up the target environment, highlight the project name in the Package Explorerand select New > Product Configuration from the context menu.

Figure 23. Product Configuration from context menu

ibm.com/developerWorks developerWorks®

Developing for the Rich Client Platform, the Ganymede way Trademarks© Copyright IBM Corporation 2008. All rights reserved. Page 33 of 74

Page 34: Os Eclipse Ganymede Pt1 PDF

This will launch a wizard that allows you to edit the configuration of your RCPapplication (see Figure 24). In the first screen of the wizard, set the parent folder tocom.devworks.tutorial.po and name the file TaskOrganizer.product.Select the radio button for Initialize the file content to Create a configuration filewith basic settings, then select Finish.

Figure 24. The New Product Configuration wizard

developerWorks® ibm.com/developerWorks

Developing for the Rich Client Platform, the Ganymede way Trademarks© Copyright IBM Corporation 2008. All rights reserved. Page 34 of 74

Page 35: Os Eclipse Ganymede Pt1 PDF

Eclipse has created a file called TaskOrganizer.product that contains a templatedefinition of the configuration, which will be displayed in the editor, defaulted to theOverview tab.

ibm.com/developerWorks developerWorks®

Developing for the Rich Client Platform, the Ganymede way Trademarks© Copyright IBM Corporation 2008. All rights reserved. Page 35 of 74

Page 36: Os Eclipse Ganymede Pt1 PDF

Specify the name that appears in the title bar of the application as PersonalOrganizer, and the product identifier is com.devworks.tutorial.po.product. Theproduct version number is 1.0.0, and the application iscom.devworks.tutorial.po.application. These latter two are selected froma drop-down list. Finally, your application's product configuration will be based onplug-ins, so select that as the radio button. Since you are editing a properties file, besure to save your work from the file menu or with the shortcut key appropriate foryour operating system.

Now select the Configuration tab, where you will add the plug-ins you need andonly the plug-ins you need (see Figure 25). Start by adding the plug-in you justwrote, by clicking Add. A dialog will appear displaying all the known plug-ins; selectcom.devworks.tutorial.po and click OK.

Figure 25. Selecting a plug-in to use for configuration

Your plug-in will now appear in a list on the Configuration tab of theTaskOranizer.product editor (see Figure 26).

developerWorks® ibm.com/developerWorks

Developing for the Rich Client Platform, the Ganymede way Trademarks© Copyright IBM Corporation 2008. All rights reserved. Page 36 of 74

Page 37: Os Eclipse Ganymede Pt1 PDF

Figure 26. Taskorganizer.product editor view

Having told Eclipse that this is one of the plug-ins you need for your distribution, itcan now intuit all the dependent plug-ins and add them automatically. Click Addrequired plug-ins, and Eclipse will add the additional plug-ins needed to the list.

Figure 27. The additional plug-ins

ibm.com/developerWorks developerWorks®

Developing for the Rich Client Platform, the Ganymede way Trademarks© Copyright IBM Corporation 2008. All rights reserved. Page 37 of 74

Page 38: Os Eclipse Ganymede Pt1 PDF

Save the changes, then navigate to the Launching tab (see Figure 28). Here, youcan provide the name of the executable for the application. EnterPersonalOrganizer in the Launcher Name field.

Figure 28 also allows us to choose icons for the application. Each target OS has adifferent means of setting these, and you can set the icon for your operating systemby choosing it from list of tabs and entering a file name. If you don't have an iconyou'd like to use for now, you can leave it blank and a default will be provided.

Figure 28. The Launching tab

developerWorks® ibm.com/developerWorks

Developing for the Rich Client Platform, the Ganymede way Trademarks© Copyright IBM Corporation 2008. All rights reserved. Page 38 of 74

Page 39: Os Eclipse Ganymede Pt1 PDF

Navigate to the Splash tab and click Browse to see a list of available plug-ins thatmay contain the splash bitmap. Recall that the templates created by the New Projectwizard created a sample bitmap, and so, for this tutorial, you will navigate to thiscurrent project. It is possible, though, if you had a number of projects, that thebranding would be identical for many of them and you would wish to reuse a bitmapfrom another plug-in you created, this would make that easy.

Figure 29. Selecting the splash-screen plug-in location

ibm.com/developerWorks developerWorks®

Developing for the Rich Client Platform, the Ganymede way Trademarks© Copyright IBM Corporation 2008. All rights reserved. Page 39 of 74

Page 40: Os Eclipse Ganymede Pt1 PDF

Select your plug-in, named com.devworks.tutorial.po, and it will be added to theSplash tab as the location of the splash screen.

Figure 30. Entering the splash-screen information

developerWorks® ibm.com/developerWorks

Developing for the Rich Client Platform, the Ganymede way Trademarks© Copyright IBM Corporation 2008. All rights reserved. Page 40 of 74

Page 41: Os Eclipse Ganymede Pt1 PDF

Finally, select the Branding tag and add the two GIF files created by the NewProject wizard under the icons directory. These are images that will display with thewindow when it runs. You may also create your own, either as GIF or PNG, andstore them with your plug-in.

Figure 31. The Branding tab

ibm.com/developerWorks developerWorks®

Developing for the Rich Client Platform, the Ganymede way Trademarks© Copyright IBM Corporation 2008. All rights reserved. Page 41 of 74

Page 42: Os Eclipse Ganymede Pt1 PDF

You can now run the application on your target environment. Select File > Export >Plug-in Development > Eclipse Product.

Figure 32. Export selection screen

developerWorks® ibm.com/developerWorks

Developing for the Rich Client Platform, the Ganymede way Trademarks© Copyright IBM Corporation 2008. All rights reserved. Page 42 of 74

Page 43: Os Eclipse Ganymede Pt1 PDF

Select Next, and Eclipse will start the Export wizard shown in Figure 33.

Figure 33. The Eclipse Product Export screen

ibm.com/developerWorks developerWorks®

Developing for the Rich Client Platform, the Ganymede way Trademarks© Copyright IBM Corporation 2008. All rights reserved. Page 43 of 74

Page 44: Os Eclipse Ganymede Pt1 PDF

Use Browse to select the TaskOrganizer.product configuration file shown in Figure34. This is the file that contains the definition of your plug-in as a stand-aloneproduct, and the export will use this to determine what should be included in thedistribution.

Figure 34. Selecting the product configuration

developerWorks® ibm.com/developerWorks

Developing for the Rich Client Platform, the Ganymede way Trademarks© Copyright IBM Corporation 2008. All rights reserved. Page 44 of 74

Page 45: Os Eclipse Ganymede Pt1 PDF

For the Root Directory, enter TaskOrganizer Ensure the checkbox is selected forSynchronize before exporting. For the destination directory, choose a locationwhere you would like to deploy this application (in the example here, we will just beusing a temp directory, but you may choose to use an application deploymentdirectory). Finally, under Export Options, select Include source code, then clickFinish.

Figure 35. The completed Eclipse Product Export screen

ibm.com/developerWorks developerWorks®

Developing for the Rich Client Platform, the Ganymede way Trademarks© Copyright IBM Corporation 2008. All rights reserved. Page 45 of 74

Page 46: Os Eclipse Ganymede Pt1 PDF

What Eclipse creates in the temp directory as a result of the export depends on yourtarget platform. On Mac OS X, for example, it will look like Figure 36.

Figure 36. Files created by the export

developerWorks® ibm.com/developerWorks

Developing for the Rich Client Platform, the Ganymede way Trademarks© Copyright IBM Corporation 2008. All rights reserved. Page 46 of 74

Page 47: Os Eclipse Ganymede Pt1 PDF

The executable it has created is called PersonalOrganizer. On Windows, it willcreate a PersonalOrganizer.exe. Double-click the executable, and the organizerapplication will run as a native application on your desktop.

Creating a distribution for another platform

What if you want to deploy your RCP on a desktop other than your current default?

ibm.com/developerWorks developerWorks®

Developing for the Rich Client Platform, the Ganymede way Trademarks© Copyright IBM Corporation 2008. All rights reserved. Page 47 of 74

Page 48: Os Eclipse Ganymede Pt1 PDF

Suppose you're developing on Mac OS X, but would like your application to run onWindows Vista? This is one of the more exciting improvements to RCP developmentin Ganymede.

In previous releases of Eclipse, you had two choices: either switch yourdevelopment to Windows or build your package with every known plug-in. This latterapproach meant your distribution would have many more plug-ins than necessary foryour target platform.

Ganymede solves this by allowing you to choose the plug-ins relevant to theplatform of your choice, without having to move your development to that platform.To target a platform different from your current host environment, you define a newtarget platform. The target platform is, essentially, an Eclipse configuration thatcontains the minimal set of plug-ins that Eclipse will build an application against. Bydefault, Eclipse is configured to use itself as the default target, which gives the RCPplug-ins potential access to everything loaded in the IDE. By setting up a specialtarget platform, you can take direct control over the set of plug-ins your RCPapplication can potentially have access to and even have your RCP applicationtarget different plug-in versions than are currently loaded in your IDE environment.

To create a new target, highlight the project from the Package Explorer and displayits context menu. Select New > Target Definition.

Figure 37. Target definition from the new context menu

Select the project shown in the tree view as the parent folder

developerWorks® ibm.com/developerWorks

Developing for the Rich Client Platform, the Ganymede way Trademarks© Copyright IBM Corporation 2008. All rights reserved. Page 48 of 74

Page 49: Os Eclipse Ganymede Pt1 PDF

(com.devworks.tutorial.po) and use the file nametaskorganizer-other.target. Finally, select Use an existing targetdefinition from the radio buttons for Initialize the file content and make sure thedrop-down shows Base RCP (Binary Only), then click Finish.

Figure 38. The target definition creation screen

ibm.com/developerWorks developerWorks®

Developing for the Rich Client Platform, the Ganymede way Trademarks© Copyright IBM Corporation 2008. All rights reserved. Page 49 of 74

Page 50: Os Eclipse Ganymede Pt1 PDF

A properties file will now open in the editor pane. Change the target name to anoperating system different from your current one. In this example, since we are

developerWorks® ibm.com/developerWorks

Developing for the Rich Client Platform, the Ganymede way Trademarks© Copyright IBM Corporation 2008. All rights reserved. Page 50 of 74

Page 51: Os Eclipse Ganymede Pt1 PDF

developing on Mac OS X, we'll choose Windows and name it as such.

If you wanted to deploy to a working set of plug-ins that were unique to an olderversion of Eclipse, you could select the target location by choosing Location andselecting the directory on your file system where that older version was stored,which his would restrict the available plug-ins to those used by that version. For now,you'll deploy to the current version of Eclipse, so select Use the same targetlocation as the host (running) platform is using for the target location.

Figure 39. The target properties file editor

Navigate to the Environment tab. Here, enter the details on your target environment.Again, for this example, we're developing on Mac OS X, so we'll show settings thatwould be appropriate for a Windows deployment, but you can choose the settings forany of the supported platforms you'd like to try.

Figure 40. The target environment tab

ibm.com/developerWorks developerWorks®

Developing for the Rich Client Platform, the Ganymede way Trademarks© Copyright IBM Corporation 2008. All rights reserved. Page 51 of 74

Page 52: Os Eclipse Ganymede Pt1 PDF

In this example, because the current default JRE for Mac OS X is V1.5, we showchanging the JRE version to J2SE V1.6, since this is widely available on Windowssystems.

When you're finished editing, be sure to save the file. You can now use this targetdefinition to create the product.

Click the link in the upper right-hand that says Set as Target Platform. You havecreated a target platform that could be used to distribute your application with theplug-ins needed for a platform other than the one you're currently developing with. Inthe next section, you'll see how to package your application for distribution with thenew p2 system in Ganymede.

developerWorks® ibm.com/developerWorks

Developing for the Rich Client Platform, the Ganymede way Trademarks© Copyright IBM Corporation 2008. All rights reserved. Page 52 of 74

Page 53: Os Eclipse Ganymede Pt1 PDF

Section 6. Packaging and distributing RCP applicationsusing p2

The last enhancement you'll look at in this tutorial is a new method of packaging anddistributing plug-ins. In previous versions of Eclipse, the packaging was essentiallycreating a ZIP archive of all the relevant files, along with an appropriate manifest,and placing it on a publicly available server. These could then be installed either byusing the Help > Updates feature from the menu, or many users simply opted todownload and unzip the plug-in archive directly in the appropriate Eclipse installationfolder. The p2 mechanism streamlines this process, allowing for a clean packagingand automated distribution. In this section, you'll create a p2 update site andpackage your plug-in for distribution through it.

Creating the feature list

Packages contain features, which themselves are composed of plug-ins. So topackage your organizer plug-in for p2, you have to start by creating a feature list.You do this by using the new project wizard. From the Eclipse menu, select New >Project > Plug-in Development > Feature Project and click Next.

Figure 41. Creating a new feature project

ibm.com/developerWorks developerWorks®

Developing for the Rich Client Platform, the Ganymede way Trademarks© Copyright IBM Corporation 2008. All rights reserved. Page 53 of 74

Page 54: Os Eclipse Ganymede Pt1 PDF

Name this project com.devworks.tutorial.po.feature and store it in thedefault location for simplicity. Leave the feature ID as its default of the project name,but change the feature name to Personal Task Organizer. Leave the rest ofthe fields at their defaults, then click Next.

Figure 42. Feature properties editor

developerWorks® ibm.com/developerWorks

Developing for the Rich Client Platform, the Ganymede way Trademarks© Copyright IBM Corporation 2008. All rights reserved. Page 54 of 74

Page 55: Os Eclipse Ganymede Pt1 PDF

Eclipse will display a screen asking for the plug-in that should be used to initializethis feature set. Since this feature set is all about your personal-organizer plug-in,select com.devworks.tutorial.po from the list, then Finish.

Figure 43. Selecting the plug-in that provides the definition of the feature

ibm.com/developerWorks developerWorks®

Developing for the Rich Client Platform, the Ganymede way Trademarks© Copyright IBM Corporation 2008. All rights reserved. Page 55 of 74

Page 56: Os Eclipse Ganymede Pt1 PDF

The wizard completes by creating a new project and populating a file calledfeature.xml. This contains information about the features, dependencies,licensing, and build instructions for your plug-ins — in short, everything needed tobuild a distribution.

Figure 44. The feature.xml shown in the editor

developerWorks® ibm.com/developerWorks

Developing for the Rich Client Platform, the Ganymede way Trademarks© Copyright IBM Corporation 2008. All rights reserved. Page 56 of 74

Page 57: Os Eclipse Ganymede Pt1 PDF

The update site you'll create next will use this feature list.

Create the update site

Now that you have a feature set, you can use this create a site from which todistribute it. What is created is a set of files that can be made publicly available onthe Internet or on a corporate intranet, or distributed on disc, or as a ZIP file. Thefiles and structure created are simply made in a directory that you can then distributeas you wish.

Creating a new update site is simple. Once again, the New Project wizard steps in.From the Project Explorer, select New > Project > Plug-in Development > UpdateSite Project, then select Next.

Figure 45. Creating a new update site project

ibm.com/developerWorks developerWorks®

Developing for the Rich Client Platform, the Ganymede way Trademarks© Copyright IBM Corporation 2008. All rights reserved. Page 57 of 74

Page 58: Os Eclipse Ganymede Pt1 PDF

This will start a wizard that will create a new project that represents your update site(see Figure 46). Enter com.devworks.tutorial.updatesite as the projectname and save it on your local file system. (Selecting the default location will createthe update site in your current workspace; choosing an external location will makethis tutorial a bit clearer, but you decide.) Click Finish.

Figure 46. The update site project properties editor

developerWorks® ibm.com/developerWorks

Developing for the Rich Client Platform, the Ganymede way Trademarks© Copyright IBM Corporation 2008. All rights reserved. Page 58 of 74

Page 59: Os Eclipse Ganymede Pt1 PDF

The wizard will create a project with a single site.xml file, displayed in the editor. Itdescribes the package as the updater will see it.

Figure 47. The site.xml shown in the editor

ibm.com/developerWorks developerWorks®

Developing for the Rich Client Platform, the Ganymede way Trademarks© Copyright IBM Corporation 2008. All rights reserved. Page 59 of 74

Page 60: Os Eclipse Ganymede Pt1 PDF

You now need to configure that site.xml to add a category and features. This fleshesout the update site with the material you are intending it to distribute. Click NewCategory on the site.xml editor, and the right side of the editor will display propertiesyou will edit (see Figure 48). Enter Personal Task Organizer for the name, andTutorial for the label. You can enter a description of your choice; we used Thisis a Personal Task Organizer.

Figure 48. Adding the category

developerWorks® ibm.com/developerWorks

Developing for the Rich Client Platform, the Ganymede way Trademarks© Copyright IBM Corporation 2008. All rights reserved. Page 60 of 74

Page 61: Os Eclipse Ganymede Pt1 PDF

Now highlight the Personal Task Organizer on the left-side list box, then click AddFeature. Eclipse will display a list of available features, including the one youcreated earlier (see Figure 49). Select com.devworks.tutorial.po.feature from thelist, then click OK.

Figure 49. Selecting the feature to add to the update site

ibm.com/developerWorks developerWorks®

Developing for the Rich Client Platform, the Ganymede way Trademarks© Copyright IBM Corporation 2008. All rights reserved. Page 61 of 74

Page 62: Os Eclipse Ganymede Pt1 PDF

This will add it to the list of features in your category.

Figure 50. Feature shown in the site.xml editor

developerWorks® ibm.com/developerWorks

Developing for the Rich Client Platform, the Ganymede way Trademarks© Copyright IBM Corporation 2008. All rights reserved. Page 62 of 74

Page 63: Os Eclipse Ganymede Pt1 PDF

You're ready to build out your distribution physically on your disk. Save your edits,then highlight the Personal Task Organizer again in the list of categories. ClickBuild All, and this will create an update site in your given path.

Congratulations! You have created a distribution of your organizer, suitable forpublishing to the world. Let's see how it would look to a user seeking to downloadand install it in his Eclipse environment, by loading it into your own Eclipseenvironment.

Loading the local site

You will add your plug-in the same as you did the Subversive plug-in, by way of theSoftware Updates function. Navigate to Help > Software Updates, then click AddSite. This time, however, instead of a URL on the Web, click Local, and Eclipse willdisplay a file browse box. Navigate to the directory where you created your updatesite, click OK, then OK again on the Add screen.

Figure 51. Adding the location of the new site in Software Updates

ibm.com/developerWorks developerWorks®

Developing for the Rich Client Platform, the Ganymede way Trademarks© Copyright IBM Corporation 2008. All rights reserved. Page 63 of 74

Page 64: Os Eclipse Ganymede Pt1 PDF

Your update site now appears in the list of available updates.

Figure 52. The organizer in the software update list

developerWorks® ibm.com/developerWorks

Developing for the Rich Client Platform, the Ganymede way Trademarks© Copyright IBM Corporation 2008. All rights reserved. Page 64 of 74

Page 65: Os Eclipse Ganymede Pt1 PDF

To install your plug-in, select it from the list, then click Install. You will see yourplug-in listed in a standard plug-in install screen.

Figure 53. The organizer installation screen

ibm.com/developerWorks developerWorks®

Developing for the Rich Client Platform, the Ganymede way Trademarks© Copyright IBM Corporation 2008. All rights reserved. Page 65 of 74

Page 66: Os Eclipse Ganymede Pt1 PDF

Click Next, and you will be presented with a license screen (see Figure 54). Sinceyou didn't enter a license, you'll see a default message, but be sure to select Iaccept, then click Finish.

Figure 54. Licensing terms screen

developerWorks® ibm.com/developerWorks

Developing for the Rich Client Platform, the Ganymede way Trademarks© Copyright IBM Corporation 2008. All rights reserved. Page 66 of 74

Page 67: Os Eclipse Ganymede Pt1 PDF

Eclipse will install the organizer plug-in and prompt for a restart. After the restart, youwill find your plug-in under Window > Show View > Other > Other.

Figure 55. Opening the organizer

ibm.com/developerWorks developerWorks®

Developing for the Rich Client Platform, the Ganymede way Trademarks© Copyright IBM Corporation 2008. All rights reserved. Page 67 of 74

Page 68: Os Eclipse Ganymede Pt1 PDF

Click OK, and your personal organizer will load and run within the Eclipseworkbench.

Figure 56. The organizer in the Eclipse workbench

developerWorks® ibm.com/developerWorks

Developing for the Rich Client Platform, the Ganymede way Trademarks© Copyright IBM Corporation 2008. All rights reserved. Page 68 of 74

Page 69: Os Eclipse Ganymede Pt1 PDF

Your personal organizer is now a part of your Eclipse workbench ready for you touse alongside everything else that makes up the Eclipse experience.

Section 7. Summary

The Ganymede release is an exciting addition to the long and rich tradition ofEclipse. This tutorial touched on some of the new features that will make developingplug-ins easier, and make their distribution cleaner and more efficient. The RCP nowhas the ability to package only those plug-ins you need or want. Subversion supportis now standard with Eclipse and will continue to become more integrated with theworkbench, giving you full support for this next-generation source-control system.

The p2 packaging and distribution system represents an evolutionary leap in thedeployment model, allowing for a simple packaging and distribution, which is cleanerand more standardized than previous versions of Eclipse. You explored all thesefeatures by creating a simple one-screen RCP personal-organizer application,packaging it for deployment, and seeing how you could create an environment fordeployment different from your current environment. You stored your source for thisapplication Subversion through the Subversive plug-in, allowing you to track your

ibm.com/developerWorks developerWorks®

Developing for the Rich Client Platform, the Ganymede way Trademarks© Copyright IBM Corporation 2008. All rights reserved. Page 69 of 74

Page 70: Os Eclipse Ganymede Pt1 PDF

changes and collaborate easily with others. And you learned how to package yourplug-in for deployment using the new p2 distribution system, making it easy forothers to download and install your work.

In Part 2 of this series, you'll expand on the work you did here by modifying theorganizer to use the Rich Ajax Platform to run your application as a nativeapplication on the Web.

developerWorks® ibm.com/developerWorks

Developing for the Rich Client Platform, the Ganymede way Trademarks© Copyright IBM Corporation 2008. All rights reserved. Page 70 of 74

Page 71: Os Eclipse Ganymede Pt1 PDF

Downloads

Description Name Size Downloadmethod

Personal-organizer sample os-eclipse-ganymede-pt1.zip 102KB HTTP

Information about download methods

ibm.com/developerWorks developerWorks®

Developing for the Rich Client Platform, the Ganymede way Trademarks© Copyright IBM Corporation 2008. All rights reserved. Page 71 of 74

Page 72: Os Eclipse Ganymede Pt1 PDF

Resources

Learn

• Read "Eclipse Ganymede at a glance" for an overview of the Ganymederelease.

• For more information on the RCP, see the Eclipse wiki.

• "Developing your first Eclipse RCP application" provides a good introduction ongetting started with RCP.

• Read "Brand your Eclipse RCP applications" for more information on brandingyour RCP application.

• "Introducing Subversion" offers a primer on Subversion.

• Subversion server code is available from Subversion.tigris.org.

• "Understanding the Eclipse p2 Provisioning System" features a Q&A on p2.

• Details on the Equinox p2 provisioning system can be found at the Eclipse wikion Equinox.

• There is also a review of p2 by Ryan Slobojan called Eclipse Ganymede: Anin-depth look at Equinox p2.

• Check out the extensive documentation, tutorials, presentations, andscreencasts that illuminate the Eclipse Test & Performance Tools Platform(TPTP).

• Check out the "Recommended Eclipse reading list."

• Browse all the Eclipse content on developerWorks.

• New to Eclipse? Read the developerWorks article "Get started with EclipsePlatform" to learn its origin and architecture, and how to extend Eclipse withplug-ins.

• Expand your Eclipse skills by checking out IBM developerWorks' Eclipse projectresources.

• To listen to interesting interviews and discussions for software developers,check out developerWorks podcasts.

• Stay current with developerWorks' Technical events and webcasts.

• Watch and learn about IBM and open source technologies and productfunctions with the no-cost developerWorks On demand demos.

• Check out upcoming conferences, trade shows, webcasts, and other Eventsaround the world that are of interest to IBM open source developers.

developerWorks® ibm.com/developerWorks

Developing for the Rich Client Platform, the Ganymede way Trademarks© Copyright IBM Corporation 2008. All rights reserved. Page 72 of 74

Page 73: Os Eclipse Ganymede Pt1 PDF

• Visit the developerWorks Open source zone for extensive how-to information,tools, and project updates to help you develop with open source technologiesand use them with IBM's products.

Get products and technologies

• The Java 2 Standard Edition V5 or greater is available from Sun Microsystems.

• Eclipse Ganymede is at the Eclipse Foundation.

• The Subversive plug-in can be downloaded from Eclipse.org/subversive.

• The Subversive connectors are hosted at Polarion.com.

• Check out the latest Eclipse technology downloads at IBM alphaWorks.

• Download Eclipse Platform and other projects from the Eclipse Foundation.

• Download IBM product evaluation versions, and get your hands on applicationdevelopment tools and middleware products from DB2®, Lotus®, Rational®,Tivoli®, and WebSphere®.

• Innovate your next open source development project with IBM trial software,available for download or on DVD.

Discuss

• The Eclipse Platform newsgroups should be your first stop to discuss questionsregarding Eclipse. (Selecting this will launch your default Usenet news readerapplication and open eclipse.platform.)

• The Eclipse newsgroups has many resources for people interested in using andextending Eclipse.

• Participate in developerWorks blogs and get involved in the developerWorkscommunity.

About the authors

Suresh KrishnaSuresh Krishna has been a programmer since 2000 and has beenworking on the domain modeling, IDEs, and productivity tools. Inspiredby the IDE evolution and developer productivity, he works primarily onthe Eclipse plug-ins and RCP applications. Extreme Programming andScrum are his favorites, along with evangelizing Eclipse to the user,developer, and corporate communities. He enjoys his free time writingblogs and product evaluations.

ibm.com/developerWorks developerWorks®

Developing for the Rich Client Platform, the Ganymede way Trademarks© Copyright IBM Corporation 2008. All rights reserved. Page 73 of 74

Page 74: Os Eclipse Ganymede Pt1 PDF

Trebor FenstermakerAlthough he's programmed in Java since 1999, Trebor Fenstermakerwas, for much of that time, highly suspicious of Java IDEs and was adie-hard command-line user, even doing all his code editing in vi -- untila colleague showed him that he really could be more efficient withEclipse. He now evangelizes his fellow UNIX command-line refugeeson its wonders and enjoys exploring its more powerful features --including its endless possibilities for expansion through customplug-ins.

developerWorks® ibm.com/developerWorks

Developing for the Rich Client Platform, the Ganymede way Trademarks© Copyright IBM Corporation 2008. All rights reserved. Page 74 of 74