-
Notifications
You must be signed in to change notification settings - Fork 84
#2097: Configure Ide Plugins in the GUI #2150
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
base: main
Are you sure you want to change the base?
Changes from all commits
029f03d
89cfb67
a53296d
37cad74
55a50ce
3f1569f
6ce99b3
7ef65f3
1764b2f
ddd3e5f
9c5a720
b28e216
234e98b
1c4e766
6fc3884
2026757
c76e185
6f92d93
9f741a5
48fe018
e0ad015
2c9fc55
2b62c60
40ff54e
0b67210
2e15d60
10cf940
5f0b40a
3b567ef
e406b65
e0e2d9d
d70f460
d6aace2
9c78eac
4c84bb9
69055d9
9978ce9
ac3a045
6c44432
c30c2ea
1e8b556
d51111d
98a7072
c55a3a3
4747bae
e03949d
e4e5bd9
44791ef
dab292f
11a9546
4781ea5
9ee0bc2
07b7773
5943b23
01d696b
df6f21b
519a8bb
aaa1763
3441ed4
a63acb0
d8b8377
625d407
9232b7b
9f5c58b
8199836
5d5b301
e79536f
2b7554d
15c20cb
828d20c
b2e10b7
f703e8e
e029f44
eca23a5
8b34cbc
0cf29a0
d26fae6
9d5982c
30a03ed
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -4,6 +4,7 @@ | |||||||||||
| import java.nio.file.Path; | ||||||||||||
| import java.util.Collection; | ||||||||||||
| import java.util.List; | ||||||||||||
| import java.util.Properties; | ||||||||||||
| import java.util.Set; | ||||||||||||
|
|
||||||||||||
| import org.slf4j.Logger; | ||||||||||||
|
|
@@ -87,15 +88,45 @@ private void loadPluginsFromDirectory(ToolPlugins map, Path pluginsPath) { | |||||||||||
| /** | ||||||||||||
| * @return {@code true} if {@link ToolPluginDescriptor#url() plugin URL} property is needed, {@code false} otherwise. | ||||||||||||
| */ | ||||||||||||
| protected boolean isPluginUrlNeeded() { | ||||||||||||
| public boolean isPluginUrlNeeded() { | ||||||||||||
|
|
||||||||||||
| return false; | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
| /** | ||||||||||||
| * Creates a new plugin properties file in the project settings and returns the resulting {@link ToolPluginDescriptor}. The plugin is created as active by | ||||||||||||
| * default. | ||||||||||||
| * | ||||||||||||
| * @param name the plugin name (used as the properties file name). | ||||||||||||
| * @param id the plugin id (e.g. marketplace or extension identifier). | ||||||||||||
| * @param url the plugin URL (update site / marketplace URL); may be {@code null} when not needed. | ||||||||||||
| * @return the created {@link ToolPluginDescriptor}. | ||||||||||||
| */ | ||||||||||||
| public ToolPluginDescriptor createPlugin(String name, String id, String url, String tags) { | ||||||||||||
|
|
||||||||||||
| Path pluginsDir = getPluginsConfigPath(); | ||||||||||||
| this.context.getFileAccess().mkdirs(pluginsDir); | ||||||||||||
| Path pluginFile = pluginsDir.resolve(name + IdeContext.EXT_PROPERTIES); | ||||||||||||
| Properties props = new Properties(); | ||||||||||||
| if (id != null && !id.isBlank()) { | ||||||||||||
| props.setProperty("id", id); | ||||||||||||
| } | ||||||||||||
| props.setProperty("active", "true"); | ||||||||||||
| if (url != null && !url.isBlank()) { | ||||||||||||
| props.setProperty("url", url); | ||||||||||||
| } | ||||||||||||
| if (tags != null && !tags.isBlank()) { | ||||||||||||
| props.setProperty("tags", tags); | ||||||||||||
| } | ||||||||||||
| this.context.getFileAccess().writeProperties(props, pluginFile); | ||||||||||||
| this.plugins = null; | ||||||||||||
| return new ToolPluginDescriptor(id, name, url, null, true, Tag.parseCsv(tags)); | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
| /** | ||||||||||||
| * @return the {@link Path} to the folder with the plugin configuration files inside the settings. | ||||||||||||
| */ | ||||||||||||
| protected Path getPluginsConfigPath() { | ||||||||||||
| public Path getPluginsConfigPath() { | ||||||||||||
|
|
||||||||||||
| return this.context.getSettingsPath().resolve(this.tool).resolve(IdeContext.FOLDER_PLUGINS); | ||||||||||||
| } | ||||||||||||
|
|
@@ -129,6 +160,7 @@ protected void postInstall(ToolInstallRequest request) { | |||||||||||
|
|
||||||||||||
| /** | ||||||||||||
| * Deletes all installed plugins for this {@link IdeToolCommandlet} by deleting the plugins installation folder and all plugin marker files. | ||||||||||||
| * | ||||||||||||
| * @param pluginsInstallationPath the {@link Path} to the plugins installation folder. | ||||||||||||
| */ | ||||||||||||
| private void deleteAllPlugins(Path pluginsInstallationPath) { | ||||||||||||
|
|
@@ -304,6 +336,21 @@ public ToolPluginDescriptor getPlugin(String key) { | |||||||||||
| return pluginDescriptor; | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
| /** | ||||||||||||
| * Persists the {@link ToolPluginDescriptor#active() active} flag for the given plugin to its properties file in the project settings. | ||||||||||||
| * | ||||||||||||
| * @param plugin the {@link ToolPluginDescriptor} whose active state to save. | ||||||||||||
| * @param active {@code true} to activate, {@code false} to deactivate. | ||||||||||||
| */ | ||||||||||||
| public void savePluginActive(ToolPluginDescriptor plugin, boolean active) { | ||||||||||||
|
|
||||||||||||
| Path pluginFile = getPluginsConfigPath().resolve(plugin.name() + IdeContext.EXT_PROPERTIES); | ||||||||||||
| Properties props = this.context.getFileAccess().readProperties(pluginFile); | ||||||||||||
| String activeKey = props.containsKey("plugin_active") ? "plugin_active" : "active"; | ||||||||||||
| props.setProperty(activeKey, Boolean.toString(active)); | ||||||||||||
| this.context.getFileAccess().writeProperties(props, pluginFile); | ||||||||||||
| } | ||||||||||||
|
Comment on lines
+351
to
+352
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There seems to be an issue where the plugin state is not refreshed after saving.
Observed: This should fix the issue:
Suggested change
Invalidate the plugin cache so that the next call to getPlugins() reloads the updated state from disk. |
||||||||||||
|
|
||||||||||||
| /** | ||||||||||||
| * @param plugin the in{@link ToolPluginDescriptor#active() active} {@link ToolPluginDescriptor} that is skipped for regular plugin installation. | ||||||||||||
| */ | ||||||||||||
|
|
||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Optional suggestion: consider checking if a plugin with the same name already exists before creating it. Otherwise, adding the same plugin multiple times can temporarily result in duplicate entries being shown in the UI.