X-Git-Url: http://git.phpeclipse.com diff --git a/net.sourceforge.phpeclipse.xdebug.core/src/net/sourceforge/phpeclipse/xdebug/core/XDebugCorePlugin.java b/net.sourceforge.phpeclipse.xdebug.core/src/net/sourceforge/phpeclipse/xdebug/core/XDebugCorePlugin.java index 716b582..bbba27c 100644 --- a/net.sourceforge.phpeclipse.xdebug.core/src/net/sourceforge/phpeclipse/xdebug/core/XDebugCorePlugin.java +++ b/net.sourceforge.phpeclipse.xdebug.core/src/net/sourceforge/phpeclipse/xdebug/core/XDebugCorePlugin.java @@ -2,26 +2,31 @@ package net.sourceforge.phpeclipse.xdebug.core; import net.sourceforge.phpeclipse.xdebug.php.launching.IXDebugConstants; - -import org.eclipse.ui.plugin.*; -import org.eclipse.core.resources.IWorkspace; -import org.eclipse.core.resources.ResourcesPlugin; +//import org.eclipse.ui.plugin.AbstractUIPlugin;// *; +import org.eclipse.ui.preferences.ScopedPreferenceStore; +//import org.eclipse.core.resources.IWorkspace; +//import org.eclipse.core.resources.ResourcesPlugin; +//import org.eclipse.core.resources.IWorkspace; +//import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Plugin; +//import org.eclipse.core.runtime.Plugin; import org.eclipse.core.runtime.Status; +import org.eclipse.core.runtime.preferences.InstanceScope; import org.eclipse.debug.core.DebugPlugin; import org.eclipse.debug.core.IBreakpointManager; import org.eclipse.debug.core.model.IBreakpoint; -import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.jface.preference.IPreferenceStore; +//import org.eclipse.jface.resource.ImageDescriptor; import org.osgi.framework.BundleContext; -/** - * The main plugin class to be used in the desktop. - */ -public class XDebugCorePlugin extends AbstractUIPlugin { - - //The shared instance. +public class XDebugCorePlugin extends Plugin { private static XDebugCorePlugin plugin; public static final String PLUGIN_ID = "net.sourceforge.phpeclipse.xdebug.core"; //$NON-NLS-1$ + + private XDebugProxy fXDebugProxy; + + private ScopedPreferenceStore preferenceStore; /** @@ -43,6 +48,8 @@ public class XDebugCorePlugin extends AbstractUIPlugin { */ public void stop(BundleContext context) throws Exception { super.stop(context); + if (fXDebugProxy != null) + fXDebugProxy.stop(); plugin = null; } @@ -53,25 +60,18 @@ public class XDebugCorePlugin extends AbstractUIPlugin { return plugin; } + /*public static IWorkspace getWorkspace() { + return ResourcesPlugin.getWorkspace(); + }*/ + public static IBreakpoint[] getBreakpoints() { return getBreakpointManager().getBreakpoints(IXDebugConstants.ID_PHP_DEBUG_MODEL); } - public static IBreakpointManager getBreakpointManager() { + public static /*static*/ IBreakpointManager getBreakpointManager() { return DebugPlugin.getDefault().getBreakpointManager(); } - /** - * Returns an image descriptor for the image file at the given - * plug-in relative path. - * - * @param path the path - * @return the image descriptor - */ - public static ImageDescriptor getImageDescriptor(String path) { - return AbstractUIPlugin.imageDescriptorFromPlugin("net.sourceforge.phpeclipse.xdebug.core", path); - } - public static void log(int severity, String message) { Status status = new Status(severity, PLUGIN_ID, IStatus.OK, message, null) ; XDebugCorePlugin.log(status) ; @@ -85,12 +85,35 @@ public class XDebugCorePlugin extends AbstractUIPlugin { log(new Status(IStatus.ERROR, PLUGIN_ID, IStatus.ERROR, "PHPLaunchingPlugin.internalErrorOccurred", e)); //$NON-NLS-1$ } - /** - * Returns the workspace instance. - */ - public static IWorkspace getWorkspace() { - return ResourcesPlugin.getWorkspace(); - } + public static String getUniqueIdentifier() { + return PLUGIN_ID; + } + public void setProxyPort(int port) { + if(fXDebugProxy!=null) { + if (fXDebugProxy.isRunning()) { + fXDebugProxy.stop(); + } + fXDebugProxy=null; + } + } + + public XDebugProxy getXDebugProxy() { + if (fXDebugProxy == null) { + int debugPort=getPreferenceStore().getInt(IXDebugPreferenceConstants.DEBUGPORT_PREFERENCE); + if (debugPort<1024) + debugPort=IXDebugPreferenceConstants.DEFAULT_DEBUGPORT; + fXDebugProxy= new XDebugProxy(debugPort); + } + return fXDebugProxy; + } -} + public IPreferenceStore getPreferenceStore() { + // Create the preference store lazily. + if (preferenceStore == null) { + preferenceStore = new ScopedPreferenceStore(new InstanceScope(),getBundle().getSymbolicName()); + + } + return preferenceStore; + } +} \ No newline at end of file