summaryrefslogtreecommitdiff
path: root/src/main/java/cuchaz/enigma/gui/dialog
diff options
context:
space:
mode:
authorGravatar Thog2017-03-07 21:24:39 +0100
committerGravatar Thog2017-03-07 21:30:02 +0100
commitb4aaff683d78ab92b83f3a7257c33b8e27d1affa (patch)
treef23c9bb0927d83cc7302881266b7df8fd37959c7 /src/main/java/cuchaz/enigma/gui/dialog
parentAvoid crash of the matcher when the obf name is invalid (set a deob it using ... (diff)
downloadenigma-fork-b4aaff683d78ab92b83f3a7257c33b8e27d1affa.tar.gz
enigma-fork-b4aaff683d78ab92b83f3a7257c33b8e27d1affa.tar.xz
enigma-fork-b4aaff683d78ab92b83f3a7257c33b8e27d1affa.zip
Drop unix case style and implement hashCode when equals is overrided
Also update Guava to version 21
Diffstat (limited to 'src/main/java/cuchaz/enigma/gui/dialog')
-rw-r--r--src/main/java/cuchaz/enigma/gui/dialog/CrashDialog.java32
-rw-r--r--src/main/java/cuchaz/enigma/gui/dialog/ProgressDialog.java16
2 files changed, 23 insertions, 25 deletions
diff --git a/src/main/java/cuchaz/enigma/gui/dialog/CrashDialog.java b/src/main/java/cuchaz/enigma/gui/dialog/CrashDialog.java
index 8d3df47..5c1d9ff 100644
--- a/src/main/java/cuchaz/enigma/gui/dialog/CrashDialog.java
+++ b/src/main/java/cuchaz/enigma/gui/dialog/CrashDialog.java
@@ -23,15 +23,15 @@ import cuchaz.enigma.utils.Utils;
23 23
24public class CrashDialog { 24public class CrashDialog {
25 25
26 private static CrashDialog m_instance = null; 26 private static CrashDialog instance = null;
27 27
28 private JFrame m_frame; 28 private JFrame frame;
29 private JTextArea m_text; 29 private JTextArea text;
30 30
31 private CrashDialog(JFrame parent) { 31 private CrashDialog(JFrame parent) {
32 // init frame 32 // init frame
33 m_frame = new JFrame(Constants.NAME + " - Crash Report"); 33 frame = new JFrame(Constants.NAME + " - Crash Report");
34 final Container pane = m_frame.getContentPane(); 34 final Container pane = frame.getContentPane();
35 pane.setLayout(new BorderLayout()); 35 pane.setLayout(new BorderLayout());
36 36
37 JLabel label = new JLabel(Constants.NAME + " has crashed! =("); 37 JLabel label = new JLabel(Constants.NAME + " has crashed! =(");
@@ -39,9 +39,9 @@ public class CrashDialog {
39 pane.add(label, BorderLayout.NORTH); 39 pane.add(label, BorderLayout.NORTH);
40 40
41 // report panel 41 // report panel
42 m_text = new JTextArea(); 42 text = new JTextArea();
43 m_text.setTabSize(2); 43 text.setTabSize(2);
44 pane.add(new JScrollPane(m_text), BorderLayout.CENTER); 44 pane.add(new JScrollPane(text), BorderLayout.CENTER);
45 45
46 // buttons panel 46 // buttons panel
47 JPanel buttonsPanel = new JPanel(); 47 JPanel buttonsPanel = new JPanel();
@@ -52,7 +52,7 @@ public class CrashDialog {
52 JButton ignoreButton = new JButton("Ignore"); 52 JButton ignoreButton = new JButton("Ignore");
53 ignoreButton.addActionListener(event -> { 53 ignoreButton.addActionListener(event -> {
54 // close (hide) the dialog 54 // close (hide) the dialog
55 m_frame.setVisible(false); 55 frame.setVisible(false);
56 }); 56 });
57 buttonsPanel.add(ignoreButton); 57 buttonsPanel.add(ignoreButton);
58 JButton exitButton = new JButton("Exit"); 58 JButton exitButton = new JButton("Exit");
@@ -64,13 +64,13 @@ public class CrashDialog {
64 pane.add(buttonsPanel, BorderLayout.SOUTH); 64 pane.add(buttonsPanel, BorderLayout.SOUTH);
65 65
66 // show the frame 66 // show the frame
67 m_frame.setSize(600, 400); 67 frame.setSize(600, 400);
68 m_frame.setLocationRelativeTo(parent); 68 frame.setLocationRelativeTo(parent);
69 m_frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); 69 frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
70 } 70 }
71 71
72 public static void init(JFrame parent) { 72 public static void init(JFrame parent) {
73 m_instance = new CrashDialog(parent); 73 instance = new CrashDialog(parent);
74 } 74 }
75 75
76 public static void show(Throwable ex) { 76 public static void show(Throwable ex) {
@@ -80,8 +80,8 @@ public class CrashDialog {
80 String report = buf.toString(); 80 String report = buf.toString();
81 81
82 // show it! 82 // show it!
83 m_instance.m_text.setText(report); 83 instance.text.setText(report);
84 m_instance.m_frame.doLayout(); 84 instance.frame.doLayout();
85 m_instance.m_frame.setVisible(true); 85 instance.frame.setVisible(true);
86 } 86 }
87} 87}
diff --git a/src/main/java/cuchaz/enigma/gui/dialog/ProgressDialog.java b/src/main/java/cuchaz/enigma/gui/dialog/ProgressDialog.java
index c752c86..8df22a7 100644
--- a/src/main/java/cuchaz/enigma/gui/dialog/ProgressDialog.java
+++ b/src/main/java/cuchaz/enigma/gui/dialog/ProgressDialog.java
@@ -87,15 +87,13 @@ public class ProgressDialog implements ProgressListener, AutoCloseable {
87 } 87 }
88 88
89 public static void runInThread(final JFrame parent, final ProgressRunnable runnable) { 89 public static void runInThread(final JFrame parent, final ProgressRunnable runnable) {
90 new Thread() { 90 new Thread(() ->
91 @Override 91 {
92 public void run() { 92 try (ProgressDialog progress = new ProgressDialog(parent)) {
93 try (ProgressDialog progress = new ProgressDialog(parent)) { 93 runnable.run(progress);
94 runnable.run(progress); 94 } catch (Exception ex) {
95 } catch (Exception ex) { 95 throw new Error(ex);
96 throw new Error(ex);
97 }
98 } 96 }
99 }.start(); 97 }).start();
100 } 98 }
101} 99}