Multiple Choice Dialogue Cleanup
This commit is contained in:
parent
c774bf441b
commit
3216b17389
3 changed files with 30 additions and 69 deletions
|
@ -554,23 +554,16 @@ public class BytecodeViewer
|
|||
*
|
||||
* @param ask if should require user input or not
|
||||
*/
|
||||
public static void resetWorkSpace(boolean ask) {
|
||||
if (ask) {
|
||||
JOptionPane pane = new JOptionPane(
|
||||
"Are you sure you want to reset the workspace?\n\rIt will also reset your file navigator and "
|
||||
+ "search.");
|
||||
Object[] options = new String[]{"Yes", "No"};
|
||||
pane.setOptions(options);
|
||||
JDialog dialog = pane.createDialog(viewer,
|
||||
"Bytecode Viewer - Reset Workspace");
|
||||
dialog.setVisible(true);
|
||||
Object obj = pane.getValue();
|
||||
int result = -1;
|
||||
for (int k = 0; k < options.length; k++)
|
||||
if (options[k].equals(obj))
|
||||
result = k;
|
||||
public static void resetWorkSpace(boolean ask)
|
||||
{
|
||||
if (ask)
|
||||
{
|
||||
MultipleChoiceDialogue dialogue = new MultipleChoiceDialogue("Bytecode Viewer - Reset Workspace",
|
||||
"Are you sure you want to reset the workspace?" +
|
||||
"\n\rIt will also reset your file navigator and search.",
|
||||
new String[]{"Yes", "No"});
|
||||
|
||||
if (result != 0)
|
||||
if (dialogue.promptChoice() != 0)
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -11,10 +11,7 @@ import javax.swing.*;
|
|||
import org.objectweb.asm.tree.ClassNode;
|
||||
import the.bytecode.club.bytecodeviewer.*;
|
||||
import the.bytecode.club.bytecodeviewer.api.ExceptionUI;
|
||||
import the.bytecode.club.bytecodeviewer.gui.components.FileChooser;
|
||||
import the.bytecode.club.bytecodeviewer.gui.components.VisibleComponent;
|
||||
import the.bytecode.club.bytecodeviewer.gui.components.AboutWindow;
|
||||
import the.bytecode.club.bytecodeviewer.gui.components.RunOptions;
|
||||
import the.bytecode.club.bytecodeviewer.gui.components.*;
|
||||
import the.bytecode.club.bytecodeviewer.gui.plugins.MaliciousCodeScannerOptions;
|
||||
import the.bytecode.club.bytecodeviewer.gui.plugins.ReplaceStringsOptions;
|
||||
import the.bytecode.club.bytecodeviewer.gui.resourcelist.ResourceListPane;
|
||||
|
@ -765,18 +762,12 @@ public class MainViewerGUI extends JFrame
|
|||
|
||||
public void reloadResources()
|
||||
{
|
||||
JOptionPane pane = new JOptionPane("Are you sure you wish to reload the resources?");
|
||||
Object[] options = new String[]{"Yes", "No"};
|
||||
pane.setOptions(options);
|
||||
JDialog dialog = pane.createDialog(BytecodeViewer.viewer, "Bytecode Viewer - Reload Resources");
|
||||
dialog.setVisible(true);
|
||||
Object obj = pane.getValue();
|
||||
int result = -1;
|
||||
for (int k = 0; k < options.length; k++)
|
||||
if (options[k].equals(obj))
|
||||
result = k;
|
||||
MultipleChoiceDialogue dialogue = new MultipleChoiceDialogue("Bytecode Viewer - Reload Resources",
|
||||
"Are you sure you wish to reload the resources?",
|
||||
new String[]{"Yes", "No"});
|
||||
|
||||
if (result == 0) {
|
||||
if (dialogue.promptChoice() == 0)
|
||||
{
|
||||
LazyNameUtil.reset();
|
||||
ArrayList<File> reopen = new ArrayList<>();
|
||||
|
||||
|
@ -944,20 +935,11 @@ public class MainViewerGUI extends JFrame
|
|||
|
||||
public void askBeforeExiting()
|
||||
{
|
||||
JOptionPane pane = new JOptionPane("Are you sure you want to exit?");
|
||||
MultipleChoiceDialogue dialogue = new MultipleChoiceDialogue("Bytecode Viewer - Exit",
|
||||
"Are you sure you want to exit?",
|
||||
new String[]{"Yes", "No"});
|
||||
|
||||
Object[] options = new String[]{"Yes", "No"};
|
||||
|
||||
pane.setOptions(options);
|
||||
JDialog dialog = pane.createDialog(BytecodeViewer.viewer, "Bytecode Viewer - Exit");
|
||||
dialog.setVisible(true);
|
||||
Object obj = pane.getValue();
|
||||
int result = -1;
|
||||
for (int k = 0; k < options.length; k++)
|
||||
if (options[k].equals(obj))
|
||||
result = k;
|
||||
|
||||
if (result == 0)
|
||||
if (dialogue.promptChoice() == 0)
|
||||
{
|
||||
Configuration.canExit = true;
|
||||
System.exit(0);
|
||||
|
|
|
@ -5,6 +5,7 @@ import the.bytecode.club.bytecodeviewer.BytecodeViewer;
|
|||
import the.bytecode.club.bytecodeviewer.Configuration;
|
||||
import the.bytecode.club.bytecodeviewer.api.ExceptionUI;
|
||||
import the.bytecode.club.bytecodeviewer.gui.components.FileChooser;
|
||||
import the.bytecode.club.bytecodeviewer.gui.components.MultipleChoiceDialogue;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.filechooser.FileFilter;
|
||||
|
@ -60,18 +61,12 @@ public class VersionChecker implements Runnable
|
|||
|
||||
if (!VERSION.equals(version))
|
||||
{
|
||||
JOptionPane pane = new JOptionPane(
|
||||
MultipleChoiceDialogue outdatedDialogue = new MultipleChoiceDialogue("Bytecode Viewer - Outdated Version",
|
||||
"Your version: " + VERSION + ", latest version: "
|
||||
+ version + nl + "What would you like to do?");
|
||||
Object[] options = new String[]{"Open The Download Page", "Download The Updated Jar", "Do Nothing"};
|
||||
pane.setOptions(options);
|
||||
JDialog dialog = pane.createDialog(BytecodeViewer.viewer, "Bytecode Viewer - Outdated Version");
|
||||
dialog.setVisible(true);
|
||||
Object obj = pane.getValue();
|
||||
int result = -1;
|
||||
for (int k = 0; k < options.length; k++)
|
||||
if (options[k].equals(obj))
|
||||
result = k;
|
||||
+ version + nl + "What would you like to do?",
|
||||
new String[]{"Open The Download Page", "Download The Updated Jar", "Do Nothing"});
|
||||
|
||||
int result = outdatedDialogue.promptChoice();
|
||||
|
||||
if (result == 0)
|
||||
{
|
||||
|
@ -80,8 +75,7 @@ public class VersionChecker implements Runnable
|
|||
else
|
||||
BytecodeViewer.showMessage("Cannot open the page, please manually type it." + nl + "https://github.com/Konloch/bytecode-viewer/releases");
|
||||
}
|
||||
|
||||
if (result == 1)
|
||||
else if (result == 1)
|
||||
{
|
||||
JFileChooser fc = new FileChooser(new File(Configuration.lastDirectory),
|
||||
"Select Save File",
|
||||
|
@ -104,19 +98,11 @@ public class VersionChecker implements Runnable
|
|||
|
||||
if (file.exists())
|
||||
{
|
||||
pane = new JOptionPane("The file " + file + " exists, would you like to overwrite it?");
|
||||
options = new String[]{"Yes", "No"};
|
||||
pane.setOptions(options);
|
||||
dialog = pane.createDialog(BytecodeViewer.viewer,
|
||||
"Bytecode Viewer - Overwrite File");
|
||||
dialog.setVisible(true);
|
||||
obj = pane.getValue();
|
||||
result = -1;
|
||||
for (int k = 0; k < options.length; k++)
|
||||
if (options[k].equals(obj))
|
||||
result = k;
|
||||
MultipleChoiceDialogue overwriteDialogue = new MultipleChoiceDialogue("Bytecode Viewer - Overwrite File",
|
||||
"The file " + file + " exists, would you like to overwrite it?",
|
||||
new String[]{"Yes", "No"});
|
||||
|
||||
if (result != 0)
|
||||
if (overwriteDialogue.promptChoice() != 0)
|
||||
return;
|
||||
|
||||
file.delete();
|
||||
|
|
Loading…
Reference in a new issue