Skip to content

Commit

Permalink
Simplify command split
Browse files Browse the repository at this point in the history
  • Loading branch information
nroduit committed Jul 26, 2024
1 parent 87d4ea0 commit 902f001
Showing 1 changed file with 4 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import java.util.*;
import java.util.Map.Entry;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import javax.swing.Action;
import javax.swing.Icon;
import javax.swing.ImageIcon;
Expand Down Expand Up @@ -406,14 +405,10 @@ public boolean isDicomSelectionAction() {

public void launch(ImageViewerEventManager<?> eventManager) {
try {

List<String> command = Optional.ofNullable(binaryPath)
.map(String::trim) // Trim the input
.filter(trimmed -> !trimmed.isEmpty())
.map(trimmed -> trimmed.split("\\s+"))// Split by one or more spaces
.stream().flatMap(Arrays::stream)
.collect(Collectors.toCollection(ArrayList::new));

if (!StringUtil.hasText(binaryPath)) {
return;
}
List<String> command = new ArrayList<>(Arrays.asList(binaryPath.trim().split("\\s+")));
if (parameters != null && !parameters.isEmpty()) {
for (String param : parameters) {
command.add(resolvePlaceholders(param, eventManager));
Expand Down

0 comments on commit 902f001

Please sign in to comment.