RSS news reader; initially copied from "all the news"
[phpeclipse.git] / archive / net.sourceforge.phpeclipse.quantum.sql / src / com / quantum / QuantumPlugin.java
index d3028d8..3842086 100644 (file)
@@ -12,6 +12,10 @@ import javax.xml.parsers.DocumentBuilder;
 import javax.xml.parsers.DocumentBuilderFactory;
 import javax.xml.parsers.ParserConfigurationException;
 
+import com.quantum.model.BookmarkCollection;
+import com.quantum.util.xml.XMLHelper;
+import com.quantum.view.subset.SubsetContentProvider;
+
 import org.eclipse.core.resources.ISavedState;
 import org.eclipse.core.resources.ResourcesPlugin;
 import org.eclipse.core.runtime.CoreException;
@@ -20,11 +24,9 @@ import org.eclipse.core.runtime.IPluginDescriptor;
 import org.eclipse.core.runtime.Path;
 import org.eclipse.jface.preference.IPreferenceStore;
 import org.eclipse.jface.preference.PreferenceConverter;
-import org.eclipse.jface.resource.ImageDescriptor;
 import org.eclipse.jface.resource.ImageRegistry;
+import org.eclipse.jface.resource.JFaceResources;
 import org.eclipse.swt.dnd.Clipboard;
-import org.eclipse.swt.graphics.FontData;
-import org.eclipse.swt.graphics.Image;
 import org.eclipse.swt.graphics.RGB;
 import org.eclipse.ui.IViewPart;
 import org.eclipse.ui.IWorkbench;
@@ -37,10 +39,6 @@ import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 import org.xml.sax.SAXException;
 
-import com.quantum.model.BookmarkCollection;
-import com.quantum.util.xml.XMLHelper;
-import com.quantum.view.subset.SubsetContentProvider;
-
 /**
  * Main class of the quantum plugin, sets defaults, saves and recovers state.
  * @author root
@@ -130,16 +128,7 @@ public class QuantumPlugin extends AbstractUIPlugin {
         sysClip = new Clipboard(null);
        }
 
-       /* (non-Javadoc)
-        * @see org.eclipse.core.runtime.Plugin#shutdown()
-        */
-       public void shutdown() throws CoreException {
-               if (!sysClip.isDisposed()) {
-                       sysClip.dispose();
-               }
-               super.shutdown();
-       }
-
+    
        /**
         * Write the bookmarks and subsets to a file, saving them for next use of the quantum plugin
         * @param target
@@ -167,42 +156,10 @@ public class QuantumPlugin extends AbstractUIPlugin {
         }
        }
        
-       
-//     public static Image getImage(String name) {
-//        ImageDescriptor imageDescriptor = getImageDescriptor(name);
-//             return imageDescriptor == null ? null : imageDescriptor.createImage();
-//     }
-
        protected void initializeDefaultPluginPreferences() {
-               RGB BACKGROUND = new RGB(255, 255, 255);
-               RGB COMMENT = new RGB(88, 148, 64);
-               RGB KEYWORD = new RGB(126, 0, 75);
-               RGB STRING = new RGB(0, 0, 255);
-               RGB NUMERIC = new RGB(255, 0, 0);
-               RGB DEFAULT = new RGB(0, 0, 0);
-               IPreferenceStore store = getPreferenceStore();
-               PreferenceConverter.setDefault(store,
-                       "quantum.background.color", BACKGROUND); //$NON-NLS-1$
-               PreferenceConverter.setDefault(store,
-                       "quantum.text.color", DEFAULT); //$NON-NLS-1$
-               PreferenceConverter.setDefault(store,
-                       "quantum.keyword.color", KEYWORD); //$NON-NLS-1$
-               PreferenceConverter.setDefault(store,
-                       "quantum.comment.color", COMMENT); //$NON-NLS-1$
-               PreferenceConverter.setDefault(store,
-                       "quantum.string.color", STRING); //$NON-NLS-1$
-               PreferenceConverter.setDefault(store,
-                       "quantum.numeric.color", NUMERIC); //$NON-NLS-1$
-               getPreferenceStore().setDefault("quantum.text.bold", false); //$NON-NLS-1$
-               getPreferenceStore().setDefault("quantum.keyword.bold", true); //$NON-NLS-1$
-               getPreferenceStore().setDefault("quantum.string.bold", false); //$NON-NLS-1$
-               getPreferenceStore().setDefault("quantum.comment.bold", false); //$NON-NLS-1$
-               getPreferenceStore().setDefault("quantum.numeric.bold", false); //$NON-NLS-1$
-               PreferenceConverter.setDefault(getPreferenceStore(), "quantum.font", (FontData) null); //$NON-NLS-1$
-        getPreferenceStore().setDefault("com.quantum.model.Bookmark.queryHistorySize", 20); //$NON-NLS-1$
-           
-
-        getPreferenceStore().setDefault(
+               PluginPreferences.initialize(getPreferenceStore());
+               
+               getPreferenceStore().setDefault(
             "phpeclipse.sql.select.template",
             "$results = mysql_query(\"SELECT {0} FROM {1} WHERE {2} \");");
 
@@ -260,6 +217,8 @@ public class QuantumPlugin extends AbstractUIPlugin {
                return tableView;
        }
 
+
+
        /**
         * @return
         */
@@ -269,7 +228,7 @@ public class QuantumPlugin extends AbstractUIPlugin {
        protected void initializeImageRegistry(ImageRegistry registry) {
                super.initializeImageRegistry(registry);
                try {
-                       ImageStore.initialize(registry, getIconLocation());
+                       ImageStore.initialize(this, registry, getIconLocation());
                } catch (MalformedURLException e) {
                        // this should never happen, but if it does, we don't get images.
                }
@@ -279,8 +238,8 @@ public class QuantumPlugin extends AbstractUIPlugin {
         * @return
         * @throws MalformedURLException
         */
-       URL getIconLocation() throws MalformedURLException {
-               URL installURL = QuantumPlugin.getDefault().getDescriptor().getInstallURL();
+       private URL getIconLocation() throws MalformedURLException {
+               URL installURL = getDescriptor().getInstallURL();
                return new URL(installURL, "icons/");
        }
 }
\ No newline at end of file