use of com.igormaznitsa.mindmap.swing.panel.MindMapPanelConfig in project netbeans-mmd-plugin by raydac.
the class MMDCfgPanel method buttonResetSettingsActionPerformed.
// GEN-LAST:event_checkBoxScalingMETAActionPerformed
private void buttonResetSettingsActionPerformed(java.awt.event.ActionEvent evt) {
// GEN-FIRST:event_buttonResetSettingsActionPerformed
this.config.makeFullCopyOf(new MindMapPanelConfig(), false, false);
loadFromPreferences(new PropertiesPreferences("NB MindMap plugin"), this.config);
this.controller.changed();
}
use of com.igormaznitsa.mindmap.swing.panel.MindMapPanelConfig in project netbeans-mmd-plugin by raydac.
the class PreferencesPanel method buttonResetToDefaultActionPerformed.
// GEN-LAST:event_checkBoxDropShadowActionPerformed
private void buttonResetToDefaultActionPerformed(java.awt.event.ActionEvent evt) {
// GEN-FIRST:event_buttonResetToDefaultActionPerformed
loadFrom(new MindMapPanelConfig(), PreferencesManager.getInstance().getPreferences());
this.fontTextEditor = TextEditor.DEFAULT_FONT;
updateFontButton(this.buttonFontForEditor, this.fontTextEditor);
}
use of com.igormaznitsa.mindmap.swing.panel.MindMapPanelConfig in project netbeans-mmd-plugin by raydac.
the class PreferencesPanel method buttonExportToFileActionPerformed.
// GEN-LAST:event_buttonFontForEditorActionPerformed
private void buttonExportToFileActionPerformed(java.awt.event.ActionEvent evt) {
// GEN-FIRST:event_buttonExportToFileActionPerformed
File file = DialogProviderManager.getInstance().getDialogProvider().msgSaveFileDialog(this, "exportProperties", "Export settings", null, true, new PropertiesFileFilter(), "Save");
if (file != null) {
if (!file.getName().toLowerCase(Locale.ENGLISH).endsWith(".properties")) {
// NOI18N
final Boolean addExt = DialogProviderManager.getInstance().getDialogProvider().msgConfirmYesNoCancel(this, "Add extension", "Add '.properties' extension?");
if (addExt == null)
return;
if (addExt) {
// NOI18N
file = new File(file.getAbsolutePath() + ".properties");
}
}
if (file.exists() && !DialogProviderManager.getInstance().getDialogProvider().msgConfirmOkCancel(this, "Override file", String.format("File %s exists, to override it?", file.getName()))) {
return;
}
final PropertiesPreferences prefs = new PropertiesPreferences("SciaReto editor settings");
final MindMapPanelConfig cfg = fillBySettings(new MindMapPanelConfig(), prefs);
cfg.saveTo(prefs);
try {
FileUtils.write(file, prefs.toString(), "UTF-8");
} catch (final Exception ex) {
// NOI18N
LOGGER.error("Can't export settings", ex);
// NOI18N
DialogProviderManager.getInstance().getDialogProvider().msgError(this, "Can't export settings [" + ex.getMessage() + ']');
}
}
}
use of com.igormaznitsa.mindmap.swing.panel.MindMapPanelConfig in project netbeans-mmd-plugin by raydac.
the class Main method convertData.
private static boolean convertData(@Nonnull @MustNotContainNull final String[] args) {
MindMapPluginRegistry.getInstance().registerPlugin(new LocalMMDExporter());
MindMapPluginRegistry.getInstance().registerPlugin(new LocalMMDImporter());
final String[] params = new String[5];
final Properties options = new Properties();
final int IN_FILE = 0;
final int OUT_FILE = 1;
final int IN_TYPE = 2;
final int OUT_TYPE = 3;
final int SETTINGS = 4;
final int OPTION = 5;
// NOI18N
params[IN_TYPE] = "mmd";
// NOI18N
params[OUT_TYPE] = "mmd";
// NOI18N
params[SETTINGS] = "";
int detected = -1;
boolean allOk = true;
for (int i = 1; i < args.length; i++) {
if (detected >= 0) {
if (detected == OPTION) {
final String text = args[i];
// NOI18N
final String[] splitted = text.split("\\=");
if (splitted.length < 2) {
// NOI18N
options.put(splitted[0], "true");
} else {
options.put(splitted[0], splitted[1]);
}
} else {
params[detected] = args[i];
}
detected = -1;
} else {
if ("--in".equalsIgnoreCase(args[i])) {
// NOI18N
detected = IN_FILE;
} else if ("--out".equalsIgnoreCase(args[i])) {
// NOI18N
detected = OUT_FILE;
} else if ("--from".equalsIgnoreCase(args[i])) {
// NOI18N
detected = IN_TYPE;
} else if ("--to".equalsIgnoreCase(args[i])) {
// NOI18N
detected = OUT_TYPE;
} else if ("--settings".equalsIgnoreCase(args[i])) {
// NOI18N
detected = SETTINGS;
} else if ("--option".equalsIgnoreCase(args[i])) {
// NOI18N
detected = OPTION;
} else {
// NOI18N
LOGGER.error("Unexpected argument : " + args[i]);
allOk = false;
break;
}
}
}
if (allOk) {
for (final String s : params) {
if (s == null) {
// NOI18N
LOGGER.error("Not provided required parameter");
allOk = true;
break;
}
}
if (allOk) {
final File inFile = new File(params[IN_FILE]);
final File outFile = new File(params[OUT_FILE]);
final AbstractImporter importer = MindMapPluginRegistry.getInstance().findImporterForMnemonic(params[IN_TYPE]);
final AbstractExporter exporter = MindMapPluginRegistry.getInstance().findExporterForMnemonic(params[OUT_TYPE]);
if (importer == null) {
// NOI18N
LOGGER.error("Unknown importer : " + params[IN_TYPE]);
allOk = false;
} else if (exporter == null) {
// NOI18N
LOGGER.error("Unknown exporter : " + params[OUT_TYPE]);
allOk = false;
}
if (allOk) {
final File settingsFile = params[SETTINGS].isEmpty() ? null : new File(params[SETTINGS]);
final MindMapPanelConfig config = new MindMapPanelConfig();
if (settingsFile != null) {
try {
config.loadFrom(new PropertiesPreferences(FileUtils.readFileToString(settingsFile, "UTF-8")));
} catch (IOException ex) {
// NOI18N
LOGGER.error("Can't load settings file : " + settingsFile, ex);
allOk = false;
}
}
if (allOk && importer != null && exporter != null) {
try {
makeConversion(inFile, importer, outFile, exporter, config, options);
} catch (final Exception ex) {
if (ex instanceof IllegalArgumentException) {
LOGGER.error(ex.getMessage());
} else {
// NOI18N
LOGGER.error("Unexpected error during conversion", ex);
}
allOk = false;
}
}
}
}
}
return allOk;
}
use of com.igormaznitsa.mindmap.swing.panel.MindMapPanelConfig in project netbeans-mmd-plugin by raydac.
the class Main method importSettings.
private static boolean importSettings(@Nonnull final File settingsFile) {
boolean result = true;
try {
final PropertiesPreferences prefs = new PropertiesPreferences(FileUtils.readFileToString(settingsFile, "UTF-8"));
final MindMapPanelConfig config = new MindMapPanelConfig();
config.loadFrom(prefs);
config.saveTo(PreferencesManager.getInstance().getPreferences());
PreferencesManager.getInstance().flush();
// NOI18N
LOGGER.info("Settings imported from file : " + settingsFile);
} catch (final Exception ex) {
// NOI18N
LOGGER.error("Error during import from file : " + settingsFile, ex);
result = false;
}
return result;
}
Aggregations