mirror of
https://github.com/developersu/ns-usbloader.git
synced 2025-05-14 07:04:50 -04:00
v0.3 UI updates. It's nightmare..
This commit is contained in:
parent
3a238d296c
commit
5e4a93af7c
11 changed files with 160 additions and 34 deletions
|
@ -13,19 +13,16 @@ import javafx.stage.FileChooser;
|
|||
import nsusbloader.AppPreferences;
|
||||
import nsusbloader.MediatorControl;
|
||||
import nsusbloader.NET.NETCommunications;
|
||||
import nsusbloader.NET.NETPacket;
|
||||
import nsusbloader.NSLMain;
|
||||
import nsusbloader.ServiceWindow;
|
||||
import nsusbloader.USB.UsbCommunications;
|
||||
|
||||
import java.io.File;
|
||||
import java.net.URL;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneOffset;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.ResourceBundle;
|
||||
import java.util.function.UnaryOperator;
|
||||
|
||||
public class NSLMainController implements Initializable {
|
||||
|
||||
|
@ -129,7 +126,12 @@ public class NSLMainController implements Initializable {
|
|||
nsIpLbl.setVisible(true);
|
||||
nsIpTextField.setVisible(true);
|
||||
}
|
||||
|
||||
nsIpTextField.setTextFormatter(new TextFormatter<>(change -> {
|
||||
if (change.getControlNewText().contains(" ") | change.getControlNewText().contains("\t"))
|
||||
return null;
|
||||
else
|
||||
return change;
|
||||
}));
|
||||
this.previouslyOpenedPath = null;
|
||||
|
||||
Region btnSwitchImage = new Region();
|
||||
|
@ -314,13 +316,20 @@ public class NSLMainController implements Initializable {
|
|||
/**
|
||||
* Save preferences before exit
|
||||
* */
|
||||
public void exit(){
|
||||
AppPreferences.getInstance().setProtocol(choiceProtocol.getSelectionModel().getSelectedItem());
|
||||
AppPreferences.getInstance().setRecent(previouslyOpenedPath);
|
||||
AppPreferences.getInstance().setNetUsb(choiceNetUsb.getSelectionModel().getSelectedItem());
|
||||
AppPreferences.getInstance().setNsIp(nsIpTextField.getText().trim());
|
||||
|
||||
AppPreferences.getInstance().setNsIpValidationNeeded(SettingsTabController.isNsIpValidate());
|
||||
AppPreferences.getInstance().setExpertMode(SettingsTabController.getExpertModeSelected());
|
||||
public void exit(){ // TODO: add method to set all in AppPreferences
|
||||
AppPreferences.getInstance().setAll(
|
||||
choiceProtocol.getSelectionModel().getSelectedItem(),
|
||||
previouslyOpenedPath,
|
||||
choiceNetUsb.getSelectionModel().getSelectedItem(),
|
||||
nsIpTextField.getText().trim(),
|
||||
SettingsTabController.isNsIpValidate(),
|
||||
SettingsTabController.getExpertModeSelected(),
|
||||
SettingsTabController.getAutoIpSelected(),
|
||||
SettingsTabController.getRandPortSelected(),
|
||||
SettingsTabController.getNotServeSelected(),
|
||||
SettingsTabController.getHostIp(),
|
||||
SettingsTabController.getHostPort(),
|
||||
SettingsTabController.getHostExtra()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,12 +4,15 @@ 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.layout.VBox;
|
||||
import nsusbloader.AppPreferences;
|
||||
import nsusbloader.ServiceWindow;
|
||||
|
||||
|
||||
import java.net.URL;
|
||||
import java.util.ResourceBundle;
|
||||
import java.util.function.UnaryOperator;
|
||||
|
||||
public class SettingsController implements Initializable {
|
||||
|
||||
|
@ -27,7 +30,7 @@ public class SettingsController implements Initializable {
|
|||
@FXML
|
||||
private TextField pcPortTextField;
|
||||
@FXML
|
||||
private TextField pcPostfixTextField;
|
||||
private TextField pcExtraTextField;
|
||||
|
||||
@FXML
|
||||
private CheckBox dontServeCb;
|
||||
|
@ -43,23 +46,96 @@ public class SettingsController implements Initializable {
|
|||
|
||||
expertModeCb.setSelected(AppPreferences.getInstance().getExpertMode());
|
||||
expertModeCb.setOnAction(e->{
|
||||
if (expertModeCb.isSelected())
|
||||
expertSettingsVBox.setDisable(false);
|
||||
else
|
||||
expertSettingsVBox.setDisable(true);
|
||||
expertSettingsVBox.setDisable(!expertModeCb.isSelected());
|
||||
});
|
||||
|
||||
autoDetectIpCb.setSelected(AppPreferences.getInstance().getAutoDetectIp());
|
||||
pcIpTextField.setDisable(AppPreferences.getInstance().getAutoDetectIp());
|
||||
autoDetectIpCb.setOnAction(e->{
|
||||
pcIpTextField.setDisable(autoDetectIpCb.isSelected());
|
||||
});
|
||||
|
||||
randPortCb.setSelected(AppPreferences.getInstance().getRandPort());
|
||||
pcPortTextField.setDisable(AppPreferences.getInstance().getRandPort());
|
||||
randPortCb.setOnAction(e->{
|
||||
pcPortTextField.setDisable(randPortCb.isSelected());
|
||||
});
|
||||
|
||||
if (AppPreferences.getInstance().getNotServeRequests()){
|
||||
dontServeCb.setSelected(true);
|
||||
|
||||
autoDetectIpCb.setSelected(false);
|
||||
autoDetectIpCb.setDisable(true);
|
||||
pcIpTextField.setDisable(false);
|
||||
|
||||
dontServeCb.setSelected(AppPreferences.getInstance().getNotServeRequests());
|
||||
randPortCb.setSelected(false);
|
||||
randPortCb.setDisable(true);
|
||||
pcPortTextField.setDisable(false);
|
||||
}
|
||||
pcExtraTextField.setDisable(!AppPreferences.getInstance().getNotServeRequests());
|
||||
|
||||
dontServeCb.setOnAction(e->{
|
||||
if (dontServeCb.isSelected()){
|
||||
autoDetectIpCb.setSelected(false);
|
||||
autoDetectIpCb.setDisable(true);
|
||||
pcIpTextField.setDisable(false);
|
||||
|
||||
randPortCb.setSelected(false);
|
||||
randPortCb.setDisable(true);
|
||||
pcPortTextField.setDisable(false);
|
||||
|
||||
pcExtraTextField.setDisable(false);
|
||||
}
|
||||
else {
|
||||
autoDetectIpCb.setDisable(false);
|
||||
autoDetectIpCb.setSelected(true);
|
||||
pcIpTextField.setDisable(true);
|
||||
|
||||
randPortCb.setDisable(false);
|
||||
randPortCb.setSelected(true);
|
||||
pcPortTextField.setDisable(true);
|
||||
|
||||
pcExtraTextField.setDisable(true);
|
||||
}
|
||||
});
|
||||
|
||||
pcIpTextField.setText(AppPreferences.getInstance().getHostIp());
|
||||
pcPortTextField.setText(AppPreferences.getInstance().getHostPort());
|
||||
pcExtraTextField.setText(AppPreferences.getInstance().getHostExtra());
|
||||
|
||||
pcIpTextField.setTextFormatter(new TextFormatter<>(change -> {
|
||||
if (change.getControlNewText().contains(" ") | change.getControlNewText().contains("\t"))
|
||||
return null;
|
||||
else
|
||||
return change;
|
||||
}));
|
||||
pcPortTextField.setTextFormatter(new TextFormatter<Object>(change -> {
|
||||
if (change.getControlNewText().matches("^[0-9]{0,5}$")) {
|
||||
if ((Integer.parseInt(change.getControlNewText()) > 65535) || (Integer.parseInt(change.getControlNewText()) == 0)) {
|
||||
ServiceWindow.getErrorNotification(resourceBundle.getString("windowTitleErrorPort"), resourceBundle.getString("windowBodyErrorPort"));
|
||||
return null;
|
||||
}
|
||||
return change;
|
||||
}
|
||||
else
|
||||
return null;
|
||||
}));
|
||||
pcExtraTextField.setTextFormatter(new TextFormatter<>(change -> {
|
||||
if (change.getControlNewText().contains(" ") | change.getControlNewText().contains("\t"))
|
||||
return null;
|
||||
else
|
||||
return change;
|
||||
}));
|
||||
}
|
||||
|
||||
public boolean getExpertModeSelected(){
|
||||
return expertModeCb.isSelected();
|
||||
}
|
||||
public boolean getExpertModeSelected(){ return expertModeCb.isSelected(); }
|
||||
public boolean getAutoIpSelected(){ return autoDetectIpCb.isSelected(); }
|
||||
public boolean getRandPortSelected(){ return randPortCb.isSelected(); }
|
||||
public boolean getNotServeSelected(){ return dontServeCb.isSelected(); }
|
||||
|
||||
public boolean isNsIpValidate(){ return validateNSHostNameCb.isSelected(); }
|
||||
}
|
||||
|
||||
public String getHostIp(){ return pcIpTextField.getText(); }
|
||||
public String getHostPort(){ return pcPortTextField.getText(); }
|
||||
public String getHostExtra(){ return pcExtraTextField.getText(); }
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue