kopia lustrzana https://github.com/jameshball/osci-render
Don't try and open a project if it doesn't exist
rodzic
49b9b1daaa
commit
ad9c3694de
|
@ -116,6 +116,7 @@ public class Gui extends Application {
|
|||
projectSelectController.setApplicationLauncher((path, muted) -> launchMainApplication(controller, path, muted));
|
||||
|
||||
controller.setAddRecentFile(projectSelectController::addRecentFile);
|
||||
controller.setRemoveRecentFile(projectSelectController::removeRecentFile);
|
||||
controller.setRecentFiles(projectSelectController::recentFiles);
|
||||
|
||||
controller.setSoftwareOscilloscopeAction(() -> {
|
||||
|
|
|
@ -81,6 +81,7 @@ public class MainController implements Initializable, FrequencyListener, MidiLis
|
|||
private static final long MAX_RECENT_FILES = 15;
|
||||
|
||||
private Consumer<String> addRecentFile;
|
||||
private Consumer<String> removeRecentFile;
|
||||
private String openProjectPath;
|
||||
private final FileChooser wavFileChooser = new FileChooser();
|
||||
|
||||
|
@ -1238,7 +1239,15 @@ public class MainController implements Initializable, FrequencyListener, MidiLis
|
|||
documentFactory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
|
||||
DocumentBuilder documentBuilder = documentFactory.newDocumentBuilder();
|
||||
|
||||
Document document = documentBuilder.parse(new File(projectFileName));
|
||||
Document document;
|
||||
try {
|
||||
document = documentBuilder.parse(new File(projectFileName));
|
||||
} catch (Exception e) {
|
||||
logger.log(Level.WARNING, e.getMessage(), e);
|
||||
removeRecentFile.accept(projectFileName);
|
||||
openProject(null);
|
||||
return;
|
||||
}
|
||||
document.getDocumentElement().normalize();
|
||||
|
||||
List<BooleanProperty> micSelected = micSelected();
|
||||
|
@ -1473,6 +1482,10 @@ public class MainController implements Initializable, FrequencyListener, MidiLis
|
|||
this.addRecentFile = addRecentFile;
|
||||
}
|
||||
|
||||
public void setRemoveRecentFile(Consumer<String> removeRecentFile) {
|
||||
this.removeRecentFile = removeRecentFile;
|
||||
}
|
||||
|
||||
public void setVolume(double volume) {
|
||||
effectsController.setVolume(volume);
|
||||
}
|
||||
|
|
|
@ -72,6 +72,10 @@ public class ProjectSelectController implements Initializable {
|
|||
try {
|
||||
String selectedItem = recentFilesListView.getSelectionModel().getSelectedItem();
|
||||
if (selectedItem != null) {
|
||||
if (!new File(selectedItem).exists()) {
|
||||
removeRecentFile(selectedItem);
|
||||
return;
|
||||
}
|
||||
launchMainApplication.accept(selectedItem, startMutedCheckBox.isSelected());
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
|
@ -176,4 +180,9 @@ public class ProjectSelectController implements Initializable {
|
|||
public void setOpenBrowser(Consumer<String> openBrowser) {
|
||||
this.openBrowser = openBrowser;
|
||||
}
|
||||
|
||||
public void removeRecentFile(String path) {
|
||||
recentFiles.remove(path);
|
||||
resetRecentFiles();
|
||||
}
|
||||
}
|
||||
|
|
Ładowanie…
Reference in New Issue