Support generation of Java class with symbols for resources supplied with bundle (like images) #1315
Replies: 7 comments 13 replies
-
That's a helpful idea. The right place to defines something like that is probably the Would generate a class named But I think there are a few questions we should answer:
All these questions can certainly be answered, but there are many and it might be cumbersome to implement all these requirements/questions in a satisfying fashion. Another solution that would probably be simpler from a tooling POV and would user also give more control is to just write the mentioned java class that represents the resources by hand add a special Annotation (and maybe use a special type) so that a suitable PDE builder can verify that the referenced resource really exists in the bundle. Should Tycho also support it? At least should Tycho check if the generated class is in sync with the available files.? |
Beta Was this translation helpful? Give feedback.
-
I know, but the idea is about promoting resource location to Java API
It may be there as well, but we need to have these generated Java symbols on runtime, to query ImageRegistry for example.
We may need some flexibility, but also should have good defaults. May be an extra bundle header can serve us to query bundle resources.
What we use in our codebase is a record with the following fields:
This will be a breaking API change, since others may reference you by Platform URI. Only resource content may be changed
Yes, this also could be a way to go. Finally we should have an API Java class with symbols that corresponds to "public" images. Actually we use this approach for all the identifiers from
Not yet clear what exactly to support. |
Beta Was this translation helpful? Give feedback.
-
One can use platform:/plugin to refer to images: Using this with a URLImageDescriptor and an ImageRegistry that provides for sharing... |
Beta Was this translation helpful? Give feedback.
-
@merks yes, sure, one can. This discussion is how to promote such a resource (image) with its URL to a Java API and put it to a regular API control. |
Beta Was this translation helpful? Give feedback.
-
This is a skeleton of API we may want to have somewhere in Equinox to switch from blind string identifiers to typed records: record BundleIdentity(String symbolic) {
//may be version or other things later
}
interface ResourceUrl {
String url();
}
record ImageIdentity(BundleIdentity bundle, String path, String key) implements ResourceUrl {
@Override
public String url() {
return "platform:/plugin/" + bundle.symbolic() + "/$nl$/" + path; //$NON-NLS-1$ //$NON-NLS-2$
}
} and here something we can write manually or generate with PDE to then use as controllable and predictable API interface BundleResources {
BundleIdentity qualifier = new BundleIdentity("org.example.bundle"); //$NON-NLS-1$
interface Obj16 {
ImageIdentity atype = new ImageIdentity(qualifier, "icons/full/obj16/atype.png", "atype"); //$NON-NLS-1$ //$NON-NLS-2$
}
} BTW, in our code base we added such an API types to generated EMF Edit bundles and it appeared to be very handy for many use cases, including usage of |
Beta Was this translation helpful? Give feedback.
-
What's wrong with the approach that is taken e.g. in org.eclipse.ui.ISharedImages? |
Beta Was this translation helpful? Give feedback.
-
Created a PR for Equinox to demonstrate how API for image identification may look like |
Beta Was this translation helpful? Give feedback.
-
may look similar to https://developer.android.com/reference/android/R and help to address the following issues:
Beta Was this translation helpful? Give feedback.
All reactions