Skip to content

Commit 884c297

Browse files
committed
Support external sources viewer command with quoted spaces, improved tooltip wording in Add Source Root dialog
1 parent f17387f commit 884c297

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

plugins/sources/src/org/graalvm/visualvm/sources/options/SourcesOptionsPanel.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@
114114
"SourcesOptionsPanel_SubdirectoriesChoice=S&ubdirectories:", // NOI18N
115115
"SourcesOptionsPanel_SubdirectoriesToolTip=Sources are in the selected subdirectories of the source root(s)", // NOI18N
116116
"SourcesOptionsPanel_CustomSubpathsChoice=&Custom subpaths:", // NOI18N
117-
"SourcesOptionsPanel_CustomSubpathsToolTip=Sources are in the defined subdirectories of the source root(s) - no wildcards allowed", // NOI18N
117+
"SourcesOptionsPanel_CustomSubpathsToolTip=Sources are in the defined subpaths of the source root(s) - no wildcards allowed", // NOI18N
118118
"SourcesOptionsPanel_SourcesEncoding=Sources Encoding:" // NOI18N
119119
})
120120
final class SourcesOptionsPanel extends JPanel {

plugins/sources/src/org/graalvm/visualvm/sources/viewer/ExternalViewerLauncher.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,18 @@
2727
import java.io.IOException;
2828
import java.util.ArrayList;
2929
import java.util.List;
30-
import java.util.StringTokenizer;
30+
import java.util.regex.Matcher;
31+
import java.util.regex.Pattern;
3132
import org.graalvm.visualvm.core.datasource.Storage;
3233

3334
/**
3435
* @author Jiri Sedlacek
3536
*/
3637
class ExternalViewerLauncher implements Runnable {
3738

39+
private static final String COMMAND_STRINGS_REGEX = "\"[^\"]*\"|\\S+"; // NOI18N
40+
41+
3842
private final String command;
3943

4044

@@ -57,9 +61,12 @@ protected void failed(IOException e) {}
5761

5862

5963
public static List<String> getCommandStrings(String commandString) {
60-
StringTokenizer tokenizer = new StringTokenizer(commandString);
6164
List<String> command = new ArrayList();
62-
while (tokenizer.hasMoreTokens()) command.add(tokenizer.nextToken());
65+
66+
Pattern pattern = Pattern.compile(COMMAND_STRINGS_REGEX);
67+
Matcher matcher = pattern.matcher(commandString);
68+
while (matcher.find()) command.add(matcher.group());
69+
6370
return command;
6471
}
6572

0 commit comments

Comments
 (0)