Anonymous avatar Anonymous committed 8d3b39e

Moved main preferences page to preferences plugin.

Comments (0)

Files changed (10)

org.lispdev.editor/plugin.xml

    <extension
          point="org.eclipse.ui.preferencePages">
       <page
-            class="org.lispdev.editor.preferences.LispdevPreferencePage"
-            id="org.lispdev"
-            name="Lispdev">
-      </page>
-      <page
             category="org.lispdev"
             class="org.lispdev.editor.preferences.EditorPreferencePage"
             id="org.lispdev.editor"

org.lispdev.editor/src/org/lispdev/editor/EditorPlugin.java

 import org.lispdev.parser.tokens.TokenString;
 import org.lispdev.parser.tokens.TokenSymbol;
 import org.lispdev.preferences.ItemListener;
+import org.lispdev.preferences.PreferencesPlugin;
 import org.lispdev.preferences.PreferenceItem;
 import org.lispdev.preferences.PreferencesService;
 import org.osgi.framework.BundleContext;
   // The plug-in ID
   public static final String ID = "org.lispdev.editor";
 
-  public static final String LangID = "CL";
-
   private static final String CONSOLE_NAME= "Lispdev Editor";
 
   private FontRegistry fFontRegistry;
   {
     if( prefServices == null )
     {
-      prefServices = new PreferencesService(LangID);
+      prefServices = new PreferencesService(PreferencesPlugin.LangID);
       // To trigger the automatic invocation of the preferences initializer:
       try
       {

org.lispdev.editor/src/org/lispdev/editor/preferences/LispdevPreferencePage.java

-package org.lispdev.editor.preferences;
-
-import org.eclipse.jface.preference.FieldEditorPreferencePage;
-import org.eclipse.ui.IWorkbench;
-import org.eclipse.ui.IWorkbenchPreferencePage;
-import org.lispdev.editor.EditorPlugin;
-
-/**
- * This class represents a preference page that
- * is contributed to the Preferences dialog. By
- * subclassing <samp>FieldEditorPreferencePage</samp>, we
- * can use the field support built into JFace that allows
- * us to create a page that is small and knows how to
- * save, restore and apply itself.
- * <p>
- * This page is used to modify preferences only. They
- * are stored in the preference store that belongs to
- * the main plug-in class. That way, preferences can
- * be accessed directly via the preference store.
- */
-
-public class LispdevPreferencePage
-	extends FieldEditorPreferencePage
-	implements IWorkbenchPreferencePage {
-
-	public LispdevPreferencePage() {
-		super(GRID);
-		setPreferenceStore(EditorPlugin.get().getPreferenceStore());
-		setDescription("A demonstration of a preference page implementation");
-	}
-
-	/**
-	 * Creates the field editors. Field editors are abstractions of
-	 * the common GUI blocks needed to manipulate various types
-	 * of preferences. Each field editor knows how to save and
-	 * restore itself.
-	 */
-	@Override
-  public void createFieldEditors() {
-	}
-
-	/* (non-Javadoc)
-	 * @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
-	 */
-	public void init(IWorkbench workbench) {
-	}
-
-}

org.lispdev.preferences/META-INF/MANIFEST.MF

 Manifest-Version: 1.0
 Bundle-ManifestVersion: 2
 Bundle-Name: Preferences
-Bundle-SymbolicName: org.lispdev.preferences
+Bundle-SymbolicName: org.lispdev.preferences;singleton:=true
 Bundle-Version: 0.0.0.qualifier
-Bundle-Activator: org.lispdev.preferences.Plugin
+Bundle-Activator: org.lispdev.preferences.PreferencesPlugin
 Require-Bundle: org.eclipse.ui,
  org.eclipse.core.runtime,
  org.eclipse.core.resources;bundle-version="3.5.0"

org.lispdev.preferences/build.properties

 source.. = src/
 output.. = bin/
 bin.includes = META-INF/,\
-               .
+               .,\
+               plugin.xml

org.lispdev.preferences/plugin.xml

+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<plugin>
+   <extension
+         point="org.eclipse.ui.preferencePages">
+      <page
+            class="org.lispdev.preferences.LispdevPreferencePage"
+            id="org.lispdev"
+            name="Lispdev">
+      </page>
+   </extension>
+
+</plugin>

org.lispdev.preferences/src/org/lispdev/preferences/LispdevPreferencePage.java

+package org.lispdev.preferences;
+
+import org.eclipse.jface.preference.FieldEditorPreferencePage;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPreferencePage;
+
+/**
+ * This class represents a preference page that is contributed to the
+ * Preferences dialog. By subclassing <samp>FieldEditorPreferencePage</samp>, we
+ * can use the field support built into JFace that allows us to create a page
+ * that is small and knows how to save, restore and apply itself.
+ * <p>
+ * This page is used to modify preferences only. They are stored in the
+ * preference store that belongs to the main plug-in class. That way,
+ * preferences can be accessed directly via the preference store.
+ */
+
+public class LispdevPreferencePage extends FieldEditorPreferencePage implements
+    IWorkbenchPreferencePage
+{
+
+  public LispdevPreferencePage()
+  {
+    super(GRID);
+    setPreferenceStore(PreferencesPlugin.get().getPreferenceStore());
+    setDescription("A demonstration of a preference page implementation");
+  }
+
+  /**
+   * Creates the field editors. Field editors are abstractions of the common GUI
+   * blocks needed to manipulate various types of preferences. Each field editor
+   * knows how to save and restore itself.
+   */
+  @Override
+  public void createFieldEditors()
+  {}
+
+  /*
+   * (non-Javadoc)
+   *
+   * @see
+   * org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
+   */
+  public void init(IWorkbench workbench)
+  {}
+
+}

org.lispdev.preferences/src/org/lispdev/preferences/Log.java

    */
   public static void abort(String message, Throwable e) throws CoreException
   {
-    throw new CoreException(new Status(IStatus.ERROR, Plugin.ID,
+    throw new CoreException(new Status(IStatus.ERROR, PreferencesPlugin.ID,
         0, message, e));
   }
 
     appendCallInformation(sb, 4, "");
     sb.append(" ");
     sb.append(message);
-    Plugin.get().getLog().log(
-        new Status(severity, Plugin.ID, 0, sb.toString(), e));
+    PreferencesPlugin.get().getLog().log(
+        new Status(severity, PreferencesPlugin.ID, 0, sb.toString(), e));
   }
 
 

org.lispdev.preferences/src/org/lispdev/preferences/Plugin.java

-package org.lispdev.preferences;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.plugin.AbstractUIPlugin;
-import org.osgi.framework.BundleContext;
-
-/**
- *
- */
-public class Plugin extends AbstractUIPlugin
-{
-
-  // The plug-in ID
-  public static final String ID = "org.lispdev.preferences";
-
-  // The shared instance
-  private static Plugin plugin;
-
-  /**
-   * The constructor
-   */
-  public Plugin()
-  {}
-
-  private static Display getDisplay()
-  {
-    Display display = Display.getCurrent();
-    //may be null if outside the UI thread
-    if (display == null)
-       display = Display.getDefault();
-    return display;
- }
-
-  public Color colorBlack = getDisplay().getSystemColor(SWT.COLOR_BLACK);
-  public Color colorWhite = getDisplay().getSystemColor(SWT.COLOR_WHITE);
-  public Color colorRed = getDisplay().getSystemColor(SWT.COLOR_RED);
-  public Color colorBluish;
-  public Color colorGreenish;
-  public Color colorLightGray;
-
-
-  /*
-   * (non-Javadoc)
-   *
-   * @see
-   * org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext
-   * )
-   */
-  @Override
-  public void start(BundleContext context) throws Exception
-  {
-    super.start(context);
-    plugin = this;
-    colorBluish = new Color(null, 175, 207, 239);;
-    colorGreenish = new Color(null, 0, 127, 239);
-    colorLightGray = new Color(null, 224, 223, 226);
-  }
-
-  /*
-   * (non-Javadoc)
-   *
-   * @see
-   * org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext
-   * )
-   */
-  @Override
-  public void stop(BundleContext context) throws Exception
-  {
-    colorBluish.dispose();
-    colorGreenish.dispose();
-    colorLightGray.dispose();
-    plugin = null;
-    super.stop(context);
-  }
-
-  /**
-   * Returns the shared instance
-   *
-   * @return the shared instance
-   */
-  public static Plugin get()
-  {
-    return plugin;
-  }
-}

org.lispdev.preferences/src/org/lispdev/preferences/PreferencesPlugin.java

+package org.lispdev.preferences;
+
+import org.eclipse.core.runtime.preferences.DefaultScope;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ *
+ */
+public class PreferencesPlugin extends AbstractUIPlugin
+{
+  public static final String LangID = "CL";
+
+  // The plug-in ID
+  public static final String ID = "org.lispdev.preferences";
+
+  // The shared instance
+  private static PreferencesPlugin plugin;
+
+  /**
+   * The constructor
+   */
+  public PreferencesPlugin()
+  {}
+
+  private static Display getDisplay()
+  {
+    Display display = Display.getCurrent();
+    //may be null if outside the UI thread
+    if (display == null)
+       display = Display.getDefault();
+    return display;
+ }
+
+  public Color colorBlack = getDisplay().getSystemColor(SWT.COLOR_BLACK);
+  public Color colorWhite = getDisplay().getSystemColor(SWT.COLOR_WHITE);
+  public Color colorRed = getDisplay().getSystemColor(SWT.COLOR_RED);
+  public Color colorBluish;
+  public Color colorGreenish;
+  public Color colorLightGray;
+
+
+  /*
+   * (non-Javadoc)
+   *
+   * @see
+   * org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext
+   * )
+   */
+  @Override
+  public void start(BundleContext context) throws Exception
+  {
+    super.start(context);
+    plugin = this;
+    colorBluish = new Color(null, 175, 207, 239);;
+    colorGreenish = new Color(null, 0, 127, 239);
+    colorLightGray = new Color(null, 224, 223, 226);
+  }
+
+  /*
+   * (non-Javadoc)
+   *
+   * @see
+   * org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext
+   * )
+   */
+  @Override
+  public void stop(BundleContext context) throws Exception
+  {
+    colorBluish.dispose();
+    colorGreenish.dispose();
+    colorLightGray.dispose();
+    plugin = null;
+    super.stop(context);
+  }
+
+  /**
+   * Returns the shared instance
+   *
+   * @return the shared instance
+   */
+  public static PreferencesPlugin get()
+  {
+    return plugin;
+  }
+
+  /**
+   * The unique project-independent preferences service for this plugin.
+   * Uses whatever this plugin activator's getLanguageID() method returns
+   * as the language.
+   */
+  protected PreferencesService prefServices = null;
+
+  public PreferencesService getPreferences()
+  {
+    if( prefServices == null )
+    {
+      prefServices = new PreferencesService(LangID);
+      // To trigger the automatic invocation of the preferences initializer:
+      try
+      {
+        new DefaultScope().getNode(ID);
+      }
+      catch(Exception e)
+      {
+        // If this ever happens, it will probably be because the preferences
+        // and their initializer haven't been defined yet. In that situation
+        // there's not really anything to do--you can't initialize preferences
+        // that don't exist. So swallow the exception and continue ...
+      }
+    }
+    return prefServices;
+  }
+
+}
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.