mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
OPENIDE #180 Buttons in Internal Error dialog don't work when OpenIDE starts
This commit is contained in:
+47
-36
@@ -5,6 +5,8 @@ import com.intellij.diagnostic.ITNProxy;
|
||||
import com.intellij.diagnostic.ImplementationConflictException;
|
||||
import com.intellij.diagnostic.LoadingState;
|
||||
import com.intellij.diagnostic.PluginException;
|
||||
import com.intellij.ide.actions.RevealFileAction;
|
||||
import com.intellij.ide.actions.ShowLogAction;
|
||||
import com.intellij.ide.logsUploader.LogUploader;
|
||||
import com.intellij.ide.plugins.EssentialPluginMissingException;
|
||||
import com.intellij.ide.plugins.PluginConflictReporter;
|
||||
@@ -36,6 +38,7 @@ import org.jspecify.annotations.NullMarked;
|
||||
|
||||
import javax.swing.BorderFactory;
|
||||
import javax.swing.ImageIcon;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JDialog;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JOptionPane;
|
||||
@@ -44,9 +47,11 @@ import javax.swing.JProgressBar;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.JTextPane;
|
||||
import javax.swing.ScrollPaneConstants;
|
||||
import javax.swing.SwingUtilities;
|
||||
import javax.swing.UIManager;
|
||||
import java.awt.AWTError;
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Component;
|
||||
import java.awt.Cursor;
|
||||
import java.awt.Desktop;
|
||||
import java.awt.Dimension;
|
||||
@@ -62,6 +67,7 @@ import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import static com.intellij.ide.BootstrapBundle.message;
|
||||
import static java.util.Objects.requireNonNullElse;
|
||||
@@ -169,21 +175,33 @@ public final class StartupErrorReporter {
|
||||
supportCenter();
|
||||
}
|
||||
});
|
||||
if (error != null) {
|
||||
var options = new Object[]{close, message("bootstrap.error.option.reset"), message("bootstrap.error.option.report"), learnMore};
|
||||
var choice = JOptionPane.showOptionDialog(
|
||||
JOptionPane.getRootFrame(), messageObj, title, JOptionPane.DEFAULT_OPTION, JOptionPane.ERROR_MESSAGE, null, options, options[0]
|
||||
);
|
||||
switch (choice) {
|
||||
case 1 -> cleanStart();
|
||||
case 2 -> reportProblem(error);
|
||||
|
||||
var closeBtn = createTextBtn(message("bootstrap.error.option.close"), e -> {
|
||||
Component component = SwingUtilities.getRoot((Component) e.getSource());
|
||||
if (component instanceof JDialog) {
|
||||
((JDialog) component).dispose();
|
||||
}
|
||||
});
|
||||
|
||||
if (error != null) {
|
||||
var resetBtn = createTextBtn(message("bootstrap.error.option.reset"), e -> cleanStart());
|
||||
var showLogBtn = createTextBtn(ShowLogAction.getActionName(), e -> reportProblem(error));
|
||||
|
||||
var options = new Object[]{
|
||||
closeBtn,
|
||||
resetBtn,
|
||||
showLogBtn,
|
||||
learnMore
|
||||
};
|
||||
JOptionPane.showOptionDialog(JOptionPane.getRootFrame(), messageObj, title, JOptionPane.DEFAULT_OPTION, JOptionPane.ERROR_MESSAGE, null, options, options[0]);
|
||||
}
|
||||
else {
|
||||
var options = new Object[]{close, learnMore};
|
||||
JOptionPane.showOptionDialog(
|
||||
JOptionPane.getRootFrame(), messageObj, title, JOptionPane.DEFAULT_OPTION, JOptionPane.ERROR_MESSAGE, null, options, options[0]
|
||||
);
|
||||
var options = new Object[]{
|
||||
closeBtn,
|
||||
learnMore
|
||||
};
|
||||
JOptionPane.showOptionDialog(JOptionPane.getRootFrame(), messageObj, title, JOptionPane.DEFAULT_OPTION,
|
||||
JOptionPane.ERROR_MESSAGE, null, options, options[0]);
|
||||
}
|
||||
}
|
||||
catch (Throwable t) {
|
||||
@@ -193,6 +211,17 @@ public final class StartupErrorReporter {
|
||||
}
|
||||
}
|
||||
|
||||
private static JButton createTextBtn(String text, Consumer<MouseEvent> onClick) {
|
||||
var button = new JButton(text);
|
||||
button.addMouseListener(new MouseAdapter() {
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
onClick.accept(e);
|
||||
}
|
||||
});
|
||||
return button;
|
||||
}
|
||||
|
||||
private static void supportCenter() {
|
||||
try {
|
||||
var url = System.getProperty(SUPPORT_URL_PROPERTY, "https://jb.gg/ide/critical-startup-errors");
|
||||
@@ -226,22 +255,16 @@ public final class StartupErrorReporter {
|
||||
var worker = new javax.swing.SwingWorker<String, Void>() {
|
||||
@Override
|
||||
protected String doInBackground() throws Exception {
|
||||
var comment = "Startup error";
|
||||
|
||||
if (error instanceof ExceptionWithAttachments ewa) {
|
||||
var logs = collectLogs(ewa);
|
||||
try {
|
||||
var uploadId = LogUploader.uploadFile(logs);
|
||||
comment += "\n\nLogs upload ID: " + uploadId;
|
||||
var path = collectLogs(ewa);
|
||||
if (RevealFileAction.isSupported()) {
|
||||
RevealFileAction.openFile(path);
|
||||
}
|
||||
finally {
|
||||
NioFiles.deleteQuietly(logs);
|
||||
else {
|
||||
RevealFileAction.openDirectory(path);
|
||||
}
|
||||
}
|
||||
|
||||
var id = ITNProxy.sendError(new IdeaLoggingEvent(comment, error));
|
||||
|
||||
return String.valueOf(id);
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -253,18 +276,6 @@ public final class StartupErrorReporter {
|
||||
|
||||
worker.execute();
|
||||
progressDialog.setVisible(true);
|
||||
|
||||
try {
|
||||
var reportId = worker.get();
|
||||
var message = message("bootstrap.error.message.submitted", reportId);
|
||||
JOptionPane.showMessageDialog(JOptionPane.getRootFrame(), message, message("bootstrap.error.title.submitted"), JOptionPane.INFORMATION_MESSAGE);
|
||||
}
|
||||
catch (Throwable t) {
|
||||
var buf = new StringWriter();
|
||||
t.printStackTrace(new PrintWriter(buf));
|
||||
var message = prepareMessage(message("bootstrap.error.message.no.report", buf));
|
||||
JOptionPane.showMessageDialog(JOptionPane.getRootFrame(), message, message("bootstrap.error.title.no.report"), JOptionPane.ERROR_MESSAGE);
|
||||
}
|
||||
}
|
||||
|
||||
private static Path collectLogs(ExceptionWithAttachments error) throws IOException {
|
||||
|
||||
Reference in New Issue
Block a user