Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[cdt-patch] Implementation of the 'Resume At C/C++ Line' action

Index: ChangeLog
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.ui/ChangeLog,v
retrieving revision 1.89
diff -u -r1.89 ChangeLog
--- ChangeLog 4 Feb 2003 23:47:51 -0000 1.89
+++ ChangeLog 5 Feb 2003 22:30:13 -0000
@@ -1,3 +1,13 @@
+2003-02-05 Mikhail Khodjaiants
+ Implementation of the 'Resume At C/C++ Line' action.
+ * RunToLineActionDelegate.java
+ * JumpToLineActionDelegate.java
+ * plugin.properties
+ * plugin.xml
+ icons/full/clcl16/jump_co.gif
+ icons/full/dlcl16/jump_co.gif
+ icons/full/elcl16/jump_co.gif

 2003-02-04 Mikhail Khodjaiants
  Implementation of the 'Resume Without Signal' action.
  * SignalZeroActionDelegate.java
Index: plugin.properties
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.ui/plugin.properties,v
retrieving revision 1.32
diff -u -r1.32 plugin.properties
--- plugin.properties 4 Feb 2003 23:47:51 -0000 1.32
+++ plugin.properties 5 Feb 2003 22:30:13 -0000
@@ -37,6 +37,7 @@
 AddExpressionAction.label=Add C/C++ &_expression_...
 AddAddressBreakpointAction.label=Add &Address Breakpoint...
 RunToLineAction.label=Run To C/C++ &Line
+JumpToLineAction.label=Resume At C/C++ Li&ne
 ShowFullPathsAction.label=Show Full Paths
 ShowFullPathsAction.tooltip=Show Full Paths
 
Index: plugin.xml
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.ui/plugin.xml,v
retrieving revision 1.49
diff -u -r1.49 plugin.xml
--- plugin.xml 4 Feb 2003 23:47:51 -0000 1.49
+++ plugin.xml 5 Feb 2003 22:30:14 -0000
@@ -135,14 +135,14 @@
             </separator>
          </menu>
          <action
-               id="org.eclipse.cdt.debug.ui.internal.actions.RestartActionDelegate"
-               hoverIcon="icons/full/clcl16/restart.gif"
-               class="org.eclipse.cdt.debug.internal.ui.actions.RestartActionDelegate"
-               disabledIcon="icons/full/dlcl16/restart.gif"
-               enablesFor="1"
-               icon="icons/full/elcl16/restart.gif"
-               helpContextId="restart_action_context"
-               label="%RestartAction.label"
+               id="org.eclipse.cdt.debug.internal.ui.actions.JumpToLineActionDelegate"
+               hoverIcon="icons/full/clcl16/jump_co.gif"
+               class="org.eclipse.cdt.debug.internal.ui.actions.JumpToLineActionDelegate"
+               disabledIcon="icons/full/dlcl16/jump_co.gif"
+               enablesFor="1"
+               icon="icons/full/elcl16/jump_co.gif"
+               helpContextId="jump_to_line_action_context"
+               label="%JumpToLineAction.label"
                menubarPath="org.eclipse.ui.run/stepGroup">
             <enablement>
                <pluginState
@@ -169,6 +169,23 @@
             </enablement>
          </action>
          <action
+               id="org.eclipse.cdt.debug.ui.internal.actions.RestartActionDelegate"
+               hoverIcon="icons/full/clcl16/restart.gif"
+               class="org.eclipse.cdt.debug.internal.ui.actions.RestartActionDelegate"
+               disabledIcon="icons/full/dlcl16/restart.gif"
+               enablesFor="1"
+               icon="icons/full/elcl16/restart.gif"
+               helpContextId="restart_action_context"
+               label="%RestartAction.label"
+               menubarPath="org.eclipse.ui.run/stepGroup">
+            <enablement>
+               <pluginState
+                     value="activated"
+                     id="org.eclipse.cdt.debug.ui">
+               </pluginState>
+            </enablement>
+         </action>
+         <action
                label="%ManageBreakpointAction.label"
                icon="icons/full/obj16/brkp_obj.gif"
                helpContextId="manage_breakpoint_action_context"
