Restructured the Preferences system
[Mograsim.git] / plugins / net.mograsim.plugin.core / src / net / mograsim / plugin / MograsimActivator.java
index 765a63a..64586b0 100644 (file)
@@ -1,9 +1,15 @@
 package net.mograsim.plugin;
 
+import org.eclipse.jface.preference.IPreferenceStore;
 import org.eclipse.ui.PlatformUI;
 import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.eclipse.ui.themes.ITheme;
 
+import net.mograsim.logic.model.preferences.RenderPreferences;
 import net.mograsim.machine.MachineRegistry;
+import net.mograsim.plugin.preferences.EclipsePluginPreferences;
+import net.mograsim.plugin.preferences.EclipseRenderPreferences;
+import net.mograsim.plugin.preferences.PluginPreferences;
 import net.mograsim.preferences.Preferences;
 
 public final class MograsimActivator extends AbstractUIPlugin
@@ -12,20 +18,36 @@ public final class MograsimActivator extends AbstractUIPlugin
 
        private static MograsimActivator instance;
 
+       public static MograsimActivator instance()
+       {
+               if (instance == null)
+                       throw new IllegalStateException("MograsimActivator not yet created!");
+               return instance;
+       }
+
+       private final RenderPreferences renderPrefs;
+       private final PluginPreferences pluginPrefs;
+
        public MograsimActivator()
        {
                if (instance != null)
                        throw new IllegalStateException("MograsimActivator already created!");
                instance = this;
+
                MachineRegistry.initialize();
-               Preferences.setPreferences(new EclipsePreferences(PlatformUI.getWorkbench().getThemeManager().getCurrentTheme(),
-                               MograsimActivator.instance().getPreferenceStore()));
+               ITheme currentTheme = PlatformUI.getWorkbench().getThemeManager().getCurrentTheme();
+               IPreferenceStore preferenceStore = getPreferenceStore();
+               renderPrefs = new EclipseRenderPreferences(currentTheme, preferenceStore);
+               pluginPrefs = new EclipsePluginPreferences(currentTheme, preferenceStore);
        }
 
-       public static MograsimActivator instance()
+       public RenderPreferences getRenderPrefs()
        {
-               if (instance == null)
-                       throw new IllegalStateException("MograsimActivator not yet created!");
-               return instance;
+               return renderPrefs;
+       }
+
+       public Preferences getPluginPrefs()
+       {
+               return pluginPrefs;
        }
 }
\ No newline at end of file