package name.abuchen.portfolio.ui.preferences;

import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
import org.eclipse.jface.preference.IPreferenceStore;

import name.abuchen.portfolio.ui.PortfolioPlugin;
import name.abuchen.portfolio.ui.UIConstants;
import name.abuchen.portfolio.ui.dialogs.transactions.PresetValues;
import name.abuchen.portfolio.ui.editor.ClientInput;

public class PreferencesInitializer extends AbstractPreferenceInitializer
{
    @Override
    public void initializeDefaultPreferences()
    {
        IPreferenceStore store = PortfolioPlugin.getDefault().getPreferenceStore();
        store.setDefault(UIConstants.Preferences.AUTO_UPDATE, true);
        store.setDefault(UIConstants.Preferences.UPDATE_SITE,
                        Platform.ARCH_X86.equals(Platform.getOSArch())
                                        ? "https://updates.portfolio-performance.info/portfolio-x86" //$NON-NLS-1$
                                        : "https://updates.portfolio-performance.info/portfolio"); //$NON-NLS-1$
        store.setDefault(UIConstants.Preferences.FORMAT_SHARES_DIGITS, 1);
        store.setDefault(UIConstants.Preferences.FORMAT_CALCULATED_QUOTE_DIGITS, 2);
        store.setDefault(UIConstants.Preferences.USE_INDIRECT_QUOTATION, true);
        store.setDefault(UIConstants.Preferences.ALWAYS_DISPLAY_CURRENCY_CODE, false);
        store.setDefault(UIConstants.Preferences.CREATE_BACKUP_BEFORE_SAVING, true);
        store.setDefault(UIConstants.Preferences.UPDATE_QUOTES_AFTER_FILE_OPEN, true);
        store.setDefault(UIConstants.Preferences.AUTO_SAVE_FILE, 0);
        store.setDefault(UIConstants.Preferences.STORE_SETTINGS_NEXT_TO_FILE, false);
        store.setDefault(UIConstants.Preferences.ENABLE_EXPERIMENTAL_FEATURES, false);
        store.setDefault(UIConstants.Preferences.ENABLE_SWTCHART_PIECHARTS, false);
        store.setDefault(UIConstants.Preferences.ALPHAVANTAGE_CALL_FREQUENCY_LIMIT, 5);
        store.setDefault(UIConstants.Preferences.CALENDAR, "default"); //$NON-NLS-1$
        store.setDefault(UIConstants.Preferences.PORTFOLIO_REPORT_API_URL, "https://api.portfolio-report.net"); //$NON-NLS-1$
        store.setDefault(UIConstants.Preferences.PRESET_VALUE_TIME, PresetValues.TimePreset.MIDNIGHT.name());

        // Backup
        store.setDefault(UIConstants.Preferences.BACKUP_MODE, BackupMode.getDefault().name());
        store.setDefault(UIConstants.Preferences.BACKUP_FOLDER_RELATIVE, ClientInput.DEFAULT_RELATIVE_BACKUP_FOLDER);
        store.setDefault(UIConstants.Preferences.BACKUP_FOLDER_ABSOLUTE, ""); //$NON-NLS-1$
    }
}

@@ -211,16 +211,51 @@
 ceStore;
+%0Aimport org.osgi.framework.Version;
 %0A%0Aimport
@@ -1940,23 +1940,185 @@
 CHARTS, 
-false);
+Platform.getOS().equals(Platform.OS_MACOSX)%0A                        && Platform.getOSArch().equals(Platform.ARCH_X86_64) && compareOSVersion(%2213.0%22) %3E= 0); //$NON-NLS-1$
 %0A       
@@ -2848,11 +2848,535 @@
 1$%0A    %7D
+%0A%0A    public static int compareOSVersion(String version)%0A    %7B%0A        String current = System.getProperty(%22os.version%22); //$NON-NLS-1$%0A        return compareVersionNumbers(current, version);%0A    %7D%0A%0A    public static int compareVersionNumbers(String newer, String older)%0A    %7B%0A        try%0A        %7B%0A            Version n = new Version(newer);%0A            Version o = new Version(older);%0A%0A            return n.compareTo(o);%0A        %7D%0A        catch (IllegalArgumentException e)%0A        %7B%0A            return -1;%0A        %7D%0A    %7D
 %0A%7D%0A

Use SWTChart instead of the embedded browser on macOS x86_64 (Intel)