Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[cdt-patch] Implementing the 'Switch to disassembly mode' action

Implementing the 'Switch to disassembly mode' action.
 
Index: ChangeLog
===================================================================
RCS file: ChangeLog
diff -N ChangeLog
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ ChangeLog 11 Oct 2002 21:48:52 -0000
@@ -0,0 +1,7 @@
+2002-10-11 Mikhail Khodjaiants
+ * SwitchToDisassemblyActionDelegate.java: Implementation of the 'Switch to disassembly mode' action.
+ * plugin.properties: Action label and tooltip.
+ * plugin.xml: Contribution to the 'Launch View'.
+ * icons/full/clcl16/disassembly.gif: Hover icon.
+ * icons/full/dlcl16/disassembly.gif: Disabled icon.
+ * icons/full/elcl16/disassembly.gif: Enabled icon.
Index: plugin.properties
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.ui/plugin.properties,v
retrieving revision 1.19
diff -u -r1.19 plugin.properties
--- plugin.properties 4 Oct 2002 20:23:28 -0000 1.19
+++ plugin.properties 11 Oct 2002 21:48:52 -0000
@@ -20,6 +20,9 @@
 RestartAction.label=Restart
 RestartAction.tooltip=Restart
 
+SwitchToDisassemblyAction.label=Disassembly Mode
+SwitchToDisassemblyAction.tooltip=Disassembly Mode On/Off
+
 AddBreakpoint.label=Add/Remove &Breakpoint
 EnableBreakpoint.label=T&oggle Breakpoint
 BreakpointProperties.label=Breakpoint P&roperties...
Index: plugin.xml
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.ui/plugin.xml,v
retrieving revision 1.28
diff -u -r1.28 plugin.xml
--- plugin.xml 4 Oct 2002 20:23:28 -0000 1.28
+++ plugin.xml 11 Oct 2002 21:48:52 -0000
@@ -222,6 +222,21 @@
                </pluginState>
             </enablement>
          </action>
+         <action
+               label="%SwitchToDisassemblyAction.label"
+               icon="icons/full/clcl16/disassembly.gif"
+               helpContextId="switch_to_disassembly_action_context"
+               class="org.eclipse.cdt.debug.internal.ui.actions.SwitchToDisassemblyActionDelegate"
+               menubarPath="renderGroup"
+               enablesFor="1"
+               id="org.eclipse.cdt.debug.internal.ui.actions.SwitchToDisassemblyActionDelegate">
+            <enablement>
+               <pluginState
+                     value="activated"
+                     id="org.eclipse.cdt.debug.ui">
+               </pluginState>
+            </enablement>
+         </action>
       </viewerContribution>
       <viewerContribution
             targetID="#CEditorRulerContext"
@@ -339,21 +354,29 @@
                label="%RestartAction.label"
                tooltip="%RestartAction.tooltip">
          </action>
-      </viewContribution>
-      <viewContribution
-            targetID="org.eclipse.debug.ui.DebugView"
-            id="org.eclipse.cdt.debug.ui.debugview.toolbar">
          <action
-               id="org.eclipse.cdt.debug.internal.ui.actions.ShowFullPathsAction"
+               label="%ShowFullPathsAction.label"
                toolbarPath="renderGroup"
+               id="org.eclipse.cdt.debug.internal.ui.actions.ShowFullPathsAction"
+               disabledIcon="icons/full/dlcl16/show_paths.gif"
                hoverIcon="icons/full/clcl16/show_paths.gif"
                class="org.eclipse.cdt.debug.internal.ui.actions.ShowFullPathsAction"
-               disabledIcon="icons/full/dlcl16/show_paths.gif"
                icon="icons/full/elcl16/show_parents.gif"
                helpContextId="show_full_paths_action_context"
-               label="%ShowFullPathsAction.label"
                tooltip="%ShowFullPathsAction.tooltip">
          </action>
+         <action
+               toolbarPath="renderGroup"
+               id="org.eclipse.cdt.debug.internal.ui.actions.SwitchToDisassemblyActionDelegate"
+               hoverIcon="icons/full/clcl16/disassembly.gif"
+               class="org.eclipse.cdt.debug.internal.ui.actions.SwitchToDisassemblyActionDelegate"
+               disabledIcon="icons/full/dlcl16/disassembly.gif"
+               enablesFor="1"
+               icon="icons/full/elcl16/disassembly.gif"
+               helpContextId="switch_to_disassembly_action_context"
+               label="%SwitchToDisassemblyAction.label"
+               tooltip="%SwitchToDisassemblyAction.tooltip">
+         </action>
       </viewContribution>
       <viewContribution
             targetID="org.eclipse.debug.ui.BreakpointView"
@@ -433,6 +456,9 @@
          </action>
          <action
                id="org.eclipse.cdt.debug.internal.ui.actions.ShowFullPathsAction">
+         </action>
+         <action
+               id="org.eclipse.cdt.debug.internal.ui.actions.SwitchToDisassemblyActionDelegate">
          </action>
       </debugActionGroup>
    </extension>
