|
1 | 1 | package Forms; |
2 | 2 |
|
3 | 3 | import Singletons.SettingsManager; |
| 4 | +import Utilities.OSValidator; |
4 | 5 | import Utilities.Utils; |
5 | 6 | import Workers.Git.GitWorker; |
6 | 7 | import Workers.Settings.SetCreateIgnoreEntryWorker; |
@@ -76,28 +77,43 @@ public void actionPerformed(ActionEvent actionEvent) { |
76 | 77 | FindURLButton.addActionListener(new ActionListener() { |
77 | 78 | @Override |
78 | 79 | public void actionPerformed(ActionEvent actionEvent) { |
79 | | - //Get top level frame |
80 | | - JFrame topFrame = (JFrame) SwingUtilities.getWindowAncestor(MasterPanel); |
81 | | - |
82 | | - //Create dialog for choosing gearspec file |
83 | | - System.setProperty("apple.awt.fileDialogForDirectories", "true"); |
84 | | - FileDialog fd = new FileDialog(topFrame, "Choose a directory", FileDialog.LOAD); |
85 | | - fd.setDirectory(SettingsManager.getInstance().getSpecsPath()); |
86 | | - fd.setVisible(true); |
87 | | - |
88 | | - //Get file |
89 | | - String filename = fd.getFile(); |
90 | | - if (filename == null) |
91 | | - System.out.println("You cancelled the choice"); |
92 | | - else { |
93 | | - System.out.println("You chose " + filename); |
94 | 80 |
|
95 | | - //Get spec file |
96 | | - File specsDirectory = new File(fd.getDirectory()+Utils.pathSeparator()+filename); |
| 81 | + if(OSValidator.isWindows()){ |
| 82 | + JFileChooser chooser = new JFileChooser(); |
| 83 | + chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); |
| 84 | + chooser.setCurrentDirectory(new File(SettingsManager.getInstance().getSpecsPath())); |
| 85 | + int returnVal = chooser.showOpenDialog(MasterPanel.getTopLevelAncestor()); |
| 86 | + |
| 87 | + if (returnVal == JFileChooser.APPROVE_OPTION) { |
| 88 | + File specsDirectory = chooser.getSelectedFile(); |
| 89 | + |
| 90 | + setSpecsRepoDirectory(specsDirectory); |
| 91 | + } |
| 92 | + } |
| 93 | + else if (OSValidator.isMac()){ |
| 94 | + //Get top level frame |
| 95 | + JFrame topFrame = (JFrame) SwingUtilities.getWindowAncestor(MasterPanel); |
| 96 | + |
| 97 | + //Create dialog for choosing gearspec file |
| 98 | + System.setProperty("apple.awt.fileDialogForDirectories", "true"); |
| 99 | + FileDialog fd = new FileDialog(topFrame, "Choose a directory", FileDialog.LOAD); |
| 100 | + fd.setDirectory(SettingsManager.getInstance().getSpecsPath()); |
| 101 | + fd.setVisible(true); |
| 102 | + |
| 103 | + //Get file |
| 104 | + String filename = fd.getFile(); |
| 105 | + if (filename == null) |
| 106 | + System.out.println("You cancelled the choice"); |
| 107 | + else { |
| 108 | + System.out.println("You chose " + filename); |
| 109 | + |
| 110 | + //Get spec file |
| 111 | + File specsDirectory = new File(fd.getDirectory()+Utils.pathSeparator()+filename); |
97 | 112 |
|
98 | | - //If it exists, set it as the selected file path |
99 | | - setSpecsRepoDirectory(specsDirectory); |
| 113 | + //If it exists, set it as the selected file path |
| 114 | + setSpecsRepoDirectory(specsDirectory); |
100 | 115 |
|
| 116 | + } |
101 | 117 | } |
102 | 118 | } |
103 | 119 | }); |
|
0 commit comments