diff options
Diffstat (limited to 'org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/expressions')
14 files changed, 0 insertions, 1173 deletions
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/expressions/AddWatchExpressionAction.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/expressions/AddWatchExpressionAction.java deleted file mode 100644 index a458d9e06..000000000 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/expressions/AddWatchExpressionAction.java +++ /dev/null @@ -1,56 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2007 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 - *******************************************************************************/ -package org.eclipse.debug.internal.ui.actions.expressions; - - -import org.eclipse.debug.core.DebugPlugin; -import org.eclipse.debug.core.model.IWatchExpression; -import org.eclipse.debug.internal.core.IInternalDebugCoreConstants; -import org.eclipse.debug.internal.ui.DebugUIPlugin; -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.window.Window; -import org.eclipse.ui.IViewActionDelegate; -import org.eclipse.ui.IViewPart; - -/** - * Open a watch expression dialog and add the created watch expression to the - * expression view. - */ -public class AddWatchExpressionAction extends WatchExpressionAction implements IViewActionDelegate { - - /** - * @see org.eclipse.ui.IViewActionDelegate#init(org.eclipse.ui.IViewPart) - */ - public void init(IViewPart view) { - } - - /** - * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction) - */ - public void run(IAction action) { - // create a watch expression - IWatchExpression watchExpression= DebugPlugin.getDefault().getExpressionManager().newWatchExpression(IInternalDebugCoreConstants.EMPTY_STRING); - // open the watch expression dialog - if (new WatchExpressionDialog(DebugUIPlugin.getShell(), watchExpression, false).open() == Window.OK) { - // if OK is selected, add the expression to the expression view and try to evaluate the expression. - DebugPlugin.getDefault().getExpressionManager().addExpression(watchExpression); - watchExpression.setExpressionContext(getContext()); - } - } - - /** - * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection) - */ - public void selectionChanged(IAction action, ISelection selection) { - } - -} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/expressions/ConvertToWatchExpressionAction.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/expressions/ConvertToWatchExpressionAction.java deleted file mode 100644 index bfa6c941b..000000000 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/expressions/ConvertToWatchExpressionAction.java +++ /dev/null @@ -1,46 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2005 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 - *******************************************************************************/ -package org.eclipse.debug.internal.ui.actions.expressions; - - -import java.util.Iterator; - -import org.eclipse.debug.core.DebugPlugin; -import org.eclipse.debug.core.IExpressionManager; -import org.eclipse.debug.core.model.IExpression; -import org.eclipse.debug.core.model.IWatchExpression; -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.viewers.IStructuredSelection; - -/** - * Convert one or more expressions to the equivalent watch expressions. - * Refresh and re-evaluate the expressions if possible. - */ -public class ConvertToWatchExpressionAction extends WatchExpressionAction { - - /** - * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction) - */ - public void run(IAction action) { - IStructuredSelection selection= getCurrentSelection(); - IExpressionManager expressionManager= DebugPlugin.getDefault().getExpressionManager(); - for (Iterator iter= selection.iterator(); iter.hasNext();) { - IExpression expression= (IExpression) iter.next(); - // create the new watch expression - IWatchExpression watchExpression= expressionManager.newWatchExpression(expression.getExpressionText()); - expressionManager.removeExpression(expression); - expressionManager.addExpression(watchExpression); - // refresh and re-evaluate - watchExpression.setExpressionContext(getContext()); - } - } - -} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/expressions/DisableWatchExpressionAction.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/expressions/DisableWatchExpressionAction.java deleted file mode 100644 index 0f0a291ea..000000000 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/expressions/DisableWatchExpressionAction.java +++ /dev/null @@ -1,23 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2005 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 - *******************************************************************************/ -package org.eclipse.debug.internal.ui.actions.expressions; - - -/** - * - */ -public class DisableWatchExpressionAction extends EnableWatchExpressionAction { - - public DisableWatchExpressionAction() { - fEnable= false; - } - -} 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 deleted file mode 100644 index c858ca31c..000000000 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/expressions/EditWatchExpressionAction.java +++ /dev/null @@ -1,38 +0,0 @@ -/******************************************************************************* - * 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 - * 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.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. - * Re-evaluate and refresh the watch expression is necessary. - */ -public class EditWatchExpressionAction extends WatchExpressionAction { - - /** - * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction) - */ - public void run(IAction action) { - 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 deleted file mode 100644 index d398287dc..000000000 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/expressions/EnableWatchExpressionAction.java +++ /dev/null @@ -1,140 +0,0 @@ -/******************************************************************************* - * 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 - * 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.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.swt.widgets.Event; -import org.eclipse.ui.IActionDelegate2; -import org.eclipse.ui.IViewActionDelegate; -import org.eclipse.ui.IViewPart; - -/** - * - */ -public class EnableWatchExpressionAction implements IViewActionDelegate, IActionDelegate2, IDebugEventSetListener { - - private ISelection fSelection; - private IAction fAction; - protected boolean fEnable= true; - - /* (non-Javadoc) - * @see org.eclipse.ui.IViewActionDelegate#init(org.eclipse.ui.IViewPart) - */ - public void init(IViewPart view) { - DebugPlugin.getDefault().addDebugEventListener(this); - } - - /** - * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction) - */ - public void run(IAction action) { - if (fSelection instanceof IStructuredSelection) { - Iterator iter= ((IStructuredSelection) fSelection).iterator(); - IWatchExpression expression; - while (iter.hasNext()) { - expression= getWatchExpression(iter.next()); - if (expression != null) { - expression.setEnabled(fEnable); - fireWatchExpressionChanged(expression); - } - } - } else if (fSelection instanceof IWatchExpression) { - IWatchExpression expression= ((IWatchExpression) fSelection); - expression.setEnabled(fEnable); - fireWatchExpressionChanged(expression); - } - } - - /** - * @param expression - */ - private void fireWatchExpressionChanged(IWatchExpression expression) { - DebugPlugin.getDefault().fireDebugEventSet(new DebugEvent[] {new DebugEvent(expression, DebugEvent.CHANGE)}); - } - - /** - * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection) - */ - public void selectionChanged(IAction action, ISelection selection) { - fSelection= selection; - if (fSelection instanceof IStructuredSelection) { - boolean enabled= false; - Iterator iter= ((IStructuredSelection) selection).iterator(); - while (iter.hasNext()) { - IWatchExpression expression = getWatchExpression(iter.next()); - if (expression != null && expression.isEnabled() != fEnable) { - enabled= true; - break; - } - } - action.setEnabled(enabled); - } else if (fSelection instanceof IWatchExpression) { - action.setEnabled(((IWatchExpression) fSelection).isEnabled() != fEnable); - } else { - action.setEnabled(false); - } - } - - 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/PasteWatchExpressionsAction.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/expressions/PasteWatchExpressionsAction.java deleted file mode 100644 index 36e8ad6b5..000000000 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/expressions/PasteWatchExpressionsAction.java +++ /dev/null @@ -1,49 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Adobe Systems, Inc. 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: - * Adobe Systems, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.debug.internal.ui.actions.expressions; - -import org.eclipse.debug.internal.ui.actions.ActionMessages; -import org.eclipse.debug.internal.ui.views.expression.ExpressionView; -import org.eclipse.ui.actions.SelectionListenerAction; - -/** - * Paste a watch expression into the expressions view. - */ -public class PasteWatchExpressionsAction extends SelectionListenerAction { - - private final ExpressionView fExpressionView; - - public PasteWatchExpressionsAction(ExpressionView expressionView) { - super(ActionMessages.PasteWatchExpressionsAction_0); - fExpressionView = expressionView; -// setToolTipText(BreakpointGroupMessages.PasteWatchExpressionsAction_1); -// PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IDebugHelpContextIds.PASTE_WATCH_EXPRESSIONS_ACTION); - } - - /* (non-Javadoc) - * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction) - */ - public void run() { - if (fExpressionView.canPaste()) { - fExpressionView.performPaste(); - } - } - - /* (non-Javadoc) - * @see org.eclipse.jface.action.Action#isEnabled() - */ - public boolean isEnabled() { - return fExpressionView.canPaste(); - } - - - -} 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 deleted file mode 100644 index c768367ad..000000000 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/expressions/ReevaluateWatchExpressionAction.java +++ /dev/null @@ -1,93 +0,0 @@ -/******************************************************************************* - * 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 - * 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.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 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) - */ - public void run(IAction action) { - IDebugElement context = getContext(); - for (Iterator iter= getCurrentSelection().iterator(); iter.hasNext();) { - IWatchExpression expression= (IWatchExpression) iter.next(); - expression.setExpressionContext(context); - if (!expression.isEnabled()) { - // Force a reevaluation - expression.evaluate(); - } - } - } - - /** - * @see IActionDelegate#selectionChanged(IAction, ISelection) - */ - public void selectionChanged(IAction action, ISelection selection) { - IDebugElement debugElement = getContext(); - if (debugElement == null) { - action.setEnabled(false); - } else { - action.setEnabled(true); - } - } - -} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/expressions/RemoveAllExpressionsAction.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/expressions/RemoveAllExpressionsAction.java deleted file mode 100644 index 209de9dac..000000000 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/expressions/RemoveAllExpressionsAction.java +++ /dev/null @@ -1,100 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2009 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 - *******************************************************************************/ -package org.eclipse.debug.internal.ui.actions.expressions; - - -import org.eclipse.debug.core.DebugPlugin; -import org.eclipse.debug.core.IExpressionManager; -import org.eclipse.debug.core.IExpressionsListener; -import org.eclipse.debug.core.model.IExpression; -import org.eclipse.debug.internal.ui.DebugUIPlugin; -import org.eclipse.debug.internal.ui.actions.AbstractRemoveAllActionDelegate; -import org.eclipse.debug.internal.ui.actions.ActionMessages; -import org.eclipse.debug.internal.ui.preferences.IDebugPreferenceConstants; -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.dialogs.IDialogConstants; -import org.eclipse.jface.dialogs.MessageDialogWithToggle; -import org.eclipse.jface.preference.IPreferenceStore; -import org.eclipse.ui.IWorkbenchWindow; - -/** - * Removes all expressions from the expressions view. - */ -public class RemoveAllExpressionsAction extends AbstractRemoveAllActionDelegate implements IExpressionsListener { - - /* (non-Javadoc) - * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction) - */ - public void run(IAction action) { - IWorkbenchWindow window = DebugUIPlugin.getActiveWorkbenchWindow(); - if (window != null) { - IPreferenceStore store = DebugUIPlugin.getDefault().getPreferenceStore(); - boolean prompt = store.getBoolean(IDebugPreferenceConstants.PREF_PROMPT_REMOVE_ALL_EXPRESSIONS); - boolean proceed = true; - if (prompt) { - MessageDialogWithToggle mdwt = MessageDialogWithToggle.openYesNoQuestion(window.getShell(), ActionMessages.RemoveAllExpressionsAction_0, - ActionMessages.RemoveAllExpressionsAction_1, ActionMessages.RemoveAllBreakpointsAction_3, !prompt, null, null); - if(mdwt.getReturnCode() != IDialogConstants.YES_ID){ - proceed = false; - } - else { - store.setValue(IDebugPreferenceConstants.PREF_PROMPT_REMOVE_ALL_EXPRESSIONS, !mdwt.getToggleState()); - } - } - if (proceed) { - IExpressionManager manager = DebugPlugin.getDefault().getExpressionManager(); - IExpression[] expressions= manager.getExpressions(); - manager.removeExpressions(expressions); - } - } - } - - /* (non-Javadoc) - * @see org.eclipse.debug.internal.ui.actions.selection.AbstractRemoveAllActionDelegate#isEnabled() - */ - protected boolean isEnabled() { - return DebugPlugin.getDefault().getExpressionManager().hasExpressions(); - } - - /* (non-Javadoc) - * @see org.eclipse.debug.internal.ui.actions.selection.AbstractRemoveAllActionDelegate#initialize() - */ - protected void initialize() { - DebugPlugin.getDefault().getExpressionManager().addExpressionListener(this); - } - - /* (non-Javadoc) - * @see org.eclipse.debug.internal.ui.actions.selection.AbstractRemoveAllActionDelegate#dispose() - */ - public void dispose() { - DebugPlugin.getDefault().getExpressionManager().removeExpressionListener(this); - super.dispose(); - } - - /* (non-Javadoc) - * @see org.eclipse.debug.core.IExpressionsListener#expressionsAdded(org.eclipse.debug.core.model.IExpression[]) - */ - public void expressionsAdded(IExpression[] expressions) { - update(); - } - - /* (non-Javadoc) - * @see org.eclipse.debug.core.IExpressionsListener#expressionsRemoved(org.eclipse.debug.core.model.IExpression[]) - */ - public void expressionsRemoved(IExpression[] expressions) { - update(); - } - - /* (non-Javadoc) - * @see org.eclipse.debug.core.IExpressionsListener#expressionsChanged(org.eclipse.debug.core.model.IExpression[]) - */ - public void expressionsChanged(IExpression[] expressions) {} -} 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 deleted file mode 100644 index 8ea98abc9..000000000 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/expressions/RemoveExpressionAction.java +++ /dev/null @@ -1,70 +0,0 @@ -/******************************************************************************* - * 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 - * 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.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; -import org.eclipse.debug.core.DebugPlugin; -import org.eclipse.debug.core.IExpressionManager; -import org.eclipse.debug.core.model.IExpression; -import org.eclipse.debug.internal.ui.actions.AbstractRemoveActionDelegate; -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.viewers.TreePath; -import org.eclipse.jface.viewers.TreeSelection; -import org.eclipse.ui.progress.WorkbenchJob; - -public class RemoveExpressionAction extends AbstractRemoveActionDelegate { - - protected IExpression[] getExpressions() { - TreeSelection selection = (TreeSelection) getSelection(); - TreePath[] paths = selection.getPaths(); - List expressions = new ArrayList(); - for (int i = paths.length-1; i >=0; i--) { - TreePath path = paths[i]; - 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()]); - } - - /* (non-Javadoc) - * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction) - */ - public void run(IAction action) { - WorkbenchJob job = new WorkbenchJob("remove expression") { //$NON-NLS-1$ - public IStatus runInUIThread(IProgressMonitor monitor) { - IExpressionManager expManager = DebugPlugin.getDefault().getExpressionManager(); - IExpression[] exp = getExpressions(); - if (exp != null) { - expManager.removeExpressions(exp); - } - return Status.OK_STATUS; - } - }; - job.setSystem(true); - schedule(job); - } -} - diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/expressions/SelectAllExpressionsAction.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/expressions/SelectAllExpressionsAction.java deleted file mode 100644 index 2e9da1b1e..000000000 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/expressions/SelectAllExpressionsAction.java +++ /dev/null @@ -1,69 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2006 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 - *******************************************************************************/ -package org.eclipse.debug.internal.ui.actions.expressions; - -import org.eclipse.debug.core.DebugPlugin; -import org.eclipse.debug.core.IExpressionsListener; -import org.eclipse.debug.core.model.IExpression; -import org.eclipse.debug.internal.ui.actions.SelectAllAction; -import org.eclipse.debug.ui.IDebugView; - -public class SelectAllExpressionsAction extends SelectAllAction implements IExpressionsListener { - - /* (non-Javadoc) - * @see org.eclipse.debug.internal.ui.actions.selection.AbstractRemoveAllActionDelegate#isEnabled() - */ - protected boolean isEnabled() { - return DebugPlugin.getDefault().getExpressionManager().hasExpressions(); - } - - /* (non-Javadoc) - * @see org.eclipse.debug.internal.ui.actions.SelectAllAction#getActionId() - */ - protected String getActionId() { - return IDebugView.SELECT_ALL_ACTION + ".Variables"; //$NON-NLS-1$ - } - - /* (non-Javadoc) - * @see org.eclipse.debug.internal.ui.actions.AbstractRemoveAllActionDelegate#initialize() - */ - protected void initialize() { - DebugPlugin.getDefault().getExpressionManager().addExpressionListener(this); - } - - /* (non-Javadoc) - * @see org.eclipse.debug.core.IExpressionsListener#expressionsAdded(org.eclipse.debug.core.model.IExpression[]) - */ - public void expressionsAdded(IExpression[] expressions) { - update(); - } - - /* (non-Javadoc) - * @see org.eclipse.debug.core.IExpressionsListener#expressionsRemoved(org.eclipse.debug.core.model.IExpression[]) - */ - public void expressionsRemoved(IExpression[] expressions) { - update(); - } - - /* (non-Javadoc) - * @see org.eclipse.debug.core.IExpressionsListener#expressionsChanged(org.eclipse.debug.core.model.IExpression[]) - */ - public void expressionsChanged(IExpression[] expressions) { - } - - /* (non-Javadoc) - * @see org.eclipse.debug.internal.ui.actions.AbstractRemoveAllActionDelegate#dispose() - */ - public void dispose() { - super.dispose(); - DebugPlugin.getDefault().getExpressionManager().removeExpressionListener(this); - } -} 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 deleted file mode 100644 index d835bfb4d..000000000 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/expressions/WatchExpressionAction.java +++ /dev/null @@ -1,118 +0,0 @@ -/******************************************************************************* - * 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 - * 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.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; -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.ui.IViewActionDelegate; -import org.eclipse.ui.IViewPart; -import org.eclipse.ui.IViewSite; -import org.eclipse.ui.IWorkbenchPage; -import org.eclipse.ui.IWorkbenchPart; - -/** - * Generic abstract class for the actions associated to the java watch - * expressions. - */ -public abstract class WatchExpressionAction implements IViewActionDelegate { - IWorkbenchPart fPart = null; - - 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) - */ - public void selectionChanged(IAction action, ISelection sel) { - } - - protected IStructuredSelection getCurrentSelection() { - IWorkbenchPage page = DebugUIPlugin.getActiveWorkbenchWindow().getActivePage(); - if (page != null) { - ISelection selection = page.getSelection(); - if (selection instanceof IStructuredSelection) { - return (IStructuredSelection) selection; - } - } - return null; - } - - /** - * Displays the given error message in the status line. - * - * @param message - */ - protected void showErrorMessage(String message) { - if (fPart instanceof IViewPart) { - IViewSite viewSite = ((IViewPart) fPart).getViewSite(); - IStatusLineManager manager = viewSite.getActionBars().getStatusLineManager(); - manager.setErrorMessage(message); - Display.getCurrent().beep(); - } - } -} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/expressions/WatchExpressionDialog.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/expressions/WatchExpressionDialog.java deleted file mode 100644 index bf994e59d..000000000 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/expressions/WatchExpressionDialog.java +++ /dev/null @@ -1,178 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2009 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 - *******************************************************************************/ -package org.eclipse.debug.internal.ui.actions.expressions; - - -import org.eclipse.debug.core.model.IWatchExpression; -import org.eclipse.debug.internal.ui.IDebugHelpContextIds; -import org.eclipse.debug.internal.ui.actions.ActionMessages; -import org.eclipse.debug.internal.ui.actions.StatusInfo; -import org.eclipse.jface.action.IMenuListener; -import org.eclipse.jface.action.IMenuManager; -import org.eclipse.jface.action.MenuManager; -import org.eclipse.jface.dialogs.StatusDialog; -import org.eclipse.jface.resource.JFaceResources; -import org.eclipse.jface.text.Document; -import org.eclipse.jface.text.DocumentEvent; -import org.eclipse.jface.text.IDocument; -import org.eclipse.jface.text.IDocumentListener; -import org.eclipse.jface.text.ITextOperationTarget; -import org.eclipse.jface.text.source.SourceViewer; -import org.eclipse.jface.text.source.SourceViewerConfiguration; -import org.eclipse.swt.SWT; -import org.eclipse.swt.graphics.Font; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Menu; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.ISharedImages; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.console.actions.TextViewerAction; - -/** - * Dialog for edit watch expression. - */ -public class WatchExpressionDialog extends StatusDialog { - - /** - * The detail formatter to edit. - */ - private IWatchExpression fWatchExpression; - - // widgets - private SourceViewer fSnippetViewer; - private Button fCheckBox; - - public WatchExpressionDialog(Shell parent, IWatchExpression watchExpression, boolean editDialog) { - super(parent); - fWatchExpression= watchExpression; - setShellStyle(getShellStyle() | SWT.MAX | SWT.RESIZE); - String helpContextId = null; - if (editDialog) { - setTitle(ActionMessages.WatchExpressionDialog_0); - helpContextId = IDebugHelpContextIds.EDIT_WATCH_EXPRESSION_DIALOG; - } else { - setTitle(ActionMessages.WatchExpressionDialog_1); - helpContextId = IDebugHelpContextIds.ADD_WATCH_EXPRESSION_DIALOG; - } - PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, helpContextId); - } - - /** - * Create the dialog area. - * - * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(Composite) - */ - protected Control createDialogArea(Composite parent) { - Font font = parent.getFont(); - - Composite container = new Composite(parent, SWT.NONE); - GridLayout layout = new GridLayout(); - container.setLayout(layout); - GridData gd= new GridData(GridData.FILL_BOTH); - container.setLayoutData(gd); - - // snippet label - Label label = new Label(container, SWT.NONE); - label.setText(ActionMessages.WatchExpressionDialog_2); - gd= new GridData(GridData.BEGINNING); - label.setLayoutData(gd); - label.setFont(font); - - fSnippetViewer = new SourceViewer(container, null, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL | SWT.LEFT_TO_RIGHT); - fSnippetViewer.setInput(this); - - IDocument document = new Document(); - fSnippetViewer.configure(new SourceViewerConfiguration()); - fSnippetViewer.setEditable(true); - fSnippetViewer.setDocument(document); - document.addDocumentListener(new IDocumentListener() { - public void documentAboutToBeChanged(DocumentEvent event) { - } - public void documentChanged(DocumentEvent event) { - checkValues(); - } - }); - - fSnippetViewer.getTextWidget().setFont(JFaceResources.getTextFont()); - - Control control= fSnippetViewer.getControl(); - gd= new GridData(GridData.FILL_BOTH); - gd.heightHint= convertHeightInCharsToPixels(10); - gd.widthHint= convertWidthInCharsToPixels(80); - control.setLayoutData(gd); - fSnippetViewer.getDocument().set(fWatchExpression.getExpressionText()); - - // actions - final TextViewerAction cutAction = new TextViewerAction(fSnippetViewer, ITextOperationTarget.CUT); - cutAction.setImageDescriptor(PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_TOOL_CUT)); - cutAction.setDisabledImageDescriptor(PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_TOOL_CUT_DISABLED)); - cutAction.setText(ActionMessages.WatchExpressionDialogMenu_0); - final TextViewerAction copyAction = new TextViewerAction(fSnippetViewer, ITextOperationTarget.COPY); - copyAction.setImageDescriptor(PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_TOOL_COPY)); - copyAction.setDisabledImageDescriptor(PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_TOOL_COPY_DISABLED)); - copyAction.setText(ActionMessages.WatchExpressionDialogMenu_1); - final TextViewerAction pasteAction = new TextViewerAction(fSnippetViewer, ITextOperationTarget.PASTE); - pasteAction.setImageDescriptor(PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_TOOL_PASTE)); - pasteAction.setDisabledImageDescriptor(PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_TOOL_PASTE_DISABLED)); - pasteAction.setText(ActionMessages.WatchExpressionDialogMenu_2); - - // context menu - MenuManager menuManager = new MenuManager(); - menuManager.add(cutAction); - menuManager.add(copyAction); - menuManager.add(pasteAction); - menuManager.addMenuListener(new IMenuListener() { - public void menuAboutToShow(IMenuManager manager) { - cutAction.update(); - copyAction.update(); - pasteAction.update(); - } - }); - Menu menu = menuManager.createContextMenu(fSnippetViewer.getTextWidget()); - fSnippetViewer.getTextWidget().setMenu(menu); - - // enable checkbox - fCheckBox= new Button(container, SWT.CHECK | SWT.LEFT); - fCheckBox.setText(ActionMessages.WatchExpressionDialog_3); - fCheckBox.setSelection(fWatchExpression.isEnabled()); - fCheckBox.setFont(font); - - applyDialogFont(container); - fSnippetViewer.getControl().setFocus(); - return container; - } - - /** - * @see org.eclipse.jface.dialogs.Dialog#okPressed() - */ - protected void okPressed() { - fWatchExpression.setEnabled(fCheckBox.getSelection()); - fWatchExpression.setExpressionText(fSnippetViewer.getDocument().get()); - super.okPressed(); - } - - /** - * Check the field values and display a message in the status if needed. - */ - private void checkValues() { - StatusInfo status= new StatusInfo(); - if (fSnippetViewer.getDocument().get().trim().length() == 0) { - status.setError(ActionMessages.WatchExpressionDialog_4); - } - updateStatus(status); - } - -} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/expressions/WatchExpressionFactoryTester.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/expressions/WatchExpressionFactoryTester.java deleted file mode 100644 index 6f300f4e3..000000000 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/expressions/WatchExpressionFactoryTester.java +++ /dev/null @@ -1,56 +0,0 @@ -/******************************************************************************* - * 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: - * Wind River Systems - initial API and implementation - *******************************************************************************/ -package org.eclipse.debug.internal.ui.actions.expressions; - -import org.eclipse.core.expressions.PropertyTester; -import org.eclipse.debug.core.DebugPlugin; -import org.eclipse.debug.core.model.IVariable; -import org.eclipse.debug.ui.actions.IWatchExpressionFactoryAdapter; -import org.eclipse.debug.ui.actions.IWatchExpressionFactoryAdapter2; -import org.eclipse.debug.ui.actions.IWatchExpressionFactoryAdapterExtension; - -/** - * This class is used to check whether a given element can be used to create - * a watch expression. A single property can be tested - * "canCreateWatchExpression". Test for this property ignores the value and - * always returns a boolean. - * - * @since 3.4 - */ -public class WatchExpressionFactoryTester extends PropertyTester { - - public static final String CAN_CREATE_WATCH_EXPRESSION_PROPERTY = "canCreateWatchExpression"; //$NON-NLS-1$ - - /* (non-Javadoc) - * @see org.eclipse.core.expressions.PropertyTester#test(java.lang.Object, java.lang.String, java.lang.Object[], java.lang.Object) - */ - public boolean test(Object element, String property, Object[] args, Object expectedValue) { - if (CAN_CREATE_WATCH_EXPRESSION_PROPERTY.equals(property)){ - if (element instanceof IVariable) { - IVariable variable = (IVariable)element; - if (DebugPlugin.getDefault().getExpressionManager().hasWatchExpressionDelegate(variable.getModelIdentifier())) { - IWatchExpressionFactoryAdapter factory = WatchHandler.getFactory(variable); - if (factory instanceof IWatchExpressionFactoryAdapterExtension) { - IWatchExpressionFactoryAdapterExtension ext = (IWatchExpressionFactoryAdapterExtension) factory; - return ext.canCreateWatchExpression(variable); - } - return true; - } - } else { - IWatchExpressionFactoryAdapter2 factory2 = WatchHandler.getFactory2(element); - if (factory2 != null) { - return factory2.canCreateWatchExpression(element); - } - } - } - return false; - } -} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/expressions/WatchHandler.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/expressions/WatchHandler.java deleted file mode 100644 index 8fbd74b21..000000000 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/expressions/WatchHandler.java +++ /dev/null @@ -1,137 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008 Wind River Systems 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 Systems - initial API and implementation - *******************************************************************************/ -package org.eclipse.debug.internal.ui.actions.expressions; - -import java.util.Iterator; - -import org.eclipse.core.commands.AbstractHandler; -import org.eclipse.core.commands.ExecutionEvent; -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.debug.core.DebugPlugin; -import org.eclipse.debug.core.ILaunch; -import org.eclipse.debug.core.model.IDebugElement; -import org.eclipse.debug.core.model.IVariable; -import org.eclipse.debug.core.model.IWatchExpression; -import org.eclipse.debug.internal.ui.DebugUIPlugin; -import org.eclipse.debug.internal.ui.actions.ActionMessages; -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.jface.viewers.ISelection; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.ui.IViewPart; -import org.eclipse.ui.IWorkbenchPage; -import org.eclipse.ui.PartInitException; -import org.eclipse.ui.handlers.HandlerUtil; - -/** - * Handler for creating a watch expression. - * - * @since 3.4 - */ -public class WatchHandler extends AbstractHandler { - - /* (non-Javadoc) - * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent) - */ - public Object execute(ExecutionEvent event) throws ExecutionException { - ISelection selection = HandlerUtil.getCurrentSelection(event); - if (selection instanceof IStructuredSelection) { - Iterator iter = ((IStructuredSelection)selection).iterator(); - while (iter.hasNext()) { - Object element = iter.next(); - createExpression(element); - } - } - return null; - } - - - private void showExpressionsView() { - IWorkbenchPage page = DebugUIPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage(); - IViewPart part = page.findView(IDebugUIConstants.ID_EXPRESSION_VIEW); - if (part == null) { - try { - page.showView(IDebugUIConstants.ID_EXPRESSION_VIEW); - } catch (PartInitException e) { - } - } else { - page.bringToTop(part); - } - - } - - 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 - 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; - if (object instanceof IDebugElement) { - context = (IDebugElement) object; - } else if (object instanceof ILaunch) { - context = ((ILaunch) object).getDebugTarget(); - } - expression.setExpressionContext(context); - showExpressionsView(); - } - - - /** - * Returns the factory adapter for the given variable or <code>null</code> if none. - * - * @param variable - * @return factory or <code>null</code> - */ - static 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> - */ - static IWatchExpressionFactoryAdapter2 getFactory2(Object element) { - if (element instanceof IAdaptable) { - return (IWatchExpressionFactoryAdapter2)((IAdaptable)element).getAdapter(IWatchExpressionFactoryAdapter2.class); - } - return null; - } - -} |