mirror of
https://github.com/developersu/ns-usbloader.git
synced 2025-05-14 07:04:50 -04:00
v0.3.1
1. Add 'check for new versions' feature. 2. Fixed broken (was it broken?) error pop-up window.
This commit is contained in:
parent
4c1fc36f9d
commit
cc00294b06
15 changed files with 229 additions and 21 deletions
|
@ -1,5 +1,6 @@
|
|||
package nsusbloader.Controllers;
|
||||
|
||||
import javafx.application.HostServices;
|
||||
import javafx.collections.FXCollections;
|
||||
import javafx.collections.ObservableList;
|
||||
import javafx.concurrent.Task;
|
||||
|
@ -11,11 +12,9 @@ import javafx.scene.input.TransferMode;
|
|||
import javafx.scene.layout.Pane;
|
||||
import javafx.scene.layout.Region;
|
||||
import javafx.stage.FileChooser;
|
||||
import nsusbloader.AppPreferences;
|
||||
import nsusbloader.MediatorControl;
|
||||
import nsusbloader.*;
|
||||
import nsusbloader.ModelControllers.UpdatesChecker;
|
||||
import nsusbloader.NET.NETCommunications;
|
||||
import nsusbloader.NSLMain;
|
||||
import nsusbloader.ServiceWindow;
|
||||
import nsusbloader.USB.UsbCommunications;
|
||||
|
||||
import java.io.File;
|
||||
|
@ -140,7 +139,28 @@ public class NSLMainController implements Initializable {
|
|||
this.switchThemeBtn.setOnAction(e->switchTheme());
|
||||
|
||||
previouslyOpenedPath = AppPreferences.getInstance().getRecent();
|
||||
|
||||
if (AppPreferences.getInstance().getAutoCheckUpdates()){
|
||||
Task<List<String>> updTask = new UpdatesChecker();
|
||||
updTask.setOnSucceeded(event->{
|
||||
List<String> result = updTask.getValue();
|
||||
if (result != null){
|
||||
if (!result.get(0).isEmpty())
|
||||
SettingsTabController.setNewVersionLink(result.get(0));
|
||||
ServiceWindow.getInfoNotification(resourceBundle.getString("windowTitleNewVersionAval"), resourceBundle.getString("windowTitleNewVersionAval")+": "+result.get(0) + "\n\n" + result.get(1));
|
||||
}
|
||||
else
|
||||
ServiceWindow.getInfoNotification(resourceBundle.getString("windowTitleNewVersionUnknown"), resourceBundle.getString("windowBodyNewVersionUnknown"));
|
||||
});
|
||||
Thread updates = new Thread(updTask);
|
||||
updates.setDaemon(true);
|
||||
updates.start();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Provide hostServices to Settings tab
|
||||
* */
|
||||
public void setHostServices(HostServices hs ){ SettingsTabController.registerHostServices(hs);}
|
||||
/**
|
||||
* Changes UI theme on the go
|
||||
* */
|
||||
|
@ -329,7 +349,8 @@ public class NSLMainController implements Initializable {
|
|||
SettingsTabController.getNotServeSelected(),
|
||||
SettingsTabController.getHostIp(),
|
||||
SettingsTabController.getHostPort(),
|
||||
SettingsTabController.getHostExtra()
|
||||
SettingsTabController.getHostExtra(),
|
||||
SettingsTabController.getAutoCheckForUpdates()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,15 +1,18 @@
|
|||
package nsusbloader.Controllers;
|
||||
|
||||
import javafx.application.HostServices;
|
||||
import javafx.concurrent.Task;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.fxml.Initializable;
|
||||
import javafx.scene.control.CheckBox;
|
||||
import javafx.scene.control.TextField;
|
||||
import javafx.scene.control.TextFormatter;
|
||||
import javafx.scene.control.*;
|
||||
import javafx.scene.layout.Region;
|
||||
import javafx.scene.layout.VBox;
|
||||
import nsusbloader.AppPreferences;
|
||||
import nsusbloader.ServiceWindow;
|
||||
import nsusbloader.ModelControllers.UpdatesChecker;
|
||||
|
||||
import java.net.URL;
|
||||
import java.util.List;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
public class SettingsController implements Initializable {
|
||||
|
@ -36,6 +39,15 @@ public class SettingsController implements Initializable {
|
|||
@FXML
|
||||
private VBox expertSettingsVBox;
|
||||
|
||||
@FXML
|
||||
private CheckBox autoCheckUpdCb;
|
||||
@FXML
|
||||
private Hyperlink newVersionLink;
|
||||
@FXML
|
||||
private Button checkForUpdBtn;
|
||||
|
||||
private HostServices hs;
|
||||
|
||||
@Override
|
||||
public void initialize(URL url, ResourceBundle resourceBundle) {
|
||||
validateNSHostNameCb.setSelected(AppPreferences.getInstance().getNsIpValidationNeeded());
|
||||
|
@ -131,6 +143,39 @@ public class SettingsController implements Initializable {
|
|||
else
|
||||
return change;
|
||||
}));
|
||||
|
||||
newVersionLink.setVisible(false);
|
||||
newVersionLink.setOnAction(e->{
|
||||
hs.showDocument(newVersionLink.getText());
|
||||
});
|
||||
|
||||
autoCheckUpdCb.setSelected(AppPreferences.getInstance().getAutoCheckUpdates());
|
||||
|
||||
Region btnSwitchImage = new Region();
|
||||
btnSwitchImage.getStyleClass().add("regionUpdatesCheck");
|
||||
checkForUpdBtn.setGraphic(btnSwitchImage);
|
||||
|
||||
checkForUpdBtn.setOnAction(e->{
|
||||
Task<List<String>> updTask = new UpdatesChecker();
|
||||
updTask.setOnSucceeded(event->{
|
||||
List<String> result = updTask.getValue();
|
||||
if (result != null){
|
||||
if (result.get(0).isEmpty()){
|
||||
ServiceWindow.getInfoNotification(resourceBundle.getString("windowTitleNewVersionNOTAval"), resourceBundle.getString("windowBodyNewVersionNOTAval"));
|
||||
}
|
||||
else {
|
||||
setNewVersionLink(result.get(0));
|
||||
ServiceWindow.getInfoNotification(resourceBundle.getString("windowTitleNewVersionAval"), resourceBundle.getString("windowTitleNewVersionAval")+": "+result.get(0) + "\n\n" + result.get(1));
|
||||
}
|
||||
}
|
||||
else {
|
||||
ServiceWindow.getInfoNotification(resourceBundle.getString("windowTitleNewVersionUnknown"), resourceBundle.getString("windowBodyNewVersionUnknown"));
|
||||
}
|
||||
});
|
||||
Thread updates = new Thread(updTask);
|
||||
updates.setDaemon(true);
|
||||
updates.start();
|
||||
});
|
||||
}
|
||||
|
||||
public boolean getExpertModeSelected(){ return expertModeCb.isSelected(); }
|
||||
|
@ -143,4 +188,12 @@ public class SettingsController implements Initializable {
|
|||
public String getHostIp(){ return pcIpTextField.getText(); }
|
||||
public String getHostPort(){ return pcPortTextField.getText(); }
|
||||
public String getHostExtra(){ return pcExtraTextField.getText(); }
|
||||
public boolean getAutoCheckForUpdates(){ return autoCheckUpdCb.isSelected(); }
|
||||
|
||||
public void registerHostServices(HostServices hostServices){this.hs = hostServices;}
|
||||
|
||||
public void setNewVersionLink(String newVer){
|
||||
newVersionLink.setVisible(true);
|
||||
newVersionLink.setText("https://github.com/developersu/ns-usbloader/releases/tag/"+newVer);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue