Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[concierge-dev] How to set Image from Bundle-Icon header where bundle is in INSTALLED state

Here is my snippet:

import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
...

private static final String ICON_HEADER = "Bundle-Icon";
...

final BundleContext bundleContext = framework.getBundleContext();

            bundleContext.addBundleListener((BundleEvent event) -> {
                Bundle bundle = event.getBundle();
                String resolvedBundleEventType = resolveBundleEventType(event.getType());
                System.out.println(bundle.getSymbolicName() + " -> " + resolvedBundleEventType);

                if (resolvedBundleEventType == "INSTALLED") {
                    Image bundleImage = null;
                    URL entry = bundle.getEntry(bundle.getHeaders().get(ICON_HEADER));
                    if (entry != null) {
                        bundleImage = new Image(entry.toString());
                    }

                    if (bundleImage != null) {
                        ImageView bundleImageView = new ImageView(bundleImage);
                        bundleImageView.setX(30);
                        bundleImageView.setY(100);
                        ((Group) scene.getRoot()).getChildren().add(bundleImageView);
                    }
                }
            });

If I replace the line
if (resolvedBundleEventType == "INSTALLED") {
to
if (resolvedBundleEventType== "RESOLVED") {
then all is ok.

There is no way to do this in INSTALLED state of bundle?

Back to the top