Search in sources :

Example 6 with MindMapPanelConfig

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() + ']');
        }
    }
}
Also used : PropertiesPreferences(com.igormaznitsa.mindmap.swing.panel.utils.PropertiesPreferences) File(java.io.File) MindMapPanelConfig(com.igormaznitsa.mindmap.swing.panel.MindMapPanelConfig)

Example 7 with MindMapPanelConfig

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();
}
Also used : MindMapPanel(com.igormaznitsa.mindmap.swing.panel.MindMapPanel) ByteArrayOutputStream(java.io.ByteArrayOutputStream) MindMapPanelConfig(com.igormaznitsa.mindmap.swing.panel.MindMapPanelConfig)

Example 8 with MindMapPanelConfig

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());
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) MindMapPanelConfig(com.igormaznitsa.mindmap.swing.panel.MindMapPanelConfig) MindMapConfigListener(com.igormaznitsa.mindmap.swing.panel.MindMapConfigListener) Test(org.junit.Test)

Example 9 with MindMapPanelConfig

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;
}
Also used : PropertiesPreferences(com.igormaznitsa.mindmap.swing.panel.utils.PropertiesPreferences) MindMapPanelConfig(com.igormaznitsa.mindmap.swing.panel.MindMapPanelConfig) URISyntaxException(java.net.URISyntaxException) IOException(java.io.IOException)

Example 10 with MindMapPanelConfig

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();
        }
    }
}
Also used : MindMapPanelConfig(com.igormaznitsa.mindmap.swing.panel.MindMapPanelConfig)

Aggregations

MindMapPanelConfig (com.igormaznitsa.mindmap.swing.panel.MindMapPanelConfig)13 PropertiesPreferences (com.igormaznitsa.mindmap.swing.panel.utils.PropertiesPreferences)6 File (java.io.File)3 IOException (java.io.IOException)3 URISyntaxException (java.net.URISyntaxException)3 HasOptions (com.igormaznitsa.mindmap.plugins.api.HasOptions)2 MindMap (com.igormaznitsa.mindmap.model.MindMap)1 AbstractExporter (com.igormaznitsa.mindmap.plugins.api.AbstractExporter)1 AbstractImporter (com.igormaznitsa.mindmap.plugins.api.AbstractImporter)1 MindMapConfigListener (com.igormaznitsa.mindmap.swing.panel.MindMapConfigListener)1 MindMapPanel (com.igormaznitsa.mindmap.swing.panel.MindMapPanel)1 MMGraphics (com.igormaznitsa.mindmap.swing.panel.ui.gfx.MMGraphics)1 KeyShortcut (com.igormaznitsa.mindmap.swing.panel.utils.KeyShortcut)1 RenderQuality (com.igormaznitsa.mindmap.swing.panel.utils.RenderQuality)1 Point (java.awt.Point)1 BufferedImage (java.awt.image.BufferedImage)1 RenderedImage (java.awt.image.RenderedImage)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 Properties (java.util.Properties)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1