Skip to content

Commit

Permalink
fix: cancel should not clear value in config screen
Browse files Browse the repository at this point in the history
  • Loading branch information
jagodevreede committed Jul 6, 2024
1 parent 0b24cc6 commit 99802bf
Showing 1 changed file with 24 additions and 15 deletions.
Original file line number Diff line number Diff line change
@@ -1,16 +1,5 @@
package io.github.jagodevreede.sdkmanui.controller;

import static io.github.jagodevreede.sdkman.api.OsHelper.isWindows;
import static io.github.jagodevreede.sdkman.api.SdkManUiPreferences.PROPERTY_LOCATION;
import static io.github.jagodevreede.sdkmanui.ConfigurationUtil.checkSymlink;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.net.URL;
import java.util.Properties;
import java.util.ResourceBundle;

import io.github.jagodevreede.sdkman.api.SdkManUiPreferences;
import io.github.jagodevreede.sdkman.api.files.ProcessStarter;
import io.github.jagodevreede.sdkmanui.service.ServiceRegistry;
Expand All @@ -23,6 +12,17 @@
import javafx.stage.FileChooser;
import javafx.stage.Stage;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.net.URL;
import java.util.Properties;
import java.util.ResourceBundle;

import static io.github.jagodevreede.sdkman.api.OsHelper.isWindows;
import static io.github.jagodevreede.sdkman.api.SdkManUiPreferences.PROPERTY_LOCATION;
import static io.github.jagodevreede.sdkmanui.ConfigurationUtil.checkSymlink;

public class ConfigScreenController implements Initializable {
final String SYMLINK_CAPABLE = "Capable";
final String SYMLINK_NOT_CAPABLE = "Not capable";
Expand Down Expand Up @@ -66,17 +66,23 @@ public void initialize(final URL url, final ResourceBundle resourceBundle) {

public void browseZipExecutablePath() {
final String path = this.browsePath("zip", new Stage());
zipExecutablePath.setText(path);
if (path != null) {
zipExecutablePath.setText(path);
}
}

public void browseUnzipExecutablePath() {
final String path = this.browsePath("unzip", new Stage());
unzipExecutablePath.setText(path);
if (path != null) {
unzipExecutablePath.setText(path);
}
}

public void browseTarExecutablePath() {
final String path = this.browsePath("tar", new Stage());
tarExecutablePath.setText(path);
if (path != null) {
tarExecutablePath.setText(path);
}
}

public void checkSymlinkCapability() {
Expand Down Expand Up @@ -123,7 +129,10 @@ private String browsePath(String command, Stage stage) {
fileChooser.getExtensionFilters().add(new FileChooser.ExtensionFilter(command, command + (isWindows() ? ".exe" : "")));
fileChooser.setInitialFileName(command);
File file = fileChooser.showOpenDialog(stage);
if (file == null || !ProcessStarter.testIfAvailable(file.getAbsolutePath())) {
if (file == null) {
return null;
}
if (!ProcessStarter.testIfAvailable(file.getAbsolutePath())) {
String name = file != null ? file.getAbsolutePath() : command;
ServiceRegistry.INSTANCE.getPopupView().showInformation("Failed to verify " + name, Alert.AlertType.INFORMATION);
return null;
Expand Down

0 comments on commit 99802bf

Please sign in to comment.