diff --git a/README.md b/README.md index b5100db..110e576 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Reset Your IDE Eval Information -1. Download and install plugin from [Download Link](https://plugins.zhile.io/files/ide-eval-resetter-2.2.2-940eb7.zip). +1. Download and install plugin from [Download Link](https://plugins.zhile.io/files/ide-eval-resetter-2.2.3-031813.zip). * Alternative installation method: * Add "Custom Plugin Repository": `https://plugins.zhile.io` manually (`Settings/Preferences` -> `Plugins`) * Search and install plugin: `IDE Eval Reset` diff --git a/build.gradle b/build.gradle index 9b7136a..c27e19a 100644 --- a/build.gradle +++ b/build.gradle @@ -4,7 +4,7 @@ plugins { } group 'io.zhile.research.intellij' -version '2.2.2' +version '2.2.3' sourceCompatibility = 1.7 targetCompatibility = 1.7 @@ -29,6 +29,8 @@ intellij { patchPluginXml { changeNotes = """
+Release v2.2.3 + 1. add custom error handler Release v2.2.2 1. fix issue with JRebel Release v2.2.1 diff --git a/src/main/java/io/zhile/research/intellij/ier/helper/ErrorReporter.java b/src/main/java/io/zhile/research/intellij/ier/helper/ErrorReporter.java new file mode 100644 index 0000000..911599d --- /dev/null +++ b/src/main/java/io/zhile/research/intellij/ier/helper/ErrorReporter.java @@ -0,0 +1,47 @@ +package io.zhile.research.intellij.ier.helper; + +import com.intellij.openapi.diagnostic.ErrorReportSubmitter; +import com.intellij.openapi.diagnostic.IdeaLoggingEvent; +import com.intellij.openapi.diagnostic.SubmittedReportInfo; +import com.intellij.util.Consumer; +import org.jetbrains.annotations.NotNull; + +import java.awt.*; +import java.awt.datatransfer.StringSelection; +import java.net.URI; + +public class ErrorReporter extends ErrorReportSubmitter { + private static final String NEW_ISSUE_URL = "https://gitee.com/pengzhile/ide-eval-resetter/issues/new"; + + public String getReportActionText() { + return "Open Browser to Submit This Issue..."; + } + + public String getPrivacyNoticeText() { + return "Click the submit button will write the stacktrace text to your clipboard!
So that you can paste it directly when writing the issue."; + } + + public boolean submit(IdeaLoggingEvent[] events, String additionalInfo, @NotNull Component parentComponent, @NotNull Consumer consumer) { + int length = events.length - 1; + StringBuilder sb = new StringBuilder(); + for (int i = 0; i <= length; i++) { + sb.append(events[i].getThrowableText()); + if (i != length) { // f**k java7 + sb.append("\n\n\n"); + } + } + + try { + Desktop.getDesktop().browse(new URI(NEW_ISSUE_URL)); + StringSelection selection = new StringSelection(sb.toString()); + Toolkit.getDefaultToolkit().getSystemClipboard().setContents(selection, selection); + + consumer.consume(new SubmittedReportInfo(SubmittedReportInfo.SubmissionStatus.NEW_ISSUE)); + } catch (Exception e) { + consumer.consume(new SubmittedReportInfo(SubmittedReportInfo.SubmissionStatus.FAILED)); + return false; + } + + return true; + } +} diff --git a/src/main/java/io/zhile/research/intellij/ier/listener/AppInitListener.java b/src/main/java/io/zhile/research/intellij/ier/listener/AppInitListener.java index 01b5902..5a5b249 100644 --- a/src/main/java/io/zhile/research/intellij/ier/listener/AppInitListener.java +++ b/src/main/java/io/zhile/research/intellij/ier/listener/AppInitListener.java @@ -2,25 +2,25 @@ package io.zhile.research.intellij.ier.listener; import com.intellij.ide.AppLifecycleListener; import com.intellij.openapi.actionSystem.ActionManager; +import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Ref; import io.zhile.research.intellij.ier.helper.Constants; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import java.util.List; - public class AppInitListener implements AppLifecycleListener { public void appFrameCreated(String[] commandLineArgs, @NotNull RefwillOpenProject) { } - public void appFrameCreated(@NotNull List commandLineArgs) { - ActionManager.getInstance().getAction(Constants.RESET_ACTION_ID); - } - public void appStarting(@Nullable Project projectFromCommandLine) { - + ApplicationManager.getApplication().executeOnPooledThread(new Runnable() { + @Override + public void run() { + ActionManager.getInstance().getAction(Constants.RESET_ACTION_ID); + } + }); } public void projectFrameClosed() { diff --git a/src/main/resources/META-INF/plugin.xml b/src/main/resources/META-INF/plugin.xml index dc00f14..b2c3d2e 100644 --- a/src/main/resources/META-INF/plugin.xml +++ b/src/main/resources/META-INF/plugin.xml @@ -29,4 +29,8 @@ + + + \ No newline at end of file+