Skip to content

Commit

Permalink
Require at 2023.1 version to be able to use new IDEA API (ProjectActi…
Browse files Browse the repository at this point in the history
…vity) to avoid deadlock on IDEA start in 2024.1
  • Loading branch information
turbanoff committed Apr 8, 2024
1 parent c5b9c17 commit f68d42e
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 18 deletions.
17 changes: 9 additions & 8 deletions resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<idea-plugin>
<id>org.turbanov.run.configuration.as.action</id>
<name>Run Configuration as Action</name>
<version>2.2</version>
<version>3.0</version>
<vendor email="turbanoff@gmail.com" url="https://github.com/turbanoff/RunConfigurationAsAction">Turbanov Andrey</vendor>

<description><![CDATA[
Expand All @@ -11,6 +11,10 @@ Also, it allows to create button in toolbar to run specific configuration.<br>
]]></description>

<change-notes><![CDATA[
<h3>3.0</h3>
<ul>
<li>Require 2023.x to be able to use new API</li>
</ul>
<h3>2.2</h3>
<ul>
<li>Version just to override incorrectly uploaded version</li>
Expand Down Expand Up @@ -72,15 +76,12 @@ Also, it allows to create button in toolbar to run specific configuration.<br>
]]>
</change-notes>

<idea-version since-build="211"/>
<idea-version since-build="231"/>

<depends>com.intellij.modules.platform</depends>

<project-components>
<component>
<implementation-class>org.turbanov.actions.Bootstrap</implementation-class>
</component>
</project-components>
<extensions defaultExtensionNs="com.intellij">
<postStartupActivity implementation="org.turbanov.actions.BootstrapActivity"/>
</extensions>
<actions>
<action id="org.turbanov.actions.CreateExecuteIconWithTextAction" class="org.turbanov.actions.CreateExecuteIconWithTextAction" text="Create Icon with Text">
<add-to-group group-id="ToolsMenu" anchor="last"/>
Expand Down
11 changes: 1 addition & 10 deletions src/org/turbanov/actions/Bootstrap.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.ex.ActionManagerEx;
import com.intellij.openapi.application.ApplicationInfo;
import com.intellij.openapi.components.ProjectComponent;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.extensions.PluginId;
import com.intellij.openapi.project.Project;
Expand All @@ -40,7 +39,7 @@
* @author Andrey Turbanov
* @since 27.01.2017
*/
public class Bootstrap implements ProjectComponent {
public class Bootstrap {
private static final Logger log = Logger.getInstance(RunConfigurationAsAction.class);
private static final String ACTION_ID_PREFIX = "RunConfigurationAsAction";
private static final PluginId PLUGIN_ID = PluginId.getId("org.turbanov.run.configuration.as.action");
Expand Down Expand Up @@ -168,13 +167,6 @@ private List<ExecutionTarget> getTargets(@NotNull RunnerAndConfigurationSettings
return targets;
}

@NotNull
@Override
public String getComponentName() {
return ACTION_ID_PREFIX;
}

@Override
public void projectOpened() {
myProject.getMessageBus().connect().subscribe(RunManagerListener.TOPIC, new RunManagerListener() {
@Override
Expand All @@ -195,7 +187,6 @@ public void runConfigurationRemoved(@NotNull RunnerAndConfigurationSettings sett
}
}

@Override
public void projectClosed() {
ActionManager actionManager = ActionManager.getInstance();
for (String actionId : registeredActions) {
Expand Down
32 changes: 32 additions & 0 deletions src/org/turbanov/actions/BootstrapActivity.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package org.turbanov.actions

import com.intellij.openapi.application.ApplicationManager
import com.intellij.openapi.project.Project
import com.intellij.openapi.project.ProjectManager
import com.intellij.openapi.project.ProjectManagerListener
import com.intellij.openapi.startup.ProjectActivity
import java.util.*

/**
* @author Andrey Turbanov
* @since 08.04.2024
*/
class BootstrapActivity() : ProjectActivity {
private val bootstraps = Collections.synchronizedMap(IdentityHashMap<Project, Bootstrap>())

init {
val connect = ApplicationManager.getApplication().getMessageBus().connect()
connect.subscribe(ProjectManager.TOPIC, object : ProjectManagerListener {
override fun projectClosing(project: Project) {
val bootstrap = bootstraps.remove(project)
bootstrap?.projectClosed()
}
})
}

override suspend fun execute(project: Project) {
val bootstrap = Bootstrap(project)
bootstraps.put(project, bootstrap)
bootstrap.projectOpened()
}
}

0 comments on commit f68d42e

Please sign in to comment.