|
31 | 31 | import java.io.IOException;
|
32 | 32 | import java.util.Arrays;
|
33 | 33 | import java.util.Comparator;
|
| 34 | +import java.util.List; |
34 | 35 | import java.util.logging.Level;
|
35 | 36 | import java.util.logging.Logger;
|
36 | 37 | import javax.swing.Box;
|
@@ -88,7 +89,7 @@ private static enum IdePreset {
|
88 | 89 | ECLIPSE("Eclipse", "eclipse " + SourceHandle.Feature.FILE.getCode() + ":" + SourceHandle.Feature.LINE.getCode()), // NOI18N
|
89 | 90 | IDEA("IntelliJ IDEA", "idea --line " + SourceHandle.Feature.LINE.getCode() + " --column " + SourceHandle.Feature.COLUMN.getCode() + " " + SourceHandle.Feature.FILE.getCode()), // NOI18N
|
90 | 91 | VSCODE("Visual Studio Code", "code -g " + SourceHandle.Feature.FILE.getCode() + ":" + SourceHandle.Feature.LINE.getCode()), // NOI18N
|
91 |
| - XCODE("Xcode", "open -a Xcode " + SourceHandle.Feature.FILE.getCode() + " ???"); // NOI18N |
| 92 | + XCODE("Xcode", "open -a Xcode " + SourceHandle.Feature.FILE.getCode()); // NOI18N |
92 | 93 |
|
93 | 94 | private final String name;
|
94 | 95 | private final String command;
|
@@ -173,7 +174,16 @@ public boolean open(SourceHandle handle) {
|
173 | 174 | if (expandedCommand.isEmpty()) {
|
174 | 175 | ProfilerDialogs.displayError(Bundle.ExternalSourcesViewer_EmptyCommand());
|
175 | 176 | } else {
|
176 |
| - new ExternalViewerLauncher(expandedCommand) { |
| 177 | + String commandS = getCommand(); |
| 178 | + List<String> commandL = ExternalViewerLauncher.getCommandStrings(commandS); |
| 179 | + |
| 180 | + for (int i = 0; i < commandL.size(); i++) { |
| 181 | + String command = commandL.get(i); |
| 182 | + command = handle.expandFeatures(command); |
| 183 | + commandL.set(i, command); |
| 184 | + } |
| 185 | + |
| 186 | + new ExternalViewerLauncher(commandL) { |
177 | 187 | @Override protected void failed(IOException e) {
|
178 | 188 | ProfilerDialogs.displayError(Bundle.ExternalSourcesViewer_CommandFailed(e.getMessage()));
|
179 | 189 | LOGGER.log(Level.INFO, "Opening external sources viewer failed", e); // NOI18N
|
@@ -326,21 +336,11 @@ private static String appendSpaces(String string, int targetLength) {
|
326 | 336 | }
|
327 | 337 |
|
328 | 338 | private static void insertFile(JTextField textField, File file) {
|
329 |
| - Document document = textField.getDocument(); |
330 |
| - int length = document.getLength(); |
331 |
| - int position = textField.getCaretPosition(); |
332 |
| - |
333 |
| - boolean dir = file.isDirectory(); |
334 | 339 | String path = file.getAbsolutePath();
|
| 340 | + if (path.contains(" ")) path = "\"" + path + "\""; // NOI18N |
335 | 341 |
|
336 |
| - try { |
337 |
| - if (dir && position == 0 && length > 0) { |
338 |
| - String nextChar = document.getText(position, 1); |
339 |
| - if (!" ".equals(nextChar) && !"{".equals(nextChar)) path = path + File.separator; // NOI18N |
340 |
| - } |
341 |
| - |
342 |
| - textField.getDocument().insertString(position, path, null); |
343 |
| - } catch (BadLocationException ex) {} |
| 342 | + try { textField.getDocument().insertString(textField.getCaretPosition(), path, null); } |
| 343 | + catch (BadLocationException ex) {} |
344 | 344 | }
|
345 | 345 |
|
346 | 346 | private static void insertParameter(JTextField textField, String parameter) {
|
|
0 commit comments