feat: menu action for connecting

This commit is contained in:
zaaarf 2023-09-07 01:52:42 +02:00
parent 4ed7704ff0
commit c6e3d00dbf
No known key found for this signature in database
GPG key ID: 82240E075E31FA4C
3 changed files with 33 additions and 3 deletions

View file

@ -1,4 +1,3 @@
package com.codemp.intellij;
public class CodeMP {
}
public class CodeMP {}

View file

@ -0,0 +1,25 @@
package com.codemp.intellij.actions;
import com.codemp.intellij.jni.CodeMPHandler;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.ui.Messages;
import org.jetbrains.annotations.NotNull;
public class ConnectAction extends AnAction {
static {
System.load("O:/dev/IRL/Rust/codemp/client/intellij/target/debug/codemp_intellij.dll");
}
@Override
public void actionPerformed(@NotNull AnActionEvent e) {
String url = Messages.showInputDialog("URL to CodeMP instance:", "CodeMP", Messages.getQuestionIcon());
try {
CodeMPHandler.connect(url);
Messages.showInfoMessage(String.format("Connected to %s!", url), "CodeMP");
} catch(Exception ex) {
Messages.showErrorDialog(String.format("Failed to connect to %s: %s!", url, ex.getMessage()), "CodeMP");
}
}
}

View file

@ -1,7 +1,7 @@
<!-- Plugin Configuration File. Read more: https://plugins.jetbrains.com/docs/intellij/plugin-configuration-file.html -->
<idea-plugin>
<!-- Unique identifier of the plugin. It should be FQN. It cannot be changed between the plugin versions. -->
<id>com.codemp.codemp-intellij</id>
<id>com.codemp.intellij</id>
<!-- Public plugin name should be written in Title Case.
Guidelines: https://plugins.jetbrains.com/docs/marketplace/plugin-overview-page.html#plugin-name -->
@ -22,6 +22,12 @@
Read more: https://plugins.jetbrains.com/docs/intellij/plugin-compatibility.html -->
<depends>com.intellij.modules.platform</depends>
<actions>
<action id="connect" class="com.codemp.intellij.actions.ConnectAction" text="Connect">
<add-to-group group-id="ToolsMenu" anchor="first"></add-to-group>
</action>
</actions>
<!-- Extension points defined by the plugin.
Read more: https://plugins.jetbrains.com/docs/intellij/plugin-extension-points.html -->
<extensions defaultExtensionNs="com.intellij">