Skip to content

Commit

Permalink
M3-21, M3-15: Addressed issues with RS422 connections
Browse files Browse the repository at this point in the history
  • Loading branch information
hohonuuli committed Dec 16, 2019
1 parent e28d058 commit 90e8939
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public class MediaControlsFactoryImpl implements MediaControlsFactory {
String title = i18n.getString("mediaplayer.vcr.open.error.title");
String header = i18n.getString("mediaplayer.vcr.open.error.header");
String content = i18n.getString("mediaplayer.vcr.open.error.content") + " " +
MediaControlsFactoryImplOriginal.getSelectedSerialPort().orElse("<undefined>");
MediaControlsFactoryImpl.getSelectedSerialPort().orElse("<undefined>");
ShowNonfatalErrorAlert alert = new ShowNonfatalErrorAlert(title, header, content, new RuntimeException(ex));
Initializer.getToolBox()
.getEventBus()
Expand Down Expand Up @@ -270,4 +270,13 @@ public static Optional<String> getSelectedSerialPort() {
return Optional.of(serialPort);
}
}

/**
* Stores the serialPort value to local preferences
* @param serialPort
*/
public static void setSelectedSerialPort(String serialPort) {
Preferences prefs = Preferences.userNodeForPackage(MediaControlsFactoryImplOriginal.PREF_NODE_KEY);
prefs.put(MediaControlsFactoryImplOriginal.PREF_SERIALPORT_KEY, serialPort);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
/**
* @author Brian Schlining
* @since 2018-03-26T10:52:00
* @deprecated
*/
public class MediaControlsFactoryImplOriginal implements MediaControlsFactory {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ void initialize() {
commportComboBox.setEditable(false);
ObservableList<String> serialPorts = FXCollections.observableArrayList(MediaControlsFactoryImpl.getSerialPorts());
commportComboBox.setItems(serialPorts);
MediaControlsFactoryImplOriginal.getSelectedSerialPort()
MediaControlsFactoryImpl.getSelectedSerialPort()
.ifPresent(sp -> commportComboBox.getSelectionModel().select(sp));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public void open(MediaParams mediaParams) {
MediaService mediaService = toolBox.getServices().getMediaService();
if (mediaParams.getSerialPort() != null) {
// Save serial port to preferences, so MediaControlsFactoryImplOriginal can look it up later
MediaControlsFactoryImplOriginal.setSelectedSerialPort(mediaParams.getSerialPort());
MediaControlsFactoryImpl.setSelectedSerialPort(mediaParams.getSerialPort());
}
mediaService.findByUri(mediaParams.getUri())
.thenAccept(media -> {
Expand Down

0 comments on commit 90e8939

Please sign in to comment.