mirror of
https://github.com/packwiz/packwiz-installer.git
synced 2025-05-06 12:36:30 +02:00
Add showExceptions
This commit is contained in:
parent
452ab15cc7
commit
78f5d76fe9
@ -1,6 +1,7 @@
|
||||
package link.infra.packwiz.installer.ui;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
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!");
|
||||
}
|
||||
|
||||
@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.border.EmptyBorder;
|
||||
import javax.swing.event.ListSelectionEvent;
|
||||
import javax.swing.event.ListSelectionListener;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.WindowAdapter;
|
||||
import java.awt.event.WindowEvent;
|
||||
import java.io.IOException;
|
||||
@ -19,16 +15,15 @@ import java.net.URISyntaxException;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
public class ExceptionListWindow extends JDialog {
|
||||
class ExceptionListWindow extends JDialog {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
private final JPanel contentPanel = new JPanel();
|
||||
private final JTextArea lblExceptionStacktrace;
|
||||
|
||||
/**
|
||||
* 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);
|
||||
|
||||
setBounds(100, 100, 540, 340);
|
||||
@ -43,6 +38,7 @@ public class ExceptionListWindow extends JDialog {
|
||||
errorPanel.add(lblWarning);
|
||||
}
|
||||
}
|
||||
JPanel contentPanel = new JPanel();
|
||||
contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
|
||||
getContentPane().add(contentPanel, BorderLayout.CENTER);
|
||||
contentPanel.setLayout(new BorderLayout(0, 0));
|
||||
@ -65,14 +61,12 @@ public class ExceptionListWindow extends JDialog {
|
||||
splitPane.setRightComponent(scrollPane);
|
||||
}
|
||||
{
|
||||
JList<String> list = new JList<String>();
|
||||
JList<String> list = new JList<>();
|
||||
list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
|
||||
list.setBorder(new EmptyBorder(5, 5, 5, 5));
|
||||
ExceptionListModel listModel = new ExceptionListModel(eList);
|
||||
list.setModel(listModel);
|
||||
list.addListSelectionListener(new ListSelectionListener() {
|
||||
@Override
|
||||
public void valueChanged(ListSelectionEvent e) {
|
||||
list.addListSelectionListener(e -> {
|
||||
int i = list.getSelectedIndex();
|
||||
if (i > -1) {
|
||||
StringWriter sw = new StringWriter();
|
||||
@ -83,7 +77,6 @@ public class ExceptionListWindow extends JDialog {
|
||||
} else {
|
||||
lblExceptionStacktrace.setText("Select a file");
|
||||
}
|
||||
}
|
||||
});
|
||||
JScrollPane scrollPane = new JScrollPane(list);
|
||||
scrollPane.setBorder(new EmptyBorder(0, 0, 0, 0));
|
||||
@ -100,36 +93,27 @@ public class ExceptionListWindow extends JDialog {
|
||||
{
|
||||
JButton btnContinue = new JButton("Continue");
|
||||
btnContinue.setToolTipText("Attempt to continue installing, excluding the failed downloads");
|
||||
btnContinue.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
btnContinue.addActionListener(e -> {
|
||||
future.complete(ExceptionListResult.CONTINUE);
|
||||
ExceptionListWindow.this.dispose();
|
||||
}
|
||||
});
|
||||
rightButtons.add(btnContinue);
|
||||
}
|
||||
{
|
||||
JButton btnCancelLaunch = new JButton("Cancel launch");
|
||||
btnCancelLaunch.setToolTipText("Stop launching the game");
|
||||
btnCancelLaunch.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
btnCancelLaunch.addActionListener(e -> {
|
||||
future.complete(ExceptionListResult.CANCEL);
|
||||
ExceptionListWindow.this.dispose();
|
||||
}
|
||||
});
|
||||
rightButtons.add(btnCancelLaunch);
|
||||
}
|
||||
{
|
||||
JButton btnIgnoreUpdate = new JButton("Ignore update");
|
||||
btnIgnoreUpdate.setToolTipText("Start the game without attempting to update");
|
||||
btnIgnoreUpdate.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
btnIgnoreUpdate.addActionListener(e -> {
|
||||
future.complete(ExceptionListResult.IGNORE);
|
||||
ExceptionListWindow.this.dispose();
|
||||
}
|
||||
});
|
||||
rightButtons.add(btnIgnoreUpdate);
|
||||
{
|
||||
@ -145,15 +129,12 @@ public class ExceptionListWindow extends JDialog {
|
||||
boolean supported = Desktop.isDesktopSupported() && Desktop.getDesktop().isSupported(Desktop.Action.BROWSE);
|
||||
btnReportIssue.setEnabled(supported);
|
||||
if (supported) {
|
||||
btnReportIssue.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
btnReportIssue.addActionListener(e -> {
|
||||
try {
|
||||
Desktop.getDesktop().browse(new URI("https://github.com/comp500/packwiz-installer/issues/new"));
|
||||
} catch (IOException | URISyntaxException e1) {
|
||||
// lol the button just won't work i guess
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
leftButtons.add(btnReportIssue);
|
||||
@ -181,7 +162,7 @@ public class ExceptionListWindow extends JDialog {
|
||||
private static final long serialVersionUID = 1L;
|
||||
private final List<IExceptionDetails> details;
|
||||
|
||||
public ExceptionListModel(List<IExceptionDetails> details) {
|
||||
ExceptionListModel(List<IExceptionDetails> details) {
|
||||
this.details = details;
|
||||
}
|
||||
|
||||
@ -193,7 +174,7 @@ public class ExceptionListWindow extends JDialog {
|
||||
return details.get(index).getName();
|
||||
}
|
||||
|
||||
public Exception getExceptionAt(int index) {
|
||||
Exception getExceptionAt(int index) {
|
||||
return details.get(index).getException();
|
||||
}
|
||||
}
|
||||
|
@ -26,4 +26,6 @@ public interface IUserInterface {
|
||||
// Return true if the installation was cancelled!
|
||||
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;
|
||||
}
|
||||
|
||||
@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