use of apps.gui3.TabbedPreferencesAction in project JMRI by JMRI.
the class JmriConfigurationManager method load.
@Override
public boolean load(URL file, boolean registerDeferred) throws JmriException {
log.debug("loading {} ...", file);
try {
if (file == null || //NOI18N
(new File(file.toURI())).getName().equals("ProfileConfig.xml") || (new File(file.toURI())).getName().equals(Profile.CONFIG)) {
Profile profile = ProfileManager.getDefault().getActiveProfile();
List<PreferencesManager> providers = new ArrayList<>(InstanceManager.getList(PreferencesManager.class));
providers.stream().forEach((provider) -> {
this.initializeProvider(provider, profile);
});
if (!this.initializationExceptions.isEmpty()) {
if (!GraphicsEnvironment.isHeadless()) {
ArrayList<String> errors = new ArrayList<>();
this.initialized.forEach((provider) -> {
List<Exception> exceptions = provider.getInitializationExceptions(profile);
if (!exceptions.isEmpty()) {
exceptions.forEach((exception) -> {
errors.add(exception.getLocalizedMessage());
});
} else if (this.initializationExceptions.get(provider) != null) {
errors.add(this.initializationExceptions.get(provider).getLocalizedMessage());
}
});
Object list;
if (errors.size() == 1) {
list = errors.get(0);
} else {
list = new JList<>(errors.toArray(new String[errors.size()]));
}
JOptionPane.showMessageDialog(null, new Object[] { (list instanceof JList) ? Bundle.getMessage("InitExMessageListHeader") : null, list, // Add a visual break between list of errors and notes // NOI18N
"<html><br></html>", // NOI18N
Bundle.getMessage("InitExMessageLogs"), // NOI18N
Bundle.getMessage("InitExMessagePrefs") }, // NOI18N
Bundle.getMessage("InitExMessageTitle", Application.getApplicationName()), JOptionPane.ERROR_MESSAGE);
(new TabbedPreferencesAction()).actionPerformed();
}
}
if (file != null && (new File(file.toURI())).getName().equals("ProfileConfig.xml")) {
// NOI18N
log.debug("Loading legacy configuration...");
return this.legacy.load(file, registerDeferred);
}
return this.initializationExceptions.isEmpty();
}
} catch (URISyntaxException ex) {
log.error("Unable to get File for {}", file);
throw new JmriException(ex.getMessage(), ex);
}
return this.legacy.load(file, registerDeferred);
// return true; // always return true once legacy support is dropped
}
Aggregations