Repository navigation
Allow products to replace icons with combinable icon packs - #4603
HeikoKlare wants to merge 1 commit into
Conversation
|
Hey @HeikoKlare, thanks for picking up this open work item. It already looks very good, and I like that packs can be combined without knowing each other. Two points that would be good to consider while this is still internal: Theme dependency. Icon sets often come in a light and a dark variant, but File extension in keys. The keys include the extension, so a mapping for |
|
Once this goes in, I can add an optional css handler so that css themes can define their favorite icon set. |
|
Thank you for the immediate feedback! Dropping the file extensions from keys sounds reasonable to me. I consider the chance that there are two icons only differing in their extension quite low, so I would accept the risk for the sake of making the mapping resilient against icon replacements with other formats. I will adapt the PR accordingly. I also like the idea of theme dependency, just that I propose to keep this for a follow-up PR. This PR currently also does not contain any preferences UI or actual theme integration (which will be part of a follow-up PR, with the code already being present on the branch linked in the PR description) and I would like to make it even smaller if possible, it's just that essential functionality and examples for demonstrating the usage are necessary. Or do you see an issue with integrating the theme dependency as a follow-up? |
No. We can add that theme dependency as easy follow-up similar to preference pages. I would recommend to not wait to long with this change before merging so that we can polish it. We already missed to deliver this functionality in the last release and starting this early should give us an edge. |
|
Great, then let's keep it as follow-up. |
I have the icon packs from ux best practices ready via my theme plug-in so unless you really want to provide them (which is fine), I can do that. |
5f44661 to
06235f3
Compare
There was a problem hiding this comment.
🟡 Changes recommended
Platform URL paths are not percent-decoded before key normalization, causing resources with filenames such as a b.svg to fail to match their mapping keys.
1 open issue
What changed in this PR
This PR adds internal, combinable icon-pack support to Eclipse Platform UI, building on the JFace IImageURLModifier hook from #4399. Products can enable ordered packs through preferences without modifying the bundles that supply the original icons.
Changes:
- Adds the icon-pack registry, mapping loader, preference handling, and low-ranked image URL modifier.
- Provides three overlapping example packs with a toolbar control for switching presets after restart.
- Adds runtime tests, packaging integration, documentation, and design decisions.
| File | Description |
|---|---|
| tests/org.eclipse.e4.ui.iconpacks.tests/src/org/eclipse/e4/ui/internal/iconpacks/IconPacksTest.java | Tests URL keys, precedence, preferences, and service registration. |
| tests/org.eclipse.e4.ui.iconpacks.tests/plugin.properties | Defines test bundle labels. |
| tests/org.eclipse.e4.ui.iconpacks.tests/META-INF/MANIFEST.MF | Declares the test fragment and JUnit dependency. |
| tests/org.eclipse.e4.ui.iconpacks.tests/icons/pinned_ovr.svg | Supplies an original test icon. |
| tests/org.eclipse.e4.ui.iconpacks.tests/icons/filenav_nav.svg | Supplies an original test icon. |
| tests/org.eclipse.e4.ui.iconpacks.tests/fragment.xml | Contributes two test packs. |
| tests/org.eclipse.e4.ui.iconpacks.tests/data/iconpacks/second/replacement.svg | Supplies the second pack’s replacement fixture. |
| tests/org.eclipse.e4.ui.iconpacks.tests/data/iconpacks/second.properties | Defines overlapping mappings and an invalid key. |
| tests/org.eclipse.e4.ui.iconpacks.tests/data/iconpacks/malformed.properties | Exercises malformed mapping handling. |
| tests/org.eclipse.e4.ui.iconpacks.tests/data/iconpacks/formats/replacement.svg | Supplies the format-matching replacement fixture. |
| tests/org.eclipse.e4.ui.iconpacks.tests/data/iconpacks/formats.properties | Exercises exact and extensionless mappings. |
| tests/org.eclipse.e4.ui.iconpacks.tests/data/iconpacks/first/replacement.svg | Supplies the first pack’s replacement fixture. |
| tests/org.eclipse.e4.ui.iconpacks.tests/data/iconpacks/first.properties | Exercises valid, missing, and invalid replacements. |
| tests/org.eclipse.e4.ui.iconpacks.tests/build.properties | Packages fixtures and configures non-UI tests. |
| tests/org.eclipse.e4.ui.iconpacks.tests/about.html | Adds test bundle license information. |
| tests/org.eclipse.e4.ui.iconpacks.tests/.settings/org.eclipse.pde.prefs | Configures plug-in validation. |
| tests/org.eclipse.e4.ui.iconpacks.tests/.settings/org.eclipse.m2e.core.prefs | Configures Maven workspace integration. |
| tests/org.eclipse.e4.ui.iconpacks.tests/.settings/org.eclipse.jdt.ui.prefs | Configures Java formatting and cleanup. |
| tests/org.eclipse.e4.ui.iconpacks.tests/.settings/org.eclipse.jdt.core.prefs | Configures Java compilation and formatting. |
| tests/org.eclipse.e4.ui.iconpacks.tests/.settings/org.eclipse.core.runtime.prefs | Sets line endings. |
| tests/org.eclipse.e4.ui.iconpacks.tests/.settings/org.eclipse.core.resources.prefs | Sets UTF-8 encoding. |
| tests/org.eclipse.e4.ui.iconpacks.tests/.project | Defines test project builders and natures. |
| tests/org.eclipse.e4.ui.iconpacks.tests/.classpath | Defines the Java test classpath. |
| features/org.eclipse.e4.rcp/feature.xml | Includes icon-pack support in E4 RCP. |
| examples/pom.xml | Adds the example to the Maven reactor. |
| examples/org.eclipse.ui.examples.iconpacks/src/org/eclipse/ui/examples/iconpacks/SwitchIconPackPresetHandler.java | Stores selected presets and requests restart. |
| examples/org.eclipse.ui.examples.iconpacks/src/org/eclipse/ui/examples/iconpacks/IconPackPreset.java | Defines preset combinations and preference storage. |
| examples/org.eclipse.ui.examples.iconpacks/red.properties | Maps icons for the red pack. |
| examples/org.eclipse.ui.examples.iconpacks/README.md | Explains pack composition and manual testing. |
| examples/org.eclipse.ui.examples.iconpacks/plugin.xml | Registers example packs and toolbar commands. |
| examples/org.eclipse.ui.examples.iconpacks/plugin.properties | Defines example labels and descriptions. |
| examples/org.eclipse.ui.examples.iconpacks/META-INF/MANIFEST.MF | Declares example bundle dependencies. |
| examples/org.eclipse.ui.examples.iconpacks/icons/red/search.svg | Adds the red Search icon. |
| examples/org.eclipse.ui.examples.iconpacks/icons/red/save.svg | Adds the red Save icon. |
| examples/org.eclipse.ui.examples.iconpacks/icons/red/paste.svg | Adds the red Paste icon. |
| examples/org.eclipse.ui.examples.iconpacks/icons/red/copy.svg | Adds the red Copy icon. |
| examples/org.eclipse.ui.examples.iconpacks/icons/presets.svg | Adds the preset toolbar icon. |
| examples/org.eclipse.ui.examples.iconpacks/icons/green/problems_view.svg | Adds the green Problems icon. |
| examples/org.eclipse.ui.examples.iconpacks/icons/green/paste.svg | Adds the green Paste icon. |
| examples/org.eclipse.ui.examples.iconpacks/icons/green/outline.svg | Adds the green Outline icon. |
| examples/org.eclipse.ui.examples.iconpacks/icons/green/copy.svg | Adds the green Copy icon. |
| examples/org.eclipse.ui.examples.iconpacks/icons/blue/search.svg | Adds the blue Search icon. |
| examples/org.eclipse.ui.examples.iconpacks/icons/blue/properties.svg | Adds the blue Properties icon. |
| examples/org.eclipse.ui.examples.iconpacks/icons/blue/paste.svg | Adds the blue Paste icon. |
| examples/org.eclipse.ui.examples.iconpacks/icons/blue/outline.svg | Adds the blue Outline icon. |
| examples/org.eclipse.ui.examples.iconpacks/green.properties | Maps icons for the green pack. |
| examples/org.eclipse.ui.examples.iconpacks/build.properties | Packages example code, mappings, and icons. |
| examples/org.eclipse.ui.examples.iconpacks/blue.properties | Maps icons for the blue pack. |
| examples/org.eclipse.ui.examples.iconpacks/about.html | Adds example bundle license information. |
| examples/org.eclipse.ui.examples.iconpacks/.settings/org.eclipse.m2e.core.prefs | Configures Maven workspace integration. |
| examples/org.eclipse.ui.examples.iconpacks/.settings/org.eclipse.jdt.core.prefs | Configures Java compilation. |
| examples/org.eclipse.ui.examples.iconpacks/.settings/org.eclipse.core.runtime.prefs | Sets line endings. |
| examples/org.eclipse.ui.examples.iconpacks/.settings/org.eclipse.core.resources.prefs | Sets UTF-8 encoding. |
| examples/org.eclipse.ui.examples.iconpacks/.project | Defines example project builders and natures. |
| examples/org.eclipse.ui.examples.iconpacks/.classpath | Defines the example classpath. |
| examples/org.eclipse.ui.examples.iconpack/README.MD | Documents the new alternative to resource transforms. |
| docs/IconPacks.md | Documents configuration, mappings, behavior, and limitations. |
| docs/adr/0003-icon-packs-mapping-file.md | Records the properties mapping format decision. |
| docs/adr/0002-icon-packs-extension-point.md | Records the extension-point contribution decision. |
| bundles/org.eclipse.jface/META-INF/MANIFEST.MF | Grants icon-pack access to the provisional resource package. |
| bundles/org.eclipse.e4.ui.iconpacks/src/org/eclipse/e4/ui/internal/iconpacks/IconPackRegistry.java | Reads and validates contributed packs. |
| bundles/org.eclipse.e4.ui.iconpacks/src/org/eclipse/e4/ui/internal/iconpacks/IconPackPreferences.java | Reads and stores ordered pack preferences. |
| bundles/org.eclipse.e4.ui.iconpacks/src/org/eclipse/e4/ui/internal/iconpacks/IconPackLookup.java | Combines mappings using pack and format precedence. |
| bundles/org.eclipse.e4.ui.iconpacks/src/org/eclipse/e4/ui/internal/iconpacks/IconPackImageURLModifier.java | Applies packs through the JFace service hook. |
| bundles/org.eclipse.e4.ui.iconpacks/src/org/eclipse/e4/ui/internal/iconpacks/IconPack.java | Loads and validates replacement mappings. |
| bundles/org.eclipse.e4.ui.iconpacks/src/org/eclipse/e4/ui/internal/iconpacks/IconKeys.java | Converts supported URLs into icon lookup keys. |
| bundles/org.eclipse.e4.ui.iconpacks/schema/iconPacks.exsd | Defines and documents the internal extension schema. |
| bundles/org.eclipse.e4.ui.iconpacks/plugin.xml | Declares the icon-pack extension point. |
| bundles/org.eclipse.e4.ui.iconpacks/plugin.properties | Defines runtime bundle and extension labels. |
| bundles/org.eclipse.e4.ui.iconpacks/META-INF/MANIFEST.MF | Declares runtime dependencies and service metadata. |
| bundles/org.eclipse.e4.ui.iconpacks/build.properties | Packages runtime code, metadata, and schema. |
| bundles/org.eclipse.e4.ui.iconpacks/about.html | Adds runtime bundle license information. |
| bundles/org.eclipse.e4.ui.iconpacks/.settings/org.eclipse.pde.prefs | Configures plug-in validation. |
| bundles/org.eclipse.e4.ui.iconpacks/.settings/org.eclipse.pde.ds.annotations.prefs | Configures service descriptor generation. |
| bundles/org.eclipse.e4.ui.iconpacks/.settings/org.eclipse.pde.api.tools.prefs | Configures API compatibility checks. |
| bundles/org.eclipse.e4.ui.iconpacks/.settings/org.eclipse.m2e.core.prefs | Configures Maven workspace integration. |
| bundles/org.eclipse.e4.ui.iconpacks/.settings/org.eclipse.jdt.ui.prefs | Configures Java formatting and cleanup. |
| bundles/org.eclipse.e4.ui.iconpacks/.settings/org.eclipse.jdt.core.prefs | Configures Java compilation and formatting. |
| bundles/org.eclipse.e4.ui.iconpacks/.settings/org.eclipse.core.runtime.prefs | Sets line endings. |
| bundles/org.eclipse.e4.ui.iconpacks/.settings/org.eclipse.core.resources.prefs | Sets UTF-8 encoding. |
| bundles/org.eclipse.e4.ui.iconpacks/.project | Defines runtime project builders and natures. |
| bundles/org.eclipse.e4.ui.iconpacks/.classpath | Defines the runtime classpath. |
Review effort: Balanced
There was a problem hiding this comment.
🔵 Needs a closer look
Restart-based pack switching depends on a separate persistence fix not included in this snapshot, while modifier-only tests leave saved-perspective and workspace integration requiring human validation.
No open issues 🎉
1 resolved since last review
Review effort: Balanced
06235f3 to
e6a1990
Compare
laeubi
left a comment
There was a problem hiding this comment.
I only did a quick look, will try to take a closer one, see some first comments below.
e6a1990 to
24ce45a
Compare
Most projects in this repository carry the m2e Maven nature and builder, although none of them is a Maven project: the build is pomless Tycho, no project has a pom.xml and no classpath uses the Maven container. In a workspace with m2e, every build therefore also runs the Maven builder on these projects for no benefit, which only costs build time. The nature and builder were never intended. They came in with 6af7769 together with a resource filter of the VS Code Java language server, so apparently through an IDE import, after Bug 539276 had already removed them from one project as unwanted. The projects from eclipse.platform.text and those added since never had them. The nature, the builder and the m2e preference files are removed, so all projects are plain PDE projects, as in the other platform repositories. eclipse-platform#4603 (comment) Assisted-by: Claude Opus 5.5 <noreply@anthropic.com>
24ce45a to
bbf46eb
Compare
|
One more idea, for later and not for this PR: an optional |
I think those ideas are best placed in the general discussion: We still need to refine how icon themes may be predefined anyway, so it fits well. We need to ensure that we provide proper UX for the use cases we have identified in addition to the technical feasibility with a simple concept as proposed in this an a follow-up PR. When initially discussing a potential design for icon themes/packs, we also considered an extension concept an ran into multiple issues with that. |
Most projects in this repository carry the m2e Maven nature and builder, although none of them is a Maven project: the build is pomless Tycho, no project has a pom.xml and no classpath uses the Maven container. In a workspace with m2e, every build therefore also runs the Maven builder on these projects for no benefit, which only costs build time. The nature and builder were never intended. They came in with 6af7769 together with a resource filter of the VS Code Java language server, so apparently through an IDE import, after Bug 539276 had already removed them from one project as unwanted. The projects from eclipse.platform.text and those added since never had them. The nature, the builder and the m2e preference files are removed, so all projects are plain PDE projects, as in the other platform repositories. #4603 (comment) Assisted-by: Claude Opus 5.5 <noreply@anthropic.com>
|
In according with #4603 (comment)
I would like to merge this PR as soon as possible, so that I can provide the follow-up PRs that make the UI configuration and actual icon packs/themes available. And so that we have sufficient time for testing until the next release. |
Agreed, only the "I" part should become a "we" part ;-) I really like that this is moving forward and it seems that my fear that this feature is discussed ot death is not happening so I'm happy to help. |
There was a problem hiding this comment.
Thanks @HeikoKlare for your patience, I now had the deeper look I promised.
I like the idea but see two things I would like to discuss/adjust before this lands.
The first is how the modifier waits for the workspace.
IconPackImageURLModifier is already a DS component and already uses constructor injection for the BundleContext, but it then "polls "Platform.getInstanceLocation().isSet() and guards a lazily created lookup with volatile and synchronized, which is custom lifecycle code for something DS can express.
Components usually declare what they need as a service dependency, and for "the workspace is available" the right level to build on is IWorkspace and the bundle IScopeContext service (IScopeContext.BUNDLE_SCOPE_FILTER is public API for exactly that reference).
CheckMissingNaturesListener.java#L65-L77 is a DS component doing that with @Reference IWorkspace, @Reference(target = IScopeContext.BUNDLE_SCOPE_FILTER) IScopeContext and an @Activate method.
Equinox only registers the IScopeContext service once the instance location is set, so it also fits RCP products without org.eclipse.core.resources.
With such a reference added to the constructor, activation itself becomes the signal and the enabled packs can be read once in @Activate.
The workbench already treats a not yet registered modifier as "no replacement" (WorkbenchSWTActivator.java#L95-L103).
The second is the structure.
The service delegates to static helpers (IconPackPreferences, IconPackRegistry) plus a separate IconPackLookup that merges the maps, and I found the flow hard to follow for a feature of this size. Could the component own its state as instance fields, with fewer classes? I think with the DS adjustment this can the become a small and focused service and if required even hold some static functions for reuse on other (internal) places.
I am happy to help with the DS variant if that is useful, and let me know if anything is missing in that regards, we should craft new code with these patterns even though large amounts of platform code still use the problematic static access patterns for the IWorkspace and alike here!
bbf46eb to
ccc9473
Compare
|
Thanks a lot for the deeper look and the pointer to One detail: the lookup is still built on the first image load rather than in the constructor. SCR creates the service right away when the workbench's tracker picks it up, which happens inside the instance location's service event while Regarding the structure: with the change I made the component is a small service that adapts JFace image loading to the lookup. I would like to keep |
There was a problem hiding this comment.
On the IScopeContext reference: using it only as the "location is set" signal and reading through the preferences service is a good reasoning, as the product default would otherwise be lost.
On the structure, my concern is mostly about testability, which is the main benefit of DS.
IconPackPreferences.getEnabledIconPackIds calls Platform.getPreferencesService() (L47) and IconPackRegistry.getIconPacks calls Platform.getExtensionRegistry() (L50).
Both are only thin accessors for OSGi services (Platform.java#L855, #L1214), registered by equinox.preferences and equinox.registry.
The component could take both as constructor parameters, as WindowsDefenderConfigurator does for IPreferencesService.
The tests would profit directly: today they write to the global InstanceScope/DefaultScope and clean up afterwards (L54-L56) and call IconPackLookup.create and IconPackRegistry statically.
With injected services, the component itself can be tested with stubbed preferences and registry, so the tests exercise the path that really runs and fewer members need to be visible for testing.
A preference page can still use the Platform accessors, but I would keep static access to the edges.
I also took this one step further and tried it out, as an example is easier to judge than an argument: 6e213c5 on top of your head commit, which you can use or discard as you like.
The modifier receives IPreferencesService and IExtensionRegistry through its constructor and creates new IconPackRegistry(registry, new IconPackPreferences(preferences)), both instance classes without Platform access.
The registry reads the enabled packs on the first findReplacement(key) and caches them, so IconPackLookup is not needed anymore, and the modifier constructor does no work.
Production code goes from +77/−151 lines with one class less, the tests change by +46/−37 and use real services directly.
From OSGi point of view, this also shows that IconPackRegistry and IconPackPreferences are actually very well suited to become a service (OSGi not strictly require a service to be an interface) and then IconPackImageURLModifier would just consume IconPackRegistry directly without even need to care about the details...
|
I tried that step on top now: 290eca0 makes The tests still create the instances directly, so only two lines changed there, if classes where not final or even interfaces one would be able to replace this detail of the icon-pack service as well. |
ccc9473 to
cddc5e7
Compare
|
Thanks a lot for taking the time to write this down as commits, that made the discussion much easier. I took both of them as they are and squashed them into the PR commit with you as co-author. I agree that with the services injected, the registry is the place where resolving a replacement belongs, so the precedence rules now live there instead of in a separate lookup class. On top of that, I made two small changes. The registry caches the enabled packs as a private record I also rebased the follow-up with the preference page onto it (https://github.com/HeikoKlare/eclipse.platform.ui/tree/icon-packs-appearance). The page creates its own |
| ### Alternatives | ||
|
|
||
| **OSGi services, e.g., declarative services components.** Each pack registers a service that | ||
| describes it and provides its replacements, as | ||
| [proposed in the discussion](https://github.com/eclipse-platform/eclipse.platform.ui/discussions/2870#discussioncomment-18799936). | ||
| This works without the Equinox extension registry and supports packs coming and going at runtime. | ||
|
|
||
| A component always needs an implementation class, though, so a pack bundle would either contain | ||
| code, against requirement 1, or reference a generic implementation of the runtime bundle, which | ||
| makes that implementation part of the contract between the runtime and every pack bundle. | ||
| Listing the packs requires the service component runtime to activate every pack bundle, against | ||
| requirement 2, and component properties have no localization of their own, against | ||
| requirement 3. Packs coming and going at runtime are of no use yet either, as images that | ||
| already exist are not reloaded, so packs only take effect after a restart. |
There was a problem hiding this comment.
I just wanted to point out that a pure "OSGi" solution would be to use the Extender Pattern.
Currently the plugin.xml fragment looks like this:
<iconPack
description="%iconPack.red.description"
id="org.eclipse.ui.examples.iconpacks.red"
mapping="red.properties"
name="%iconPack.red.name">
</iconPack>
If we now assume that its unlikely one bundle would supply more than one individual choose-able icon pack one could say an Icon-Pack-Bundle is shaped like this:
- Its
Bundle-Symbolic-Nameis the id of the icon pack. - Its
Bundle-Descriptionis the description of the icon pack - Its
Bundle-Nameis the name of the icon pack - There is a custom Header
Eclipse-IconPackand its value is the properties file e.g. herered.properties
As Bundle headers are translatable (except e.g. the bsn), this would then allows a plain OSGi solution without the dependency to the Equinox extension registry but also in a completely declarative way.
On the producer side, this has the nice effect that one can relatively easily have a plain maven build where one just configures some extra headers to the jar packaging without the need to maintain a vendor/eclipse specific plugin.xml or even use bnd directly as it was done here: https://github.com/eclipse-platform/eclipse.platform.images/blob/master/org.eclipse.images/pom.xml
On the consumer side, this would allow others to consume icon packs without the need of understanding/implementing plugin.xml parsing and extension points in general, the code here can even be generalized and move to a "core" bundle in most parts (e.g. only IconPackPreferences is Eclipse/E4/Platform specific).
Even if that approach is not chosen it should be noted here and maybe with why not. With the current approach, I think it would rather easy to even combine all those strategies.
There was a problem hiding this comment.
Thanks for pointing this out, I added it to the ADR as an alternative. It does meet the three requirements as they are listed (no code, no activation, translatable headers), and I agree that working without the extension registry and building pack bundles without a plugin.xml would be nice. What speaks against it is that it ties a pack to its bundle:
- A bundle could only provide one pack, unless a header lists several packs with attributes that the runtime has to localize itself, while a bundle may well provide variants of its icons, as the example bundle does with its three packs.
- The pack ID would be the bundle symbolic name, and that is what the preference of the enabled packs stores, so renaming the bundle or moving the pack to another bundle would silently disable it for everyone who enabled it.
- The bundle name, as shown in the installation details, would double as the name by which users choose the pack.
- Most importantly, we expect packs to get more structure: the light or dark theme a pack is meant for, as Lars suggested, a pack extending another one, or icon themes combining several packs. With an extension point, these become optional attributes and elements described by the schema, while with manifest headers they would need further custom headers with a syntax of their own that PDE does not validate.
As you say, the approaches do not exclude each other, so I also extended the consequence in the ADR that manifest headers, like OSGi services, can be added as a further source of packs later without changing how users enable and order packs.
There was a problem hiding this comment.
Just some remarks:
- Changing the bundle ID is really rare so I won't count this, the same would apply if someone changes the pack-id and I think both will have some relation anyway (e.g. lets say a bundle
company.aexposing a pack with idcompany.bwould be rather unusual and ids more for internal use. - A bundle that provides multiple packs would mean you can not install/uninstall them individually so I would expect one bundle to provide one pack anyway, at least it is not really limiting as a bundle cost not much but gives more flexibility, one can still group "packs" by a feature for example.
- If one really needs a complex structure, then maybe an structured format like XML/json would be more suitable than a properties file like e.g. OSGi DS so one does not encode things at different places.
I also want to mention it here because the bundle is meant as an E4/RCP bundle by the name org.eclipse.e4.ui.iconpacks and plugin.xml is actually more tied to the E3 world (aka compatibility layer). As the e4 model is extensible, a fragment.e4xmi would be a more natural choice and should possibly at least be evaluated/listed as an alternative as well.
There was a problem hiding this comment.
If one really needs a complex structure, then maybe an structured format like XML/json would be more suitable than a properties file like e.g. OSGi DS so one does not encode things at different places.
Just to clarify: the configurations we have discussed so far will be at the level of the extension, not at the level of an individual icon replacement.
| Bundle-Localization: plugin | ||
| Bundle-RequiredExecutionEnvironment: JavaSE-21 | ||
| Bundle-ActivationPolicy: lazy | ||
| Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.29.0,4.0.0)", |
There was a problem hiding this comment.
can we replace this maybe by package imports (if no split package is involved) or at least by the dedicated require bundle? org.eclipse.core.runtime sadly has some bad dependency shape and from a first look it seems not needing anything from that particularly.
There was a problem hiding this comment.
The registry and preference types indeed come from the narrower org.eclipse.equinox.registry and org.eclipse.equinox.preferences bundles, but the bundle also uses ILog for logging, which only org.eclipse.core.runtime provides. As org.eclipse.core.runtime is a split package, a package import would be wired to org.eclipse.core.runtime as well, so getting rid of that dependency would mean replacing ILog, which is the logging the Platform code consistently uses, also in DS components such as ThemeEngineManager. In addition, the modifier is only installed by the E4 workbench (org.eclipse.e4.ui.workbench.swt), which requires org.eclipse.core.runtime itself, so narrowing the dependency here would not remove it from any runtime in which icon packs are applied. So I think we need to / should keep it for now.
There was a problem hiding this comment.
Right, I forgot about that ILog is still part of org.eclipse.core.runtime :-\
| * an icon in all the formats a bundle provides it in, e.g., <code>a.png</code> | ||
| * and <code>a.svg</code>. | ||
| */ | ||
| public final class IconKeys { |
There was a problem hiding this comment.
Just as a nitpick, IconKeys could be a DS service as well, this would move the BundleContext dependency into this e.g. like:
@Activate
public IconKeys(BundleContext ctx) {
this(bundleId-> {
Bundle bundle = bundleContext.getBundle(bundleId);
return bundle == null ? null : bundle.getSymbolicName();
}
}
public IconKeys(LongFunction<String> bundleIdToSymbolicName) {
...
}
IconPackImageURLModifier can then become
@Activate
public IconPackImageURLModifier(@Reference IconKeys key, @Reference IconPackRegistry iconPacks) {
...
}
The effect would be that one can even replace how keys are computed, and IconPackImageURLModifier is free from any OSGi semantics or how things are computed/derived, it become a pure adapter and might even later live in a generic place:
- As long as no one eve register an
IconKeysorIconPackRegistryservice (and those become interfaces) it will do nothing - The
org.eclipse.e4.ui.iconpacksbecomes the default implementation and supply those (e.g. asBundleContextIconKeysandExtensionsIconPackRegistry) - A product might replace the
IconKeysor theIconPackRegistryindividually or not useorg.eclipse.e4.ui.iconpacksand supply an own way to find/configure icon packs.
There was a problem hiding this comment.
I agree that this would be the way to go if we want to generalize the runtime. For now I would keep it as it is, though: the key is not really a free variable, as <bundle>/<path> is the contract with the mapping files of all packs, so a different key computation would only be useful together with a different mapping format, i.e., a different mechanism. That mechanism can already be plugged in as a whole by registering an individual IImageURLModifier, and having one place to replace it keeps the behavior easier to follow than components that can be exchanged independently. As everything is internal, we can still split it into interfaces and services later without breaking anyone, once there is a concrete need, e.g., a second source of packs.
laeubi
left a comment
There was a problem hiding this comment.
I think it looks good in general, I have added some remarks as general comments now where I think it can be beneficial to take them into account.
cddc5e7 to
ed425b0
Compare
Products that want a different icon style can only replace icons by patching resources of the Platform bundles, e.g., with the Equinox transforms hook, which requires full control over the product's content. Icon packs from different providers, such as the Platform, other projects or third parties, cannot be combined that way, although the icon pack discussion (eclipse-platform#2870) agreed on packs that are combinable without knowing each other. Products can now enable icon packs in their plugin_customization.ini. An icon pack is a bundle that replaces icons of other bundles without changing them. Enabled packs are combined in the order of the preference: the first enabled pack that replaces an icon wins, and icons that no pack replaces keep their original appearance. Changes take effect after a restart. The new bundle org.eclipse.e4.ui.iconpacks defines an internal extension point, in which a pack maps original icons (bundle and path) to replacement icons via a properties file, and registers an IImageURLModifier service that applies the enabled packs whenever JFace loads an image. A mapping key may omit the file extension to match the icon in all formats its bundle provides, as bundles often ship PNG and SVG variants of an icon side by side. ADRs record why packs are contributed via an extension point and mapped in a properties file. The example org.eclipse.ui.examples.iconpacks provides three overlapping packs and a toolbar drop-down to switch between combinations of them. Nothing is exported or declared as API, so that everything can still change; a preference UI for users to select packs follows separately. Co-authored-by: Christoph Läubrich <laeubi@laeubi-soft.de> Assisted-by: Claude Opus 5.5 <noreply@anthropic.com>
ed425b0 to
a3c3fd7
Compare
HannesWell
left a comment
There was a problem hiding this comment.
After looking through the ADR I question if the first two requirements are really suitable, as I've described below.
With them a Java code based definition of Icon packs would be possible (as described in #2870 (reply in thread)) and I still believe that such a definition would be better. It would be
- saver even with existing tooling (type checks etc. ensure the basic structure is correct) and only 'paths' could be done wrong.
- more powerful since different techniques of defining replacements could be combine (e.g. 1-1, pattern or path based). Theoretically that would also be possible with a file based approach.
- avoid the extra
plugin.xmland files with a new format to learn (and without tool support as of now) - It would allow (as follow-up) even more advanced integrations that, after being adopted, would avoid the need for a restart.
And it would be as flexible as the file based approach since one can define an arbitrary number of packs in one bundle.
However a Java API based approach could also be added later.
And, in general, even both approaches could be supported (if we really want that).
| 1. A pack bundle needs no code, so that contributors who create icons can provide a pack without | ||
| writing Java. |
There was a problem hiding this comment.
Why is that a requirement?
When contributing to a platform that's written in Java such a requirement seems a bit strict for me.
My guess is that it is based on the assumption that icons are potentially created by non-technical designers that might not be proficient with Java?
And while I believe that can certainly be the case, I question that such a person will have the intention to contribute icon Packs for an Eclipse based product solely on their own and will then be able to distribute it through the usual channels without a technical person proficient in all these technologies.
Therefore I assume providing icon packs will always be an interdisciplinary task and I don't think this restriction will help to significantly improve adaption and will more restrict the design process.
| 2. The installed packs can be listed, e.g., on a preference page, without activating the pack | ||
| bundles or loading classes from them. |
There was a problem hiding this comment.
If icon packs are designed without an activator (or at least only with a small one) and the classes that only provide overview information are lazy or lean, the performance overhead is very small.
Furthermore the question is, in which scenarios the listing use-case even happens and how important performance in that case is?
My assumption is that listing is only relevant when a user opens the preferences to select the pack?
In that case a slight delay of maybe half second could be acceptable. But I expect it not to take that long.
| A component always needs an implementation class, though, so a pack bundle would either contain | ||
| code, against requirement 1, or reference a generic implementation of the runtime bundle, which | ||
| makes that implementation part of the contract between the runtime and every pack bundle. | ||
| Listing the packs requires the service component runtime to activate every pack bundle, against | ||
| requirement 2, and component properties have no localization of their own, against | ||
| requirement 3. Packs coming and going at runtime are of no use yet either, as images that |
There was a problem hiding this comment.
Based on my comments from above, I'd say the violation of requirement 1 isn't a problem.
And a code/Java based API could also be designed in a way that the violation of requirement 2 isn't a practical problem.
The violation of requirement three isn't true.
If labels and descriptions are supplied through methods of the service component defining an icon pack the returned strings can be translated through the NLS mechanism used everywhere else in Eclipse.
It would only be difficult/impossible if labels and descriptions where service properties, but it's not required to design such 'user-facing' content that way.
Yes I think that concept is important to make Icon packs convenient. |
|
Just as a note: I think If or not we really need ADRs, if they are value or normative here is a bit out of scope as I was not even aware that we agreed to write them and what the process is to them become agreed. |
|
Thank you for the additional input. I will rephrase the ADRs to not state properties of certain alternatives as requirements if we do not really require them (such as no Java code being required). I would like to clarify what exactly is challenged and requires further input now:
|
If that targets my comment, I just wanted to express that I would not put too much weight on the "ADR nature" of these documents, as we have no written requirement or process for them (neither If ADRs help us to settle a structure for documenting such state, I am fine with that as well. The move to FFM would definitely be worth an ADR. |
I find ADR (or however one calls them) definitively useful to record the considerations for an architectural decisions. Previously such considerations where captured in bug reports or PRs, but since such system are probably not forever (as we saw with Bugzilla which is still readable and Gerrit at EF, which is gone), it makes sense to record important discussions in the repo. But from my POV such ADRs are just informative and are not normative and are especially not normative for future discussion. In general I think we are just bound to the rules of the EDP plus what the PMC decided additionally (e.g. API deprecation rules etc.)
Personally I'm still convinced a Java API based approach would be superior and of course I'd find it nice if it would be done now. But currently I cannot if I have the time to do it by myself and of course I cannot expect that somebody else does it just because I think so. Furthermore the way how icon packs are modeled is only one part of the problem.
The mentioned requirements are excluding Java based APIs literally, but don't give a rational or justification for that (at least I didn't find saw it). Subsequently a Java based modeling using DS components is rejected based on these requirements.
Maybe I forgot it, but I just recalled just the agreed on starting simple with really just Icon packs and always requiring a restart. It has been some time since we discussed that already.
I don't want to be the one delaying that. And I think this is okay, but not ideal. But maybe I'm also the only one. |
I would relax that and say that's not your POV but that's how ADRs are defined. Just as the name says, they are records for architectural decision, and they can be revised/superceded. They are just important to document why some architectural decision was made (particularly including evaluated alternatives). They do not are based on requirements at that point in time, but they do not normatively define that those requirements as well as architectural decision must not be changed in the future.
I propose to do that in an agile while (actually I starting doing it like that). I have just started adding ADRs and I actually have a template lying around, but wanted to gather some ADRs first before we have length discussion about the need of it in the beginning.
Yes, that's part of the branch I have linked as well and will be part of a direct successor PR I will propose once this is merged.
I don't think it really matter what was discussed if we do not all recall anyway. Seems like all of us had different takeaways from the discussions we had (e.g., also on the technical mechanism contributed without any adoption of it shortly after). Back then we also discussed that the Java-based representation is something optional and depending on how it will be realized, it must will be something that may not be adopted everywhere (in particular if not only an icon replacement but an icon itself is modeled in Java) and then it can only be complementary to another, generic mechanism anyway. That's why I took away that we start with something generic and simple that we can extend with more sophisticated mechanisms if needed.
It is intended to be like that, yes. But I am also not sure what you mean by this not being "ideal". How is "ideal" defined? No one says this will be the perfect representation, but I am not as convinced that a Java-based representation of icons / icon packs is. That one may be prone to be over-engineered (YAGNI) whereas with this approach (internal, so that it can be revised), we follow KISS. If we want to come to good solution, starting with something simple and internal and revising it during adoption in the framework is more likely to reveal a good solution that doing high upfront design of a complex solution. |

What & Why
Products that want a different icon style can today only replace icons by patching the resources of the Platform bundles, e.g., with the Equinox transforms hook, which requires full control over the product's content. Icon packs from different providers, such as the Platform, other projects or third parties, cannot be combined that way. The discussion in #2870 agreed on icon packs that are combinable without knowing each other, built on the
IImageURLModifierhook from #4399.With this change, a product can enable icon packs in its
plugin_customization.ini. An icon pack is a bundle that replaces icons of other bundles without changing them. Several enabled packs are combined in the order of the preference: the first enabled pack that replaces an icon wins, and icons that no pack replaces keep their original appearance. Changes take effect after a restart. The exampleorg.eclipse.ui.examples.iconpacksprovides three small packs with overlapping icons and a toolbar drop-down that switches between combinations of them, to try out how packs are combined.The new bundle
org.eclipse.e4.ui.iconpacksdefines an internal extension point, in which a pack maps original icons, identified by bundle and path, to its replacement icons via a properties file. It registers anIImageURLModifierservice that applies the enabled packs whenever JFace loads an image. The service has the default ranking, so a bundle that registers its own modifier with a higher ranking replaces it.docs/IconPacks.mddescribes the concept and its limitations, and two ADRs record why packs are contributed via an extension point and mapped in a properties file.This is the first increment: nothing is exported or declared as API, so that everything can still change. Letting users select packs in the preferences, and a dual-tone pack for the Platform UI, come in a follow-up. A preview of that full implementation is on the branch icon-packs-appearance of my fork. This PR depends on a separate fix of the
IImageURLModifierhook, which stops the workbench from persisting replacement icon URLs in the workbench model (e.g., in perspectives saved while a pack is enabled), so that changing the enabled packs fully takes effect after a restart; that fix will be opened as its own PR.How to test
The test shows that icons are replaced by the enabled packs and that combined packs resolve overlaps by their order.
org.eclipse.e4.ui.iconpacksandorg.eclipse.ui.examples.iconpacks.-pluginCustomization <file>, where the file containsorg.eclipse.e4.ui.iconpacks/enabledIconPacks=org.eclipse.ui.examples.iconpacks.green: only Copy, Paste, Problems and Outline are green.Screenshots
The main toolbar and the Outline and Problems tabs of the Java perspective (light theme, 100% zoom), without an icon pack, with the example packs enabled as Red, Green, Blue, and as Blue, Green, Red. The first enabled pack that replaces an icon wins: Search turns red and then blue, Outline green and then blue, while Problems stays green, as only the green pack replaces it.