diff options
author | Kevin Barnes | 2005-11-21 16:10:22 +0000 |
---|---|---|
committer | Kevin Barnes | 2005-11-21 16:10:22 +0000 |
commit | 1fa778c0a5c53b2869df5d597d31a4ddecc84531 (patch) | |
tree | f08a04d045beff96b33b8e5cbd62a2b2157333aa /org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/expression | |
parent | 6f61758dcf785a86427fe62929a0833c5178436e (diff) | |
download | eclipse.platform.debug-1fa778c0a5c53b2869df5d597d31a4ddecc84531.tar.gz eclipse.platform.debug-1fa778c0a5c53b2869df5d597d31a4ddecc84531.tar.xz eclipse.platform.debug-1fa778c0a5c53b2869df5d597d31a4ddecc84531.zip |
merging async_viewer_branch_2
Diffstat (limited to 'org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/expression')
5 files changed, 36 insertions, 444 deletions
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/expression/ExpressionPopupContentProvider.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/expression/ExpressionPopupContentProvider.java deleted file mode 100644 index 928450515..000000000 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/expression/ExpressionPopupContentProvider.java +++ /dev/null @@ -1,44 +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.views.expression; - -import org.eclipse.debug.internal.ui.views.RemoteTreeViewer; -import org.eclipse.debug.internal.ui.views.variables.VariablesView; -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.ui.IWorkbenchPartSite; - - -public class ExpressionPopupContentProvider extends RemoteExpressionsContentProvider { - - private Object input = null; - - public ExpressionPopupContentProvider(RemoteTreeViewer viewer, IWorkbenchPartSite site, VariablesView view) { - super(viewer, site, view); - } - - - /* (non-Javadoc) - * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object) - */ - public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { - super.inputChanged(viewer, oldInput, newInput); - input = newInput; - } - /* (non-Javadoc) - * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object) - */ - public Object[] getElements(Object parent) { - if (parent == input) { - return (Object[]) input; - } - return super.getElements(parent); - } -} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/expression/ExpressionView.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/expression/ExpressionView.java index 65c7a65f0..850516a53 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/expression/ExpressionView.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/expression/ExpressionView.java @@ -12,37 +12,21 @@ package org.eclipse.debug.internal.ui.views.expression; 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.IErrorReportingExpression; -import org.eclipse.debug.core.model.IExpression; -import org.eclipse.debug.core.model.IWatchExpression; import org.eclipse.debug.internal.ui.IDebugHelpContextIds; import org.eclipse.debug.internal.ui.preferences.IDebugPreferenceConstants; -import org.eclipse.debug.internal.ui.views.DebugViewInterimLabelProvider; -import org.eclipse.debug.internal.ui.views.DebugViewLabelDecorator; -import org.eclipse.debug.internal.ui.views.RemoteTreeViewer; +import org.eclipse.debug.internal.ui.views.AbstractViewerState; import org.eclipse.debug.internal.ui.views.variables.AvailableLogicalStructuresAction; -import org.eclipse.debug.internal.ui.views.variables.RemoteVariablesContentProvider; import org.eclipse.debug.internal.ui.views.variables.VariablesView; -import org.eclipse.debug.internal.ui.views.variables.VariablesViewEventHandler; import org.eclipse.debug.internal.ui.views.variables.VariablesViewMessages; import org.eclipse.debug.ui.IDebugUIConstants; import org.eclipse.jface.action.IAction; import org.eclipse.jface.action.IMenuManager; import org.eclipse.jface.action.IToolBarManager; import org.eclipse.jface.action.Separator; -import org.eclipse.jface.viewers.IBaseLabelProvider; -import org.eclipse.jface.viewers.ILabelProvider; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.ITreeContentProvider; import org.eclipse.jface.viewers.SelectionChangedEvent; -import org.eclipse.jface.viewers.StructuredViewer; -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.swt.SWT; -import org.eclipse.swt.graphics.Color; -import org.eclipse.swt.widgets.Display; import org.eclipse.ui.IMemento; import org.eclipse.ui.IWorkbenchActionConstants; import org.eclipse.ui.IWorkbenchPart; @@ -53,61 +37,7 @@ import org.eclipse.ui.IWorkbenchPart; */ public class ExpressionView extends VariablesView { - /** - * A decorating label provider which provides color for expressions. - */ - protected class ExpressionViewDecoratingLabelProvider extends VariablesView.VariablesViewDecoratingLabelProvider { - /** - * @see org.eclipse.jface.viewers.IColorProvider#getForeground(java.lang.Object) - */ - public Color getForeground(Object element) { - boolean expressionWithError= false; - IErrorReportingExpression expression= null; - if (element instanceof IErrorReportingExpression) { - expression= (IErrorReportingExpression) element; - } else if (element instanceof String) { - Object parent= ((ITreeContentProvider)getVariablesViewer().getContentProvider()).getParent(element); - if (parent instanceof IErrorReportingExpression) { - expression= (IErrorReportingExpression) parent; - } - } - if (expression != null && expression.hasErrors()) { - expressionWithError= true; - } - if (expressionWithError) { - return Display.getDefault().getSystemColor(SWT.COLOR_RED); - } - return super.getForeground(element); - } - - public ExpressionViewDecoratingLabelProvider(StructuredViewer viewer, ILabelProvider provider, DebugViewLabelDecorator decorator) { - super(viewer, provider, decorator); - } - } - /** - * @see org.eclipse.debug.internal.ui.views.variables.VariablesView#createLabelProvider() - */ - protected IBaseLabelProvider createLabelProvider(StructuredViewer viewer) { - return new ExpressionViewDecoratingLabelProvider(viewer, new DebugViewInterimLabelProvider(getModelPresentation()), new DebugViewLabelDecorator(getModelPresentation())); - } - - /** - * Creates this view's content provider. - * - * @return a content provider - */ - protected RemoteVariablesContentProvider createContentProvider(Viewer viewer) { - return new RemoteExpressionsContentProvider((RemoteTreeViewer)viewer, getSite(), this); - } - - /** - * Creates this view's event handler. - * - * @return an event handler - */ - protected VariablesViewEventHandler createEventHandler() { - return new ExpressionViewEventHandler(this); - } + private AbstractViewerState fState; /** * @see AbstractDebugView#getHelpContextId() @@ -153,38 +83,10 @@ public class ExpressionView extends VariablesView { menu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS)); } - /** - * The <code>ExpressionView</code> listens for selection changes in the <code>LaunchesView</code> - * to correctly set the editable state of the details pane. Updates the context of - * watch expressions. - * - * @see ISelectionListener#selectionChanged(IWorkbenchPart, ISelection) - */ - public void selectionChanged(IWorkbenchPart part, ISelection selection) { + public void contextActivated(ISelection selection, IWorkbenchPart part) { if (!isVisible()) { return; } - if (selection instanceof IStructuredSelection) { - IDebugElement context = null; - IStructuredSelection ss = (IStructuredSelection)selection; - if (ss.size() < 2) { - Object object = ss.getFirstElement(); - if (object instanceof IDebugElement) { - context= (IDebugElement) object; - } else if (object instanceof ILaunch) { - context= ((ILaunch) object).getDebugTarget(); - } - } - // update watch expressions with new context - IExpression[] expressions = DebugPlugin.getDefault().getExpressionManager().getExpressions(); - for (int i = 0; i < expressions.length; i++) { - IExpression expression = expressions[i]; - if (expression instanceof IWatchExpression) { - ((IWatchExpression)expression).setExpressionContext(context); - } - } - } - // update actions updateAction("ContentAssist"); //$NON-NLS-1$ } @@ -195,7 +97,7 @@ public class ExpressionView extends VariablesView { * * @see VariablesView#setViewerInput(IStructuredSelection) */ - protected void setViewerInput(IStructuredSelection ssel) { + protected void setViewerInput(Object obj) { } /* (non-Javadoc) @@ -243,10 +145,42 @@ public class ExpressionView extends VariablesView { * @see org.eclipse.debug.internal.ui.views.variables.VariablesView#restoreState() */ protected void restoreState() { + if (fState != null) { + fState.restoreState(getVariablesViewer()); + } } + /* (non-Javadoc) * @see org.eclipse.ui.IViewPart#saveState(org.eclipse.ui.IMemento) */ public void saveState(IMemento memento) { } + + /* (non-Javadoc) + * @see org.eclipse.debug.internal.ui.views.variables.VariablesView#dispose() + */ + public void dispose() { + super.dispose(); + fState = null; + } + + /* (non-Javadoc) + * @see org.eclipse.debug.internal.ui.views.variables.VariablesView#becomesHidden() + */ + protected void becomesHidden() { + fState = getViewerState(); + super.becomesHidden(); + getViewer().setInput(null); + } + + /* (non-Javadoc) + * @see org.eclipse.debug.internal.ui.views.variables.VariablesView#becomesVisible() + */ + protected void becomesVisible() { + super.becomesVisible(); + setInitialContent(); + restoreState(); + } + + } diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/expression/ExpressionViewEventHandler.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/expression/ExpressionViewEventHandler.java deleted file mode 100644 index f87c70047..000000000 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/expression/ExpressionViewEventHandler.java +++ /dev/null @@ -1,180 +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.views.expression; - - -import java.util.List; - -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.debug.core.DebugEvent; -import org.eclipse.debug.core.DebugPlugin; -import org.eclipse.debug.core.IExpressionsListener; -import org.eclipse.debug.core.ILaunch; -import org.eclipse.debug.core.model.IDebugElement; -import org.eclipse.debug.core.model.IDebugTarget; -import org.eclipse.debug.core.model.IExpression; -import org.eclipse.debug.core.model.IWatchExpression; -import org.eclipse.debug.internal.ui.views.variables.VariablesViewEventHandler; -import org.eclipse.debug.ui.AbstractDebugView; -import org.eclipse.debug.ui.DebugUITools; -import org.eclipse.jface.viewers.IContentProvider; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.StructuredSelection; - -/** - * Updates the expression view - */ -public class ExpressionViewEventHandler extends VariablesViewEventHandler implements IExpressionsListener { - - /** - * Also update expressions if a target terminates - * - * @see org.eclipse.debug.internal.ui.views.variables.VariablesViewEventHandler#doHandleTerminateEvent(org.eclipse.debug.core.DebugEvent) - */ - protected void doHandleTerminateEvent(DebugEvent event) { - super.doHandleTerminateEvent(event); - if (event.getSource() instanceof IDebugTarget) { - IExpression[] expressions = DebugPlugin.getDefault().getExpressionManager().getExpressions(); - IAdaptable object = DebugUITools.getDebugContext(); - IDebugElement context= null; - if (object instanceof IDebugElement) { - context= (IDebugElement) object; - } else if (object instanceof ILaunch) { - context= ((ILaunch) object).getDebugTarget(); - } - for (int i = 0; i < expressions.length; i++) { - IExpression expression = expressions[i]; - if (expression instanceof IWatchExpression) { - ((IWatchExpression)expression).setExpressionContext(context); - } - } - } - } - - /** - * Constructs a new event handler on the given view - * - * @param view variables view - */ - public ExpressionViewEventHandler(AbstractDebugView view) { - super(view); - DebugPlugin plugin= DebugPlugin.getDefault(); - plugin.getExpressionManager().addExpressionListener(this); - } - - /** - * De-registers this event handler from the debug model. - */ - public void dispose() { - DebugPlugin plugin= DebugPlugin.getDefault(); - plugin.getExpressionManager().removeExpressionListener(this); - super.dispose(); - } - - /** - * @see IExpressionsListener#expressionsAdded(IExpression[]) - */ - public void expressionsAdded(final IExpression[] expressions) { - Runnable r = new Runnable() { - public void run() { - if (isAvailable()) { - getTreeViewer().refresh(); - if (expressions.length > 0) { - ISelection selection = new StructuredSelection(expressions[0]); - getTreeViewer().setSelection(selection, true); - } - } - } - }; - getView().asyncExec(r); - } - - /** - * @see IExpressionsListener#expressionsRemoved(IExpression[]) - */ - public void expressionsRemoved(final IExpression[] expressions) { - Runnable r = new Runnable() { - public void run() { - if (isAvailable()) { - getTreeViewer().getControl().setRedraw(false); - for (int i = 0; i < expressions.length; i++) { - IExpression expression = expressions[i]; - remove(expression); - IContentProvider provider= getTreeViewer().getContentProvider(); - if (provider instanceof RemoteExpressionsContentProvider) { - RemoteExpressionsContentProvider expressionProvider= (RemoteExpressionsContentProvider) provider; - List decendants = expressionProvider.getCachedDecendants(expression); - decendants.add(expression); - // Remove the parent cache for the expression and its children - expressionProvider.removeCache(decendants.toArray()); - IExpression[] allExpressions= DebugPlugin.getDefault().getExpressionManager().getExpressions(); - if (allExpressions.length > 0) { - getTreeViewer().setSelection(new StructuredSelection(allExpressions[0]), true); - } - } - } - getTreeViewer().getControl().setRedraw(true); - } - } - }; - getView().asyncExec(r); - } - - /** - * @see IExpressionsListener#expressionsChanged(IExpression[]) - */ - public void expressionsChanged(final IExpression[] expressions) { - Runnable r = new Runnable() { - public void run() { - if (isAvailable()) { - getTreeViewer().getControl().setRedraw(false); - for (int i = 0; i < expressions.length; i++) { - IExpression expression = expressions[i]; - refresh(expression); - // update details if selected - IStructuredSelection selection = (IStructuredSelection)getViewer().getSelection(); - if (selection.size() == 1 && selection.getFirstElement().equals(expression)) { - getVariablesView().populateDetailPane(); - } - } - getTreeViewer().getControl().setRedraw(true); - } - } - }; - getView().asyncExec(r); - } - - /** - * Override the superclass method. Do nothing. - */ - protected void doHandleResumeEvent(DebugEvent event) { - } - /** - * @see org.eclipse.debug.internal.ui.views.variables.VariablesViewEventHandler#doHandleChangeEvent(org.eclipse.debug.core.DebugEvent) - */ - protected void doHandleChangeEvent(DebugEvent event) { - if (event.getSource() instanceof IExpression) { - refresh(event.getSource()); - getVariablesView().populateDetailPane(); - } else { - super.doHandleChangeEvent(event); - } - } - - protected boolean isFiltered(DebugEvent event) { - // TODO Auto-generated method stub - return false; - } - - - -} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/expression/RemoteExpressionContentManager.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/expression/RemoteExpressionContentManager.java deleted file mode 100644 index e5c60c54c..000000000 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/expression/RemoteExpressionContentManager.java +++ /dev/null @@ -1,84 +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.views.expression; - -import org.eclipse.debug.core.DebugException; -import org.eclipse.debug.core.model.IErrorReportingExpression; -import org.eclipse.debug.core.model.IExpression; -import org.eclipse.debug.core.model.IValue; -import org.eclipse.debug.core.model.IVariable; -import org.eclipse.debug.internal.ui.elements.adapters.DeferredExpressionLogicalStructure; -import org.eclipse.debug.internal.ui.views.RemoteTreeViewer; -import org.eclipse.debug.internal.ui.views.variables.RemoteVariableContentManager; -import org.eclipse.debug.internal.ui.views.variables.VariablesView; -import org.eclipse.jface.viewers.ITreeContentProvider; -import org.eclipse.ui.IWorkbenchPartSite; -import org.eclipse.ui.progress.IDeferredWorkbenchAdapter; - -/** - * Remote content manager for variables. Creates an appropriate adapter for - * logical structures. - */ -public class RemoteExpressionContentManager extends RemoteVariableContentManager { - - private IDeferredWorkbenchAdapter fExpressionLogicalStructureAdapter = new DeferredExpressionLogicalStructure(); - - /** - * Constructs a remote content manager for a variables view. - */ - public RemoteExpressionContentManager(ITreeContentProvider provider, RemoteTreeViewer viewer, IWorkbenchPartSite site, VariablesView view) { - super(provider, viewer, site, view); - } - - /* (non-Javadoc) - * @see org.eclipse.ui.progress.DeferredTreeContentManager#getAdapter(java.lang.Object) - */ - protected IDeferredWorkbenchAdapter getAdapter(Object element) { - if (element instanceof IExpression && fView !=null && fView.isShowLogicalStructure()) { - return fExpressionLogicalStructureAdapter; - } - return super.getAdapter(element); - } - - public boolean mayHaveChildren(Object element) { - if (element instanceof IErrorReportingExpression) { - IErrorReportingExpression iere = (IErrorReportingExpression) element; - if (iere.hasErrors()) { - //errors are displayed as children of the expression - return true; - } - } - - if (element instanceof IExpression) { - IExpression expression = (IExpression) element; - IValue value = expression.getValue(); - if (value != null) { - try { - IVariable[] variables = value.getVariables(); - if (variables.length > 0) { - //definitely children... - return true; - } - - //returning false because value!=null && variables.length=0 means no children - return false; - } catch (DebugException e) { - } - } - } - - //expression has not been evaluated - return super.mayHaveChildren(element); - } - - - -} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/expression/RemoteExpressionsContentProvider.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/expression/RemoteExpressionsContentProvider.java deleted file mode 100644 index bae39c852..000000000 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/expression/RemoteExpressionsContentProvider.java +++ /dev/null @@ -1,34 +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.views.expression; - -import org.eclipse.debug.internal.ui.views.RemoteTreeContentManager; -import org.eclipse.debug.internal.ui.views.RemoteTreeViewer; -import org.eclipse.debug.internal.ui.views.variables.RemoteVariablesContentProvider; -import org.eclipse.debug.internal.ui.views.variables.VariablesView; -import org.eclipse.ui.IWorkbenchPartSite; - -public class RemoteExpressionsContentProvider extends RemoteVariablesContentProvider { - - /** - * @param viewer - * @param site - * @param view - */ - public RemoteExpressionsContentProvider(RemoteTreeViewer viewer, IWorkbenchPartSite site, VariablesView view) { - super(viewer, site, view); - } - - protected RemoteTreeContentManager createContentManager(RemoteTreeViewer viewer, IWorkbenchPartSite site, VariablesView view) { - return new RemoteExpressionContentManager(this, viewer, site, view); - } - -} |