Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMikhail Khodjaiants2004-05-28 16:31:36 -0400
committerMikhail Khodjaiants2004-05-28 16:31:36 -0400
commit764632f0c3a65c2f13b45146b9ae58de754acce4 (patch)
tree526abc52514ec5f73ad3985b7da748694d43205f
parentc17d871ba5cab13fddc917fa37120b74705ec55c (diff)
downloadorg.eclipse.cdt-764632f0c3a65c2f13b45146b9ae58de754acce4.tar.gz
org.eclipse.cdt-764632f0c3a65c2f13b45146b9ae58de754acce4.tar.xz
org.eclipse.cdt-764632f0c3a65c2f13b45146b9ae58de754acce4.zip
New implementation of the "Add Expression" editor action.
-rw-r--r--debug/org.eclipse.cdt.debug.ui/ChangeLog8
-rw-r--r--debug/org.eclipse.cdt.debug.ui/icons/full/dtool16/watch_exp.gifbin0 -> 94 bytes
-rw-r--r--debug/org.eclipse.cdt.debug.ui/icons/full/etool16/watch_exp.gifbin0 -> 125 bytes
-rw-r--r--debug/org.eclipse.cdt.debug.ui/plugin.xml123
-rw-r--r--debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/AddExpressionActionDelegate.java165
-rw-r--r--debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/AddExpressionEditorActionDelegate.java91
6 files changed, 103 insertions, 284 deletions
diff --git a/debug/org.eclipse.cdt.debug.ui/ChangeLog b/debug/org.eclipse.cdt.debug.ui/ChangeLog
index 2c9d74bac2..8c41fe8b76 100644
--- a/debug/org.eclipse.cdt.debug.ui/ChangeLog
+++ b/debug/org.eclipse.cdt.debug.ui/ChangeLog
@@ -1,4 +1,12 @@
2004-05-28 Mikhail Khodjaiants
+ New implementation of the "Add Expression" editor action.
+ * AddExpressionActionDelegate.java: removed
+ * AddExpressionEditorActionDelegate.java: new
+ * icons/full/dtool16/watch_exp.gif: new
+ * icons/full/etool16/watch_exp.gif: new
+ * plugin.xml
+
+2004-05-28 Mikhail Khodjaiants
Changed the error handling of the "Add Globals" and "Enable/Disable Variable" actions.
* AddGlobalsActionDelegate.java
* EnableVariablesActionDelegate.java
diff --git a/debug/org.eclipse.cdt.debug.ui/icons/full/dtool16/watch_exp.gif b/debug/org.eclipse.cdt.debug.ui/icons/full/dtool16/watch_exp.gif
new file mode 100644
index 0000000000..38f60cd7d2
--- /dev/null
+++ b/debug/org.eclipse.cdt.debug.ui/icons/full/dtool16/watch_exp.gif
Binary files differ
diff --git a/debug/org.eclipse.cdt.debug.ui/icons/full/etool16/watch_exp.gif b/debug/org.eclipse.cdt.debug.ui/icons/full/etool16/watch_exp.gif
new file mode 100644
index 0000000000..d37495a839
--- /dev/null
+++ b/debug/org.eclipse.cdt.debug.ui/icons/full/etool16/watch_exp.gif
Binary files differ
diff --git a/debug/org.eclipse.cdt.debug.ui/plugin.xml b/debug/org.eclipse.cdt.debug.ui/plugin.xml
index adc0a925b8..593fa38442 100644
--- a/debug/org.eclipse.cdt.debug.ui/plugin.xml
+++ b/debug/org.eclipse.cdt.debug.ui/plugin.xml
@@ -224,20 +224,6 @@
</enablement>
</action>
<action
- label="%GlobalAddExpressionAction.label"
- icon="icons/full/obj16/expression_obj.gif"
- helpContextId="add_expression_action_context"
- class="org.eclipse.cdt.debug.internal.ui.actions.AddExpressionActionDelegate"
- menubarPath="org.eclipse.ui.run/cExpressionGroup"
- id="org.eclipse.cdt.debug.internal.ui.actions.AddExpressionActionDelegate">
- <enablement>
- <pluginState
- value="activated"
- id="org.eclipse.cdt.debug.ui">
- </pluginState>
- </enablement>
- </action>
- <action
id="org.eclipse.cdt.debug.internal.ui.actions.SignalZeroWorkbenchActionDelegate"
hoverIcon="icons/full/clcl16/signal0_co.gif"
class="org.eclipse.cdt.debug.internal.ui.actions.SignalZeroWorkbenchActionDelegate"
@@ -344,9 +330,9 @@
id="org.eclipse.cdt.debug.ui.CEditorPopupActions">
<action
label="%AddExpressionAction.label"
- icon="icons/full/obj16/expression_obj.gif"
+ icon="icons/full/etool16/watch_exp.gif"
helpContextId="add_expression_action_context"
- class="org.eclipse.cdt.debug.internal.ui.actions.AddExpressionActionDelegate"
+ class="org.eclipse.cdt.debug.internal.ui.actions.AddExpressionEditorActionDelegate"
menubarPath="additions"
id="org.eclipse.cdt.debug.internal.ui.actions.AddExpressionActionDelegate">
<enablement>
@@ -467,9 +453,9 @@
id="org.eclipse.cdt.debug.ui.AsmEditorPopupActions">
<action
label="%AddExpressionAction.label"
- icon="icons/full/obj16/expression_obj.gif"
+ icon="icons/full/etool16/watch_exp.gif"
helpContextId="add_expression_action_context"
- class="org.eclipse.cdt.debug.internal.ui.actions.AddExpressionActionDelegate"
+ class="org.eclipse.cdt.debug.internal.ui.actions.AddExpressionEditorActionDelegate"
menubarPath="additions"
id="org.eclipse.cdt.debug.internal.ui.actions.AddExpressionActionDelegate">
<enablement>
@@ -547,107 +533,6 @@
</action>
</objectContribution>
<viewerContribution
- targetID="#DisassemblyEditorRulerContext"
- id="org.eclipse.cdt.debug.ui.DisassemblyEditorRulerActions">
-<!--
- <action
- label="%RunToLineAction.label"
- icon="icons/full/clcl16/runtoline_co.gif"
- helpContextId="run_to_line_action_context"
- class="org.eclipse.cdt.debug.internal.ui.actions.RunToLineRulerActionDelegate"
- menubarPath="debug"
- id="org.eclipse.cdt.debug.internal.ui.actions.RunToLineRulerActionDelegate">
- </action>
--->
- <action
- label="%BreakpointProperties.label"
- helpContextId="breakpoint_properties_action_context"
- class="org.eclipse.cdt.debug.internal.ui.actions.CBreakpointPropertiesRulerActionDelegate"
- menubarPath="debug"
- id="org.eclipse.cdt.debug.internal.ui.actions.CBreakpointPropertiesRulerActionDelegate">
- <enablement>
- <pluginState
- value="activated"
- id="org.eclipse.cdt.debug.ui">
- </pluginState>
- </enablement>
- </action>
- <action
- label="%EnableBreakpoint.label"
- helpContextId="enable_disable_breakpoint_action_context"
- class="org.eclipse.cdt.debug.internal.ui.actions.EnableDisableBreakpointRulerActionDelegate"
- menubarPath="debug"
- id="org.eclipse.cdt.debug.internal.ui.actions.EnableDisableBreakpointRulerActionDelegate">
- <enablement>
- <pluginState
- value="activated"
- id="org.eclipse.cdt.debug.ui">
- </pluginState>
- </enablement>
- </action>
- <action
- label="%AddBreakpoint.label"
- helpContextId="manage_breakpoint_action_context"
- class="org.eclipse.cdt.debug.internal.ui.actions.ManageBreakpointRulerActionDelegate"
- menubarPath="debug"
- id="org.eclipse.cdt.debug.internal.ui.actions.ManageBreakpointRulerActionDelegate">
- <enablement>
- <pluginState
- value="activated"
- id="org.eclipse.cdt.debug.ui">
- </pluginState>
- </enablement>
- </action>
- </viewerContribution>
- <viewerContribution
- targetID="#DisassemblyEditorContext"
- id="org.eclipse.cdt.debug.ui.DisassemblyEditorPopupActions">
- <action
- label="%AddExpressionAction.label"
- icon="icons/full/obj16/expression_obj.gif"
- helpContextId="add_expression_action_context"
- class="org.eclipse.cdt.debug.internal.ui.actions.AddExpressionActionDelegate"
- menubarPath="additions"
- id="org.eclipse.cdt.debug.internal.ui.actions.AddExpressionActionDelegate">
- <enablement>
- <pluginState
- value="activated"
- id="org.eclipse.cdt.debug.ui">
- </pluginState>
- </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"
- class="org.eclipse.cdt.debug.internal.ui.actions.RunToLineActionDelegate"
- menubarPath="additions"
- enablesFor="1"
- id="org.eclipse.cdt.debug.internal.ui.actions.RunToLineActionDelegate">
- <enablement>
- <pluginState
- value="activated"
- id="org.eclipse.cdt.debug.ui">
- </pluginState>
- </enablement>
- </action>
- </viewerContribution>
- <viewerContribution
targetID="org.eclipse.cdt.debug.ui.SharedLibrariesView"
id="org.eclipse.cdt.debug.ui.SharedLibrariesViewPopupActions">
</viewerContribution>
diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/AddExpressionActionDelegate.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/AddExpressionActionDelegate.java
deleted file mode 100644
index f9a269db5b..0000000000
--- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/AddExpressionActionDelegate.java
+++ /dev/null
@@ -1,165 +0,0 @@
-/*
- *(c) Copyright QNX Software Systems Ltd. 2002.
- * All Rights Reserved.
- *
- */
-package org.eclipse.cdt.debug.internal.ui.actions;
-
-import org.eclipse.cdt.debug.core.CDebugModel;
-import org.eclipse.cdt.debug.core.model.ICExpressionEvaluator;
-import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.debug.core.DebugException;
-import org.eclipse.debug.core.DebugPlugin;
-import org.eclipse.debug.core.model.IDebugElement;
-import org.eclipse.debug.core.model.IDebugTarget;
-import org.eclipse.debug.core.model.IExpression;
-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.jface.window.Window;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.IViewPart;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.PartInitException;
-
-/**
- *
- * Enter type comment.
- *
- * @since Sep 17, 2002
- */
-public class AddExpressionActionDelegate extends AbstractEditorActionDelegate
-{
- /**
- * Constructor for AddExpressionActionDelegate.
- */
- public AddExpressionActionDelegate()
- {
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.IActionDelegate#run(IAction)
- */
- public void run( IAction action )
- {
- String text = getSelectedText();
- ExpressionDialog dlg = new ExpressionDialog( getShell(), text );
- if ( dlg.open() != Window.OK )
- return;
- createExpression( dlg.getExpression() );
- }
-
- protected String getSelectedText()
- {
- ISelection selection = getTargetSelection();
- if ( selection != null && selection instanceof ITextSelection )
- {
- return ((ITextSelection)selection).getText().trim();
- }
- return ""; //$NON-NLS-1$
- }
-
- protected Shell getShell()
- {
- return ( getTargetPart() != null ) ?
- getTargetPart().getSite().getShell() : CDebugUIPlugin.getActiveWorkbenchShell();
- }
-
- private void createExpression( final String text )
- {
- final Display display = CDebugUIPlugin.getStandardDisplay();
- if ( display.isDisposed() )
- {
- return;
- }
- display.asyncExec( new Runnable()
- {
- public void run()
- {
- try
- {
- IExpression expression = CDebugModel.createExpression( getDebugTarget(), text );
- DebugPlugin.getDefault().getExpressionManager().addExpression( expression );
- showExpressionView();
- }
- catch( DebugException e )
- {
- CDebugUIPlugin.errorDialog( CDebugUIPlugin.getResourceString("internal.ui.actions.AddExpressionActionDelegate.Evaluation_of_expression_failed"), e ); //$NON-NLS-1$
- }
- }
- } );
- }
-
- /**
- * @see org.eclipse.ui.ISelectionListener#selectionChanged(IWorkbenchPart, ISelection)
- */
- public void selectionChanged( IWorkbenchPart part, ISelection selection )
- {
- IDebugTarget target = null;
- if ( part != null && part.getSite().getId().equals( IDebugUIConstants.ID_DEBUG_VIEW ) )
- {
- if ( selection instanceof IStructuredSelection )
- {
- Object element = ((IStructuredSelection)selection).getFirstElement();
- if ( element != null && element instanceof IDebugElement )
- {
- IDebugTarget target1 = ((IDebugElement)element).getDebugTarget();
- if ( target1 != null && target1 instanceof ICExpressionEvaluator )
- {
- target = target1;
- }
- }
- }
- setDebugTarget( target );
- update();
- }
- }
-
- 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 ICExpressionEvaluator )
- {
- setDebugTarget( target );
- }
- }
- }
-
- /**
- * Make the expression view visible or open one if required.
- *
- */
- protected void showExpressionView()
- {
- IWorkbenchPage page = CDebugUIPlugin.getActivePage();
- if ( page != null )
- {
- IViewPart part = page.findView( IDebugUIConstants.ID_EXPRESSION_VIEW );
- if ( part == null )
- {
- try
- {
- page.showView( IDebugUIConstants.ID_EXPRESSION_VIEW );
- }
- catch( PartInitException e )
- {
- CDebugUIPlugin.log( e.getStatus() );
- }
- }
- else
- {
- page.bringToTop( part );
- }
- }
- }
-}
diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/AddExpressionEditorActionDelegate.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/AddExpressionEditorActionDelegate.java
new file mode 100644
index 0000000000..b9682692c4
--- /dev/null
+++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/AddExpressionEditorActionDelegate.java
@@ -0,0 +1,91 @@
+/**********************************************************************
+ * Copyright (c) 2004 QNX Software Systems and others.
+ * 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:
+ * QNX Software Systems - Initial API and implementation
+ ***********************************************************************/
+package org.eclipse.cdt.debug.internal.ui.actions;
+
+import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.core.model.IDebugElement;
+import org.eclipse.debug.core.model.IWatchExpression;
+import org.eclipse.debug.ui.DebugUITools;
+import org.eclipse.jface.action.IAction;
+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.swt.widgets.Shell;
+import org.eclipse.ui.IEditorActionDelegate;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.actions.ActionDelegate;
+
+
+/**
+ * The "Add Expression" action contribution to editors.
+ */
+public class AddExpressionEditorActionDelegate extends ActionDelegate implements IEditorActionDelegate {
+
+ private IEditorPart fEditorPart;
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IEditorActionDelegate#setActiveEditor(org.eclipse.jface.action.IAction, org.eclipse.ui.IEditorPart)
+ */
+ public void setActiveEditor( IAction action, IEditorPart targetEditor ) {
+ setEditorPart( targetEditor );
+ }
+
+ private IEditorPart getEditorPart() {
+ return fEditorPart;
+ }
+
+ private void setEditorPart( IEditorPart editorPart ) {
+ fEditorPart = editorPart;
+ }
+
+ public void run( IAction action ) {
+ String text = getSelectedText();
+ ExpressionDialog dlg = new ExpressionDialog( getShell(), text );
+ if ( dlg.open() != Window.OK )
+ return;
+ createExpression( dlg.getExpression() );
+ }
+
+ private String getSelectedText() {
+ ISelection selection = getTargetSelection();
+ if ( selection != null && selection instanceof ITextSelection ) {
+ return ((ITextSelection)selection).getText().trim();
+ }
+ return ""; //$NON-NLS-1$
+ }
+
+ protected ISelection getTargetSelection() {
+ IWorkbenchPart part = getEditorPart();
+ if ( part != null ) {
+ ISelectionProvider provider = part.getSite().getSelectionProvider();
+ if ( provider != null ) {
+ return provider.getSelection();
+ }
+ }
+ return null;
+ }
+
+ private void createExpression( String text ) {
+ IWatchExpression watchExpression= DebugPlugin.getDefault().getExpressionManager().newWatchExpression( text );
+ DebugPlugin.getDefault().getExpressionManager().addExpression( watchExpression );
+ IAdaptable context = DebugUITools.getDebugContext();
+ if ( context instanceof IDebugElement )
+ watchExpression.setExpressionContext( (IDebugElement)context );
+ }
+
+ protected Shell getShell() {
+ return ( getEditorPart() != null ) ? getEditorPart().getSite().getShell() : CDebugUIPlugin.getActiveWorkbenchShell();
+ }
+}

Back to the top