[Pydev-cvs] org.python.pydev.debug/src/org/python/pydev/debug/model AdapterDebug.java, NONE, 1.1 Py
Brought to you by:
fabioz
From: Fabio Z. <fa...@us...> - 2008-04-10 16:16:06
|
Update of /cvsroot/pydev/org.python.pydev.debug/src/org/python/pydev/debug/model In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26717/src/org/python/pydev/debug/model Modified Files: PyVariableCollection.java PyDebugModelPresentation.java PyThread.java DeferredWorkbenchAdapter.java PyVariable.java PyWatchExpressionDelegate.java PyStackFrame.java AbstractDebugTarget.java Added Files: AdapterDebug.java Log Message: Raised the timeout for variable request from 2.5 to 10 seconds: DeferredWorkbenchAdapter. Others are only minors. Index: PyThread.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.debug/src/org/python/pydev/debug/model/PyThread.java,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** PyThread.java 24 Jun 2006 01:45:53 -0000 1.13 --- PyThread.java 10 Apr 2008 16:15:59 -0000 1.14 *************** *** 210,219 **** public Object getAdapter(Class adapter) { if (adapter.equals(ILaunch.class) || ! adapter.equals(IResource.class)) return target.getAdapter(adapter); ! else if (adapter.equals(ITaskListResourceAdapter.class)) return null; ! else if (adapter.equals(IPropertySource.class) || adapter.equals(ITaskListResourceAdapter.class) || adapter.equals(org.eclipse.debug.ui.actions.IToggleBreakpointsTarget.class) --- 210,221 ---- public Object getAdapter(Class adapter) { + AdapterDebug.print(this, adapter); + if (adapter.equals(ILaunch.class) || ! adapter.equals(IResource.class)){ return target.getAdapter(adapter); ! }else if (adapter.equals(ITaskListResourceAdapter.class)){ return null; ! }else if (adapter.equals(IPropertySource.class) || adapter.equals(ITaskListResourceAdapter.class) || adapter.equals(org.eclipse.debug.ui.actions.IToggleBreakpointsTarget.class) *************** *** 222,231 **** || adapter.equals(org.eclipse.ui.model.IWorkbenchAdapter.class) || adapter.equals(org.eclipse.ui.IActionFilter.class) ! ) return super.getAdapter(adapter); - else { - // System.err.println("PythonThread Need adapter " + adapter.toString()); - Platform.getAdapterManager().getAdapter(this, adapter); } // ongoing, I do not fully understand all the interfaces they'd like me to support return super.getAdapter(adapter); --- 224,232 ---- || adapter.equals(org.eclipse.ui.model.IWorkbenchAdapter.class) || adapter.equals(org.eclipse.ui.IActionFilter.class) ! ) { return super.getAdapter(adapter); } + //Platform.getAdapterManager().getAdapter(this, adapter); + AdapterDebug.printDontKnow(this, adapter); // ongoing, I do not fully understand all the interfaces they'd like me to support return super.getAdapter(adapter); Index: PyStackFrame.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.debug/src/org/python/pydev/debug/model/PyStackFrame.java,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** PyStackFrame.java 24 Jun 2006 01:45:53 -0000 1.14 --- PyStackFrame.java 10 Apr 2008 16:15:59 -0000 1.15 *************** *** 252,255 **** --- 252,257 ---- public Object getAdapter(Class adapter) { + AdapterDebug.print(this, adapter); + if (adapter.equals(ILaunch.class) || adapter.equals(IResource.class)){ *************** *** 273,278 **** } // ongoing, I do not fully understand all the interfaces they'd like me to support - // System.err.println("PyStackFrame Need adapter " + adapter.toString()); return super.getAdapter(adapter); } --- 275,280 ---- } + AdapterDebug.printDontKnow(this, adapter); // ongoing, I do not fully understand all the interfaces they'd like me to support return super.getAdapter(adapter); } Index: DeferredWorkbenchAdapter.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.debug/src/org/python/pydev/debug/model/DeferredWorkbenchAdapter.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** DeferredWorkbenchAdapter.java 13 Apr 2006 20:02:54 -0000 1.5 --- DeferredWorkbenchAdapter.java 10 Apr 2008 16:15:59 -0000 1.6 *************** *** 99,105 **** // it causes unneeded scrolling, because view preserves selection instead // of visibility. ! // I try to minimize the occurence here, by giving pydevd time to complete the // task before we are forced to do asynchronous notification. ! int i = 50; while (--i > 0 && commandVariables == null){ if(this.monitor != null && this.monitor.isCanceled() == true){ --- 99,105 ---- // it causes unneeded scrolling, because view preserves selection instead // of visibility. ! // I try to minimize the occurrence here, by giving pydevd time to complete the // task before we are forced to do asynchronous notification. ! int i = 1000; while (--i > 0 && commandVariables == null){ if(this.monitor != null && this.monitor.isCanceled() == true){ *************** *** 107,111 **** return new PyVariable[0]; } ! Thread.sleep(50); } } catch (InterruptedException e) { --- 107,111 ---- return new PyVariable[0]; } ! Thread.sleep(10); //10 seconds } } catch (InterruptedException e) { Index: PyDebugModelPresentation.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.debug/src/org/python/pydev/debug/model/PyDebugModelPresentation.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** PyDebugModelPresentation.java 11 May 2007 19:47:27 -0000 1.8 --- PyDebugModelPresentation.java 10 Apr 2008 16:15:59 -0000 1.9 *************** *** 24,27 **** --- 24,28 ---- import org.eclipse.ui.IEditorInput; import org.eclipse.ui.IEditorPart; + import org.python.pydev.core.bundle.ImageCache; import org.python.pydev.debug.core.PydevDebugPlugin; import org.python.pydev.plugin.PydevPlugin; *************** *** 34,37 **** --- 35,41 ---- static public String PY_DEBUG_MODEL_ID = "org.python.pydev.debug"; + /** + * Listeners compared by identity + */ protected ListenerList fListeners = new ListenerList(ListenerList.IDENTITY); *************** *** 42,45 **** --- 46,51 ---- */ public Image getImage(Object element) { + ImageCache imageCache = PydevDebugPlugin.getImageCache(); + if (element instanceof PyBreakpoint) { try { *************** *** 48,60 **** if ((pyBreakpoint).isEnabled()) if (pyBreakpoint.isConditionEnabled()){ ! return PydevDebugPlugin.getImageCache().get("icons/breakmarker_conditional.gif"); }else{ ! return PydevDebugPlugin.getImageCache().get("icons/breakmarker.gif"); } else if (pyBreakpoint.isConditionEnabled()){ ! return PydevDebugPlugin.getImageCache().get("icons/breakmarker_gray_conditional.gif"); }else{ ! return PydevDebugPlugin.getImageCache().get("icons/breakmarker_gray.gif"); } --- 54,66 ---- if ((pyBreakpoint).isEnabled()) if (pyBreakpoint.isConditionEnabled()){ ! return imageCache.get("icons/breakmarker_conditional.gif"); }else{ ! return imageCache.get("icons/breakmarker.gif"); } else if (pyBreakpoint.isConditionEnabled()){ ! return imageCache.get("icons/breakmarker_gray_conditional.gif"); }else{ ! return imageCache.get("icons/breakmarker_gray.gif"); } *************** *** 64,71 **** } else if (element instanceof PyVariableCollection) { ! return PydevDebugPlugin.getImageCache().get("icons/greendot_big.gif"); } else if (element instanceof PyVariable) { ! return PydevDebugPlugin.getImageCache().get("icons/greendot.gif"); } else if (element instanceof PyDebugTarget || element instanceof PyThread || element instanceof PyStackFrame){ --- 70,77 ---- } else if (element instanceof PyVariableCollection) { ! return imageCache.get("icons/greendot_big.gif"); } else if (element instanceof PyVariable) { ! return imageCache.get("icons/greendot.gif"); } else if (element instanceof PyDebugTarget || element instanceof PyThread || element instanceof PyStackFrame){ *************** *** 182,189 **** public void setAttribute(String attribute, Object value) { ! if (attribute.equals(IDebugModelPresentation.DISPLAY_VARIABLE_TYPE_NAMES)) displayVariableTypeNames = ((Boolean) value).booleanValue(); ! else System.err.println("setattribute"); } --- 188,196 ---- public void setAttribute(String attribute, Object value) { ! if (attribute.equals(IDebugModelPresentation.DISPLAY_VARIABLE_TYPE_NAMES)){ displayVariableTypeNames = ((Boolean) value).booleanValue(); ! }else{ System.err.println("setattribute"); + } } Index: PyWatchExpressionDelegate.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.debug/src/org/python/pydev/debug/model/PyWatchExpressionDelegate.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** PyWatchExpressionDelegate.java 7 Feb 2007 00:46:13 -0000 1.6 --- PyWatchExpressionDelegate.java 10 Apr 2008 16:15:59 -0000 1.7 *************** *** 130,134 **** synchronized(variables) { if (variables[0] instanceof PyVariableCollection) { ! ((PyVariableCollection)variables[0]).requestedVariables = 2; } } --- 130,134 ---- synchronized(variables) { if (variables[0] instanceof PyVariableCollection) { ! ((PyVariableCollection)variables[0]).networkState = PyVariableCollection.NETWORK_REQUEST_ARRIVED; } } Index: PyVariableCollection.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.debug/src/org/python/pydev/debug/model/PyVariableCollection.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** PyVariableCollection.java 7 Feb 2007 00:46:13 -0000 1.8 --- PyVariableCollection.java 10 Apr 2008 16:15:59 -0000 1.9 *************** *** 16,19 **** --- 16,20 ---- import org.python.pydev.debug.model.remote.GetVariableCommand; import org.python.pydev.debug.model.remote.ICommandResponseListener; + import org.python.pydev.plugin.PydevPlugin; /** *************** *** 27,32 **** PyVariable[] variables = new PyVariable[0]; IVariable[] waitVariables = null; ! int requestedVariables = 0; // Network request state: 0 did not request, 1 requested, 2 requested & arrived ! boolean fireChangeEvent = true; public PyVariableCollection(AbstractDebugTarget target, String name, String type, String value, IVariableLocator locator) { --- 28,42 ---- PyVariable[] variables = new PyVariable[0]; IVariable[] waitVariables = null; ! ! static final int NETWORK_REQUEST_NOT_REQUESTED = 0; ! static final int NETWORK_REQUEST_NOT_ARRIVED = 1; ! static final int NETWORK_REQUEST_ARRIVED = 2; ! ! /** ! * Defines the network state ! */ ! int networkState = NETWORK_REQUEST_NOT_REQUESTED; // Network request state: 0 did not request, 1 requested, 2 requested & arrived ! ! private boolean fireChangeEvent = true; public PyVariableCollection(AbstractDebugTarget target, String name, String type, String value, IVariableLocator locator) { *************** *** 58,62 **** variables = getCommandVariables(cmd); ! requestedVariables = 2; if (fireChangeEvent){ target.fireEvent(new DebugEvent(this, DebugEvent.CHANGE, DebugEvent.STATE)); --- 68,72 ---- variables = getCommandVariables(cmd); ! networkState = NETWORK_REQUEST_ARRIVED; if (fireChangeEvent){ target.fireEvent(new DebugEvent(this, DebugEvent.CHANGE, DebugEvent.STATE)); *************** *** 89,95 **** public IVariable[] getVariables() throws DebugException { ! if (requestedVariables == 2){ return variables; ! } else if (requestedVariables == 1){ return getWaitVariables(); } --- 99,105 ---- public IVariable[] getVariables() throws DebugException { ! if (networkState == NETWORK_REQUEST_ARRIVED){ return variables; ! } else if (networkState == NETWORK_REQUEST_NOT_ARRIVED){ return getWaitVariables(); } *************** *** 99,103 **** GetVariableCommand cmd = getVariableCommand(dbg); cmd.setCompletionListener(this); ! requestedVariables = 1; fireChangeEvent = false; // do not fire change event while we are waiting on response dbg.postCommand(cmd); --- 109,113 ---- GetVariableCommand cmd = getVariableCommand(dbg); cmd.setCompletionListener(this); ! networkState = NETWORK_REQUEST_NOT_ARRIVED; fireChangeEvent = false; // do not fire change event while we are waiting on response dbg.postCommand(cmd); *************** *** 109,122 **** // task before we are forced to do asynchronous notification. int i = 10; ! while (--i > 0 && requestedVariables != 2) Thread.sleep(50); } catch (InterruptedException e) { ! e.printStackTrace(); } fireChangeEvent = true; ! if (requestedVariables == 2) return variables; ! else return getWaitVariables(); } --- 119,135 ---- // task before we are forced to do asynchronous notification. int i = 10; ! while (--i > 0 && networkState != NETWORK_REQUEST_ARRIVED){ Thread.sleep(50); + } + } catch (InterruptedException e) { ! PydevPlugin.log(e); } fireChangeEvent = true; ! if (networkState == NETWORK_REQUEST_ARRIVED){ return variables; ! }else{ return getWaitVariables(); + } } --- NEW FILE: AdapterDebug.java --- package org.python.pydev.debug.model; public class AdapterDebug { public static void print(Object askedfor, Class adapter) { if(false){ System.out.println(askedfor.getClass().getName() + " requests "+adapter.toString()); } } public static void printDontKnow(Object askedfor, Class adapter) { if(false){ System.out.println("DONT KNOW: "+askedfor.getClass().getName() + " requests "+adapter.toString()); } } } Index: AbstractDebugTarget.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.debug/src/org/python/pydev/debug/model/AbstractDebugTarget.java,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** AbstractDebugTarget.java 11 May 2007 01:57:53 -0000 1.13 --- AbstractDebugTarget.java 10 Apr 2008 16:16:00 -0000 1.14 *************** *** 553,556 **** --- 553,558 ---- public Object getAdapter(Class adapter) { + AdapterDebug.print(this, adapter); + // Not really sure what to do here, but I am trying if (adapter.equals(ILaunch.class)){ *************** *** 580,584 **** return super.getAdapter(adapter); } ! // System.err.println("Need adapter " + adapter.toString()); return super.getAdapter(adapter); } --- 582,587 ---- return super.getAdapter(adapter); } ! ! AdapterDebug.printDontKnow(this, adapter); return super.getAdapter(adapter); } Index: PyVariable.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.debug/src/org/python/pydev/debug/model/PyVariable.java,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** PyVariable.java 7 Feb 2007 10:34:08 -0000 1.13 --- PyVariable.java 10 Apr 2008 16:15:59 -0000 1.14 *************** *** 129,132 **** --- 129,134 ---- public Object getAdapter(Class adapter) { + AdapterDebug.print(this, adapter); + if (adapter.equals(ILaunch.class)) return target.getAdapter(adapter); *************** *** 147,151 **** return new DeferredWorkbenchAdapter(this); } ! //System.err.println("PyVariable Need adapter " + adapter.toString()); return super.getAdapter(adapter); } --- 149,153 ---- return new DeferredWorkbenchAdapter(this); } ! AdapterDebug.printDontKnow(this, adapter); return super.getAdapter(adapter); } |