Index: icons/full/clcl16/disassembly.gif
===================================================================
RCS file: icons/full/clcl16/disassembly.gif
diff -N icons/full/clcl16/disassembly.gif
Binary files /dev/null and disassembly.gif differ
Index: icons/full/dlcl16/disassembly.gif
===================================================================
RCS file: icons/full/dlcl16/disassembly.gif
diff -N icons/full/dlcl16/disassembly.gif
Binary files /dev/null and disassembly.gif differ
Index: icons/full/elcl16/disassembly.gif
===================================================================
RCS file: icons/full/elcl16/disassembly.gif
diff -N icons/full/elcl16/disassembly.gif
Binary files /dev/null and disassembly.gif differ
Index: src/org/eclipse/cdt/debug/internal/ui/actions/SwitchToDisassemblyActionDelegate.java
===================================================================
RCS file: src/org/eclipse/cdt/debug/internal/ui/actions/SwitchToDisassemblyActionDelegate.java
diff -N src/org/eclipse/cdt/debug/internal/ui/actions/SwitchToDisassemblyActionDelegate.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/cdt/debug/internal/ui/actions/SwitchToDisassemblyActionDelegate.java 11 Oct 2002 21:48:52 -0000
@@ -0,0 +1,126 @@
+/*
+ *(c) Copyright QNX Software Systems Ltd. 2002.
+ * All Rights Reserved.
+ *
+ */
+package org.eclipse.cdt.debug.internal.ui.actions;
+
+import org.eclipse.cdt.debug.core.sourcelookup.ISourceMode;
+import org.eclipse.cdt.debug.internal.core.model.CDebugElement;
+import org.eclipse.debug.core.DebugEvent;
+import org.eclipse.debug.core.DebugException;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.ui.IViewPart;
+
+/**
+ * Enter type comment.
+ *
+ * @since: Oct 11, 2002
+ */
+public class SwitchToDisassemblyActionDelegate extends AbstractListenerActionDelegate
+{
+ private IViewPart fViewPart = null;
+
+ /* (non-Javadoc)
+  * @see org.eclipse.cdt.debug.internal.ui.actions.AbstractDebugActionDelegate#doAction(Object)
+  */
+ protected void doAction( Object element ) throws DebugException
+ {
+  if ( element != null && element instanceof CDebugElement )
+  {
+   ISourceMode sourceMode = (ISourceMode)((CDebugElement)element).getDebugTarget().getAdapter( ISourceMode.class );
+   if ( sourceMode != null )
+   {
+    sourceMode.setMode( ( sourceMode.getMode() == ISourceMode.MODE_SOURCE ) ? ISourceMode.MODE_DISASSEMBLY : ISourceMode.MODE_SOURCE );
+    ((CDebugElement)element).fireChangeEvent( DebugEvent.CLIENT_REQUEST );
+    if ( fViewPart != null && fViewPart instanceof ISelectionChangedListener )
+    {
+     final ISelectionChangedListener view = (ISelectionChangedListener)fViewPart;
+     fViewPart.getViewSite().getShell().getDisplay().asyncExec(
+         new Runnable()
+          {
+           public void run()
+           {
+            view.selectionChanged( null );
+           }
+          } );
+    }
+   }
+  }
+ }
+
+ /* (non-Javadoc)
+  * @see org.eclipse.cdt.debug.internal.ui.actions.AbstractDebugActionDelegate#isEnabledFor(Object)
+  */
+ protected boolean isEnabledFor( Object element )
+ {
+  if ( element != null && element instanceof CDebugElement )
+  {
+   return ( ((CDebugElement)element).getDebugTarget().getAdapter( ISourceMode.class ) != null );
+  }
+  return false;
+ }
+
+ /**
+  * @see AbstractDebugActionDelegate#enableForMultiSelection()
+  */
+ protected boolean enableForMultiSelection()
+ {
+  return false;
+ }
+
+ /**
+  * @see AbstractDebugActionDelegate#getStatusMessage()
+  */
+ protected String getStatusMessage()
+ {
+  return "Exceptions occurred attempting to switch to disassembly/source mode.";
+ }
+
+ /**
+  * @see AbstractDebugActionDelegate#getErrorDialogMessage()
+  */
+ protected String getErrorDialogMessage()
+ {
+  return "Switch to disassembly/source mode failed.";
+ }
+
+ /**
+  * @see AbstractDebugActionDelegate#getErrorDialogTitle()
+  */
+ protected String getErrorDialogTitle()
+ {
+  return "Switch to disassembly/source mode";
+ }
+
+ /* (non-Javadoc)
+  * @see org.eclipse.ui.IActionDelegate#selectionChanged(IAction, ISelection)
+  */
+ public void selectionChanged( IAction action, ISelection selection )
+ {
+  super.selectionChanged( action, selection );
+  boolean checked = false;
+  if ( selection != null && selection instanceof IStructuredSelection )
+  {
+   Object element = ((IStructuredSelection)selection).getFirstElement();
+   if ( element != null && element instanceof CDebugElement )
+   {
+    ISourceMode sourceMode =  (ISourceMode)((CDebugElement)element).getDebugTarget().getAdapter( ISourceMode.class );
+    checked = ( sourceMode != null && sourceMode.getMode() == ISourceMode.MODE_DISASSEMBLY );
+   }
+  }
+  action.setChecked( checked );
+ }
+
+ /* (non-Javadoc)
+  * @see org.eclipse.ui.IViewActionDelegate#init(IViewPart)
+  */
+ public void init( IViewPart view )
+ {
+  super.init( view );
+  fViewPart = view;
+ }
+}

Back to the top