use of com.igormaznitsa.mindmap.swing.panel.utils.PropertiesPreferences in project netbeans-mmd-plugin by raydac.
the class MMDCfgPanel method buttonExportSettingsActionPerformed.
// GEN-LAST:event_buttonResetSettingsActionPerformed
private void buttonExportSettingsActionPerformed(java.awt.event.ActionEvent evt) {
// GEN-FIRST:event_buttonExportSettingsActionPerformed
File file = DialogProviderManager.getInstance().getDialogProvider().msgSaveFileDialog(null, "exportSettings", "Export settings", lastExportedSettingsFile, true, new PropertiesFileFilter(), "Save");
if (file != null) {
lastExportedSettingsFile = file;
if (!file.getName().toLowerCase(Locale.ENGLISH).endsWith(".properties")) {
final Boolean addExt = DialogProviderManager.getInstance().getDialogProvider().msgConfirmYesNoCancel(null, "Add extension", "Add '.properties' extension?");
if (addExt == null) {
return;
}
if (addExt) {
file = new File(file.getAbsolutePath() + ".properties");
}
}
if (file.exists() && !DialogProviderManager.getInstance().getDialogProvider().msgConfirmOkCancel(null, "Override file", String.format("File %s exists, to override it?", file.getName()))) {
return;
}
final PropertiesPreferences prefs = new PropertiesPreferences("NB MindMap plugin");
final MindMapPanelConfig cfg = store(prefs, new MindMapPanelConfig(), false);
cfg.saveTo(prefs);
try {
FileUtils.write(file, prefs.toString(), "UTF-8");
} catch (final Exception ex) {
LOGGER.error("Can't export settings", ex);
DialogProviderManager.getInstance().getDialogProvider().msgError(null, "Can't export settings [" + ex.getMessage() + ']');
}
}
}
use of com.igormaznitsa.mindmap.swing.panel.utils.PropertiesPreferences in project netbeans-mmd-plugin by raydac.
the class Main method exportSettings.
private static boolean exportSettings(@Nonnull final File settingsFile) {
boolean result = true;
final MindMapPanelConfig config = new MindMapPanelConfig();
config.loadFrom(PreferencesManager.getInstance().getPreferences());
// NOI18N
final PropertiesPreferences prefs = new PropertiesPreferences("Exported configuration for SciaReto editor https://github.com/raydac/netbeans-mmd-plugin");
config.saveTo(prefs);
try {
FileUtils.write(settingsFile, prefs.toString(), "UTF-8");
} catch (final Exception ex) {
// NOI18N
LOGGER.error("Can't export settings for error", ex);
result = false;
}
return result;
}
Aggregations