Search in sources :

Example 1 with PreferenceConstants

use of org.autorefactor.preferences.PreferenceConstants in project AutoRefactor by JnRouvignac.

the class PreferenceInitializer method initializeDefaultPreferences.

@Override
public void initializeDefaultPreferences() {
    // TODO initialize preferences from the JDT preferences like:
    // code style/cleanup/formatting
    final IPreferenceStore store = AutoRefactorPlugin.getDefault().getPreferenceStore();
    for (PreferenceConstants preference : PreferenceConstants.values()) {
        final String name = preference.getName();
        final Object defaultValue = preference.getDefaultValue();
        if (defaultValue instanceof Boolean) {
            store.setDefault(name, (Boolean) defaultValue);
        } else if (defaultValue instanceof Integer) {
            store.setDefault(name, (Integer) defaultValue);
        } else if (defaultValue instanceof Long) {
            store.setDefault(name, (Long) defaultValue);
        } else if (defaultValue instanceof Double) {
            store.setDefault(name, (Double) defaultValue);
        } else if (defaultValue instanceof Float) {
            store.setDefault(name, (Float) defaultValue);
        } else if (defaultValue instanceof String) {
            store.setDefault(name, (String) defaultValue);
        } else {
            throw new NotImplementedException(null, defaultValue);
        }
    }
    for (RefactoringRule refactoringRule : AllCleanUpRules.getAllCleanUpRules()) {
        store.setDefault(refactoringRule.getClass().getCanonicalName(), refactoringRule.isByDefault());
    }
}
Also used : PreferenceConstants(org.autorefactor.preferences.PreferenceConstants) RefactoringRule(org.autorefactor.jdt.internal.corext.dom.RefactoringRule) NotImplementedException(org.autorefactor.util.NotImplementedException) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore)

Aggregations

RefactoringRule (org.autorefactor.jdt.internal.corext.dom.RefactoringRule)1 PreferenceConstants (org.autorefactor.preferences.PreferenceConstants)1 NotImplementedException (org.autorefactor.util.NotImplementedException)1 IPreferenceStore (org.eclipse.jface.preference.IPreferenceStore)1