I have found using the new update manager (P2) in a standalone RCP application to be rather tricky. It's best to start by reading Equinox/p2/Adding Self-Update to an RCP Application and looking at the example (org.eclipse.equinox.p2.examples.rcp.sdkui) which can be retrieved from CVS: /cvsroot/rt (Eclipse CVS access info ). Place that application in your workspace.
Right-click your bundle project and make new Product Configuration
- select "Use an existing product" (and select the org.eclipse.equinox.p2.examples.rcp.sdkui.product)
- give product configuration file a name
After the product configuration is created, in the dependencies tab remove the org.eclipse.equinox.p2.examples.rcp.sdkui plugin.
Replace with your own bundle/plugin.
In your bundle, you must have a p2.inf file in the root. Mine has:
instructions.configure=\
addRepository(type:0,location:file:///C:/somepath/updatesite );\
addRepository(type:1,location:file:///C:/somepath/updatesite );
(Note that mine uses a file URL. You can of course also use an HTTP URL. If anyone can show me how to have multiple entries in here, let me know. I have yet to figure that out.)
You must also add the P2 UI elements to your application. The easiest way to do that is by adding the menu items to your application declaratively (i.e. via plugin.xml). On the extensions tab, click add and select org.eclipse.ui.menus. Then right-click that entry and add -> new -> menu contribution. Set the locationURI to menu:org.eclipse.ui.main.menu?after=additions. Now right-click -> new -> menu and give it a user friendly label. Then right click that menu and -> new -> command and I did this 4 times for these commandId's which each show up on the menu: org.eclipse.ui.window.preferences, org.eclipse.equinox.p2.ui.sdk.update, org.eclipse.equinox.p2.ui.sdk.install, org.eclipse.ui.help.aboutAction
Use Eclipse Product Export Wizard found in overview tab of product configuration file. During export, make sure "Generate metadata repository" is selected.
When you launch you should be able to use the install and update commands as well as verify installation configuration from the preferences and about menu items.
Wednesday, September 30, 2009
Ordering is significant in constructing a TableViewer
Context
I wanted to create a table viewer (3 columns) with my own content and label provider.Problem
I found out that, if I set the content provider and label provider before I added all the columns to the table viewer, it would show no content, or only the columns that I added before I set the label provider.Code
TableViewer tableViewer = new TableViewer(tabFolder, SWT.BORDER | SWT.FULL_SELECTION);
TableViewerColumn tableViewerColumn1 = new TableViewerColumn(tableViewer, SWT.NONE);
...
//call setters before all columns are added, which will cause no content display for the column 2 and 3
tableViewer.setContentProvider(new UserManagementContentProvider());
tableViewer.setInput(...);
...
TableViewerColumn tableViewerColumn2 = new TableViewerColumn(tableViewer, SWT.NONE);
TableViewerColumn tableViewerColumn3 = new TableViewerColumn(tableViewer, SWT.NONE);
...
tableViewer.setLabelProvider(new UserAssignmentLabelProvider());
tableViewer.setContentProvider(new UserManagementContentProvider());
tableViewer.setInput(...);
Why I abandoned Swing and went for SWT/RCP?
- Cleanly Structured Rich Client Application Framework (branding, integration, provisioning, etc)
- Better native look-n-feel.
- A lot of useful open source OSGi plug-ins for your application development
- Developer can manage resource directly (some people might argue this is a step backward)
Subscribe to:
Posts (Atom)