I am trying to follow the instructions on this page for creating actions in an IntelliJ plugin. I have copied the code exactly as written, however the code does not work when run. When I click run code, IntelliJ opens in a new window. According to the above page, the plugin should work in that window. However, the plugin, which is supposed to add an item to the tools menu, does not work. The additional item does not appear in the menu. Additionally, I get this (possibly unrelated) warning message when I run the code.
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by com.intellij.util.ReflectionUtil to field java.awt.event.InvocationEvent.runnable
WARNING: Please consider reporting this to the maintainers of com.intellij.util.ReflectionUtil
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
2020-10-22 17:40:24,829 [ 6980] WARN - tellij.ide.SystemHealthMonitor - issue detected: bundled.jre.version.message
2020-10-22 17:40:27,369 [ 9520] WARN - ion.impl.NotificationCollector - Notification group 'Heap Dump Analysis' is already registered in whitelist
2020-10-22 17:40:27,369 [ 9520] WARN - ion.impl.NotificationCollector - Notification group 'Low Memory' is already registered in whitelist
2020-10-22 17:40:28,602 [ 10753] WARN - Container.ComponentManagerImpl - Do not use constructor injection (requestorClass=org.jetbrains.android.compose.AndroidComposeAutoDocumentation)
2020-10-22 17:40:29,801 [ 11952] WARN - tartup.impl.StartupManagerImpl - Activities registered via registerPostStartupActivity must be dumb-aware: org.jetbrains.kotlin.idea.configuration.ui.KotlinConfigurationCheckerComponent$projectOpened$1@133a2dbe
2020-10-22 17:40:35,401 [ 17552] WARN - com.intellij.util.xmlb.Binding - no accessors for org.jetbrains.kotlin.idea.highlighter.KotlinDefaultHighlightingSettingsProvider
2020-10-22 17:40:51,973 [ 34124] WARN - com.intellij.util.xmlb.Binding - no accessors for org.jetbrains.kotlin.idea.core.script.configuration.utils.ScriptClassRootsStorage
I don't know what this warning message is or how to fix it. I am including my source code in the event that I have copied something incorrectly from the instruction page linked above.
PopupDialogAction.java
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.CommonDataKeys;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.Messages;
import com.intellij.pom.Navigatable;
import org.jetbrains.annotations.NotNull;
public class PopupDialogAction extends AnAction {
@Override
public void update(AnActionEvent e) {
// Set the availability based on whether a project is open
Project project = e.getProject();
e.getPresentation().setEnabledAndVisible(project != null);
}
@Override
public void actionPerformed(@NotNull AnActionEvent event) {
// Using the event, create and show a dialog
Project currentProject = event.getProject();
StringBuffer dlgMsg = new StringBuffer(event.getPresentation().getText() + " Selected!");
String dlgTitle = event.getPresentation().getDescription();
// If an element is selected in the editor, add info about it.
Navigatable nav = event.getData(CommonDataKeys.NAVIGATABLE);
if (nav != null) {
dlgMsg.append(String.format("\nSelected Element: %s", nav.toString()));
}
Messages.showMessageDialog(currentProject, dlgMsg.toString(), dlgTitle, Messages.getInformationIcon());
}
}