mirror of
https://github.com/packwiz/packwiz-installer.git
synced 2025-05-06 20:46:30 +02:00
Add showExceptions
This commit is contained in:
parent
452ab15cc7
commit
78f5d76fe9
@ -1,6 +1,7 @@
|
|||||||
package link.infra.packwiz.installer.ui;
|
package link.infra.packwiz.installer.ui;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
import java.util.concurrent.Future;
|
import java.util.concurrent.Future;
|
||||||
|
|
||||||
public class CLIHandler implements IUserInterface {
|
public class CLIHandler implements IUserInterface {
|
||||||
@ -38,4 +39,11 @@ public class CLIHandler implements IUserInterface {
|
|||||||
throw new RuntimeException("Optional mods not implemented for CLI! Make sure your optional mods are only on the client side!");
|
throw new RuntimeException("Optional mods not implemented for CLI! Make sure your optional mods are only on the client side!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Future<IExceptionDetails.ExceptionListResult> showExceptions(List<IExceptionDetails> opts, int numTotal) {
|
||||||
|
CompletableFuture<IExceptionDetails.ExceptionListResult> future = new CompletableFuture<>();
|
||||||
|
future.complete(IExceptionDetails.ExceptionListResult.CANCEL);
|
||||||
|
return future;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -4,11 +4,7 @@ import link.infra.packwiz.installer.ui.IExceptionDetails.ExceptionListResult;
|
|||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import javax.swing.border.EmptyBorder;
|
import javax.swing.border.EmptyBorder;
|
||||||
import javax.swing.event.ListSelectionEvent;
|
|
||||||
import javax.swing.event.ListSelectionListener;
|
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.awt.event.ActionEvent;
|
|
||||||
import java.awt.event.ActionListener;
|
|
||||||
import java.awt.event.WindowAdapter;
|
import java.awt.event.WindowAdapter;
|
||||||
import java.awt.event.WindowEvent;
|
import java.awt.event.WindowEvent;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@ -19,16 +15,15 @@ import java.net.URISyntaxException;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
public class ExceptionListWindow extends JDialog {
|
class ExceptionListWindow extends JDialog {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
private final JPanel contentPanel = new JPanel();
|
|
||||||
private final JTextArea lblExceptionStacktrace;
|
private final JTextArea lblExceptionStacktrace;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create the dialog.
|
* Create the dialog.
|
||||||
*/
|
*/
|
||||||
public ExceptionListWindow(List<IExceptionDetails> eList, CompletableFuture<ExceptionListResult> future, int numTotal, JFrame parentWindow) {
|
ExceptionListWindow(List<IExceptionDetails> eList, CompletableFuture<ExceptionListResult> future, int numTotal, JFrame parentWindow) {
|
||||||
super(parentWindow, "Failed file downloads", true);
|
super(parentWindow, "Failed file downloads", true);
|
||||||
|
|
||||||
setBounds(100, 100, 540, 340);
|
setBounds(100, 100, 540, 340);
|
||||||
@ -43,6 +38,7 @@ public class ExceptionListWindow extends JDialog {
|
|||||||
errorPanel.add(lblWarning);
|
errorPanel.add(lblWarning);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
JPanel contentPanel = new JPanel();
|
||||||
contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
|
contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
|
||||||
getContentPane().add(contentPanel, BorderLayout.CENTER);
|
getContentPane().add(contentPanel, BorderLayout.CENTER);
|
||||||
contentPanel.setLayout(new BorderLayout(0, 0));
|
contentPanel.setLayout(new BorderLayout(0, 0));
|
||||||
@ -65,24 +61,21 @@ public class ExceptionListWindow extends JDialog {
|
|||||||
splitPane.setRightComponent(scrollPane);
|
splitPane.setRightComponent(scrollPane);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
JList<String> list = new JList<String>();
|
JList<String> list = new JList<>();
|
||||||
list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
|
list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
|
||||||
list.setBorder(new EmptyBorder(5, 5, 5, 5));
|
list.setBorder(new EmptyBorder(5, 5, 5, 5));
|
||||||
ExceptionListModel listModel = new ExceptionListModel(eList);
|
ExceptionListModel listModel = new ExceptionListModel(eList);
|
||||||
list.setModel(listModel);
|
list.setModel(listModel);
|
||||||
list.addListSelectionListener(new ListSelectionListener() {
|
list.addListSelectionListener(e -> {
|
||||||
@Override
|
int i = list.getSelectedIndex();
|
||||||
public void valueChanged(ListSelectionEvent e) {
|
if (i > -1) {
|
||||||
int i = list.getSelectedIndex();
|
StringWriter sw = new StringWriter();
|
||||||
if (i > -1) {
|
listModel.getExceptionAt(i).printStackTrace(new PrintWriter(sw));
|
||||||
StringWriter sw = new StringWriter();
|
lblExceptionStacktrace.setText(sw.toString());
|
||||||
listModel.getExceptionAt(i).printStackTrace(new PrintWriter(sw));
|
// Scroll to the top
|
||||||
lblExceptionStacktrace.setText(sw.toString());
|
lblExceptionStacktrace.setCaretPosition(0);
|
||||||
// Scroll to the top
|
} else {
|
||||||
lblExceptionStacktrace.setCaretPosition(0);
|
lblExceptionStacktrace.setText("Select a file");
|
||||||
} else {
|
|
||||||
lblExceptionStacktrace.setText("Select a file");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
JScrollPane scrollPane = new JScrollPane(list);
|
JScrollPane scrollPane = new JScrollPane(list);
|
||||||
@ -100,36 +93,27 @@ public class ExceptionListWindow extends JDialog {
|
|||||||
{
|
{
|
||||||
JButton btnContinue = new JButton("Continue");
|
JButton btnContinue = new JButton("Continue");
|
||||||
btnContinue.setToolTipText("Attempt to continue installing, excluding the failed downloads");
|
btnContinue.setToolTipText("Attempt to continue installing, excluding the failed downloads");
|
||||||
btnContinue.addActionListener(new ActionListener() {
|
btnContinue.addActionListener(e -> {
|
||||||
@Override
|
future.complete(ExceptionListResult.CONTINUE);
|
||||||
public void actionPerformed(ActionEvent e) {
|
ExceptionListWindow.this.dispose();
|
||||||
future.complete(ExceptionListResult.CONTINUE);
|
|
||||||
ExceptionListWindow.this.dispose();
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
rightButtons.add(btnContinue);
|
rightButtons.add(btnContinue);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
JButton btnCancelLaunch = new JButton("Cancel launch");
|
JButton btnCancelLaunch = new JButton("Cancel launch");
|
||||||
btnCancelLaunch.setToolTipText("Stop launching the game");
|
btnCancelLaunch.setToolTipText("Stop launching the game");
|
||||||
btnCancelLaunch.addActionListener(new ActionListener() {
|
btnCancelLaunch.addActionListener(e -> {
|
||||||
@Override
|
future.complete(ExceptionListResult.CANCEL);
|
||||||
public void actionPerformed(ActionEvent e) {
|
ExceptionListWindow.this.dispose();
|
||||||
future.complete(ExceptionListResult.CANCEL);
|
|
||||||
ExceptionListWindow.this.dispose();
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
rightButtons.add(btnCancelLaunch);
|
rightButtons.add(btnCancelLaunch);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
JButton btnIgnoreUpdate = new JButton("Ignore update");
|
JButton btnIgnoreUpdate = new JButton("Ignore update");
|
||||||
btnIgnoreUpdate.setToolTipText("Start the game without attempting to update");
|
btnIgnoreUpdate.setToolTipText("Start the game without attempting to update");
|
||||||
btnIgnoreUpdate.addActionListener(new ActionListener() {
|
btnIgnoreUpdate.addActionListener(e -> {
|
||||||
@Override
|
future.complete(ExceptionListResult.IGNORE);
|
||||||
public void actionPerformed(ActionEvent e) {
|
ExceptionListWindow.this.dispose();
|
||||||
future.complete(ExceptionListResult.IGNORE);
|
|
||||||
ExceptionListWindow.this.dispose();
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
rightButtons.add(btnIgnoreUpdate);
|
rightButtons.add(btnIgnoreUpdate);
|
||||||
{
|
{
|
||||||
@ -145,14 +129,11 @@ public class ExceptionListWindow extends JDialog {
|
|||||||
boolean supported = Desktop.isDesktopSupported() && Desktop.getDesktop().isSupported(Desktop.Action.BROWSE);
|
boolean supported = Desktop.isDesktopSupported() && Desktop.getDesktop().isSupported(Desktop.Action.BROWSE);
|
||||||
btnReportIssue.setEnabled(supported);
|
btnReportIssue.setEnabled(supported);
|
||||||
if (supported) {
|
if (supported) {
|
||||||
btnReportIssue.addActionListener(new ActionListener() {
|
btnReportIssue.addActionListener(e -> {
|
||||||
@Override
|
try {
|
||||||
public void actionPerformed(ActionEvent e) {
|
Desktop.getDesktop().browse(new URI("https://github.com/comp500/packwiz-installer/issues/new"));
|
||||||
try {
|
} catch (IOException | URISyntaxException e1) {
|
||||||
Desktop.getDesktop().browse(new URI("https://github.com/comp500/packwiz-installer/issues/new"));
|
// lol the button just won't work i guess
|
||||||
} catch (IOException | URISyntaxException e1) {
|
|
||||||
// lol the button just won't work i guess
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -181,7 +162,7 @@ public class ExceptionListWindow extends JDialog {
|
|||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
private final List<IExceptionDetails> details;
|
private final List<IExceptionDetails> details;
|
||||||
|
|
||||||
public ExceptionListModel(List<IExceptionDetails> details) {
|
ExceptionListModel(List<IExceptionDetails> details) {
|
||||||
this.details = details;
|
this.details = details;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -193,7 +174,7 @@ public class ExceptionListWindow extends JDialog {
|
|||||||
return details.get(index).getName();
|
return details.get(index).getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Exception getExceptionAt(int index) {
|
Exception getExceptionAt(int index) {
|
||||||
return details.get(index).getException();
|
return details.get(index).getException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,4 +26,6 @@ public interface IUserInterface {
|
|||||||
// Return true if the installation was cancelled!
|
// Return true if the installation was cancelled!
|
||||||
Future<Boolean> showOptions(List<IOptionDetails> option);
|
Future<Boolean> showOptions(List<IOptionDetails> option);
|
||||||
|
|
||||||
|
Future<IExceptionDetails.ExceptionListResult> showExceptions(List<IExceptionDetails> opts, int numTotal);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -173,4 +173,15 @@ public class InstallWindow implements IUserInterface {
|
|||||||
return future;
|
return future;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Future<IExceptionDetails.ExceptionListResult> showExceptions(List<IExceptionDetails> opts, int numTotal) {
|
||||||
|
CompletableFuture<IExceptionDetails.ExceptionListResult> future = new CompletableFuture<>();
|
||||||
|
EventQueue.invokeLater(() -> {
|
||||||
|
ExceptionListWindow dialog = new ExceptionListWindow(opts, future, numTotal, frmPackwizlauncher);
|
||||||
|
dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
|
||||||
|
dialog.setVisible(true);
|
||||||
|
});
|
||||||
|
return future;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user