Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » How to contribute a view programatically?
How to contribute a view programatically? [message #452803] Sun, 16 July 2006 01:46 Go to next message
sensystems is currently offline sensystemsFriend
Messages: 24
Registered: July 2009
Junior Member
Hello, can you tellme how to add views programatically to a rcp
application? maybe some example.

The app im working should load the view list from the remote server, and
then register it in the iviewregistry which i assume is the right way of
register then im the workbench? right?

thanks
Re: How to contribute a view programatically ? [message #452810 is a reply to message #452803] Sun, 16 July 2006 22:21 Go to previous messageGo to next message
sensystems is currently offline sensystemsFriend
Messages: 24
Registered: July 2009
Junior Member
Well i have spent a lot of hours on this issue,
Here is how to doit:

the answer is to register a bundle dynamically
in this case my plugin wich defines the new views is in the dir
"t:/aBundle" so if you want to add new views, just edit the plugin.xml

Bundle[] toRefresh = new Bundle[1];
toRefresh[0] = context.installBundle("reference:file:t:/aBundle");
ServiceReference packageAdminRef =
context.getServiceReference(PackageAdmin.class.getName());
PackageAdmin packageAdmin = null;
if (packageAdminRef != null) {
packageAdmin = (PackageAdmin) context.getService(packageAdminRef);
if (packageAdmin == null)
return;
}
packageAdmin.refreshPackages(toRefresh);

note: the bundle context in this scenario is passed to an extra plugin
ive created in order to get the context, once the plugin is started.

public void start(BundleContext context) throws Exception {

I hope this can be helpfull fore someone else


sensystems wrote:
> Hello, can you tellme how to add views programatically to a rcp
> application? maybe some example.
>
> The app im working should load the view list from the remote server,
> and then register it in the iviewregistry which i assume is the right
> way of register then im the workbench? right?
>
> thanks
Re: How to contribute a view programatically ? [message #452824 is a reply to message #452810] Mon, 17 July 2006 13:29 Go to previous message
sensystems is currently offline sensystemsFriend
Messages: 24
Registered: July 2009
Junior Member
Well, there is another way using "Dynamic Extensions" which is available
from 3.2

https://bugs.eclipse.org/bugs/show_bug.cgi?id=112954

Here is an example, maybe not the best one:

URL u = Platform.getBundle("rcp.dynamicpluginloaderTest").getEntry(
"icons/myplugin.xml");
IExtensionRegistry reg = RegistryFactory.getRegistry();
Object key = ((ExtensionRegistry) reg).getTemporaryUserToken();
Bundle bundle = Activator.getDefault().getBundle();
IContributor contributor =
ContributorFactoryOSGi.createContributor(bundle);
try {
reg.addContribution(u.openStream(), contributor, false, null, null, key);
} catch (Exception e) {
e.printStackTrace();
}

sensystems wrote:
> Well i have spent a lot of hours on this issue,
> Here is how to doit:
>
> the answer is to register a bundle dynamically
> in this case my plugin wich defines the new views is in the dir
> "t:/aBundle" so if you want to add new views, just edit the plugin.xml
>
> Bundle[] toRefresh = new Bundle[1];
> toRefresh[0] = context.installBundle("reference:file:t:/aBundle");
> ServiceReference packageAdminRef =
> context.getServiceReference(PackageAdmin.class.getName());
> PackageAdmin packageAdmin = null;
> if (packageAdminRef != null) {
> packageAdmin = (PackageAdmin) context.getService(packageAdminRef);
> if (packageAdmin == null)
> return;
> }
> packageAdmin.refreshPackages(toRefresh);
>
> note: the bundle context in this scenario is passed to an extra plugin
> ive created in order to get the context, once the plugin is started.
>
> public void start(BundleContext context) throws Exception {
>
> I hope this can be helpfull fore someone else
>
>
> sensystems wrote:
>> Hello, can you tellme how to add views programatically to a rcp
>> application? maybe some example.
>>
>> The app im working should load the view list from the remote server,
>> and then register it in the iviewregistry which i assume is the right
>> way of register then im the workbench? right?
>>
>> thanks
Previous Topic:IPartListener2 question
Next Topic:adding menu items
Goto Forum:
  


Current Time: Sun Oct 13 16:51:21 GMT 2024

Powered by FUDForum. Page generated in 0.03539 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top