diff options
Diffstat (limited to 'org.eclipse.debug.ui/ui/org/eclipse/debug/internal')
17 files changed, 274 insertions, 99 deletions
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/DebugContextManager.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/DebugContextManager.java index ffbd69851..7b700fea1 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/DebugContextManager.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/DebugContextManager.java @@ -7,6 +7,8 @@ * * Contributors: * IBM Corporation - initial API and implementation + * Patrick Chuong (Texas Instruments) - Allow multiple debug views and + * multiple debug context providers (Bug 327263) *******************************************************************************/ package org.eclipse.debug.internal.ui.contexts; @@ -64,6 +66,20 @@ public class DebugContextManager implements IDebugContextManager { } public void addDebugContextListener(IDebugContextListener listener) { } + public void addDebugContextListener(IDebugContextListener listener, String partId, String partSecondaryId) { + + } + public void removeDebugContextListener(IDebugContextListener listener, String partId, String partSecondaryId) { + } + + public ISelection getActiveContext(String partId, String partSecondaryId) { + return null; + } + public void addPostDebugContextListener(IDebugContextListener listener, String partId, String partSecondaryId) { + } + + public void removePostDebugContextListener(IDebugContextListener listener, String partId, String partSecondaryId) { + } }; private class WindowListener implements IWindowListener { diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/DebugWindowContextService.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/DebugWindowContextService.java index 6cc2f2c92..dcc731559 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/DebugWindowContextService.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/DebugWindowContextService.java @@ -8,11 +8,15 @@ * Contributors: * IBM Corporation - initial API and implementation * Wind River - Pawel Piech - added an evaluation context source provider (bug 229219) + * Patrick Chuong (Texas Instruments) and Pawel Piech (Wind River) - + * Allow multiple debug views and multiple debug context providers (Bug 327263) *******************************************************************************/ package org.eclipse.debug.internal.ui.contexts; import java.util.ArrayList; +import java.util.Arrays; import java.util.HashMap; +import java.util.Iterator; import java.util.List; import java.util.Map; @@ -23,10 +27,12 @@ import org.eclipse.debug.internal.ui.DebugUIPlugin; import org.eclipse.debug.ui.contexts.DebugContextEvent; import org.eclipse.debug.ui.contexts.IDebugContextListener; import org.eclipse.debug.ui.contexts.IDebugContextProvider; +import org.eclipse.debug.ui.contexts.IDebugContextProvider2; import org.eclipse.debug.ui.contexts.IDebugContextService; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.StructuredSelection; import org.eclipse.ui.IPartListener2; +import org.eclipse.ui.IViewSite; import org.eclipse.ui.IWorkbenchPage; import org.eclipse.ui.IWorkbenchPart; import org.eclipse.ui.IWorkbenchPartReference; @@ -69,7 +75,7 @@ public class DebugWindowContextService implements IDebugContextService, IPartLis IWorkbenchPart part = provider.getPart(); String id = null; if (part != null) { - id = part.getSite().getId(); + id = getCombinedPartId(part); } fProvidersByPartId.put(id, provider); fProviders.add(provider); @@ -90,7 +96,7 @@ public class DebugWindowContextService implements IDebugContextService, IPartLis IWorkbenchPart part = provider.getPart(); String id = null; if (part != null) { - id = part.getSite().getId(); + id = getCombinedPartId(part); } fProvidersByPartId.remove(id); fProviders.remove(index); @@ -158,48 +164,100 @@ public class DebugWindowContextService implements IDebugContextService, IPartLis } protected void notify(DebugContextEvent event) { - notify(event, getListeners(null)); - IWorkbenchPart part = event.getDebugContextProvider().getPart(); - if (part != null) { - notify(event, getListeners(part)); - } - notify(event, getPostListeners(null)); - if (part != null) { - notify(event, getPostListeners(part)); + IDebugContextProvider provider = getActiveProvider(); + if (provider != null) { + IWorkbenchPart part = event.getDebugContextProvider().getPart(); + + // Once for listeners + if (provider == event.getDebugContextProvider()) { + notify(event, getListeners(null)); + } + if (part != null) { + notify(event, getListeners(part)); + } + + // Again for post-listeners + if (provider == event.getDebugContextProvider()) { + notify(event, getPostListeners(null)); + } + if (part != null) { + notify(event, getPostListeners(part)); + } } } - protected void notify(final DebugContextEvent event, ListenerList list) { - if (list != null) { - Object[] listeners = list.getListeners(); - for (int i = 0; i < listeners.length; i++) { - final IDebugContextListener listener = (IDebugContextListener) listeners[i]; - SafeRunner.run(new ISafeRunnable() { - public void run() throws Exception { - listener.debugContextChanged(event); - } - public void handleException(Throwable exception) { - DebugUIPlugin.log(exception); - } - }); - } + protected void notify(final DebugContextEvent event, Object[] listeners) { + for (int i = 0; i < listeners.length; i++) { + final IDebugContextListener listener = (IDebugContextListener) listeners[i]; + SafeRunner.run(new ISafeRunnable() { + public void run() throws Exception { + listener.debugContextChanged(event); + } + public void handleException(Throwable exception) { + DebugUIPlugin.log(exception); + } + }); } } - protected ListenerList getListeners(IWorkbenchPart part) { - String id = null; - if (part != null) { - id = part.getSite().getId(); - } - return (ListenerList) fListenersByPartId.get(id); + protected Object[] getListeners(IWorkbenchPart part) { + String id = null; + if (part != null) { + id = getCombinedPartId(part); + ListenerList listenerList = (ListenerList)fListenersByPartId.get(id); + return listenerList != null ? listenerList.getListeners() : new Object[0]; + } else { + List retVal = new ArrayList(); + retVal.addAll(Arrays.asList(((ListenerList)fListenersByPartId.get(null)).getListeners()) ); + outer: for (Iterator itr = fListenersByPartId.keySet().iterator(); itr.hasNext();) { + String listenerPartId = (String)itr.next(); + for (int i = 0; i < fProviders.size(); i++) { + String providerPartId = getCombinedPartId(((IDebugContextProvider)fProviders.get(i)).getPart()); + if ((listenerPartId == null && providerPartId == null) || + (listenerPartId != null && listenerPartId.equals(providerPartId))) + { + continue outer; + } + } + + List toAdd = Arrays.asList(((ListenerList)fListenersByPartId.get(listenerPartId)).getListeners()); + for (Iterator addItr = toAdd.iterator(); addItr.hasNext();) { + Object element = addItr.next(); + if (!retVal.contains(element)) retVal.add(element); + + } + } + return retVal.toArray(); + } } - protected ListenerList getPostListeners(IWorkbenchPart part) { - String id = null; - if (part != null) { - id = part.getSite().getId(); - } - return (ListenerList) fPostListenersByPartId.get(id); + protected Object[] getPostListeners(IWorkbenchPart part) { + String id = null; + if (part != null) { + id = getCombinedPartId(part); + ListenerList listenerList = (ListenerList)fPostListenersByPartId.get(id); + return listenerList != null ? listenerList.getListeners() : new Object[0]; + } else { + List retVal = new ArrayList(); + ListenerList postListenersList = (ListenerList)fPostListenersByPartId.get(null); + if (postListenersList != null) { + retVal.addAll( Arrays.asList(postListenersList.getListeners()) ); + } + + outer: for (Iterator itr = fPostListenersByPartId.keySet().iterator(); itr.hasNext();) { + String listenerPartId = (String)itr.next(); + for (int i = 0; i < fProviders.size(); i++) { + String providerPartId = getCombinedPartId(((IDebugContextProvider)fProviders.get(i)).getPart()); + if ((listenerPartId == null && providerPartId == null) || + (listenerPartId != null && listenerPartId.equals(providerPartId))) + { + continue outer; + } + } + retVal.addAll( Arrays.asList(((ListenerList)fPostListenersByPartId.get(listenerPartId)).getListeners()) ); + } + return retVal.toArray(); + } } /* (non-Javadoc) @@ -221,6 +279,8 @@ public class DebugWindowContextService implements IDebugContextService, IPartLis ListenerList list = (ListenerList) fListenersByPartId.get(partId); if (list != null) { list.remove(listener); + if (list.size() == 0) + fListenersByPartId.remove(partId); } } @@ -232,7 +292,7 @@ public class DebugWindowContextService implements IDebugContextService, IPartLis if (provider != null) { return provider.getActiveContext(); } - return null; + return getActiveContext(); } /* (non-Javadoc) @@ -251,7 +311,7 @@ public class DebugWindowContextService implements IDebugContextService, IPartLis * * @return active provider or <code>null</code> */ - protected IDebugContextProvider getActiveProvider() { + private IDebugContextProvider getActiveProvider() { if (!fProviders.isEmpty()) { return (IDebugContextProvider)fProviders.get(0); } @@ -264,11 +324,18 @@ public class DebugWindowContextService implements IDebugContextService, IPartLis public void partActivated(IWorkbenchPartReference partRef) { IDebugContextProvider provider = (IDebugContextProvider) fProvidersByPartId.get(partRef.getId()); if (provider != null) { - int index = fProviders.indexOf(provider); - if (index > 0) { - fProviders.remove(index); - fProviders.add(0, provider); - notify(provider); + boolean canSetActive = true; + if (provider instanceof IDebugContextProvider2) { + canSetActive = ((IDebugContextProvider2) provider).isWindowContextProvider(); + } + + if (canSetActive) { + int index = fProviders.indexOf(provider); + if (index > 0) { + fProviders.remove(index); + fProviders.add(0, provider); + notify(provider); + } } } @@ -319,13 +386,56 @@ public class DebugWindowContextService implements IDebugContextService, IPartLis /* (non-Javadoc) * @see org.eclipse.debug.internal.ui.contexts.provisional.IDebugContextEventListener#contextEvent(org.eclipse.debug.internal.ui.contexts.provisional.DebugContextEvent) */ - public void debugContextChanged(DebugContextEvent event) { - if (!fProviders.isEmpty()) { - IDebugContextProvider provider = (IDebugContextProvider) fProviders.get(0); - if (provider == event.getDebugContextProvider()) { - notify(event); - } - } + public void debugContextChanged(DebugContextEvent event) { + notify(event); + } + + private String getCombinedPartId(IWorkbenchPart part) { + if (part.getSite() instanceof IViewSite) { + IViewSite site = (IViewSite)part.getSite(); + return getCombinedPartId(site.getId(), site.getSecondaryId()); + + } else { + return part.getSite().getId(); + } + } + + private String getCombinedPartId(String id, String secondaryId) { + return id + (secondaryId != null ? ":" + secondaryId : ""); //$NON-NLS-1$//$NON-NLS-2$ + } + + /* (non-Javadoc) + * @see org.eclipse.debug.ui.contexts.IDebugContextService2#addDebugContextListener(org.eclipse.debug.ui.contexts.IDebugContextListener, java.lang.String, java.lang.String) + */ + public void addDebugContextListener(IDebugContextListener listener, String partId, String partSecondaryId) { + addDebugContextListener(listener, getCombinedPartId(partId, partSecondaryId)); + } + + /* (non-Javadoc) + * @see org.eclipse.debug.ui.contexts.IDebugContextService2#removeDebugContextListener(org.eclipse.debug.ui.contexts.IDebugContextListener, java.lang.String, java.lang.String) + */ + public void removeDebugContextListener(IDebugContextListener listener, String partId, String partSecondaryId) { + removeDebugContextListener(listener, getCombinedPartId(partId, partSecondaryId)); + } + + /* (non-Javadoc) + * @see org.eclipse.debug.ui.contexts.IDebugContextService2#addPostDebugContextListener(org.eclipse.debug.ui.contexts.IDebugContextListener, java.lang.String, java.lang.String) + */ + public void addPostDebugContextListener(IDebugContextListener listener, String partId, String partSecondaryId) { + addPostDebugContextListener(listener, getCombinedPartId(partId, partSecondaryId)); } + /* (non-Javadoc) + * @see org.eclipse.debug.ui.contexts.IDebugContextService2#removePostDebugContextListener(org.eclipse.debug.ui.contexts.IDebugContextListener, java.lang.String, java.lang.String) + */ + public void removePostDebugContextListener(IDebugContextListener listener, String partId, String partSecondaryId) { + removePostDebugContextListener(listener, getCombinedPartId(partId, partSecondaryId)); + } + + /* (non-Javadoc) + * @see org.eclipse.debug.ui.contexts.IDebugContextService2#getActiveContext(java.lang.String, java.lang.String) + */ + public ISelection getActiveContext(String partId, String partSecondaryId) { + return getActiveContext(getCombinedPartId(partId, partSecondaryId)); + } } diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/memory/provisional/AbstractAsyncTableRendering.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/memory/provisional/AbstractAsyncTableRendering.java index 781c36376..cecec5685 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/memory/provisional/AbstractAsyncTableRendering.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/memory/provisional/AbstractAsyncTableRendering.java @@ -288,8 +288,8 @@ public abstract class AbstractAsyncTableRendering extends AbstractBaseTableRende private class RenderingGoToAddressAction extends GoToAddressAction { - public RenderingGoToAddressAction(AbstractBaseTableRendering rendering) { - super(rendering); + public RenderingGoToAddressAction(IMemoryRenderingContainer container, AbstractBaseTableRendering rendering) { + super(container, rendering); } public void run() { @@ -2038,7 +2038,7 @@ public abstract class AbstractAsyncTableRendering extends AbstractBaseTableRende protected void createActions() { fCopyToClipboardAction = new AsyncCopyTableRenderingAction(this, fTableViewer); - fGoToAddressAction = new RenderingGoToAddressAction(this); + fGoToAddressAction = new RenderingGoToAddressAction(getMemoryRenderingContainer(), this); fResetMemoryBlockAction = new ResetToBaseAddressAction(this); fPrintViewTabAction = new AsyncPrintTableRenderingAction(this, fTableViewer); diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/LabelUpdate.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/LabelUpdate.java index ab991f695..3ffc28db7 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/LabelUpdate.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/LabelUpdate.java @@ -35,7 +35,6 @@ class LabelUpdate extends Request implements ILabelUpdate, ICheckUpdate { private String[] fLabels; private FontData[] fFontDatas; private TreeModelLabelProvider fProvider; - private ITreeModelLabelProviderTarget fTreeViewer; private int fNumColumns; private IPresentationContext fContext; private Object fViewerInput; @@ -50,7 +49,7 @@ class LabelUpdate extends Request implements ILabelUpdate, ICheckUpdate { * @param columnIds column identifiers or <code>null</code> * @param context presentation context */ - public LabelUpdate(Object viewerInput, TreePath elementPath, TreeModelLabelProvider provider, ITreeModelLabelProviderTarget treeViewer, String[] columnIds, IPresentationContext context) { + public LabelUpdate(Object viewerInput, TreePath elementPath, TreeModelLabelProvider provider, String[] columnIds, IPresentationContext context) { fContext = context; fViewerInput = viewerInput; fElementPath = elementPath; @@ -61,7 +60,6 @@ class LabelUpdate extends Request implements ILabelUpdate, ICheckUpdate { fNumColumns = columnIds.length; } fLabels = new String[fNumColumns]; - fTreeViewer = treeViewer; } /* (non-Javadoc) @@ -155,9 +153,7 @@ class LabelUpdate extends Request implements ILabelUpdate, ICheckUpdate { * Applies settings to viewer cell */ public void update() { - fTreeViewer.setElementData(fElementPath, fNumColumns, fLabels, fImageDescriptors, fFontDatas, fForegrounds, fBackgrounds); - if (fTreeViewer instanceof ITreeModelCheckProviderTarget) - ((ITreeModelCheckProviderTarget) fTreeViewer).setElementChecked(fElementPath, fChecked, fGrayed); + fProvider.setElementData(fElementPath, fNumColumns, fLabels, fImageDescriptors, fFontDatas, fForegrounds, fBackgrounds, fChecked, fGrayed); fProvider.updateComplete(this); } diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/TreeModelLabelProvider.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/TreeModelLabelProvider.java index 2e3b7cac7..833124807 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/TreeModelLabelProvider.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/TreeModelLabelProvider.java @@ -264,7 +264,7 @@ public class TreeModelLabelProvider extends ColumnLabelProvider updates = new LinkedList(); fPendingUpdates.put(presentation, updates); } - updates.add(new LabelUpdate(fViewer.getInput(), elementPath, this, fViewer, visibleColumns, fViewer.getPresentationContext())); + updates.add(new LabelUpdate(fViewer.getInput(), elementPath, this, visibleColumns, fViewer.getPresentationContext())); if (fPendingUpdatesJob != null) { fPendingUpdatesJob.cancel(); } @@ -297,6 +297,22 @@ public class TreeModelLabelProvider extends ColumnLabelProvider } } + /** + * Sets the element's display information in the viewer. + * + * @see ITreeModelLabelProviderTarget#setElementData(TreePath, int, String[], ImageDescriptor[], FontData[], RGB[], RGB[]) + * @see ITreeModelCheckProviderTarget#setElementChecked(TreePath, boolean, boolean) + */ + protected void setElementData(TreePath path, int numColumns, String[] labels, ImageDescriptor[] images, + FontData[] fontDatas, RGB[] foregrounds, RGB[] backgrounds, boolean checked, boolean grayed) + { + fViewer.setElementData(path, numColumns, labels, images, fontDatas, foregrounds, backgrounds); + + if (fViewer instanceof ITreeModelCheckProviderTarget) + ((ITreeModelCheckProviderTarget) fViewer).setElementChecked(path, checked, grayed); + } + + private void startRequests(UIJob updateJob) { // Avoid calling providers inside a synchronized section. Instead // copy the updates map into a new variable. 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 cbaced58f..207cd4bad 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 @@ -42,6 +42,7 @@ import org.eclipse.swt.dnd.DND; import org.eclipse.swt.dnd.DropTargetEvent; import org.eclipse.swt.dnd.TextTransfer; import org.eclipse.swt.dnd.TransferData; +import org.eclipse.ui.IWorkbenchPartSite; /** * Drop Adapter allowing expressions, variables and text to be dropped in the Expression View. @@ -54,7 +55,8 @@ import org.eclipse.swt.dnd.TransferData; */ public class ExpressionDropAdapter extends ViewerDropAdapter { - private TransferData fCurrentTransferType = null; + private IWorkbenchPartSite fSite; + private TransferData fCurrentTransferType = null; private boolean fInsertBefore; private int fDropType; @@ -67,8 +69,9 @@ public class ExpressionDropAdapter extends ViewerDropAdapter { * Constructor takes the viewer this drop adapter applies to. * @param viewer the viewer to add drop to */ - protected ExpressionDropAdapter(TreeModelViewer viewer) { + protected ExpressionDropAdapter(IWorkbenchPartSite site, TreeModelViewer viewer) { super(viewer); + fSite = site; setFeedbackEnabled(true); setSelectionFeedbackEnabled(false); setScrollExpandEnabled(false); @@ -473,7 +476,7 @@ public class ExpressionDropAdapter extends ViewerDropAdapter { */ private IExpression createExpression(String exp) { IWatchExpression expression = DebugPlugin.getDefault().getExpressionManager().newWatchExpression(exp); - IAdaptable object = DebugUITools.getDebugContext(); + IAdaptable object = DebugUITools.getPartDebugContext(fSite); IDebugElement context = null; if (object instanceof IDebugElement) { context = (IDebugElement) object; 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 bcf9c86f0..984b37ede 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 @@ -155,7 +155,7 @@ public class ExpressionView extends VariablesView { */ protected void initDragAndDrop(TreeModelViewer viewer) { viewer.addDragSupport(DND.DROP_MOVE, new Transfer[] {LocalSelectionTransfer.getTransfer()}, new SelectionDragAdapter(viewer)); - viewer.addDropSupport(DND.DROP_MOVE|DND.DROP_COPY, new Transfer[] {LocalSelectionTransfer.getTransfer(), TextTransfer.getInstance()}, new ExpressionDropAdapter(viewer)); + viewer.addDropSupport(DND.DROP_MOVE|DND.DROP_COPY, new Transfer[] {LocalSelectionTransfer.getTransfer(), TextTransfer.getInstance()}, new ExpressionDropAdapter(getSite(), viewer)); } /* (non-Javadoc) @@ -226,7 +226,7 @@ public class ExpressionView extends VariablesView { // TODO: duplicate code from WatchExpressionAction protected IDebugElement getContext() { - IAdaptable object = DebugUITools.getDebugContext(); + IAdaptable object = DebugUITools.getPartDebugContext(getSite()); IDebugElement context = null; if (object instanceof IDebugElement) { context = (IDebugElement) object; diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/AbstractMemoryViewPane.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/AbstractMemoryViewPane.java index 6dad2ff78..791dd71ff 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/AbstractMemoryViewPane.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/AbstractMemoryViewPane.java @@ -115,8 +115,8 @@ public abstract class AbstractMemoryViewPane implements IMemoryBlockListener, IS addListeners(); - Object context = DebugUITools.getDebugContext(); - if (context != null) + Object context = DebugUITools.getPartDebugContext(fParent.getSite()); + if (context != null) { IMemoryBlockRetrieval retrieval = MemoryViewUtil.getMemoryBlockRetrieval(context); if (retrieval != null) @@ -132,7 +132,7 @@ public abstract class AbstractMemoryViewPane implements IMemoryBlockListener, IS { MemoryViewUtil.getMemoryBlockManager().addListener(this); fParent.getViewSite().getPage().addSelectionListener(this); - DebugUITools.getDebugContextManager().getContextService(fParent.getSite().getWorkbenchWindow()).addDebugContextListener(this); + DebugUITools.addPartDebugContextListener(fParent.getSite(), this); DebugPlugin.getDefault().addDebugEventListener(this); } @@ -140,8 +140,7 @@ public abstract class AbstractMemoryViewPane implements IMemoryBlockListener, IS { MemoryViewUtil.getMemoryBlockManager().removeListener(this); fParent.getViewSite().getPage().removeSelectionListener(this); - DebugUITools.getDebugContextManager().getContextService(fParent.getSite().getWorkbenchWindow()).removeDebugContextListener(this); - + DebugUITools.removePartDebugContextListener(fParent.getSite(), this); if (fStackLayout.topControl != null) { CTabFolder old = (CTabFolder)fStackLayout.topControl; diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/AddMemoryBlockAction.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/AddMemoryBlockAction.java index c0188450b..0ebcbb4f0 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/AddMemoryBlockAction.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/AddMemoryBlockAction.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2008 IBM Corporation and others. + * Copyright (c) 2004, 2010 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 @@ -104,11 +104,11 @@ public class AddMemoryBlockAction extends Action implements IDebugContextListene setDisabledImageDescriptor(DebugPluginImages.getImageDescriptor(IInternalDebugUIConstants.IMG_DLCL_MONITOR_EXPRESSION)); PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IDebugUIConstants.PLUGIN_ID + ".addMemoryMonitorAction_context"); //$NON-NLS-1$ - // listen for context changed - DebugUITools.getDebugContextManager().getContextService(site.getSite().getWorkbenchWindow()).addDebugContextListener(this); + // listen for context changed + DebugUITools.addPartDebugContextListener(fSite.getSite(), this); // get current context - fCurrentContext = DebugUITools.getDebugContext(); + fCurrentContext = DebugUITools.getPartDebugContext(site.getSite()); // set up enablement based on current selection updateAction(fCurrentContext); @@ -127,7 +127,7 @@ public class AddMemoryBlockAction extends Action implements IDebugContextListene { exit = true; - Object elem = DebugUITools.getDebugContext(); + Object elem = fCurrentContext; IMemoryBlockRetrieval retrieval = MemoryViewUtil.getMemoryBlockRetrieval(elem); @@ -347,7 +347,7 @@ public class AddMemoryBlockAction extends Action implements IDebugContextListene // remove listeners DebugPlugin.getDefault().removeDebugEventListener(this); - DebugUITools.getDebugContextManager().getContextService(fSite.getSite().getWorkbenchWindow()).removeDebugContextListener(this); + DebugUITools.removePartDebugContextListener(fSite.getSite(), this); } private void addDefaultRenderings(IMemoryBlock memoryBlock) @@ -422,7 +422,7 @@ public class AddMemoryBlockAction extends Action implements IDebugContextListene */ public void debugContextChanged(DebugContextEvent event) { if ((event.getFlags() & DebugContextEvent.ACTIVATED) > 0) { - IAdaptable context = DebugUITools.getDebugContext(); + IAdaptable context = DebugUITools.getPartDebugContext(fSite.getSite()); updateAction(context); fCurrentContext = context; } diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/AddMemoryRenderingDialog.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/AddMemoryRenderingDialog.java index 3eef011ab..9e57d147b 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/AddMemoryRenderingDialog.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/AddMemoryRenderingDialog.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2007 IBM Corporation and others. + * Copyright (c) 2004, 2010 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 @@ -432,7 +432,7 @@ public class AddMemoryRenderingDialog extends SelectionDialog { if (element == null) { - IAdaptable context = DebugUITools.getDebugContext(); + IAdaptable context = DebugUITools.getPartDebugContext(fSite.getSite()); if (context != null) { diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/MemoryBlocksTreeViewPane.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/MemoryBlocksTreeViewPane.java index eeba2d96b..2e4179594 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/MemoryBlocksTreeViewPane.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/MemoryBlocksTreeViewPane.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2009 IBM Corporation and others. + * Copyright (c) 2004, 2010 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 @@ -296,7 +296,7 @@ public class MemoryBlocksTreeViewPane implements ISelectionListener, ISelectionC fPresentationContext = new MemoryViewPresentationContext(site, this, null); fTreeViewer = new MemoryViewTreeViewer(parent, style, fPresentationContext); - IAdaptable context = DebugUITools.getDebugContext(); + IAdaptable context = DebugUITools.getPartDebugContext(fParent.getSite()); IMemoryBlockRetrieval retrieval = MemoryViewUtil.getMemoryBlockRetrieval(context); if (retrieval != null) fTreeViewer.setInput(retrieval); @@ -307,7 +307,7 @@ public class MemoryBlocksTreeViewPane implements ISelectionListener, ISelectionC fParent.getViewSite().getPage().addSelectionListener(this); fDebugContextListener = new TreeViewPaneContextListener(); - DebugUITools.getDebugContextManager().getContextService(fParent.getSite().getWorkbenchWindow()).addDebugContextListener(fDebugContextListener); + DebugUITools.addPartDebugContextListener(fParent.getSite(), fDebugContextListener); fTreeViewer.addSelectionChangedListener(new ISelectionChangedListener() { @@ -342,7 +342,7 @@ public class MemoryBlocksTreeViewPane implements ISelectionListener, ISelectionC */ private void updateRetrieval() { - Object context = DebugUITools.getDebugContext(); + Object context = DebugUITools.getPartDebugContext(fParent.getSite()); fRetrieval = MemoryViewUtil.getMemoryBlockRetrieval(context); } @@ -367,7 +367,7 @@ public class MemoryBlocksTreeViewPane implements ISelectionListener, ISelectionC fParent.getViewSite().getSelectionProvider().removeSelectionChangedListener(this); fParent.getViewSite().getPage().removeSelectionListener(this); fAddMemoryBlockAction.dispose(); - DebugUITools.getDebugContextManager().getContextService(fParent.getSite().getWorkbenchWindow()).removeDebugContextListener(fDebugContextListener); + DebugUITools.removePartDebugContextListener(fParent.getSite(), fDebugContextListener); fEvtHandler.dispose(); fPresentationContext.dispose(); } diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/MemoryView.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/MemoryView.java index 5e8333be2..bccacccaf 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/MemoryView.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/MemoryView.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2008 IBM Corporation and others. + * Copyright (c) 2004, 2010 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 @@ -352,7 +352,7 @@ public class MemoryView extends ViewPart implements IMemoryRenderingSite { fAddHandler = new AbstractHandler() { public Object execute(ExecutionEvent event) throws ExecutionException { - IAdaptable context = DebugUITools.getDebugContext(); + IAdaptable context = DebugUITools.getPartDebugContext(getSite()); if (context != null && MemoryViewUtil.isValidSelection(new StructuredSelection(context))) { RetargetAddMemoryBlockAction action = new RetargetAddMemoryBlockAction(MemoryView.this); diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/RenderingViewPane.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/RenderingViewPane.java index 137e5b004..d45f55b35 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/RenderingViewPane.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/RenderingViewPane.java @@ -821,7 +821,7 @@ public class RenderingViewPane extends AbstractMemoryViewPane implements IMemory if (memoryBlock == null) { // get a memory block from current debug context - IAdaptable context = DebugUITools.getDebugContext(); + IAdaptable context = DebugUITools.getPartDebugContext(fParent.getSite()); if (context != null) { IMemoryBlockRetrieval retrieval = MemoryViewUtil.getMemoryBlockRetrieval(context); diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/RetargetAddMemoryBlockAction.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/RetargetAddMemoryBlockAction.java index dfa60c091..a0667815d 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/RetargetAddMemoryBlockAction.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/RetargetAddMemoryBlockAction.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2006 IBM Corporation and others. + * Copyright (c) 2005, 2010 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 @@ -45,7 +45,7 @@ public class RetargetAddMemoryBlockAction extends AddMemoryBlockAction { public void run() { // get current selection from Debug View - Object debugContext = DebugUITools.getDebugContext(); + Object debugContext = DebugUITools.getPartDebugContext(fSite.getSite()); IAddMemoryBlocksTarget target = getAddMemoryBlocksTarget(debugContext); if (target != null) diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/SwitchMemoryBlockAction.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/SwitchMemoryBlockAction.java index a6d135739..3ce617599 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/SwitchMemoryBlockAction.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/SwitchMemoryBlockAction.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2008 IBM Corporation and others. + * Copyright (c) 2005, 2010 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 @@ -74,7 +74,7 @@ public class SwitchMemoryBlockAction extends Action implements IViewActionDelega */ public IStatus runInUIThread(IProgressMonitor monitor) { if (fAction != null) { - IAdaptable context = DebugUITools.getDebugContext(); + IAdaptable context = getDebugContext(); if (context != null) { IMemoryBlockRetrieval retrieval = MemoryViewUtil.getMemoryBlockRetrieval(context); @@ -229,7 +229,7 @@ public class SwitchMemoryBlockAction extends Action implements IViewActionDelega // get selection from memory view IMemoryBlock memoryBlock = getCurrentMemoryBlock(); - Object context = DebugUITools.getDebugContext(); + Object context = getDebugContext(); IMemoryBlockRetrieval retrieval = MemoryViewUtil.getMemoryBlockRetrieval(context); if (retrieval != null) { allMemoryBlocks = DebugPlugin.getDefault().getMemoryBlockManager().getMemoryBlocks(retrieval); @@ -299,7 +299,7 @@ public class SwitchMemoryBlockAction extends Action implements IViewActionDelega } private void switchToNext() { - IAdaptable context = DebugUITools.getDebugContext(); + IAdaptable context = getDebugContext(); if (context instanceof IDebugElement) { IDebugElement debugContext = (IDebugElement)context; IMemoryBlockRetrieval retrieval = MemoryViewUtil.getMemoryBlockRetrieval(debugContext); @@ -407,4 +407,11 @@ public class SwitchMemoryBlockAction extends Action implements IViewActionDelega return label; } + private IAdaptable getDebugContext() { + if (fView != null) { + return DebugUITools.getPartDebugContext(fView.getSite()); + } else { + return DebugUITools.getDebugContext(); + } + } } diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/GoToAddressAction.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/GoToAddressAction.java index c078b7a20..690b788ca 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/GoToAddressAction.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/GoToAddressAction.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2008 IBM Corporation and others. + * Copyright (c) 2004, 2010 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 @@ -28,6 +28,7 @@ import org.eclipse.debug.ui.DebugUITools; import org.eclipse.debug.ui.IDebugUIConstants; import org.eclipse.debug.ui.memory.AbstractMemoryRendering; import org.eclipse.debug.ui.memory.IMemoryRendering; +import org.eclipse.debug.ui.memory.IMemoryRenderingContainer; import org.eclipse.debug.ui.memory.IMemoryRenderingType; import org.eclipse.debug.ui.memory.IRepositionableMemoryRendering; import org.eclipse.jface.action.Action; @@ -43,11 +44,13 @@ import org.eclipse.ui.PlatformUI; */ public class GoToAddressAction extends Action { + private IMemoryRenderingContainer fContainer; private IRepositionableMemoryRendering fRendering; - public GoToAddressAction(IRepositionableMemoryRendering rendering) + public GoToAddressAction(IMemoryRenderingContainer container, IRepositionableMemoryRendering rendering) { super(DebugUIMessages.GoToAddressAction_title); + fContainer = container; setToolTipText(DebugUIMessages.GoToAddressAction_title); fRendering = rendering; @@ -166,7 +169,7 @@ public class GoToAddressAction extends Action private void addNewMemoryBlock(String expression, IMemoryBlockRetrievalExtension retrieval) { - Object elem = DebugUITools.getDebugContext(); + Object elem = DebugUITools.getPartDebugContext(fContainer.getMemoryRenderingSite().getSite()); if (!(elem instanceof IDebugElement)) return; diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/VariablesView.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/VariablesView.java index 1473e28e2..e8d826dfe 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/VariablesView.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/VariablesView.java @@ -14,6 +14,8 @@ * Wind River - Pawel Piech - Fix viewer input race condition (Bug 234908) * Wind River - Anton Leherbauer - Fix selection provider (Bug 254442) * Patrick Chuong (Texas Instruments) - Improve usability of the breakpoint view (Bug 238956) + * Patrick Chuong (Texas Instruments) and Pawel Piech (Wind River) - + * Allow multiple debug views and multiple debug context providers (Bug 327263) *******************************************************************************/ package org.eclipse.debug.internal.ui.views.variables; @@ -64,6 +66,7 @@ import org.eclipse.debug.ui.IDebugModelPresentation; import org.eclipse.debug.ui.IDebugUIConstants; import org.eclipse.debug.ui.contexts.DebugContextEvent; import org.eclipse.debug.ui.contexts.IDebugContextListener; +import org.eclipse.debug.ui.contexts.IDebugContextService; import org.eclipse.jface.action.IAction; import org.eclipse.jface.action.IMenuListener; import org.eclipse.jface.action.IMenuManager; @@ -418,7 +421,7 @@ public class VariablesView extends AbstractDebugView implements IDebugContextLis */ public void dispose() { - DebugUITools.getDebugContextManager().getContextService(getSite().getWorkbenchWindow()).removeDebugContextListener(this); + DebugUITools.removePartDebugContextListener(getSite(), this); getSite().getWorkbenchWindow().removePerspectiveListener(this); DebugUIPlugin.getDefault().getPreferenceStore().removePropertyChangeListener(this); JFaceResources.getFontRegistry().removeListener(this); @@ -696,17 +699,39 @@ public class VariablesView extends AbstractDebugView implements IDebugContextLis }); variablesViewer.addPostSelectionChangedListener(getTreeSelectionChangedListener()); - DebugUITools.getDebugContextManager().getContextService(getSite().getWorkbenchWindow()).addDebugContextListener(this); + DebugUITools.addPartDebugContextListener(getSite(), this); + return variablesViewer; } /** + * Returns the active debug context for this view based on the view's + * site IDs. + * + * @since 3.7 + */ + protected ISelection getDebugContext() { + IViewSite site = (IViewSite)getSite(); + IDebugContextService contextService = DebugUITools.getDebugContextManager().getContextService(site.getWorkbenchWindow()); + return contextService.getActiveContext(site.getId(), site.getSecondaryId()); + } + + /** * Returns the presentation context id for this view. * * @return context id */ protected String getPresentationContextId() { return IDebugUIConstants.ID_VARIABLE_VIEW; + } + + /** + * Returns the presentation context secondary id for this view. + * + * @return context secondary id. + */ + protected String getPresentationContextSecondaryId() { + return ((IViewSite)getSite()).getSecondaryId(); } /** @@ -1291,7 +1316,7 @@ public class VariablesView extends AbstractDebugView implements IDebugContextLis */ protected void becomesVisible() { super.becomesVisible(); - ISelection selection = DebugUITools.getDebugContextManager().getContextService(getSite().getWorkbenchWindow()).getActiveContext(); + ISelection selection = getDebugContext(); contextActivated(selection); } |