use of com.igormaznitsa.mindmap.swing.panel.MindMapPanelConfig 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.MindMapPanelConfig in project netbeans-mmd-plugin by raydac.
the class AbstractStandardExporterTest method export.
public byte[] export(final MindMap map, final MindMapPanelConfig nullableConfig) throws Exception {
final T exporter = generateExporterInstance();
final MindMapPanelConfig config = nullableConfig == null ? new MindMapPanelConfig() : nullableConfig;
final MindMapPanel panel = mock(MindMapPanel.class);
when(panel.getModel()).thenReturn(map);
when(panel.getConfiguration()).thenReturn(config);
final ByteArrayOutputStream buffer = new ByteArrayOutputStream();
exporter.doExport(panel, prepareOptions(), buffer);
return buffer.toByteArray();
}
use of com.igormaznitsa.mindmap.swing.panel.MindMapPanelConfig in project netbeans-mmd-plugin by raydac.
the class MindMapPanelConfigTest method testMakeFullCopyOf.
@Test
public void testMakeFullCopyOf() {
final MindMapPanelConfig dst = new MindMapPanelConfig();
final MindMapPanelConfig src = new MindMapPanelConfig();
assertTrue(dst.isDropShadow());
assertTrue(dst.isDrawBackground());
src.setDrawBackground(false);
src.setDropShadow(false);
final AtomicInteger callCounter = new AtomicInteger();
final MindMapConfigListener lstnr = new MindMapConfigListener() {
@Override
public void onConfigurationPropertyChanged(MindMapPanelConfig changedConfig) {
callCounter.incrementAndGet();
}
};
src.addConfigurationListener(lstnr);
dst.makeFullCopyOf(src, true, true);
assertFalse(dst.isDropShadow());
assertFalse(dst.isDrawBackground());
assertEquals(1, callCounter.get());
}
use of com.igormaznitsa.mindmap.swing.panel.MindMapPanelConfig 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;
}
use of com.igormaznitsa.mindmap.swing.panel.MindMapPanelConfig in project netbeans-mmd-plugin by raydac.
the class PreferencesPanel method save.
public void save() {
final MindMapPanelConfig config = this.config;
if (config != null) {
try {
fillBySettings(config, PreferencesManager.getInstance().getPreferences());
PreferencesManager.getInstance().flush();
} finally {
context.notifyReloadConfig();
}
}
}
Aggregations