|
24 | 24 | public class JDA |
25 | 25 | { |
26 | 26 | /*per version*/ |
27 | | - public static final String version = "0.0.3.1"; |
| 27 | + public static final String version = "0.0.3.2"; |
28 | 28 | public static final boolean previewCopy = false; |
29 | 29 | /* Constants */ |
30 | 30 | public static final String fs = System.getProperty("file.separator"); |
@@ -436,30 +436,39 @@ public static void showMessage(String message) |
436 | 436 | */ |
437 | 437 | public static void resetWorkSpace(boolean ask) |
438 | 438 | { |
439 | | - if (!ask) |
440 | | - { |
441 | | - files.clear(); |
442 | | - viewer.resetWorkspace(); |
443 | | - } |
444 | | - else |
| 439 | + if (ask) |
445 | 440 | { |
446 | 441 | JOptionPane pane = new JOptionPane("Are you sure you want to reset the workspace?\n\rIt will also reset your file navigator and search."); |
447 | 442 | Object[] options = new String[] { "Yes", "No" }; |
448 | 443 | pane.setOptions(options); |
449 | 444 | JDialog dialog = pane.createDialog(viewer, "JDA - Reset Workspace"); |
450 | 445 | dialog.setVisible(true); |
451 | 446 | Object obj = pane.getValue(); |
452 | | - int result = -1; |
453 | 447 | for (int k = 0; k < options.length; k++) |
454 | | - if (options[k].equals(obj)) |
455 | | - result = k; |
| 448 | + if (options[k].equals(obj) && k != 0) |
| 449 | + return; |
| 450 | + } |
456 | 451 |
|
457 | | - if (result == 0) |
458 | | - { |
459 | | - files.clear(); |
460 | | - viewer.resetWorkspace(); |
461 | | - } |
| 452 | + closeResources(false); |
| 453 | + viewer.resetWindows(); |
| 454 | + } |
| 455 | + |
| 456 | + public static void closeResources(boolean ask) { |
| 457 | + if (ask) |
| 458 | + { |
| 459 | + JOptionPane pane = new JOptionPane("Are you sure you want to close all resources?"); |
| 460 | + Object[] options = new String[] { "Yes", "No" }; |
| 461 | + pane.setOptions(options); |
| 462 | + JDialog dialog = pane.createDialog(viewer, "JDA - Close Resources"); |
| 463 | + dialog.setVisible(true); |
| 464 | + Object obj = pane.getValue(); |
| 465 | + for (int k = 0; k < options.length; k++) |
| 466 | + if (options[k].equals(obj) && k != 0) |
| 467 | + return; |
462 | 468 | } |
| 469 | + |
| 470 | + files.clear(); |
| 471 | + viewer.closeResources(); |
463 | 472 | } |
464 | 473 |
|
465 | 474 | private static ArrayList<String> killList = new ArrayList<>(); |
@@ -597,14 +606,22 @@ private static void hideFile(File f) |
597 | 606 | sm.setBlocking(); |
598 | 607 | } |
599 | 608 |
|
| 609 | + private static boolean isCtrlDown(KeyEvent e) { |
| 610 | + return ((e.getModifiers() & KeyEvent.CTRL_MASK) != 0); |
| 611 | + } |
| 612 | + |
| 613 | + private static boolean isShiftDown(KeyEvent e) { |
| 614 | + return ((e.getModifiers() & KeyEvent.SHIFT_MASK) != 0); |
| 615 | + } |
| 616 | + |
600 | 617 | /** |
601 | 618 | * Checks the hotkeys |
602 | 619 | * |
603 | 620 | * @param e |
604 | 621 | */ |
605 | 622 | public static void checkHotKey(KeyEvent e) |
606 | 623 | { |
607 | | - if ((e.getKeyCode() == KeyEvent.VK_O) && ((e.getModifiers() & KeyEvent.CTRL_MASK) != 0)) |
| 624 | + if ((e.getKeyCode() == KeyEvent.VK_O) && isCtrlDown(e)) |
608 | 625 | { |
609 | 626 | JFileChooser fc = new JFileChooser(); |
610 | 627 | try |
@@ -656,15 +673,19 @@ public String getDescription() |
656 | 673 | } |
657 | 674 | } |
658 | 675 | } |
659 | | - else if ((e.getKeyCode() == KeyEvent.VK_N) && ((e.getModifiers() & KeyEvent.CTRL_MASK) != 0)) |
| 676 | + else if ((e.getKeyCode() == KeyEvent.VK_N) && isCtrlDown(e)) |
660 | 677 | { |
661 | 678 | JDA.resetWorkSpace(true); |
662 | 679 | } |
663 | | - else if ((e.getKeyCode() == KeyEvent.VK_R) && ((e.getModifiers() & KeyEvent.CTRL_MASK) != 0)) |
| 680 | + else if ((e.getKeyCode() == KeyEvent.VK_R) && isCtrlDown(e)) |
664 | 681 | { |
665 | 682 | viewer.reloadResources(); |
666 | 683 | } |
667 | | - else if ((e.getKeyCode() == KeyEvent.VK_S) && ((e.getModifiers() & KeyEvent.CTRL_MASK) != 0)) |
| 684 | + else if ((e.getKeyCode() == KeyEvent.VK_W) && isCtrlDown(e) && isShiftDown(e)) |
| 685 | + { |
| 686 | + JDA.closeResources(true); |
| 687 | + } |
| 688 | + else if ((e.getKeyCode() == KeyEvent.VK_S) && isCtrlDown(e)) |
668 | 689 | { |
669 | 690 | if (JDA.getLoadedClasses().isEmpty()) |
670 | 691 | { |
@@ -741,7 +762,7 @@ public void run() |
741 | 762 | }; |
742 | 763 | t.start(); |
743 | 764 | } |
744 | | - else if ((e.getKeyCode() == KeyEvent.VK_W) && ((e.getModifiers() & KeyEvent.CTRL_MASK) != 0)) |
| 765 | + else if ((e.getKeyCode() == KeyEvent.VK_W) && isCtrlDown(e)) |
745 | 766 | { |
746 | 767 | if (viewer.workPane.getCurrentViewer() != null) |
747 | 768 | viewer.workPane.tabs.remove(viewer.workPane.getCurrentViewer()); |
|
0 commit comments