X-Git-Url: http://git.phpeclipse.com diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/QuantumPlugin.java b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/QuantumPlugin.java index 5a8b0e9..ab4f399 100644 --- a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/QuantumPlugin.java +++ b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/QuantumPlugin.java @@ -18,12 +18,8 @@ import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IPath; 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.ImageRegistry; -import org.eclipse.jface.resource.JFaceResources; import org.eclipse.swt.dnd.Clipboard; -import org.eclipse.swt.graphics.RGB; import org.eclipse.ui.IViewPart; import org.eclipse.ui.IWorkbench; import org.eclipse.ui.IWorkbenchPage; @@ -31,6 +27,7 @@ import org.eclipse.ui.IWorkbenchPart; import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.PartInitException; import org.eclipse.ui.plugin.AbstractUIPlugin; +import org.osgi.framework.BundleContext; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.xml.sax.SAXException; @@ -57,7 +54,13 @@ public class QuantumPlugin extends AbstractUIPlugin { * @param descriptor */ public QuantumPlugin(IPluginDescriptor descriptor) { - super(descriptor); + this(); + } + /** + * This version is recommended for eclipse3.0 and above + */ + public QuantumPlugin(){ + super(); plugin = this; } @@ -109,9 +112,23 @@ public class QuantumPlugin extends AbstractUIPlugin { /* (non-Javadoc) * @see org.eclipse.core.runtime.Plugin#startup() + * This method is deprecated in Eclipse3.0 we must use start(BundleContext context): + * Migration completed. */ public void startup() throws CoreException { super.startup(); + startupMigrationTempMethod(); // To be removed later + } + + /** + * Used during startup Eclipse3.0 compatible + */ + public void start(BundleContext bundleContext) throws Exception { + super.start(bundleContext); + startupMigrationTempMethod(); // To be removed later + } + private void startupMigrationTempMethod() throws CoreException { + // the contents of this.startup() is moved to here to avoid code duplication - see this.start(BundleContext) ISavedState lastState = ResourcesPlugin.getWorkspace().addSaveParticipant( this, @@ -128,7 +145,7 @@ public class QuantumPlugin extends AbstractUIPlugin { sysClip = new Clipboard(null); } - + /** * Write the bookmarks and subsets to a file, saving them for next use of the quantum plugin * @param target @@ -156,43 +173,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", //$NON-NLS-1$ - JFaceResources.getTextFont().getFontData()); - 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} \");"); @@ -250,6 +234,8 @@ public class QuantumPlugin extends AbstractUIPlugin { return tableView; } + + /** * @return */ @@ -259,7 +245,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. } @@ -269,8 +255,9 @@ 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(); + URL installURL = getBundle().getEntry("/"); return new URL(installURL, "icons/"); } } \ No newline at end of file