Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDarin Wright2008-01-23 17:33:43 +0000
committerDarin Wright2008-01-23 17:33:43 +0000
commitbd7938c116d41fe636bf75a4b0918e18d24d5ac2 (patch)
tree6f0e1629c47187c65106c1ae9f7bd11d7b56f4a4 /org.eclipse.debug.ui
parent2b262a1db519bc3d12fb9808665b74db008d52f4 (diff)
downloadeclipse.platform.debug-bd7938c116d41fe636bf75a4b0918e18d24d5ac2.tar.gz
eclipse.platform.debug-bd7938c116d41fe636bf75a4b0918e18d24d5ac2.tar.xz
eclipse.platform.debug-bd7938c116d41fe636bf75a4b0918e18d24d5ac2.zip
Bug 209883 - Expression view actions use getAdapter() to work with non-standard debug models
Diffstat (limited to 'org.eclipse.debug.ui')
-rw-r--r--org.eclipse.debug.ui/plugin.xml56
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/expressions/EditWatchExpressionAction.java9
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/expressions/EnableWatchExpressionAction.java77
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/expressions/ReevaluateWatchExpressionAction.java43
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/expressions/RemoveExpressionAction.java9
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/expressions/WatchAction.java108
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/expressions/WatchExpressionAction.java97
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/expression/ExpressionDropAdapter.java197
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/IWatchExpressionFactoryAdapter2.java53
9 files changed, 488 insertions, 161 deletions
diff --git a/org.eclipse.debug.ui/plugin.xml b/org.eclipse.debug.ui/plugin.xml
index 82a78e141..f52220fd2 100644
--- a/org.eclipse.debug.ui/plugin.xml
+++ b/org.eclipse.debug.ui/plugin.xml
@@ -937,15 +937,16 @@
helpContextId="console_show_preferences_action_context"/>
</viewerContribution>
<!-- Watch expression actions -->
- <objectContribution
- objectClass="org.eclipse.debug.core.model.IExpression"
+ <viewerContribution
+ targetID="org.eclipse.debug.ui.ExpressionView"
id="org.eclipse.debug.ui.ExpressionActions">
<visibility>
- <not>
- <objectClass
- name="org.eclipse.debug.core.model.IWatchExpression">
- </objectClass>
- </not>
+ <and>
+ <objectClass name="org.eclipse.debug.core.model.IExpression"/>
+ <not>
+ <objectClass name="org.eclipse.debug.core.model.IWatchExpression"/>
+ </not>
+ </and>
</visibility>
<action
label="%convertToWatchExpressionAction.label"
@@ -956,10 +957,10 @@
enablesFor="*"
id="org.eclipse.debug.ui.actions.ConvertToWatchExpression">
</action>
- </objectContribution>
- <objectContribution
- objectClass="org.eclipse.debug.core.model.IVariable"
- id="org.eclipse.debug.ui.WatchActions">
+ </viewerContribution>
+ <viewerContribution
+ targetID="org.eclipse.debug.ui.VariableView"
+ id="org.eclipse.debug.ui.variablesView.popupMenu.watch">
<action
label="%Watch.label"
icon="$nl$/icons/full/etool16/watch_exp.gif"
@@ -969,9 +970,22 @@
enablesFor="+"
id="org.eclipse.jdt.debug.ui.actions.WatchAction">
</action>
- </objectContribution>
- <objectContribution
- objectClass="org.eclipse.debug.core.model.IWatchExpression"
+ </viewerContribution>
+ <viewerContribution
+ targetID="org.eclipse.debug.ui.RegisterView"
+ id="org.eclipse.debug.ui.registerView.popupMenu.watch">
+ <action
+ label="%Watch.label"
+ icon="$nl$/icons/full/etool16/watch_exp.gif"
+ helpContextId="variable_watch_action_context"
+ class="org.eclipse.debug.internal.ui.actions.expressions.WatchAction"
+ menubarPath="openOnGroup"
+ enablesFor="+"
+ id="org.eclipse.jdt.debug.ui.actions.WatchAction">
+ </action>
+ </viewerContribution>
+ <viewerContribution
+ targetID="org.eclipse.debug.ui.ExpressionView"
id="org.eclipse.debug.ui.WatchExpressionActions">
<action
label="%editWatchExpressionAction.label"
@@ -982,9 +996,9 @@
enablesFor="1"
id="org.eclipse.debug.ui.watchExpressionActions.EditWatchExpression">
</action>
- </objectContribution>
- <objectContribution
- objectClass="org.eclipse.debug.core.model.IWatchExpression"
+ </viewerContribution>
+ <viewerContribution
+ targetID="org.eclipse.debug.ui.ExpressionView"
id="org.eclipse.debug.ui.WatchExpressionActions">
<action
label="%enableWatchExpressionAction.label"
@@ -995,9 +1009,9 @@
enablesFor="1"
id="org.eclipse.debug.ui.watchExpressionActions.EnableWatchExpression">
</action>
- </objectContribution>
- <objectContribution
- objectClass="org.eclipse.debug.core.model.IWatchExpression"
+ </viewerContribution>
+ <viewerContribution
+ targetID="org.eclipse.debug.ui.ExpressionView"
id="org.eclipse.debug.ui.WatchExpressionActions">
<action
label="%disableWatchExpressionAction.label"
@@ -1008,7 +1022,7 @@
enablesFor="1"
id="org.eclipse.debug.ui.watchExpressionActions.DisableWatchExpression">
</action>
- </objectContribution>
+ </viewerContribution>
<objectContribution
objectClass="org.eclipse.debug.core.model.IWatchExpression"
id="org.eclipse.debug.WatchExpressionActions">
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/expressions/EditWatchExpressionAction.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/expressions/EditWatchExpressionAction.java
index 715c6db2e..c858ca31c 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/expressions/EditWatchExpressionAction.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/expressions/EditWatchExpressionAction.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2005 IBM Corporation and others.
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -7,6 +7,7 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Wind River Systems - integration with non-standard debug models (Bug 209883)
*******************************************************************************/
package org.eclipse.debug.internal.ui.actions.expressions;
@@ -14,6 +15,7 @@ package org.eclipse.debug.internal.ui.actions.expressions;
import org.eclipse.debug.core.model.IWatchExpression;
import org.eclipse.debug.internal.ui.DebugUIPlugin;
import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.viewers.ISelection;
/**
* Open the watch expression dialog for the select watch expression.
@@ -25,9 +27,12 @@ public class EditWatchExpressionAction extends WatchExpressionAction {
* @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
*/
public void run(IAction action) {
- IWatchExpression watchExpression= (IWatchExpression)getCurrentSelection().getFirstElement();
+ IWatchExpression watchExpression= getSelectedExpressions()[0];
// display the watch expression dialog for the currently selected watch expression
new WatchExpressionDialog(DebugUIPlugin.getShell(), watchExpression, true).open();
}
+ public void selectionChanged(IAction action, ISelection sel) {
+ action.setEnabled(getSelectedExpressions().length == 1);
+ }
}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/expressions/EnableWatchExpressionAction.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/expressions/EnableWatchExpressionAction.java
index d71ea695b..d398287dc 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/expressions/EnableWatchExpressionAction.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/expressions/EnableWatchExpressionAction.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2005 IBM Corporation and others.
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -7,32 +7,39 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Wind River Systems - integration with non-standard debug models (Bug 209883)
*******************************************************************************/
package org.eclipse.debug.internal.ui.actions.expressions;
import java.util.Iterator;
+import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.debug.core.DebugEvent;
import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.core.IDebugEventSetListener;
import org.eclipse.debug.core.model.IWatchExpression;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.ui.IObjectActionDelegate;
-import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.ui.IActionDelegate2;
+import org.eclipse.ui.IViewActionDelegate;
+import org.eclipse.ui.IViewPart;
/**
*
*/
-public class EnableWatchExpressionAction implements IObjectActionDelegate {
+public class EnableWatchExpressionAction implements IViewActionDelegate, IActionDelegate2, IDebugEventSetListener {
private ISelection fSelection;
+ private IAction fAction;
protected boolean fEnable= true;
- /**
- * @see org.eclipse.ui.IObjectActionDelegate#setActivePart(org.eclipse.jface.action.IAction, org.eclipse.ui.IWorkbenchPart)
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IViewActionDelegate#init(org.eclipse.ui.IViewPart)
*/
- public void setActivePart(IAction action, IWorkbenchPart targetPart) {
+ public void init(IViewPart view) {
+ DebugPlugin.getDefault().addDebugEventListener(this);
}
/**
@@ -43,9 +50,11 @@ public class EnableWatchExpressionAction implements IObjectActionDelegate {
Iterator iter= ((IStructuredSelection) fSelection).iterator();
IWatchExpression expression;
while (iter.hasNext()) {
- expression= ((IWatchExpression) iter.next());
- expression.setEnabled(fEnable);
- fireWatchExpressionChanged(expression);
+ expression= getWatchExpression(iter.next());
+ if (expression != null) {
+ expression.setEnabled(fEnable);
+ fireWatchExpressionChanged(expression);
+ }
}
} else if (fSelection instanceof IWatchExpression) {
IWatchExpression expression= ((IWatchExpression) fSelection);
@@ -70,8 +79,8 @@ public class EnableWatchExpressionAction implements IObjectActionDelegate {
boolean enabled= false;
Iterator iter= ((IStructuredSelection) selection).iterator();
while (iter.hasNext()) {
- IWatchExpression expression = (IWatchExpression) iter.next();
- if (expression.isEnabled() != fEnable) {
+ IWatchExpression expression = getWatchExpression(iter.next());
+ if (expression != null && expression.isEnabled() != fEnable) {
enabled= true;
break;
}
@@ -84,4 +93,48 @@ public class EnableWatchExpressionAction implements IObjectActionDelegate {
}
}
+ private IWatchExpression getWatchExpression(Object element) {
+ if (element instanceof IWatchExpression) {
+ return (IWatchExpression)element;
+ } else if (element instanceof IAdaptable) {
+ return (IWatchExpression)((IAdaptable)element).getAdapter(IWatchExpression.class);
+ }
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IActionDelegate2#dispose()
+ */
+ public void dispose() {
+ DebugPlugin.getDefault().removeDebugEventListener(this);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IActionDelegate2#init(org.eclipse.jface.action.IAction)
+ */
+ public void init(IAction action) {
+ fAction = action;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IActionDelegate2#runWithEvent(org.eclipse.jface.action.IAction, org.eclipse.swt.widgets.Event)
+ */
+ public void runWithEvent(IAction action, Event event) {
+ run(action);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.IDebugEventSetListener#handleDebugEvents(org.eclipse.debug.core.DebugEvent[])
+ */
+ public void handleDebugEvents(DebugEvent[] events) {
+ for (int i = 0; i < events.length; i++) {
+ DebugEvent event = events[i];
+ if (event.getSource() instanceof IWatchExpression) {
+ if (event.getKind() == DebugEvent.CHANGE) {
+ selectionChanged(fAction, fSelection);
+ }
+ }
+ }
+
+ }
}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/expressions/ReevaluateWatchExpressionAction.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/expressions/ReevaluateWatchExpressionAction.java
index 3f2ac4a43..c768367ad 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/expressions/ReevaluateWatchExpressionAction.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/expressions/ReevaluateWatchExpressionAction.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2005 IBM Corporation and others.
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -7,22 +7,61 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Wind River Systems - integration with non-standard debug models (Bug 209883)
*******************************************************************************/
package org.eclipse.debug.internal.ui.actions.expressions;
import java.util.Iterator;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.debug.core.ILaunch;
import org.eclipse.debug.core.model.IDebugElement;
import org.eclipse.debug.core.model.IWatchExpression;
+import org.eclipse.debug.internal.ui.DebugUIPlugin;
+import org.eclipse.debug.ui.DebugUITools;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.ui.IObjectActionDelegate;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchPart;
/**
* Ask to re-evaluate one or more watch expressions in the context of the
* currently selected thread.
*/
-public class ReevaluateWatchExpressionAction extends WatchExpressionAction {
+public class ReevaluateWatchExpressionAction implements IObjectActionDelegate {
+
+ public void setActivePart(IAction action, IWorkbenchPart targetPart) {
+ // TODO Auto-generated method stub
+
+ }
+
+ /**
+ * Finds the currently selected context in the UI.
+ */
+ protected IDebugElement getContext() {
+ IAdaptable object = DebugUITools.getDebugContext();
+ IDebugElement context = null;
+ if (object instanceof IDebugElement) {
+ context = (IDebugElement) object;
+ } else if (object instanceof ILaunch) {
+ context = ((ILaunch) object).getDebugTarget();
+ }
+ return context;
+ }
+
+ protected IStructuredSelection getCurrentSelection() {
+ IWorkbenchPage page = DebugUIPlugin.getActiveWorkbenchWindow().getActivePage();
+ if (page != null) {
+ ISelection selection = page.getSelection();
+ if (selection instanceof IStructuredSelection) {
+ return (IStructuredSelection) selection;
+ }
+ }
+ return null;
+ }
/**
* @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/expressions/RemoveExpressionAction.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/expressions/RemoveExpressionAction.java
index 4382ccbae..8ea98abc9 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/expressions/RemoveExpressionAction.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/expressions/RemoveExpressionAction.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -7,6 +7,7 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Wind River Systems - integration with non-standard debug models (Bug 209883)
*******************************************************************************/
package org.eclipse.debug.internal.ui.actions.expressions;
@@ -14,6 +15,7 @@ package org.eclipse.debug.internal.ui.actions.expressions;
import java.util.ArrayList;
import java.util.List;
+import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
@@ -37,6 +39,11 @@ public class RemoveExpressionAction extends AbstractRemoveActionDelegate {
Object segment = path.getFirstSegment();
if (segment instanceof IExpression) {
expressions.add(segment);
+ } else if (segment instanceof IAdaptable) {
+ IExpression expression = (IExpression)((IAdaptable)segment).getAdapter(IExpression.class);
+ if (expression != null) {
+ expressions.add(expression);
+ }
}
}
return (IExpression[]) expressions.toArray(new IExpression[expressions.size()]);
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/expressions/WatchAction.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/expressions/WatchAction.java
index b04c83043..ed1fe5427 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/expressions/WatchAction.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/expressions/WatchAction.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -7,15 +7,16 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Wind River Systems - integration with non-standard debug models (Bug 209883)
*******************************************************************************/
package org.eclipse.debug.internal.ui.actions.expressions;
import java.util.Iterator;
+import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.debug.core.DebugPlugin;
-import org.eclipse.debug.core.IExpressionManager;
import org.eclipse.debug.core.ILaunch;
import org.eclipse.debug.core.model.IDebugElement;
import org.eclipse.debug.core.model.IVariable;
@@ -26,27 +27,24 @@ import org.eclipse.debug.internal.ui.views.variables.IndexedVariablePartition;
import org.eclipse.debug.ui.DebugUITools;
import org.eclipse.debug.ui.IDebugUIConstants;
import org.eclipse.debug.ui.actions.IWatchExpressionFactoryAdapter;
+import org.eclipse.debug.ui.actions.IWatchExpressionFactoryAdapter2;
import org.eclipse.debug.ui.actions.IWatchExpressionFactoryAdapterExtension;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.ui.IObjectActionDelegate;
+import org.eclipse.ui.IViewActionDelegate;
import org.eclipse.ui.IViewPart;
import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.PartInitException;
/**
*
*/
-public class WatchAction implements IObjectActionDelegate {
+public class WatchAction implements IViewActionDelegate {
private IStructuredSelection fSelection;
- /**
- * @see org.eclipse.ui.IObjectActionDelegate#setActivePart(org.eclipse.jface.action.IAction, org.eclipse.ui.IWorkbenchPart)
- */
- public void setActivePart(IAction action, IWorkbenchPart targetPart) {
+ public void init(IViewPart view) {
}
/**
@@ -58,8 +56,8 @@ public class WatchAction implements IObjectActionDelegate {
}
Iterator iter = fSelection.iterator();
while (iter.hasNext()) {
- IVariable variable = (IVariable) iter.next();
- createExpression(variable);
+ Object element = iter.next();
+ createExpression(element);
}
}
@@ -77,19 +75,33 @@ public class WatchAction implements IObjectActionDelegate {
}
- private void createExpression(IVariable variable) {
- IWatchExpression expression;
- IWatchExpressionFactoryAdapter factory = getFactory(variable);
- try {
- String exp = variable.getName();
- if (factory != null) {
- exp = factory.createWatchExpression(variable);
- }
- expression = DebugPlugin.getDefault().getExpressionManager().newWatchExpression(exp);
- } catch (CoreException e) {
- DebugUIPlugin.errorDialog(DebugUIPlugin.getShell(), ActionMessages.WatchAction_0, ActionMessages.WatchAction_1, e); //
- return;
- }
+ private void createExpression(Object element) {
+ String expressionString;
+ try {
+ if (element instanceof IVariable) {
+ IVariable variable = (IVariable)element;
+ IWatchExpressionFactoryAdapter factory = getFactory(variable);
+ expressionString = variable.getName();
+ if (factory != null) {
+ expressionString = factory.createWatchExpression(variable);
+ }
+ } else {
+ IWatchExpressionFactoryAdapter2 factory2 = getFactory2(element);
+ if (factory2 != null) {
+ expressionString = factory2.createWatchExpression(element);
+ } else {
+ // Action should not have been enabled
+ Assert.isTrue(false);
+ return;
+ }
+ }
+ } catch (CoreException e) {
+ DebugUIPlugin.errorDialog(DebugUIPlugin.getShell(), ActionMessages.WatchAction_0, ActionMessages.WatchAction_1, e); //
+ return;
+ }
+
+ IWatchExpression expression;
+ expression = DebugPlugin.getDefault().getExpressionManager().newWatchExpression(expressionString);
DebugPlugin.getDefault().getExpressionManager().addExpression(expression);
IAdaptable object = DebugUITools.getDebugContext();
IDebugElement context = null;
@@ -112,20 +124,19 @@ public class WatchAction implements IObjectActionDelegate {
if (selection instanceof IStructuredSelection) {
fSelection = (IStructuredSelection) selection;
size = fSelection.size();
- IExpressionManager manager = DebugPlugin.getDefault().getExpressionManager();
Iterator iterator = fSelection.iterator();
while (iterator.hasNext()) {
- IVariable variable = (IVariable) iterator.next();
- if (variable instanceof IndexedVariablePartition) {
+ Object element = iterator.next();
+ if (element instanceof IndexedVariablePartition) {
break;
- } else if (manager.hasWatchExpressionDelegate(variable.getModelIdentifier()) && isFactoryEnabled(variable)) {
+ } else if (isFactoryEnabled(element)) {
enabled++;
} else {
break;
}
}
}
- action.setEnabled(enabled == size);
+ action.setEnabled(enabled > 0 && enabled == size);
}
/**
@@ -134,13 +145,25 @@ public class WatchAction implements IObjectActionDelegate {
* @param variable
* @return whether the factory is enabled
*/
- private boolean isFactoryEnabled(IVariable variable) {
- IWatchExpressionFactoryAdapter factory = getFactory(variable);
- if (factory instanceof IWatchExpressionFactoryAdapterExtension) {
- IWatchExpressionFactoryAdapterExtension ext = (IWatchExpressionFactoryAdapterExtension) factory;
- return ext.canCreateWatchExpression(variable);
- }
- return true;
+ private boolean isFactoryEnabled(Object element) {
+
+ if (element instanceof IVariable) {
+ IVariable variable = (IVariable)element;
+ DebugPlugin.getDefault().getExpressionManager().hasWatchExpressionDelegate(variable.getModelIdentifier());
+
+ IWatchExpressionFactoryAdapter factory = getFactory(variable);
+ if (factory instanceof IWatchExpressionFactoryAdapterExtension) {
+ IWatchExpressionFactoryAdapterExtension ext = (IWatchExpressionFactoryAdapterExtension) factory;
+ return ext.canCreateWatchExpression(variable);
+ }
+ return true;
+ } else {
+ IWatchExpressionFactoryAdapter2 factory2 = getFactory2(element);
+ if (factory2 != null) {
+ return factory2.canCreateWatchExpression(element);
+ }
+ return false;
+ }
}
/**
@@ -152,4 +175,17 @@ public class WatchAction implements IObjectActionDelegate {
private IWatchExpressionFactoryAdapter getFactory(IVariable variable) {
return (IWatchExpressionFactoryAdapter) variable.getAdapter(IWatchExpressionFactoryAdapter.class);
}
+
+ /**
+ * Returns the factory adapter for the given variable or <code>null</code> if none.
+ *
+ * @param variable
+ * @return factory or <code>null</code>
+ */
+ private IWatchExpressionFactoryAdapter2 getFactory2(Object element) {
+ if (element instanceof IAdaptable) {
+ return (IWatchExpressionFactoryAdapter2)((IAdaptable)element).getAdapter(IWatchExpressionFactoryAdapter2.class);
+ }
+ return null;
+ }
}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/expressions/WatchExpressionAction.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/expressions/WatchExpressionAction.java
index 20bf6dc58..d835bfb4d 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/expressions/WatchExpressionAction.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/expressions/WatchExpressionAction.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2005 IBM Corporation and others.
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -7,12 +7,18 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Wind River Systems - integration with non-standard debug models (Bug 209883)
*******************************************************************************/
package org.eclipse.debug.internal.ui.actions.expressions;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.debug.core.ILaunch;
import org.eclipse.debug.core.model.IDebugElement;
+import org.eclipse.debug.core.model.IWatchExpression;
import org.eclipse.debug.internal.ui.DebugUIPlugin;
import org.eclipse.debug.ui.DebugUITools;
import org.eclipse.jface.action.IAction;
@@ -20,9 +26,7 @@ import org.eclipse.jface.action.IStatusLineManager;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.ui.IActionDelegate2;
-import org.eclipse.ui.IObjectActionDelegate;
+import org.eclipse.ui.IViewActionDelegate;
import org.eclipse.ui.IViewPart;
import org.eclipse.ui.IViewSite;
import org.eclipse.ui.IWorkbenchPage;
@@ -32,28 +36,55 @@ import org.eclipse.ui.IWorkbenchPart;
* Generic abstract class for the actions associated to the java watch
* expressions.
*/
-public abstract class WatchExpressionAction implements IObjectActionDelegate, IActionDelegate2 {
+public abstract class WatchExpressionAction implements IViewActionDelegate {
IWorkbenchPart fPart = null;
- /**
- * Finds the currently selected context in the UI.
- */
- protected IDebugElement getContext() {
- IAdaptable object = DebugUITools.getDebugContext();
- IDebugElement context = null;
- if (object instanceof IDebugElement) {
- context = (IDebugElement) object;
- } else if (object instanceof ILaunch) {
- context = ((ILaunch) object).getDebugTarget();
- }
- return context;
- }
- /**
- * @see IObjectActionDelegate#setActivePart(IAction, IWorkbenchPart)
- */
- public void setActivePart(IAction action, IWorkbenchPart targetPart) {
- fPart = targetPart;
+
+ private static IWatchExpression[] EMPTY_EXPRESSION_ARRAY = new IWatchExpression[0];
+
+ public void init(IViewPart view) {
+ fPart = view;
}
+ /**
+ * Finds the currently selected context in the UI.
+ */
+ protected IDebugElement getContext() {
+ IAdaptable object = DebugUITools.getDebugContext();
+ IDebugElement context = null;
+ if (object instanceof IDebugElement) {
+ context = (IDebugElement) object;
+ } else if (object instanceof ILaunch) {
+ context = ((ILaunch) object).getDebugTarget();
+ }
+ return context;
+ }
+
+ protected IWatchExpression[] getSelectedExpressions() {
+ List list = new LinkedList();
+ IStructuredSelection currentSelection = getCurrentSelection();
+ if (currentSelection == null) {
+ return EMPTY_EXPRESSION_ARRAY;
+ }
+
+ for (Iterator iter= currentSelection.iterator(); iter.hasNext();) {
+ Object element = iter.next();
+ if (element instanceof IWatchExpression) {
+ list.add(element);
+ } else if (element instanceof IAdaptable) {
+ IWatchExpression expr = (IWatchExpression)((IAdaptable)element).getAdapter(IWatchExpression.class);
+ if (expr != null) {
+ list.add(expr);
+ } else {
+ return EMPTY_EXPRESSION_ARRAY;
+ }
+ } else {
+ return EMPTY_EXPRESSION_ARRAY;
+ }
+ }
+
+ return (IWatchExpression[])list.toArray(new IWatchExpression[list.size()]);
+ }
+
/**
* @see IActionDelegate#selectionChanged(IAction, ISelection)
*/
@@ -84,24 +115,4 @@ public abstract class WatchExpressionAction implements IObjectActionDelegate, IA
Display.getCurrent().beep();
}
}
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.IActionDelegate2#dispose()
- */
- public void dispose() {
- fPart = null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.IActionDelegate2#init(org.eclipse.jface.action.IAction)
- */
- public void init(IAction action) {
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.IActionDelegate2#runWithEvent(org.eclipse.jface.action.IAction, org.eclipse.swt.widgets.Event)
- */
- public void runWithEvent(IAction action, Event event) {
- run(action);
- }
}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/expression/ExpressionDropAdapter.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/expression/ExpressionDropAdapter.java
index 3c60272c4..30f775724 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/expression/ExpressionDropAdapter.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/expression/ExpressionDropAdapter.java
@@ -1,13 +1,14 @@
/*******************************************************************************
- * Copyright (c) 2007 IBM Corporation and others.
+ * Copyright (c) 2007, 2008 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * Wind River - Pawel Piech - Initial Implementation - Drag/Drop to Expressions View (Bug 184057)
+ * Wind River Systems - Pawel Piech - Initial Implementation - Drag/Drop to Expressions View (Bug 184057), Integration with non-standard debug models (Bug 209883)
* IBM Corporation - further implementation and documentation
+ * Wind River Systems - integration with non-standard debug models
*******************************************************************************/
package org.eclipse.debug.internal.ui.views.expression;
@@ -32,6 +33,7 @@ import org.eclipse.debug.internal.ui.viewers.model.provisional.TreeModelViewer;
import org.eclipse.debug.internal.ui.views.variables.IndexedVariablePartition;
import org.eclipse.debug.ui.DebugUITools;
import org.eclipse.debug.ui.actions.IWatchExpressionFactoryAdapter;
+import org.eclipse.debug.ui.actions.IWatchExpressionFactoryAdapter2;
import org.eclipse.debug.ui.actions.IWatchExpressionFactoryAdapterExtension;
import org.eclipse.jface.util.LocalSelectionTransfer;
import org.eclipse.jface.viewers.IStructuredSelection;
@@ -59,6 +61,7 @@ public class ExpressionDropAdapter extends ViewerDropAdapter {
private static final int DROP_TYPE_DEFAULT = 0;
private static final int DROP_TYPE_VARIABLE = 1;
private static final int DROP_TYPE_EXPRESSION = 2;
+ private static final int DROP_TYPE_WATCH_ADAPTABLE_ELEMENT = 3;
/**
* Constructor takes the viewer this drop adapter applies to.
@@ -79,15 +82,20 @@ public class ExpressionDropAdapter extends ViewerDropAdapter {
for (int i = 0; i < event.dataTypes.length; i++) {
if (LocalSelectionTransfer.getTransfer().isSupportedType(event.dataTypes[i])) {
- if (isVariableDrop()){
+ if (isExpressionDrop()){
+ event.currentDataType = event.dataTypes[i];
+ event.detail = DND.DROP_MOVE;
+ fDropType = DROP_TYPE_EXPRESSION;
+ return;
+ } else if (isVariableDrop()){
event.currentDataType = event.dataTypes[i];
event.detail = DND.DROP_COPY;
fDropType = DROP_TYPE_VARIABLE;
return;
- } else if (isExpressionDrop()){
- event.currentDataType = event.dataTypes[i];
- event.detail = DND.DROP_MOVE;
- fDropType = DROP_TYPE_EXPRESSION;
+ } else if (isWatchAdaptableElementDrop()){
+ event.currentDataType = event.dataTypes[i];
+ event.detail = DND.DROP_COPY;
+ fDropType = DROP_TYPE_WATCH_ADAPTABLE_ELEMENT;
return;
}
}
@@ -114,7 +122,7 @@ public class ExpressionDropAdapter extends ViewerDropAdapter {
Iterator iterator = selection.iterator();
while (iterator.hasNext()) {
Object element = iterator.next();
- if (!(element instanceof IExpression)){
+ if (getTargetExpression(element) == null){
return false;
}
}
@@ -136,6 +144,24 @@ public class ExpressionDropAdapter extends ViewerDropAdapter {
return true;
}
+ /**
+ * @return whether the selection transfer contains only objects adaptable
+ * to IWatchExpressionFactoryAdapter2
+ */
+ private boolean isWatchAdaptableElementDrop() {
+ IStructuredSelection selection = (IStructuredSelection) LocalSelectionTransfer.getTransfer().getSelection();
+ Iterator iterator = selection.iterator();
+ while (iterator.hasNext()) {
+ Object element = iterator.next();
+ if (!(element instanceof IAdaptable &&
+ ((IAdaptable)element).getAdapter(IWatchExpressionFactoryAdapter2.class) != null))
+ {
+ return false;
+ }
+ }
+ return true;
+ }
+
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.ViewerDropAdapter#dragOver(org.eclipse.swt.dnd.DropTargetEvent)
*/
@@ -154,7 +180,9 @@ public class ExpressionDropAdapter extends ViewerDropAdapter {
return validateExpressionDrop(target);
} else if (fDropType == DROP_TYPE_VARIABLE){
return validateVariableDrop(target);
- }
+ } else if (fDropType == DROP_TYPE_WATCH_ADAPTABLE_ELEMENT){
+ return validateWatchAdaptableDrop(target);
+ }
} else if (TextTransfer.getInstance().isSupportedType(transferType)) {
return validateTextDrop(target);
}
@@ -168,9 +196,19 @@ public class ExpressionDropAdapter extends ViewerDropAdapter {
* @return whether the drop is valid
*/
private boolean validateExpressionDrop(Object target){
- return target instanceof IExpression;
+ return target instanceof IExpression ||
+ ((target instanceof IAdaptable) && ((IAdaptable)target).getAdapter(IExpression.class) != null);
}
+ private IExpression getTargetExpression(Object target) {
+ if (target instanceof IExpression) {
+ return (IExpression)target;
+ } else if (target instanceof IAdaptable) {
+ return (IExpression)((IAdaptable)target).getAdapter(IExpression.class);
+ }
+ return null;
+ }
+
/**
* Validates if the drop is valid by validating the local selection transfer
* to ensure that a watch expression can be created for each contained IVariable.
@@ -179,9 +217,10 @@ public class ExpressionDropAdapter extends ViewerDropAdapter {
*/
private boolean validateVariableDrop(Object target) {
// Target must be null or an IExpression, you cannot add a new watch expression inside another
- if (target != null && !(target instanceof IExpression)){
- return false;
+ if (target != null && getTargetExpression(target) == null) {
+ return false;
}
+
IStructuredSelection selection = (IStructuredSelection) LocalSelectionTransfer.getTransfer().getSelection();
int enabled = 0;
int size = -1;
@@ -205,7 +244,37 @@ public class ExpressionDropAdapter extends ViewerDropAdapter {
}
return enabled == size;
}
-
+
+ /**
+ * Validates if the drop is valid by validating the local selection transfer
+ * to ensure that a watch expression can be created for each contained element.
+ * @param target target of the drop
+ * @return whether the drop is valid
+ */
+ private boolean validateWatchAdaptableDrop(Object target) {
+ // Target must be null or an IExpression, you cannot add a new watch expression inside another
+ if (target != null && getTargetExpression(target) == null) {
+ return false;
+ }
+
+ IStructuredSelection selection = (IStructuredSelection) LocalSelectionTransfer.getTransfer().getSelection();
+ int enabled = 0;
+ int size = -1;
+ if (selection != null) {
+ size = selection.size();
+ Iterator iterator = selection.iterator();
+ while (iterator.hasNext()) {
+ Object element = iterator.next();
+ if (isFactory2Enabled(element)) {
+ enabled++;
+ } else {
+ break;
+ }
+ }
+ }
+ return enabled == size;
+ }
+
/**
* Validates if the drop is valid by validating the drop location.
* Only valid if the target is <code>null</code> or an <code>IExpression</code>.
@@ -214,7 +283,7 @@ public class ExpressionDropAdapter extends ViewerDropAdapter {
* @return whether the drop is valid
*/
private boolean validateTextDrop(Object target){
- return target == null || target instanceof IExpression;
+ return target == null || getTargetExpression(target) != null;
}
/**
@@ -232,6 +301,20 @@ public class ExpressionDropAdapter extends ViewerDropAdapter {
return true;
}
+ /**
+ * Returns whether the factory adapter for the given element is currently enabled.
+ *
+ * @param element the element to ask for the adapter
+ * @return whether the factory is enabled
+ */
+ private boolean isFactory2Enabled(Object element) {
+ IWatchExpressionFactoryAdapter2 factory = getFactory2(element);
+ if (factory != null) {
+ return factory.canCreateWatchExpression(element);
+ }
+ return false;
+ }
+
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.ViewerDropAdapter#drop(org.eclipse.swt.dnd.DropTargetEvent)
*/
@@ -250,8 +333,8 @@ public class ExpressionDropAdapter extends ViewerDropAdapter {
IStructuredSelection selection = (IStructuredSelection) LocalSelectionTransfer.getTransfer().getSelection();
if (fDropType == DROP_TYPE_EXPRESSION){
return performExpressionDrop(selection);
- } else if (fDropType == DROP_TYPE_VARIABLE){
- return performVariableDrop(selection);
+ } else if (fDropType == DROP_TYPE_VARIABLE || fDropType == DROP_TYPE_WATCH_ADAPTABLE_ELEMENT){
+ return performVariableOrWatchAdaptableDrop(selection);
}
} else if (TextTransfer.getInstance().isSupportedType(fCurrentTransferType)) {
if (data != null) {
@@ -269,13 +352,17 @@ public class ExpressionDropAdapter extends ViewerDropAdapter {
* @return whether the drop could be completed
*/
private boolean performExpressionDrop(IStructuredSelection selection) {
- if (getCurrentTarget() instanceof IExpression){
+ IExpression targetExpression = getTargetExpression(getCurrentTarget());
+ if (targetExpression != null){
IExpression[] expressions = new IExpression[selection.size()];
- System.arraycopy(selection.toArray(), 0, expressions, 0, expressions.length);
+ Object[] selectionElements = selection.toArray();
+ for (int i = 0; i < selectionElements.length; i++) {
+ expressions[i] = getTargetExpression(selectionElements[i]);
+ }
IExpressionManager manager = DebugPlugin.getDefault().getExpressionManager();
if (manager instanceof ExpressionManager){
- ((ExpressionManager)manager).moveExpressions(expressions, (IExpression)getCurrentTarget(), fInsertBefore);
+ ((ExpressionManager)manager).moveExpressions(expressions, targetExpression, fInsertBefore);
}
return true;
}
@@ -292,30 +379,29 @@ public class ExpressionDropAdapter extends ViewerDropAdapter {
* @param selection Structured selection containing IVariables
* @return whether the drop was successful
*/
- private boolean performVariableDrop(IStructuredSelection selection) {
+ private boolean performVariableOrWatchAdaptableDrop(IStructuredSelection selection) {
List expressions = new ArrayList(selection.size());
for (Iterator itr = selection.iterator(); itr.hasNext(); ) {
Object element = itr.next();
- if (element instanceof IVariable) {
- String expressionText = createExpressionString((IVariable)element);
- if (expressionText != null){
- IExpression expression = createExpression(expressionText);
- if (expression != null){
- expressions.add(expression);
- } else {
- DebugUIPlugin.log(new Status(IStatus.ERROR,DebugUIPlugin.getUniqueIdentifier(),"Drop failed. Watch expression could not be created for the text " + expressionText)); //$NON-NLS-1$
- return false;
- }
+ String expressionText = createExpressionString(element);
+ if (expressionText != null){
+ IExpression expression = createExpression(expressionText);
+ if (expression != null){
+ expressions.add(expression);
} else {
+ DebugUIPlugin.log(new Status(IStatus.ERROR,DebugUIPlugin.getUniqueIdentifier(),"Drop failed. Watch expression could not be created for the text " + expressionText)); //$NON-NLS-1$
return false;
}
- }
+ } else {
+ return false;
+ }
}
if (expressions.size() == selection.size()){
IExpressionManager manager = DebugPlugin.getDefault().getExpressionManager();
if (manager instanceof ExpressionManager){
- if (getCurrentTarget() != null){
- ((ExpressionManager)manager).insertExpressions((IExpression[])expressions.toArray(new IExpression[expressions.size()]), (IExpression)getCurrentTarget(), fInsertBefore);
+ IExpression targetExpression = getTargetExpression(getCurrentTarget());
+ if (targetExpression != null){
+ ((ExpressionManager)manager).insertExpressions((IExpression[])expressions.toArray(new IExpression[expressions.size()]), targetExpression, fInsertBefore);
} else {
((ExpressionManager)manager).addExpressions((IExpression[])expressions.toArray(new IExpression[expressions.size()]));
}
@@ -324,7 +410,8 @@ public class ExpressionDropAdapter extends ViewerDropAdapter {
}
return false;
}
-
+
+
/**
* Performs the drop when text was dragged. Creates a new watch expression from
* the text. Inserts the expression at the currently selected target or adds it
@@ -338,8 +425,9 @@ public class ExpressionDropAdapter extends ViewerDropAdapter {
if (expression != null){
IExpressionManager manager = DebugPlugin.getDefault().getExpressionManager();
if (manager instanceof ExpressionManager){
- if (getCurrentTarget() != null){
- ((ExpressionManager)manager).insertExpressions(new IExpression[]{expression}, (IExpression)getCurrentTarget(), fInsertBefore);
+ IExpression targetExpression = getTargetExpression(getCurrentTarget());
+ if (targetExpression != null){
+ ((ExpressionManager)manager).insertExpressions(new IExpression[]{expression}, targetExpression, fInsertBefore);
} else {
((ExpressionManager)manager).addExpression(expression);
}
@@ -357,18 +445,26 @@ public class ExpressionDropAdapter extends ViewerDropAdapter {
* @param variable the variable to use to create the watch expression
* @return whether the creation was successful
*/
- private String createExpressionString(IVariable variable) {
- IWatchExpressionFactoryAdapter factory = getFactory(variable);
+ private String createExpressionString(Object element) {
try {
- String exp = variable.getName();
- if (factory != null) {
- exp = factory.createWatchExpression(variable);
- return exp;
+ if (element instanceof IVariable) {
+ IVariable variable = (IVariable)element;
+ IWatchExpressionFactoryAdapter factory = getFactory(variable);
+ String exp = variable.getName();
+ if (factory != null) {
+ exp = factory.createWatchExpression(variable);
+ return exp;
+ } else {
+ DebugUIPlugin.log(new Status(IStatus.ERROR,DebugUIPlugin.getUniqueIdentifier(),"Drop failed. Watch Expression Factory could not be found for variable " + variable)); //$NON-NLS-1$
+ }
} else {
- DebugUIPlugin.log(new Status(IStatus.ERROR,DebugUIPlugin.getUniqueIdentifier(),"Drop failed. Watch Expression Factory could not be found for variable " + variable)); //$NON-NLS-1$
+ IWatchExpressionFactoryAdapter2 factory2 = getFactory2(element);
+ if (factory2 != null) {
+ return factory2.createWatchExpression(element);
+ }
}
} catch (CoreException e) {
- DebugUIPlugin.log(e.getStatus());
+ DebugUIPlugin.log(e.getStatus());
}
return null;
}
@@ -402,4 +498,17 @@ public class ExpressionDropAdapter extends ViewerDropAdapter {
return (IWatchExpressionFactoryAdapter) variable.getAdapter(IWatchExpressionFactoryAdapter.class);
}
+ /**
+ * Returns the factory adapter for the given element or <code>null</code> if none.
+ *
+ * @param element
+ * @return factory or <code>null</code>
+ */
+ private IWatchExpressionFactoryAdapter2 getFactory2(Object element) {
+ if (element instanceof IAdaptable) {
+ return (IWatchExpressionFactoryAdapter2)((IAdaptable)element).getAdapter(IWatchExpressionFactoryAdapter2.class);
+ }
+ return null;
+ }
+
}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/IWatchExpressionFactoryAdapter2.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/IWatchExpressionFactoryAdapter2.java
new file mode 100644
index 000000000..fb963f094
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/IWatchExpressionFactoryAdapter2.java
@@ -0,0 +1,53 @@
+/*******************************************************************************
+ * Copyright (c) 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ * Wind River Systems - integration with non-standard debug models (Bug 209883)
+ *******************************************************************************/
+package org.eclipse.debug.ui.actions;
+
+import org.eclipse.core.runtime.CoreException;
+
+/**
+ * An optional adapter used to create a watch expression for a selected element.
+ * <p>
+ * The 'Create Watch Expression' action is enabled for an adaptable element
+ * that have an associated <code>IWatchExpressionFactoryAdapter2</code>.
+ *
+ * When a watch expression factory adapter is available for an element, the factory is
+ * consulted to create a watch expression for that element.
+ * </p>
+ * <p>
+ * Clients may implement this interface.
+ * </p>
+ * @since 3.4
+ */
+public interface IWatchExpressionFactoryAdapter2 {
+
+ /**
+ * Creates and returns an expression for the specified variable
+ * which is used to created an {@link org.eclipse.debug.core.model.IWatchExpression}.
+ *
+ * @param element element a watch expression is required for
+ * @return text used to create a watch expression
+ * @exception org.eclipse.core.runtime.CoreException if unable to create a watch
+ * expression
+ */
+ public String createWatchExpression(Object element) throws CoreException;
+
+ /**
+ * Returns whether a watch expression can be created for the specified variable.
+ *
+ * @param variable variable a watch expression is required for
+ * @return whether an expression can be created
+ * @exception org.eclipse.core.runtime.CoreException if unable to create a watch
+ * expression
+ */
+ public boolean canCreateWatchExpression(Object element);
+
+}

Back to the top