@@ -364,6 +381,21 @@
             </enablement>
          </action>
          <action
+               label="%JumpToLineAction.label"
+               icon="icons/full/clcl16/jump_co.gif"
+               helpContextId="jump_to_line_action_context"
+               class="org.eclipse.cdt.debug.internal.ui.actions.JumpToLineActionDelegate"
+               menubarPath="additions"
+               enablesFor="1"
+               id="org.eclipse.cdt.debug.internal.ui.actions.JumpToLineActionDelegate">
+            <enablement>
+               <pluginState
+                     value="activated"
+                     id="org.eclipse.cdt.debug.ui">
+               </pluginState>
+            </enablement>
+         </action>
+         <action
                label="%RunToLineAction.label"
                icon="icons/full/clcl16/runtoline_co.gif"
                helpContextId="run_to_line_action_context"
@@ -505,6 +537,21 @@
             </enablement>
          </action>
          <action
+               menubarPath="additions"
+               class="org.eclipse.cdt.debug.internal.ui.actions.JumpToLineActionDelegate"
+               icon="icons/full/clcl16/jump_co.gif"
+               label="%JumpToLineAction.label"
+               enablesFor="1"
+               id="org.eclipse.cdt.debug.internal.ui.actions.JumpToLineActionDelegate"
+               helpContextId="jump_to_line_action_context">
+            <enablement>
+               <pluginState
+                     id="org.eclipse.cdt.debug.ui"
+                     value="activated">
+               </pluginState>
+            </enablement>
+         </action>
+         <action
                label="%RunToLineAction.label"
                icon="icons/full/clcl16/runtoline_co.gif"
                helpContextId="run_to_line_action_context"
@@ -627,6 +674,21 @@
             </enablement>
          </action>
          <action
+               menubarPath="additions"
+               label="%JumpToLineAction.label"
+               icon="icons/full/clcl16/jump_co.gif"
+               class="org.eclipse.cdt.debug.internal.ui.actions.JumpToLineActionDelegate"
+               enablesFor="1"
+               id="org.eclipse.cdt.debug.internal.ui.actions.JumpToLineActionDelegate"
+               helpContextId="jump_to_line_action_context">
+            <enablement>
+               <pluginState
+                     value="activated"
+                     id="org.eclipse.cdt.debug.ui">
+               </pluginState>
+            </enablement>
+         </action>
+         <action
                label="%RunToLineAction.label"
                icon="icons/full/clcl16/runtoline_co.gif"
                helpContextId="run_to_line_action_context"
@@ -711,8 +773,8 @@
                id="org.eclipse.cdt.debug.internal.ui.actions.SignalZeroActionDelegate">
             <enablement>
                <pluginState
-                     id="org.eclipse.cdt.debug.ui"
-                     value="activated">
+                     value="activated"
+                     id="org.eclipse.cdt.debug.ui">
                </pluginState>
             </enablement>
          </action>
@@ -964,6 +1026,21 @@
          </action>
          <action
                id="org.eclipse.cdt.debug.internal.ui.AddAddressBreakpointActionDelegate">
+         </action>
+         <action
+               id="org.eclipse.cdt.debug.internal.ui.actions.JumpToLineActionDelegate">
+         </action>
+         <action
+               id="org.eclipse.cdt.debug.ui.internal.actions.RunToLineActionDelegate">
+         </action>
+         <action
+               id="org.eclipse.cdt.debug.ui.internal.actions.ManageBreakpointActionDelegate">
+         </action>
+         <action
+               id="org.eclipse.cdt.debug.internal.ui.actions.ManageWatchpointActionDelegate">
+         </action>
+         <action
+               id="org.eclipse.cdt.debug.internal.ui.actions.AddExpressionActionDelegate">
          </action>
       </debugActionGroup>
    </extension>
