-
Notifications
You must be signed in to change notification settings - Fork 52
Fix #364 - Use image registries #365
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
4081440
feat: Add image registries (#364)
travkin79 cd4a030
Migrate image loading and disposal to using image registries (#364)
travkin79 2e88e7e
Use image registries to access shared images from other plug-ins (#364)
travkin79 45c02b3
Simplify WrappableIconLink to take only an Image parameter (#364)
travkin79 9427256
Remove unused buildImage(Descriptor)FromPngPath helpers (#364)
travkin79 d7d4e2b
Document image registry usage and disposal rules in copilot instructi…
travkin79 0d6ad79
Improve javadoc: clarify image disposal
travkin79 0a2880a
Fix mixed image ownership in McpUtils.loadServerIcon
travkin79 dc5f822
Fix stale SpinnerAnimator Javadoc on frame ownership
travkin79 d580fea
fix: Remove unused dependencies
travkin79 980d83f
Remove unused image registry methods returning ImageDescriptor
travkin79 e820a33
Complete Javadoc for public image registry APIs
travkin79 49bee87
Hide spinner frame constants
travkin79 4cd7c6c
Use shared registry image for NES ruler column icon
travkin79 4d0b6dc
Add insert icon to copilot's image registry
travkin79 c333bd7
Remove unused method
travkin79 31dfca0
Use the image registry in McpRuntimeLogger
travkin79 0f0f128
Use the image registry for accessing the terminal icon
travkin79 9766881
Provide a populated image registry to turn widget tests
travkin79 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <classpath> | ||
| <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-17"/> | ||
| <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> | ||
| <classpathentry kind="src" path="src"> | ||
| <attributes> | ||
| <attribute name="test" value="true"/> | ||
| </attributes> | ||
| </classpathentry> | ||
| <classpathentry kind="output" path="target/classes"/> | ||
| </classpath> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <projectDescription> | ||
| <name>com.microsoft.copilot.eclipse.ui.jobs.test</name> | ||
| <comment></comment> | ||
| <projects> | ||
| </projects> | ||
| <buildSpec> | ||
| <buildCommand> | ||
| <name>org.eclipse.jdt.core.javabuilder</name> | ||
| <arguments> | ||
| </arguments> | ||
| </buildCommand> | ||
| <buildCommand> | ||
| <name>org.eclipse.m2e.core.maven2Builder</name> | ||
| <arguments> | ||
| </arguments> | ||
| </buildCommand> | ||
| <buildCommand> | ||
| <name>org.eclipse.pde.ManifestBuilder</name> | ||
| <arguments> | ||
| </arguments> | ||
| </buildCommand> | ||
| <buildCommand> | ||
| <name>org.eclipse.pde.SchemaBuilder</name> | ||
| <arguments> | ||
| </arguments> | ||
| </buildCommand> | ||
| </buildSpec> | ||
| <natures> | ||
| <nature>org.eclipse.m2e.core.maven2Nature</nature> | ||
| <nature>org.eclipse.pde.PluginNature</nature> | ||
| <nature>org.eclipse.jdt.core.javanature</nature> | ||
| </natures> | ||
| </projectDescription> |
9 changes: 9 additions & 0 deletions
9
com.microsoft.copilot.eclipse.ui.jobs.test/.settings/org.eclipse.jdt.core.prefs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| eclipse.preferences.version=1 | ||
| org.eclipse.jdt.core.compiler.codegen.targetPlatform=17 | ||
| org.eclipse.jdt.core.compiler.compliance=17 | ||
| org.eclipse.jdt.core.compiler.problem.assertIdentifier=error | ||
| org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled | ||
| org.eclipse.jdt.core.compiler.problem.enumIdentifier=error | ||
| org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning | ||
| org.eclipse.jdt.core.compiler.release=enabled | ||
| org.eclipse.jdt.core.compiler.source=17 |
4 changes: 4 additions & 0 deletions
4
com.microsoft.copilot.eclipse.ui.jobs.test/.settings/org.eclipse.m2e.core.prefs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| activeProfiles= | ||
| eclipse.preferences.version=1 | ||
| resolveWorkspaceProjects=true | ||
| version=1 |
11 changes: 11 additions & 0 deletions
11
com.microsoft.copilot.eclipse.ui.jobs.test/META-INF/MANIFEST.MF
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| Manifest-Version: 1.0 | ||
| Bundle-ManifestVersion: 2 | ||
| Bundle-Name: com.microsoft.copilot.eclipse.ui.jobs.test | ||
| Bundle-SymbolicName: com.microsoft.copilot.eclipse.ui.jobs.test;singleton:=true | ||
| Bundle-Version: 0.20.0.qualifier | ||
| Bundle-Vendor: GitHub Copilot | ||
| Bundle-RequiredExecutionEnvironment: JavaSE-17 | ||
| Fragment-Host: com.microsoft.copilot.eclipse.ui.jobs | ||
| Automatic-Module-Name: com.microsoft.copilot.eclipse.ui.jobs.test | ||
| Require-Bundle: junit-jupiter-api;bundle-version="5.10.1", | ||
| junit-jupiter-params;bundle-version="5.10.1" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| source.. = src | ||
| output.. = target/classes | ||
| bin.includes = META-INF/,\ | ||
| .,\ | ||
| fragment.xml | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <?eclipse version="3.4"?> | ||
| <plugin> | ||
|
|
||
| </plugin> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| <project xmlns="http://maven.apache.org/POM/4.0.0" | ||
| xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
| xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
| <modelVersion>4.0.0</modelVersion> | ||
| <parent> | ||
| <groupId>com.microsoft.copilot.eclipse</groupId> | ||
| <artifactId>github-copilot-for-eclipse</artifactId> | ||
| <version>${copilot-plugin-version}</version> | ||
| </parent> | ||
| <artifactId>com.microsoft.copilot.eclipse.ui.jobs.test</artifactId> | ||
| <packaging>eclipse-test-plugin</packaging> | ||
| <name>${base.name} :: UI Jobs Tests</name> | ||
|
|
||
| <properties> | ||
| <checkstyle.skip>true</checkstyle.skip> | ||
| </properties> | ||
|
|
||
| <profiles> | ||
| <profile> | ||
| <id>skip-tests-during-ui-probe</id> | ||
| <activation> | ||
| <property> | ||
| <name>probe.script</name> | ||
| </property> | ||
| </activation> | ||
| <build> | ||
| <plugins> | ||
| <plugin> | ||
| <groupId>org.eclipse.tycho</groupId> | ||
| <artifactId>tycho-surefire-plugin</artifactId> | ||
| <version>${tycho-version}</version> | ||
| <configuration> | ||
| <skipTests>true</skipTests> | ||
| </configuration> | ||
| </plugin> | ||
| </plugins> | ||
| </build> | ||
| </profile> | ||
| </profiles> | ||
|
|
||
| <build> | ||
| <plugins> | ||
| <plugin> | ||
| <groupId>org.eclipse.tycho</groupId> | ||
| <artifactId>tycho-surefire-plugin</artifactId> | ||
| <version>${tycho-version}</version> | ||
| <configuration> | ||
| <useUIHarness>true</useUIHarness> | ||
| <useUIThread>false</useUIThread> | ||
| </configuration> | ||
| </plugin> | ||
| </plugins> | ||
| </build> | ||
| </project> |
41 changes: 41 additions & 0 deletions
41
...eclipse.ui.jobs.test/src/com/microsoft/copilot/eclipse/ui/jobs/CopilotJobsImagesTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| // Copyright (c) Microsoft Corporation. | ||
| // Licensed under the MIT license. | ||
|
|
||
| package com.microsoft.copilot.eclipse.ui.jobs; | ||
|
|
||
| import static org.junit.jupiter.api.Assertions.assertNotNull; | ||
|
|
||
| import java.util.stream.Stream; | ||
|
|
||
| import org.junit.jupiter.params.ParameterizedTest; | ||
| import org.junit.jupiter.params.provider.Arguments; | ||
| import org.junit.jupiter.params.provider.MethodSource; | ||
|
|
||
| /** | ||
| * Verifies that every public constant in {@link CopilotJobsImages} refers to a bundle resource | ||
| * that actually exists on the classpath. | ||
| * | ||
| * <p>New constants are discovered automatically via reflection; no separate list needs to be | ||
| * maintained. | ||
| */ | ||
| class CopilotJobsImagesTest { | ||
|
|
||
| static Stream<Arguments> iconPaths() { | ||
| return Stream.of(CopilotJobsImages.class.getDeclaredFields()) | ||
| .filter(f -> f.getName().startsWith("IMG_")) | ||
| .map(f -> { | ||
| try { | ||
| return Arguments.of(f.getName(), f.get(null)); | ||
| } catch (IllegalAccessException e) { | ||
| throw new IllegalStateException("Cannot read constant: " + f.getName(), e); | ||
| } | ||
| }); | ||
| } | ||
|
|
||
| @ParameterizedTest(name = "{0}") | ||
| @MethodSource("iconPaths") | ||
| void testIconFileExists(String fieldName, String path) { | ||
| assertNotNull(CopilotJobsImages.class.getResource("/" + path), | ||
| "Bundle resource not found for constant " + fieldName + ": " + path); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
93 changes: 93 additions & 0 deletions
93
....copilot.eclipse.ui.jobs/src/com/microsoft/copilot/eclipse/ui/jobs/CopilotJobsImages.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,93 @@ | ||
| // Copyright (c) Microsoft Corporation. | ||
| // Licensed under the MIT license. | ||
|
|
||
| package com.microsoft.copilot.eclipse.ui.jobs; | ||
|
|
||
| import java.net.URL; | ||
|
|
||
| import org.eclipse.jface.resource.ImageDescriptor; | ||
| import org.eclipse.jface.resource.ImageRegistry; | ||
| import org.eclipse.swt.graphics.Image; | ||
| import org.eclipse.ui.ISharedImages; | ||
| import org.eclipse.ui.PlatformUI; | ||
|
|
||
| /** | ||
| * Centralized access to all static icons in the Copilot Jobs UI bundle. | ||
| * | ||
| * <p>Bundle images are owned by the plugin's {@link ImageRegistry} and disposed automatically when | ||
| * the plugin stops. Callers must <em>not</em> dispose images returned by {@link #getImage(String)}. | ||
| */ | ||
| public final class CopilotJobsImages { | ||
|
|
||
| // Path prefixes | ||
| private static final String ICONS_ROOT = "icons/"; | ||
| private static final String ICONS_STATUS = ICONS_ROOT + "status/"; | ||
|
|
||
| // Icons | ||
| public static final String IMG_REPO = ICONS_ROOT + "repo.png"; | ||
| public static final String IMG_INFORMATION = ICONS_ROOT + "information.png"; | ||
| public static final String IMG_STATUS_LOADING = ICONS_STATUS + "loading.png"; | ||
| public static final String IMG_STATUS_COMPLETE = ICONS_STATUS + "complete.png"; | ||
|
|
||
| private CopilotJobsImages() { | ||
| // prevent instantiation | ||
| } | ||
|
|
||
| /** | ||
| * Returns the plugin's image registry. | ||
| */ | ||
| static ImageRegistry getImageRegistry() { | ||
| return CopilotJobs.getPlugin().getImageRegistry(); | ||
| } | ||
|
|
||
| /** | ||
| * Registers all static icon descriptors. Called once from | ||
| * {@link CopilotJobs#initializeImageRegistry(ImageRegistry)}. | ||
| */ | ||
| static void initialize(ImageRegistry registry) { | ||
| register(registry, IMG_REPO); | ||
| register(registry, IMG_INFORMATION); | ||
| register(registry, IMG_STATUS_LOADING); | ||
| register(registry, IMG_STATUS_COMPLETE); | ||
| } | ||
|
|
||
| private static void register(ImageRegistry registry, String path) { | ||
| URL url = CopilotJobsImages.class.getResource("/" + path); | ||
| ImageDescriptor descriptor = url != null | ||
| ? ImageDescriptor.createFromURL(url) : ImageDescriptor.getMissingImageDescriptor(); | ||
| registry.put(path, descriptor); | ||
| } | ||
|
|
||
| /** | ||
| * Returns the image for the given key. The returned image is owned by the plugin registry; | ||
| * callers must <em>not</em> dispose it. | ||
| * | ||
| * @param key one of the {@code IMG_*} constants defined in this class | ||
| * @return the registry-owned image for the given key | ||
| */ | ||
| public static Image getImage(String key) { | ||
| return getImageRegistry().get(key); | ||
| } | ||
|
|
||
| /** | ||
| * Returns the {@link ImageDescriptor} for the given key. Useful where a descriptor is required, | ||
| * e.g. for {@code Action.setImageDescriptor()}. | ||
| * | ||
| * @param key one of the {@code IMG_*} constants defined in this class | ||
| * @return the image descriptor for the given key | ||
| */ | ||
| public static ImageDescriptor getImageDescriptor(String key) { | ||
| return getImageRegistry().getDescriptor(key); | ||
| } | ||
|
|
||
| /** | ||
| * Convenience access to Eclipse's workbench shared images. | ||
| * | ||
| * @param imageId a constant from {@link ISharedImages}, e.g. {@link ISharedImages#IMG_OBJS_WARN_TSK} | ||
| * @return the shared workbench image for the given id | ||
| */ | ||
| public static Image getSharedImage(String imageId) { | ||
| return PlatformUI.getWorkbench().getSharedImages().getImage(imageId); | ||
| } | ||
|
|
||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.