Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMikhail Khodjaiants2005-02-01 20:35:40 +0000
committerMikhail Khodjaiants2005-02-01 20:35:40 +0000
commit87d8aa1f41328a56e8016edcf836c79f13b8e784 (patch)
tree24b0b1548ab7e7719e503c993d35ca644f161879
parenta738590ac31cf97acfee6943316ceb820f87d756 (diff)
downloadorg.eclipse.cdt-87d8aa1f41328a56e8016edcf836c79f13b8e784.tar.gz
org.eclipse.cdt-87d8aa1f41328a56e8016edcf836c79f13b8e784.tar.xz
org.eclipse.cdt-87d8aa1f41328a56e8016edcf836c79f13b8e784.zip
Fix for bug 84165: Resurrect the "Add Watchpoint (C/C++)" Code.
-rw-r--r--debug/org.eclipse.cdt.debug.ui/ChangeLog6
-rw-r--r--debug/org.eclipse.cdt.debug.ui/plugin.properties2
-rw-r--r--debug/org.eclipse.cdt.debug.ui/plugin.xml8
-rw-r--r--debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/AddWatchpointActionDelegate.java247
4 files changed, 42 insertions, 221 deletions
diff --git a/debug/org.eclipse.cdt.debug.ui/ChangeLog b/debug/org.eclipse.cdt.debug.ui/ChangeLog
index 7999f37fad0..48e86bc28cf 100644
--- a/debug/org.eclipse.cdt.debug.ui/ChangeLog
+++ b/debug/org.eclipse.cdt.debug.ui/ChangeLog
@@ -1,3 +1,9 @@
+2005-02-01 Mikhail Khodjaiants
+ Fix for bug 84165: Resurrect the "Add Watchpoint (C/C++)" Code.
+ * plugin.properties
+ * plugin.xml
+ * AddWatchpointActionDelegate.java
+
2005-01-21 Mikhail Khodjaiants
Fix for bug 83437: Loading symbols should be run in the background.
* ActionMessages.properties
diff --git a/debug/org.eclipse.cdt.debug.ui/plugin.properties b/debug/org.eclipse.cdt.debug.ui/plugin.properties
index 0c528f4cb8c..3c3d0ab3d74 100644
--- a/debug/org.eclipse.cdt.debug.ui/plugin.properties
+++ b/debug/org.eclipse.cdt.debug.ui/plugin.properties
@@ -48,6 +48,8 @@ JumpToLineAction.label=Resume At Li&ne
GlobalJumpToLineAction.label=Resume At Li&ne (C/C++)
ShowFullPathsAction.label=Show Full &Paths
ShowFullPathsAction.tooltip=Show Full Paths
+AddWatchpoint.label=Add Watchpoint (C/C++)...
+AddWatchpoint.tooltip=Add Watchpoint (C/C++)
AddGlobalsAction.label=Add Global Variables...
AddGlobalsAction.tooltip=Add Global Variables
diff --git a/debug/org.eclipse.cdt.debug.ui/plugin.xml b/debug/org.eclipse.cdt.debug.ui/plugin.xml
index 981a2a7934b..1a73086904e 100644
--- a/debug/org.eclipse.cdt.debug.ui/plugin.xml
+++ b/debug/org.eclipse.cdt.debug.ui/plugin.xml
@@ -323,6 +323,14 @@
<viewerContribution
targetID="org.eclipse.debug.ui.BreakpointView"
id="org.eclipse.cdt.debug.ui.breakpointview.popupMenu">
+ <action
+ helpContextId="add_watchpoint_action_context"
+ label="%AddWatchpoint.label"
+ icon="icons/full/elcl16/watchpoint_co.gif"
+ class="org.eclipse.cdt.debug.internal.ui.actions.AddWatchpointActionDelegate"
+ tooltip="%AddWatchpoint.tooltip"
+ menubarPath="additions"
+ id="org.eclipse.cdt.debug.ui.addWatchpoint"/>
</viewerContribution>
<viewerContribution
targetID="#ASMEditorRulerContext"
diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/AddWatchpointActionDelegate.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/AddWatchpointActionDelegate.java
index d18ff3fbe2a..45060b90d44 100644
--- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/AddWatchpointActionDelegate.java
+++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/AddWatchpointActionDelegate.java
@@ -1,259 +1,64 @@
/**********************************************************************
* Copyright (c) 2004 QNX Software Systems and others.
- * All rights reserved. This program and the accompanying materials
+ * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
+ *
+ * Contributors:
* QNX Software Systems - Initial API and implementation
- ***********************************************************************/
-package org.eclipse.cdt.debug.internal.ui.actions;
+ ***********************************************************************/
+package org.eclipse.cdt.debug.internal.ui.actions;
import org.eclipse.cdt.debug.core.CDIDebugModel;
import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.ITextSelection;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionProvider;
import org.eclipse.jface.window.Window;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IFileEditorInput;
-import org.eclipse.ui.IPartListener;
-import org.eclipse.ui.IStorageEditorInput;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.IWorkbenchWindowActionDelegate;
+import org.eclipse.ui.IViewActionDelegate;
+import org.eclipse.ui.IViewPart;
import org.eclipse.ui.actions.ActionDelegate;
-import org.eclipse.ui.texteditor.ITextEditor;
-
+
/**
- * Action for adding a watchpoint at a selection in the active
- * C/C++ or assembly editor.
+ * A delegate for the "Add Watchpoint" action.
*/
-public class AddWatchpointActionDelegate extends ActionDelegate implements IWorkbenchWindowActionDelegate, IPartListener {
-
- private boolean fInitialized = false;
-
- private IAction fAction = null;
-
- private ITextEditor fTextEditor = null;
-
- private IWorkbenchWindow fWorkbenchWindow = null;
-
- private IResource fResource = null;
-
- private String fSourceHandle = ""; //$NON-NLS-1$
-
- /**
- * Constructor for AddWatchpointActionDelegate.
- */
- public AddWatchpointActionDelegate() {
- }
+public class AddWatchpointActionDelegate extends ActionDelegate implements IViewActionDelegate {
/* (non-Javadoc)
- * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#dispose()
+ * @see org.eclipse.ui.IViewActionDelegate#init(org.eclipse.ui.IViewPart)
*/
- public void dispose() {
+ public void init( IViewPart view ) {
+ // TODO Auto-generated method stub
}
/* (non-Javadoc)
- * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#init(IWorkbenchWindow)
- */
- public void init( IWorkbenchWindow window ) {
- setWorkbenchWindow( window );
- window.getPartService().addPartListener( this );
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.IActionDelegate#run(IAction)
+ * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
*/
public void run( IAction action ) {
- String expression = getSelectedExpression();
- AddWatchpointDialog dlg = new AddWatchpointDialog( CDebugUIPlugin.getActiveWorkbenchShell(), true, false, expression );
- if ( dlg.open() != Window.OK )
- return;
- if ( getTextEditor() != null ) {
- update();
- addWatchpoint( getTextEditor().getEditorInput(), dlg.getWriteAccess(), dlg.getReadAccess(), dlg.getExpression() );
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.IActionDelegate#selectionChanged(IAction, ISelection)
- */
- public void selectionChanged( IAction action, ISelection selection ) {
- if ( !fInitialized ) {
- setAction( action );
- if ( getWorkbenchWindow() != null ) {
- IWorkbenchPage page = getWorkbenchWindow().getActivePage();
- if ( page != null ) {
- IEditorPart part = page.getActiveEditor();
- if ( part instanceof ITextEditor ) {
- setTextEditor( (ITextEditor)part );
- }
- }
- }
- fInitialized = true;
+ AddWatchpointDialog dlg = new AddWatchpointDialog( CDebugUIPlugin.getActiveWorkbenchShell(), true, false, "" ); //$NON-NLS-1$
+ if ( dlg.open() == Window.OK ) {
+ addWatchpoint( dlg.getWriteAccess(), dlg.getReadAccess(), dlg.getExpression() );
}
}
- protected IAction getAction() {
- return fAction;
- }
-
- protected void setAction( IAction action ) {
- fAction = action;
- }
-
- protected IWorkbenchWindow getWorkbenchWindow() {
- return fWorkbenchWindow;
- }
-
- protected void setWorkbenchWindow( IWorkbenchWindow workbenchWindow ) {
- fWorkbenchWindow = workbenchWindow;
- }
-
- protected ITextEditor getTextEditor() {
- return fTextEditor;
- }
-
- protected void setTextEditor( ITextEditor editor ) {
- fTextEditor = editor;
- if ( fTextEditor != null ) {
- IEditorInput input = fTextEditor.getEditorInput();
- setSourceHandle( input );
- setResource( input );
- }
- setEnabledState( editor );
- }
-
- protected String getSelectedExpression() {
- if ( getTextEditor() != null ) {
- ISelectionProvider sp = getTextEditor().getSelectionProvider();
- if ( sp != null ) {
- ISelection s = sp.getSelection();
- if ( s instanceof ITextSelection ) {
- return ((ITextSelection)s).getText().trim();
- }
- }
- }
- return ""; //$NON-NLS-1$
- }
-
- protected void update( ISelection selection ) {
- setEnabledState( getTextEditor() );
- }
-
- protected void update() {
- IAction action = getAction();
- if ( action != null ) {
- action.setEnabled( getTextEditor() != null );
- }
- }
-
- protected void setEnabledState( ITextEditor editor ) {
- if ( getAction() != null ) {
- getAction().setEnabled( editor != null );
- }
- }
-
- protected IResource getResource() {
- return fResource;
- }
-
- protected void setResource( IEditorInput input ) {
- if ( input instanceof IFileEditorInput ) {
- fResource = ((IFileEditorInput)input).getFile().getProject();
- }
- else {
- fResource = ResourcesPlugin.getWorkspace().getRoot();
- }
- }
-
- protected void addWatchpoint( IEditorInput editorInput, boolean write, boolean read, String expression ) {
+ private void addWatchpoint( boolean write, boolean read, String expression ) {
if ( getResource() == null )
return;
- IDocument document = getTextEditor().getDocumentProvider().getDocument( editorInput );
- WatchpointExpressionVerifier wev = new WatchpointExpressionVerifier();
- if ( wev.isValidExpression( document, expression ) ) {
- try {
- CDIDebugModel.createWatchpoint( getSourceHandle(), getResource(), write, read, expression, true, 0, "", true ); //$NON-NLS-1$
- }
- catch( CoreException ce ) {
- CDebugUIPlugin.errorDialog( ActionMessages.getString( "AddWatchpointActionDelegate.0" ), ce ); //$NON-NLS-1$
- }
+ try {
+ CDIDebugModel.createWatchpoint( getSourceHandle(), getResource(), write, read, expression, true, 0, "", true ); //$NON-NLS-1$
}
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.IPartListener#partActivated(IWorkbenchPart)
- */
- public void partActivated( IWorkbenchPart part ) {
- if ( part instanceof ITextEditor ) {
- setTextEditor( (ITextEditor)part );
+ catch( CoreException ce ) {
+ CDebugUIPlugin.errorDialog( ActionMessages.getString( "AddWatchpointActionDelegate1.0" ), ce ); //$NON-NLS-1$
}
}
- /* (non-Javadoc)
- * @see org.eclipse.ui.IPartListener#partBroughtToTop(IWorkbenchPart)
- */
- public void partBroughtToTop( IWorkbenchPart part ) {
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.IPartListener#partClosed(IWorkbenchPart)
- */
- public void partClosed( IWorkbenchPart part ) {
- if ( part == getTextEditor() ) {
- setTextEditor( null );
- if ( getAction() != null ) {
- getAction().setEnabled( false );
- }
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.IPartListener#partDeactivated(IWorkbenchPart)
- */
- public void partDeactivated( IWorkbenchPart part ) {
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.IPartListener#partOpened(IWorkbenchPart)
- */
- public void partOpened( IWorkbenchPart part ) {
- if ( part instanceof ITextEditor ) {
- if ( getTextEditor() == null ) {
- setTextEditor( (ITextEditor)part );
- }
- }
+ private IResource getResource() {
+ return ResourcesPlugin.getWorkspace().getRoot();
}
private String getSourceHandle() {
- return fSourceHandle;
- }
-
- private void setSourceHandle( IEditorInput input ) {
- fSourceHandle = ""; //$NON-NLS-1$
- if ( input instanceof IFileEditorInput ) {
- fSourceHandle = ((IFileEditorInput)input).getFile().getFullPath().toOSString();
- }
- else if ( input instanceof IStorageEditorInput ) {
- try {
- IPath path = ((IStorageEditorInput)input).getStorage().getFullPath();
- if ( path != null )
- fSourceHandle = path.toOSString();
- }
- catch( CoreException e ) {
- }
- }
+ return ""; //$NON-NLS-1$
}
-} \ No newline at end of file
+}

Back to the top