Index: icons/full/clcl16/jump_co.gif
===================================================================
RCS file: icons/full/clcl16/jump_co.gif
diff -N icons/full/clcl16/jump_co.gif
Binary files /dev/null and jump_co.gif differ
Index: icons/full/dlcl16/jump_co.gif
===================================================================
RCS file: icons/full/dlcl16/jump_co.gif
diff -N icons/full/dlcl16/jump_co.gif
Binary files /dev/null and jump_co.gif differ
Index: icons/full/elcl16/jump_co.gif
===================================================================
RCS file: icons/full/elcl16/jump_co.gif
diff -N icons/full/elcl16/jump_co.gif
Binary files /dev/null and jump_co.gif differ
Index: src/org/eclipse/cdt/debug/internal/ui/actions/JumpToLineActionDelegate.java
===================================================================
RCS file: src/org/eclipse/cdt/debug/internal/ui/actions/JumpToLineActionDelegate.java
diff -N src/org/eclipse/cdt/debug/internal/ui/actions/JumpToLineActionDelegate.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/cdt/debug/internal/ui/actions/JumpToLineActionDelegate.java 5 Feb 2003 22:30:14 -0000
@@ -0,0 +1,172 @@
+/*
+ *(c) Copyright QNX Software Systems Ltd. 2002.
+ * All Rights Reserved.
+ *
+ */
+package org.eclipse.cdt.debug.internal.ui.actions;
+
+import org.eclipse.cdt.debug.core.model.IJumpToAddress;
+import org.eclipse.cdt.debug.core.model.IJumpToLine;
+import org.eclipse.cdt.debug.core.sourcelookup.IDisassemblyStorage;
+import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IStorage;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.debug.core.DebugException;
+import org.eclipse.debug.core.model.IDebugElement;
+import org.eclipse.debug.core.model.IDebugTarget;
+import org.eclipse.debug.ui.DebugUITools;
+import org.eclipse.debug.ui.IDebugUIConstants;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.text.ITextSelection;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IFileEditorInput;
+import org.eclipse.ui.IStorageEditorInput;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.texteditor.ITextEditor;
+
+/**
+ * Enter type comment.
+ *
+ * @since: Feb 5, 2003
+ */
+public class JumpToLineActionDelegate extends AbstractEditorActionDelegate
+{
+ /**
+  * Constructor for JumpToLineActionDelegate.
+  */
+ public JumpToLineActionDelegate()
+ {
+  super();
+ }
+
+ /* (non-Javadoc)
+  * @see org.eclipse.ui.ISelectionListener#selectionChanged(IWorkbenchPart, ISelection)
+  */
+ public void selectionChanged( IWorkbenchPart part, ISelection selection )
+ {
+  IDebugTarget target = null;
+  if ( part.getSite().getId().equals( IDebugUIConstants.ID_DEBUG_VIEW ) )
+  {
+   if ( selection != null && selection instanceof IStructuredSelection )
+   {
+    Object element = ((IStructuredSelection)selection).getFirstElement();
+    if ( element != null && element instanceof IDebugElement )
+    {
+     IDebugTarget target1 = ((IDebugElement)element).getDebugTarget();
+     if ( target1 != null &&
+       ( target1 instanceof IJumpToLine || target1 instanceof IJumpToAddress ) )
+     {
+      target = target1;
+     }
+    }
+   }
+   setDebugTarget( target );
+   update();
+  }
+ }
+
+ /* (non-Javadoc)
+  * @see org.eclipse.ui.IActionDelegate#run(IAction)
+  */
+ public void run( IAction action )
+ {
+  if ( getTargetPart() != null && getTargetPart() instanceof ITextEditor )
+  {
+   IEditorInput input = ((ITextEditor)getTargetPart()).getEditorInput();
+   if ( input != null && input instanceof IFileEditorInput )
+   {
+    IFile file = ((IFileEditorInput)input).getFile();
+    if ( file != null )
+    {
+     ITextSelection selection = (ITextSelection)((ITextEditor)getTargetPart()).getSelectionProvider().getSelection();
+     int lineNumber = selection.getStartLine() + 1;
+     jumpToLine( file, lineNumber );
+    }
+   }
+   else if ( input != null && input instanceof IStorageEditorInput )
+   {
+    try
+    {
+     IStorage storage = ((IStorageEditorInput)input).getStorage();
+     if ( storage != null && storage.getAdapter( IDisassemblyStorage.class ) != null )
+     {
+      IDisassemblyStorage disassemblyStorage = (IDisassemblyStorage)storage.getAdapter( IDisassemblyStorage.class );
+      ITextSelection selection = (ITextSelection)((ITextEditor)getTargetPart()).getSelectionProvider().getSelection();
+      int lineNumber = selection.getStartLine();
+      long address = disassemblyStorage.getAddress( lineNumber );
+      if ( address > 0 )
+       jumpToAddress( address );
+     }
+    }
+    catch( CoreException e )
+    {
+    }
+   }
+  }
+ }
+
+ /* (non-Javadoc)
+  * @see org.eclipse.cdt.debug.internal.ui.actions.AbstractEditorActionDelegate#initializeDebugTarget()
+  */
+ protected void initializeDebugTarget()
+ {
+  setDebugTarget( null );
+  IAdaptable context = DebugUITools.getDebugContext();
+  if ( context != null && context instanceof IDebugElement )
+  {
+   IDebugTarget target = ((IDebugElement)context).getDebugTarget();
+   if ( target != null &&
+     ( target instanceof IJumpToLine || target instanceof IJumpToAddress ) )
+   {
+    setDebugTarget( target );
+   }   
+  }
+ }
+
+ protected void jumpToLine( IResource resource, int lineNumber )
+ {
+  IJumpToLine target = (IJumpToLine)getDebugTarget().getAdapter( IJumpToLine.class );
+  if ( target != null )
+  {
+   if ( !target.canJumpToLine( resource, lineNumber ) )
+   {
+    getTargetPart().getSite().getShell().getDisplay().beep();
+    return;
+   }
+   try
+   {
+    target.jumpToLine( resource, lineNumber );
+   }
+   catch( DebugException e )
+   {
+    CDebugUIPlugin.errorDialog( e.getMessage(), e );
+   }
+  }
+ }
+
+ protected void jumpToAddress( long address )
+ {
+  IJumpToAddress target = (IJumpToAddress)getDebugTarget().getAdapter( IJumpToAddress.class );
+  if ( target != null )
+  {
+   if ( !target.canJumpToAddress( address ) )
+   {
+    getTargetPart().getSite().getShell().getDisplay().beep();
+    return;
+   }
+   try
+   {
+    target.jumpToAddress( address );
+   }
+   catch( DebugException e )
+   {
+    CDebugUIPlugin.errorDialog( e.getMessage(), e );
+   }
+  }
+ }
+}
Index: src/org/eclipse/cdt/debug/internal/ui/actions/RunToLineActionDelegate.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/RunToLineActionDelegate.java,v
retrieving revision 1.5
diff -u -r1.5 RunToLineActionDelegate.java
--- src/org/eclipse/cdt/debug/internal/ui/actions/RunToLineActionDelegate.java 13 Jan 2003 22:28:48 -0000 1.5
+++ src/org/eclipse/cdt/debug/internal/ui/actions/RunToLineActionDelegate.java 5 Feb 2003 22:30:15 -0000
@@ -94,7 +94,8 @@
   if ( context != null && context instanceof IDebugElement )
   {
    IDebugTarget target = ((IDebugElement)context).getDebugTarget();
-   if ( target != null && target instanceof IRunToLine )
+   if ( target != null &&
+     ( target instanceof IRunToLine || target instanceof IRunToAddress ) )
    {
     setDebugTarget( target );
    }   
@@ -115,7 +116,8 @@
     if ( element != null && element instanceof IDebugElement )
     {
      IDebugTarget target1 = ((IDebugElement)element).getDebugTarget();
-     if ( target1 != null && target1 instanceof IRunToLine )
+     if ( target1 != null &&
+       ( target1 instanceof IRunToLine || target1 instanceof IRunToAddress ) )
      {
       target = target1;
      }

Back to the top