|
|
Re: How to contribute a view programatically ? [message #452824 is a reply to message #452810] |
Mon, 17 July 2006 13:29 |
sensystems 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
|
|
|
Powered by
FUDForum. Page generated in 0.03539 seconds