Implementing UI classes for disassembly
mode.
Index:
src/org/eclipse/cdt/debug/internal/ui/CDTDebugModelPresentation.java =================================================================== RCS
file:
/home/tools/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDTDebugModelPresentation.java,v retrieving
revision 1.23 diff -u -r1.23 CDTDebugModelPresentation.java ---
src/org/eclipse/cdt/debug/internal/ui/CDTDebugModelPresentation.java 4 Oct
2002 20:23:28 -0000 1.23 +++
src/org/eclipse/cdt/debug/internal/ui/CDTDebugModelPresentation.java 9 Oct
2002 23:01:39 -0000 @@ -16,6 +16,7 @@ import
org.eclipse.cdt.debug.core.ICLineBreakpoint; import
org.eclipse.cdt.debug.core.ICValue; import
org.eclipse.cdt.debug.core.ICWatchpoint; +import
org.eclipse.cdt.debug.core.IDisassemblyStorage; import
org.eclipse.cdt.debug.core.IStackFrameInfo; import
org.eclipse.cdt.debug.core.IState; import
org.eclipse.cdt.debug.core.cdi.ICDIBreakpointHit; @@ -23,10 +24,12
@@ import org.eclipse.cdt.debug.core.cdi.ICDISignal; import
org.eclipse.cdt.debug.core.cdi.ICDIWatchpointScope; import
org.eclipse.cdt.debug.core.cdi.ICDIWatchpointTrigger; +import
org.eclipse.cdt.debug.internal.ui.editors.DisassemblyEditorInput; import
org.eclipse.cdt.debug.ui.CDebugUIPlugin; import
org.eclipse.core.resources.IFile; import
org.eclipse.core.resources.IMarker; import
org.eclipse.core.resources.IResource; +import
org.eclipse.core.resources.IStorage; import
org.eclipse.core.runtime.CoreException; import
org.eclipse.core.runtime.IPath; import
org.eclipse.core.runtime.Path; @@ -136,11 +139,11
@@ { return new
FileStorageEditorInput( (IFileStorage)element
); } +*/ if ( element instanceof
IDisassemblyStorage ) { return
new DisassemblyEditorInput( (IStorage)element
); } -*/ return
null; } Index:
src/org/eclipse/cdt/debug/internal/ui/editors/DisassemblyEditorInput.java =================================================================== RCS
file:
/home/tools/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/editors/DisassemblyEditorInput.java,v retrieving
revision 1.1 diff -u -r1.1 DisassemblyEditorInput.java ---
src/org/eclipse/cdt/debug/internal/ui/editors/DisassemblyEditorInput.java 8
Oct 2002 22:03:22 -0000 1.1 +++
src/org/eclipse/cdt/debug/internal/ui/editors/DisassemblyEditorInput.java 9
Oct 2002 23:01:39 -0000 @@ -20,6 +20,7 @@ */ public class
DisassemblyEditorInput implements
IStorageEditorInput { + private final static String
FILE_NAME_EXTENSION = ".s"; protected IStorage
fStorage; /** @@ -59,7 +60,18 @@
*/ public String
getName() { - return
"disassembly.s"; + try + { + if
( getStorage() != null
) + { + return
getStorage().getName() +
FILE_NAME_EXTENSION; + } + } + catch(
CoreException e ) + { + //
ignore + } + return
""; } /* (non-Javadoc) @@ -75,7 +87,7
@@ */ public String
getToolTipText() { - return
null; + return
"Disassembly"; } /* (non-Javadoc) @@
-84,5 +96,27 @@ public Object getAdapter( Class adapter
) { return
null; + } + + /* (non-Javadoc) + * @see
java.lang.Object#equals(Object) + */ + public boolean equals(
Object obj ) + { + if ( obj != null && obj
instanceof DisassemblyEditorInput
) + { + try + { + IStorage
storage =
((DisassemblyEditorInput)obj).getStorage(); + if (
storage != null && storage.equals( fStorage )
) + return
true; + else if ( storage == null && fStorage
== null ) + return
true; + } + catch( CoreException e
) + { + } + } + return
false; } } Index:
src/org/eclipse/cdt/debug/ui/CDebugUIPlugin.java =================================================================== RCS
file:
/home/tools/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/CDebugUIPlugin.java,v retrieving
revision 1.8 diff -u -r1.8 CDebugUIPlugin.java ---
src/org/eclipse/cdt/debug/ui/CDebugUIPlugin.java 4 Oct 2002 18:09:02
-0000 1.8 +++ src/org/eclipse/cdt/debug/ui/CDebugUIPlugin.java 9
Oct 2002 23:01:39 -0000 @@ -5,6 +5,7 @@ import
java.util.MissingResourceException; import
java.util.ResourceBundle; +import
org.eclipse.cdt.debug.core.IDisassemblyStorage; import
org.eclipse.cdt.debug.core.IFormattedMemoryBlock; import
org.eclipse.cdt.debug.core.IFormattedMemoryRetrieval; import
org.eclipse.cdt.debug.core.ISwitchToFrame; @@ -12,9 +13,11 @@ import
org.eclipse.cdt.debug.internal.ui.CDTDebugModelPresentation; import
org.eclipse.cdt.debug.internal.ui.CDebugImageDescriptorRegistry; import
org.eclipse.cdt.debug.internal.ui.ColorManager; +import
org.eclipse.cdt.debug.internal.ui.editors.DisassemblyEditorInput; import
org.eclipse.cdt.debug.internal.ui.preferences.CDebugPreferencePage; import
org.eclipse.cdt.debug.internal.ui.preferences.MemoryViewPreferencePage; import
org.eclipse.cdt.debug.internal.ui.preferences.RegistersViewPreferencePage; +import
org.eclipse.core.resources.IStorage; import
org.eclipse.core.resources.IWorkspace; import
org.eclipse.core.resources.ResourcesPlugin; import
org.eclipse.core.runtime.CoreException; @@ -23,7 +26,11 @@ import
org.eclipse.core.runtime.IPluginDescriptor; import
org.eclipse.core.runtime.IStatus; import
org.eclipse.core.runtime.Status; +import
org.eclipse.debug.core.DebugEvent; import
org.eclipse.debug.core.DebugException; +import
org.eclipse.debug.core.DebugPlugin; +import
org.eclipse.debug.core.IDebugEventSetListener; +import
org.eclipse.debug.core.model.IDebugTarget; import
org.eclipse.debug.core.model.IStackFrame; import
org.eclipse.debug.core.model.IThread; import
org.eclipse.debug.ui.IDebugUIConstants; @@ -36,6 +43,9 @@ import
org.eclipse.swt.graphics.Color; import
org.eclipse.swt.widgets.Display; import
org.eclipse.swt.widgets.Shell; +import
org.eclipse.ui.IEditorInput; +import org.eclipse.ui.IEditorPart; +import
org.eclipse.ui.IEditorReference; import
org.eclipse.ui.ISelectionListener; import
org.eclipse.ui.IWorkbenchPage; import
org.eclipse.ui.IWorkbenchPart; @@ -45,7 +55,7 @@ /** * The
main plugin class to be used in the desktop. */ -public class
CDebugUIPlugin extends AbstractUIPlugin implements ISelectionListener +public
class CDebugUIPlugin extends AbstractUIPlugin implements ISelectionListener,
IDebugEventSetListener { file://The shared instance. private static
CDebugUIPlugin plugin; @@ -312,6 +322,7 @@
*/ public void shutdown() throws
CoreException { + DebugPlugin.getDefault().removeDebugEventListener(
this ); IWorkbenchWindow ww =
getActiveWorkbenchWindow(); if ( ww != null
) { @@ -335,6 +346,7
@@ { ww.getSelectionService().addSelectionListener(
IDebugUIConstants.ID_DEBUG_VIEW, this
); } + DebugPlugin.getDefault().addDebugEventListener(
this ); } /* (non-Javadoc) @@ -372,6
+384,78 @@ catch( DebugException e
) { errorDialog(
"Switch to stack frame failed.", e
); + } + } + } + } + } + } + + /*
(non-Javadoc) + * @see
org.eclipse.debug.core.IDebugEventSetListener#handleDebugEvents(DebugEvent[]) +
*/ + public void handleDebugEvents( DebugEvent[] events
) + { + for ( int i = 0; i < events.length; i++
) + { + DebugEvent event =
events[i]; + if ( event.getKind() == DebugEvent.TERMINATE
) + { + Object element =
event.getSource(); + if ( element != null &&
element instanceof IDebugTarget
) + { + closeDisassemblyEditors(
(IDebugTarget)element
); + } + } + } + } + + private
void closeDisassemblyEditors( final IDebugTarget target
) + { + IWorkbenchWindow[] windows =
getWorkbench().getWorkbenchWindows(); + for ( int i = 0; i <
windows.length; ++i ) + { + IWorkbenchPage[]
pages = windows[i].getPages(); + for ( int j = 0; j <
pages.length; ++j
) + { + IEditorReference[] refs =
pages[j].getEditorReferences(); + for ( int k = 0; k
< refs.length; ++k
) + { + IEditorPart
editor = refs[k].getEditor( false ); + if (
editor != null
) + { + IEditorInput
input = editor.getEditorInput(); + if (
input != null && input instanceof DisassemblyEditorInput
) + { + try + { + IStorage
storage =
((DisassemblyEditorInput)input).getStorage(); + if
( storage != null && storage instanceof IDisassemblyStorage &&
+ target.equals(
((IDisassemblyStorage)storage).getDebugTarget() )
) + { + Shell
shell =
windows[i].getShell(); + if
( shell != null
) + { + Display
display =
shell.getDisplay(); + if
( display != null
) + { + final
IWorkbenchPage page =
pages[j]; + final
IEditorPart editor0 =
editor; + display.asyncExec(
new
Runnable() + { + public
void
run() + { + page.closeEditor(
editor0, false
); + } + }
); + } + } + } + } + catch(
CoreException e
) + { + //
ignore + } } } }
|