Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--org.eclipse.debug.ui/plugin.xml2
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/breakpoints/provisional/IBreakpointUIConstants.java10
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/elements/adapters/AsynchronousDebugLabelAdapter.java47
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/elements/adapters/DefaultBreakpointManagerInput.java58
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/elements/adapters/DefaultBreakpointsViewInput.java (renamed from org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/elements/adapters/AbstractBreakpointManagerInput.java)37
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/elements/adapters/DefaultViewerInputProvider.java2
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/elements/adapters/StackFrameViewerInputProvider.java2
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/memory/provisional/MemoryViewPresentationContext.java4
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/AbstractBreakpointManagerContentProvider.java948
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/BreakpointManagerContentProvider.java1203
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/PartPresentationContext.java8
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/ModelContentProvider.java61
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/provisional/IPresentationContext.java22
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/provisional/PresentationContext.java58
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/BreakpointManagerProxy.java129
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/DefaultModelProxyFactory.java4
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/DebugModelPresentationContext.java6
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/breakpoints/BreakpointsView.java39
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/launch/DebugElementAdapterFactory.java8
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/launch/LaunchView.java2
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/MemoryViewTreeModelContentProvider.java8
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/VariablesView.java2
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/ui/InspectPopupDialog.java2
23 files changed, 1409 insertions, 1253 deletions
diff --git a/org.eclipse.debug.ui/plugin.xml b/org.eclipse.debug.ui/plugin.xml
index 213f49597..2a3f20c30 100644
--- a/org.eclipse.debug.ui/plugin.xml
+++ b/org.eclipse.debug.ui/plugin.xml
@@ -2482,7 +2482,7 @@ M4 = Platform-specific fourth key
</adapter>
</factory>
<factory
- adaptableType="org.eclipse.debug.internal.ui.elements.adapters.DefaultBreakpointManagerInput"
+ adaptableType="org.eclipse.debug.internal.ui.elements.adapters.DefaultBreakpointsViewInput"
class="org.eclipse.debug.internal.ui.views.launch.DebugElementAdapterFactory">
<adapter
type="org.eclipse.debug.internal.ui.viewers.model.provisional.IElementContentProvider">
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/breakpoints/provisional/IBreakpointUIConstants.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/breakpoints/provisional/IBreakpointUIConstants.java
index f983492c8..85784cdba 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/breakpoints/provisional/IBreakpointUIConstants.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/breakpoints/provisional/IBreakpointUIConstants.java
@@ -60,14 +60,4 @@ public interface IBreakpointUIConstants {
*/
public static final String PROP_BREAKPOINTS_ELEMENT_COMPARATOR = "ElementComparator"; //$NON-NLS-1$
- /**
- * The property for tracking the active debug context for the breakpoints
- * view. For most debuggers, the input into the breakpoints view will
- * remain constant as to avoid unnecessary flickering in the view.
- * However, to implement the track selection features, debugger still
- * need access to the active debug context for the breakpoints view.
- * This property is updated by the breakpoints view whenever the active
- * debug context changes.
- */
- public static final String PROP_BREAKPOINTS_ACTIVE_DEBUG_CONTEXT = "ActiveDebugContext"; //$NON-NLS-1$
}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/elements/adapters/AsynchronousDebugLabelAdapter.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/elements/adapters/AsynchronousDebugLabelAdapter.java
index 7f84fba56..16c0ba82e 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/elements/adapters/AsynchronousDebugLabelAdapter.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/elements/adapters/AsynchronousDebugLabelAdapter.java
@@ -20,7 +20,6 @@ import org.eclipse.core.runtime.CoreException;
import org.eclipse.debug.core.model.IDebugElement;
import org.eclipse.debug.internal.ui.DelegatingModelPresentation;
import org.eclipse.debug.internal.ui.LazyModelPresentation;
-import org.eclipse.debug.internal.ui.viewers.PartPresentationContext;
import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext;
import org.eclipse.debug.internal.ui.viewers.provisional.AsynchronousLabelAdapter;
import org.eclipse.debug.internal.ui.viewers.provisional.ILabelRequestMonitor;
@@ -30,7 +29,6 @@ import org.eclipse.debug.ui.IDebugView;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.swt.graphics.FontData;
import org.eclipse.swt.graphics.RGB;
-import org.eclipse.ui.IWorkbenchPart;
/**
* Asynchronous label adapter for debug elements.
@@ -47,32 +45,27 @@ public class AsynchronousDebugLabelAdapter extends AsynchronousLabelAdapter {
// Honor view specific settings in a debug view by copying model presentation settings
// into the debug element helper's presentation before we get the label. This allows
// for qualified name and type name settings to remain in tact.
- if (context instanceof PartPresentationContext) {
- PartPresentationContext ppc = (PartPresentationContext) context;
- if (element instanceof IDebugElement && ppc.getPart() instanceof IDebugView) {
- IWorkbenchPart part = ppc.getPart();
- if (part instanceof IDebugView) {
- IDebugModelPresentation pres = ((IDebugView)part).getPresentation(((IDebugElement)element).getModelIdentifier());
- Map settings = null;
- synchronized (presentation) {
- if (pres instanceof DelegatingModelPresentation) {
- settings = ((DelegatingModelPresentation)pres).getAttributes();
- } else if (pres instanceof LazyModelPresentation) {
- settings = ((LazyModelPresentation)pres).getAttributes();
- }
- if (settings != null) {
- Iterator iterator = settings.entrySet().iterator();
- while (iterator.hasNext()) {
- Map.Entry entry = (Entry) iterator.next();
- presentation.setAttribute((String) entry.getKey(), entry.getValue());
- }
- super.computeLabels(element, context, monitor);
- return;
- }
+ if (element instanceof IDebugElement && context.getPart() instanceof IDebugView) {
+ IDebugView debugView = (IDebugView)context.getPart();
+ IDebugModelPresentation pres = debugView.getPresentation(((IDebugElement)element).getModelIdentifier());
+ Map settings = null;
+ synchronized (presentation) {
+ if (pres instanceof DelegatingModelPresentation) {
+ settings = ((DelegatingModelPresentation)pres).getAttributes();
+ } else if (pres instanceof LazyModelPresentation) {
+ settings = ((LazyModelPresentation)pres).getAttributes();
+ }
+ if (settings != null) {
+ Iterator iterator = settings.entrySet().iterator();
+ while (iterator.hasNext()) {
+ Map.Entry entry = (Entry) iterator.next();
+ presentation.setAttribute((String) entry.getKey(), entry.getValue());
}
- }
- }
- }
+ super.computeLabels(element, context, monitor);
+ return;
+ }
+ }
+ }
super.computeLabels(element, context, monitor);
}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/elements/adapters/DefaultBreakpointManagerInput.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/elements/adapters/DefaultBreakpointManagerInput.java
deleted file mode 100644
index ae0ab52e2..000000000
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/elements/adapters/DefaultBreakpointManagerInput.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*****************************************************************
- * Copyright (c) 2009 Texas Instruments 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:
- * Patrick Chuong (Texas Instruments) - Initial API and implementation (Bug 238956)
- *****************************************************************/
-package org.eclipse.debug.internal.ui.elements.adapters;
-
-import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext;
-
-/**
- * Default breakpoint manager input.
- *
- * @since 3.6
- */
-public class DefaultBreakpointManagerInput extends AbstractBreakpointManagerInput {
-
- /**
- * Constructor - Default breakpoint manager input.
- *
- * @param context the presentation context.
- */
- public DefaultBreakpointManagerInput(IPresentationContext context) {
- super(context);
- }
-
-
- /*
- * (non-Javadoc)
- * @see java.lang.Object#hashCode()
- */
- public int hashCode() {
- if (getContext() != null) {
- return getContext().hashCode();
- } else {
- return 1;
- }
- }
-
- /*
- * (non-Javadoc)
- * @see java.lang.Object#equals(java.lang.Object)
- */
- public boolean equals(Object arg0) {
- if ( (arg0 != null) && arg0.getClass().equals(this.getClass()) ) {
-
- IPresentationContext context = ((DefaultBreakpointManagerInput) arg0).getContext();
- if (getContext() != null && context != null)
- return getContext().equals(context);
- }
-
- return super.equals(arg0);
- }
-}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/elements/adapters/AbstractBreakpointManagerInput.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/elements/adapters/DefaultBreakpointsViewInput.java
index 148a03b5e..27a161a3a 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/elements/adapters/AbstractBreakpointManagerInput.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/elements/adapters/DefaultBreakpointsViewInput.java
@@ -7,18 +7,19 @@
*
* Contributors:
* Patrick Chuong (Texas Instruments) - Initial API and implementation (Bug 238956)
+ * Wind River Systems - ongoing enhancements and bug fixing
*****************************************************************/
package org.eclipse.debug.internal.ui.elements.adapters;
import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext;
/**
- * A breakpoint manager input allows the breakpoints view to link the active debug context
- * per workbench window.
+ * The default breakpoints view input populates the view with content
+ * from the default breakpoint manager.
*
* @since 3.6
*/
-public abstract class AbstractBreakpointManagerInput {
+public class DefaultBreakpointsViewInput {
/**
* The presentation context of the breakpoints view.
@@ -30,7 +31,7 @@ public abstract class AbstractBreakpointManagerInput {
*
* @param context the presentation context for this input
*/
- protected AbstractBreakpointManagerInput(IPresentationContext context) {
+ public DefaultBreakpointsViewInput(IPresentationContext context) {
fContext = context;
}
@@ -42,4 +43,32 @@ public abstract class AbstractBreakpointManagerInput {
public IPresentationContext getContext() {
return fContext;
}
+
+ /*
+ * (non-Javadoc)
+ * @see java.lang.Object#hashCode()
+ */
+ public int hashCode() {
+ if (getContext() != null) {
+ return getContext().hashCode();
+ } else {
+ return 1;
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ public boolean equals(Object arg0) {
+ if ( (arg0 != null) && arg0.getClass().equals(this.getClass()) ) {
+
+ IPresentationContext context = ((DefaultBreakpointsViewInput) arg0).getContext();
+ if (getContext() != null && context != null)
+ return getContext().equals(context);
+ }
+
+ return super.equals(arg0);
+ }
+
}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/elements/adapters/DefaultViewerInputProvider.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/elements/adapters/DefaultViewerInputProvider.java
index 74a830a63..04997ef06 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/elements/adapters/DefaultViewerInputProvider.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/elements/adapters/DefaultViewerInputProvider.java
@@ -31,7 +31,7 @@ public class DefaultViewerInputProvider extends ViewerInputProvider {
*/
protected Object getViewerInput(Object source, IPresentationContext context, IViewerUpdate update) throws CoreException {
if (IDebugUIConstants.ID_BREAKPOINT_VIEW.equals(context.getId())) {
- AbstractBreakpointManagerInput input = new DefaultBreakpointManagerInput(context);
+ DefaultBreakpointsViewInput input = new DefaultBreakpointsViewInput(context);
return input;
}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/elements/adapters/StackFrameViewerInputProvider.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/elements/adapters/StackFrameViewerInputProvider.java
index 97b3ce6fa..1b76b8eaa 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/elements/adapters/StackFrameViewerInputProvider.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/elements/adapters/StackFrameViewerInputProvider.java
@@ -32,7 +32,7 @@ public class StackFrameViewerInputProvider extends ViewerInputProvider {
if ( IDebugUIConstants.ID_REGISTER_VIEW.equals(context.getId()) ) {
return new RegisterGroupProxy((IStackFrame) source);
} else if ( IDebugUIConstants.ID_BREAKPOINT_VIEW.equals(context.getId()) ) {
- return new DefaultBreakpointManagerInput(context);
+ return new DefaultBreakpointsViewInput(context);
} else {
return DebugPlugin.getDefault().getExpressionManager();
}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/memory/provisional/MemoryViewPresentationContext.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/memory/provisional/MemoryViewPresentationContext.java
index ade979113..0daa5452c 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/memory/provisional/MemoryViewPresentationContext.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/memory/provisional/MemoryViewPresentationContext.java
@@ -10,7 +10,7 @@
*******************************************************************************/
package org.eclipse.debug.internal.ui.memory.provisional;
-import org.eclipse.debug.internal.ui.viewers.PartPresentationContext;
+import org.eclipse.debug.internal.ui.viewers.model.provisional.PresentationContext;
import org.eclipse.debug.ui.memory.IMemoryRendering;
import org.eclipse.debug.ui.memory.IMemoryRenderingContainer;
import org.eclipse.debug.ui.memory.IMemoryRenderingSite;
@@ -24,7 +24,7 @@ import org.eclipse.debug.ui.memory.IMemoryRenderingSite;
* @since 3.2
*
*/
-public class MemoryViewPresentationContext extends PartPresentationContext {
+public class MemoryViewPresentationContext extends PresentationContext {
private IMemoryRenderingContainer fContainer;
private IMemoryRendering fRendering;
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/AbstractBreakpointManagerContentProvider.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/AbstractBreakpointManagerContentProvider.java
deleted file mode 100644
index d880c9ff5..000000000
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/AbstractBreakpointManagerContentProvider.java
+++ /dev/null
@@ -1,948 +0,0 @@
-/*****************************************************************
- * Copyright (c) 2009, 2010 Texas Instruments 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:
- * Patrick Chuong (Texas Instruments) - Initial API and implementation (Bug 238956)
- * IBM Corporation - ongoing enhancements and bug fixing
- *****************************************************************/
-package org.eclipse.debug.internal.ui.model.elements;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.eclipse.core.resources.IMarkerDelta;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.jobs.ISchedulingRule;
-import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.debug.core.DebugPlugin;
-import org.eclipse.debug.core.IBreakpointManager;
-import org.eclipse.debug.core.IBreakpointsListener;
-import org.eclipse.debug.core.model.IBreakpoint;
-import org.eclipse.debug.core.model.IStackFrame;
-import org.eclipse.debug.core.model.IThread;
-import org.eclipse.debug.internal.ui.DebugUIPlugin;
-import org.eclipse.debug.internal.ui.breakpoints.provisional.IBreakpointOrganizer;
-import org.eclipse.debug.internal.ui.breakpoints.provisional.IBreakpointUIConstants;
-import org.eclipse.debug.internal.ui.elements.adapters.AbstractBreakpointManagerInput;
-import org.eclipse.debug.internal.ui.viewers.model.provisional.IModelDelta;
-import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext;
-import org.eclipse.debug.internal.ui.viewers.model.provisional.IViewerUpdate;
-import org.eclipse.debug.internal.ui.viewers.model.provisional.ModelDelta;
-import org.eclipse.debug.internal.ui.viewers.provisional.AbstractModelProxy;
-import org.eclipse.debug.internal.ui.views.breakpoints.BreakpointContainer;
-import org.eclipse.debug.internal.ui.views.breakpoints.ElementComparator;
-import org.eclipse.debug.ui.IDebugUIConstants;
-import org.eclipse.jface.util.IPropertyChangeListener;
-import org.eclipse.jface.util.PropertyChangeEvent;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.StructuredSelection;
-
-/**
- * This class provides breakpoint content for the breakpoint manager.
- *
- * @since 3.6
- */
-public abstract class AbstractBreakpointManagerContentProvider extends ElementContentProvider
- implements IBreakpointsListener {
-
- /**
- * Breakpoint input data. Contains all input specific data.
- *
- * @since 3.6
- */
- private class InputData implements IPropertyChangeListener{
- /**
- * Breakpoint manager input
- */
- private AbstractBreakpointManagerInput fInput;
-
- /**
- * Model proxy of the input
- */
- private List/*<AbstractModelProxy>*/ fProxies = new ArrayList(1);
-
- /**
- * Element comparator, use to compare the ordering of elements for the model
- * <br/> Note: We assume that the comparator does not change.
- */
- private ElementComparator fComparator;
-
- /**
- * The breakpoint root container.<br/>
- * Note: The final qualifier guarantees that fContainer will be
- * initialized before the class is accessed on other threads.
- */
- final private BreakpointContainer fContainer;
-
- /**
- * Known current breakpoint organizers.
- */
- private IBreakpointOrganizer[] fOrganizers;
-
- /**
- * Constructor
- *
- * @param input the breakpoint manager input
- * @param proxy the model proxy
- * @param filter the debug context selection
- * @param comparator the element comparator
- */
- InputData(AbstractBreakpointManagerInput input) {
- fInput = input;
- fProxies = new ArrayList(1);
- fComparator = (ElementComparator)
- input.getContext().getProperty(IBreakpointUIConstants.PROP_BREAKPOINTS_ELEMENT_COMPARATOR);
-
- fOrganizers = (IBreakpointOrganizer[])
- input.getContext().getProperty(IBreakpointUIConstants.PROP_BREAKPOINTS_ORGANIZERS);
-
- // Create the initial container.
- ModelDelta initialDelta = new ModelDelta(fInput, 0, IModelDelta.NO_CHANGE, -1);
- fContainer = createRootContainer(initialDelta, fInput, fOrganizers, fBpManager);
-
- registerOrganizersListener(null, fOrganizers);
- }
-
- void proxyInstalled(AbstractModelProxy proxy) {
- ModelDelta rootDelta = null;
- synchronized(this) {
- fProxies.add(proxy);
-
- // Generate an install delta
-
- rootDelta = new ModelDelta(fInput, 0, IModelDelta.NO_CHANGE, -1);
- buildInstallDelta(rootDelta, fContainer);
- }
- proxy.fireModelChanged(rootDelta);
- }
-
- synchronized void proxyDisposed(AbstractModelProxy proxy) {
- fProxies.remove(proxy);
- }
-
- public void propertyChange(PropertyChangeEvent event) {
- // For any property changes in breakpiont organizers, refresh the containers.
- updateContainers();
- }
-
- /**
- * Change the breakpoint organizers for the root container.
- *
- * @param organizers the new organizers.
- */
- void setOrganizers(IBreakpointOrganizer[] organizers) {
- IBreakpointOrganizer[] oldOrganizers = null;
- synchronized(this) {
- oldOrganizers = fOrganizers;
- fOrganizers = organizers;
- }
- registerOrganizersListener(oldOrganizers, organizers);
- updateContainers();
- }
-
- private void registerOrganizersListener(IBreakpointOrganizer[] oldOrganizers, IBreakpointOrganizer[] newOrganizers) {
- if (oldOrganizers != null) {
- for (int i = 0; i < oldOrganizers.length; i++) {
- oldOrganizers[i].removePropertyChangeListener(this);
- }
- }
- if (newOrganizers != null) {
- for (int i = 0; i < newOrganizers.length; i++) {
- newOrganizers[i].addPropertyChangeListener(this);
- }
- }
- }
-
- synchronized void updateContainers() {
- // create a reference container, use for deleting elements and adding elements
- ModelDelta dummyDelta = new ModelDelta(null, IModelDelta.NO_CHANGE);
- BreakpointContainer refContainer = createRootContainer(dummyDelta, fInput, fOrganizers, fBpManager);
-
- // delete the removed elements
- ModelDelta deletedDelta = new ModelDelta(fInput, IModelDelta.NO_CHANGE);
- deleteRemovedElements(fContainer, refContainer, deletedDelta);
- fireModelChanged(fInput, deletedDelta, "setOrganizers - Delete removed elements"); //$NON-NLS-1$
-
- // adjust the old organizer with the reference organizer
- BreakpointContainer.copyOrganizers(fContainer, refContainer);
-
- // insert the added elements
- ModelDelta addedDelta = new ModelDelta(fInput, 0, IModelDelta.NO_CHANGE, -1);
- IBreakpoint newBreakpoint = insertAddedElements(fContainer, refContainer, addedDelta);
- addedDelta.setChildCount(fContainer.getChildren().length);
-
- // select the new breakpoint
- if (newBreakpoint != null)
- appendModelDeltaToElement(addedDelta, newBreakpoint, IModelDelta.SELECT);
-
- fireModelChanged(fInput, addedDelta, "setOrganizers - Insert added elements"); //$NON-NLS-1$
- }
-
- synchronized public void setFilterSelection(IStructuredSelection ss) {
- ModelDelta delta = new ModelDelta(fInput, IModelDelta.NO_CHANGE);
-
- Set existingBreakpoints = new HashSet(Arrays.asList(fContainer.getBreakpoints()));
- IBreakpoint[] allBreakpoints = fBpManager.getBreakpoints();
-
- for (int i = 0; i < allBreakpoints.length; ++i) {
- boolean supported = supportsBreakpoint(ss, allBreakpoints[i]);
- boolean contain = existingBreakpoints.contains(allBreakpoints[i]);
-
- if (supported) {
- if (!contain)
- fContainer.addBreakpoint(allBreakpoints[i], delta);
- } else {
- if (contain)
- fContainer.removeBreakpoint(allBreakpoints[i], delta);
- }
-
- }
-
- fireModelChanged(fInput, delta, "setFilterSelection"); //$NON-NLS-1$
- }
-
- synchronized public void trackSelection(IBreakpoint[] bps) {
- ModelDelta delta = new ModelDelta(fInput, IModelDelta.NO_CHANGE);
- Set bpsSet = new HashSet(bps.length * 4/3);
- for (int i = 0; i< bps.length; i++) {
- bpsSet.add(bps[i]);
- }
- buildTrackSelectionDelta(delta, fContainer, bpsSet);
-
- fireModelChanged(fInput, delta, "trackSelection"); //$NON-NLS-1$
- }
-
- /**
- * Helper method to add breakpoints to the given input.
- *
- * @param data the input to add the breakpoints
- * @param breakpoints the breakpoints
- */
- synchronized void breakpointsAdded(IBreakpoint[] breakpoints) {
- IBreakpoint[] filteredBreakpoints = filterBreakpoints(fInput, breakpoints);
- ModelDelta delta = new ModelDelta(fInput, 0, IModelDelta.NO_CHANGE, -1);
- for (int i = 0; i < filteredBreakpoints.length; ++i) {
- fContainer.addBreakpoint(filteredBreakpoints[i], delta);
- }
- delta.setChildCount(fContainer.getChildren().length);
-
- // select the breakpoint
- if (filteredBreakpoints.length > 0) {
- appendModelDeltaToElement(delta, filteredBreakpoints[0], IModelDelta.SELECT);
- }
-
- fireModelChanged(fInput, delta, "breakpointsAddedInput"); //$NON-NLS-1$
- }
-
- /**
- * Helper method to remove breakpoints from a given input.
- *
- * @param data the input to add the breakpoints
- * @param breakpoints the breakpoints
- */
- synchronized void breakpointsRemoved(IBreakpoint[] breakpoints) {
- IBreakpoint[] filteredBreakpoints = filterBreakpoints(fInput, breakpoints);
- ModelDelta delta = new ModelDelta(fInput, IModelDelta.NO_CHANGE);
- for (int i = 0; i < filteredBreakpoints.length; ++i) {
- fContainer.removeBreakpoint(filteredBreakpoints[i], delta);
- }
- fireModelChanged(fInput, delta, "breakpointsRemovedInput"); //$NON-NLS-1$
- }
-
- synchronized void breakpointsChanged(IBreakpoint[] breakpoints) {
- IBreakpoint[] filteredBreakpoints = filterBreakpoints(fInput, breakpoints);
-
- // If the change caused a breakpoint to be added (installed) or remove (un-installed) update accordingly.
- List removed = new ArrayList();
- List added = new ArrayList();
- List filteredAsList = Arrays.asList(filteredBreakpoints);
- for (int i = 0; i < breakpoints.length; i++) {
- IBreakpoint bp = breakpoints[i];
- boolean oldContainedBp = fContainer.contains(bp);
- boolean newContained = filteredAsList.contains(bp);
- if (oldContainedBp && !newContained) {
- removed.add(bp);
- } else if (!oldContainedBp && newContained) {
- added.add(bp);
- }
- }
- if (!added.isEmpty()) {
- breakpointsAdded((IBreakpoint[]) added.toArray(new IBreakpoint[added.size()]));
- }
- if (!removed.isEmpty()) {
- breakpointsRemoved((IBreakpoint[]) removed.toArray(new IBreakpoint[removed.size()]));
- }
-
- ModelDelta delta = new ModelDelta(fInput, IModelDelta.NO_CHANGE);
- for (int i = 0; i < filteredBreakpoints.length; ++i)
- appendModelDelta(fContainer, delta, IModelDelta.STATE | IModelDelta.CONTENT, filteredBreakpoints[i]); // content flag triggers detail refresh
- fireModelChanged(fInput, delta, "breakpointsChanged"); //$NON-NLS-1$
- }
-
-
- /**
- * Recursive function to build the model delta to install breakpoint
- * model proxies for all breakpoints and breakpoint containers.
- *
- * @param delta Delta node to build on
- * @param container Container element to build delta for.
- */
- private void buildInstallDelta(ModelDelta delta, BreakpointContainer container) {
- Object[] children = container.getChildren();
- delta.setChildCount(children.length);
- for (int i = 0; i < children.length; i++) {
- ModelDelta childDelta = delta.addNode(children[i], i, IModelDelta.NO_CHANGE);
- if (children[i] instanceof BreakpointContainer) {
- childDelta.setFlags(IModelDelta.INSTALL);
- buildInstallDelta(childDelta, (BreakpointContainer)children[i]);
- } else if (children[i] instanceof IBreakpoint) {
- childDelta.setFlags(IModelDelta.INSTALL);
- }
- }
- }
-
- /**
- * Recursive function to build the model delta to select a breakpoint
- * corresponding to the active debug context selection.
- *
- * @param delta Delta node to build on
- * @param container Container element to build delta for.
- * @param breakpoints Breakpoint set to be selected.
- * @return whether to continue building delta.
- */
- private boolean buildTrackSelectionDelta(ModelDelta delta, BreakpointContainer container, Set breakpoints) {
- Object[] children = container.getChildren();
- delta.setChildCount(children.length);
- for (int i = 0; i < children.length; i++) {
- ModelDelta childDelta = delta.addNode(children[i], i, IModelDelta.NO_CHANGE);
- if (children[i] instanceof BreakpointContainer) {
- if (!buildTrackSelectionDelta(childDelta, (BreakpointContainer)children[i], breakpoints) ) {
- return false;
- }
- } else if (children[i] instanceof IBreakpoint &&
- breakpoints.contains(children[i]))
- {
- childDelta.setFlags(IModelDelta.SELECT | IModelDelta.EXPAND);
- return false;
- }
- }
- return true;
- }
-
-
- /**
- * Insert elements from the reference container to an existing container.
- *
- * @param container the existing container to insert the new elements.
- * @param refContainer the reference container to compare elements that are added.
- * @param containerDelta the delta of the existing container.
- */
- private IBreakpoint insertAddedElements(BreakpointContainer container, BreakpointContainer refContainer, ModelDelta containerDelta) {
- IBreakpoint newBreakpoint = null;
-
- Object[] children = container.getChildren();
- Object[] refChildren = refContainer.getChildren();
-
-
- for (int i = 0; i < refChildren.length; ++i) {
- Object element = getElement(children, refChildren[i]);
-
- // if a child of refContainer doesn't exist in container, than insert it to container
- // - if the reference child is a container, than copy the reference child container to container
- // - otherwise (Breakpoint), add the breakpoint to container
- if (element == null) {
- if (refChildren[i] instanceof BreakpointContainer) {
- BreakpointContainer.addChildContainer(container, (BreakpointContainer) refChildren[i], containerDelta);
- } else {
- BreakpointContainer.addBreakpoint(container, (IBreakpoint) refChildren[i], containerDelta);
- if (newBreakpoint == null)
- newBreakpoint = (IBreakpoint) refChildren[i];
- }
-
- // if a child exist in container, than recursively search into container. And also update the organizer of
- // of container to the one in the refContainer's child.
- } else if (element instanceof BreakpointContainer) {
- int index = Arrays.asList(children).indexOf(element);
- ModelDelta childDelta = containerDelta.addNode(element, index, IModelDelta.STATE, -1);
- BreakpointContainer.copyOrganizers((BreakpointContainer) element, (BreakpointContainer) refChildren[i]);
- newBreakpoint = insertAddedElements((BreakpointContainer) element, (BreakpointContainer) refChildren[i], childDelta);
- childDelta.setChildCount(((BreakpointContainer) element).getChildren().length);
- }
- }
-
- return newBreakpoint;
- }
-
- /**
- * Delete elements from existing container that doesn't exist in the reference container.
- *
- * @param container the existing container to delete the removed elements.
- * @param refContainer the reference container to compare elements that are removed.
- * @param containerDelta the delta of the existing container.
- */
- private void deleteRemovedElements(BreakpointContainer container, BreakpointContainer refContainer, ModelDelta containerDelta) {
- Object[] children = container.getChildren();
- Object[] refChildren = refContainer.getChildren();
-
- // if a child of container doesn't exist in refContainer, than remove it from container
- for (int i = 0; i < children.length; ++i) {
- Object element = getElement(refChildren, children[i]);
-
- if (element == null) {
- if (children[i] instanceof BreakpointContainer) {
- BreakpointContainer.removeAll((BreakpointContainer) children[i], containerDelta);
- } else {
- BreakpointContainer.removeBreakpoint(container, (IBreakpoint) children[i], containerDelta);
- }
- } else if (element instanceof BreakpointContainer){
-
- ModelDelta childDelta = containerDelta.addNode(children[i], IModelDelta.STATE);
- deleteRemovedElements((BreakpointContainer) children[i], (BreakpointContainer) element, childDelta);
- }
- }
- }
-
- /**
- * Get the element that is in the collection.
- *
- * @param collection the collection of elements.
- * @param element the element to search.
- * @return if element exist in collection, than it is returned, otherwise <code>null</code> is returned.
- * @see insertAddedElements
- * @see deleteRemovedElements
- */
- private Object getElement(Object[] collection, Object element) {
- for (int i = 0; i < collection.length; ++i)
- if (collection[i] instanceof BreakpointContainer && element instanceof BreakpointContainer) {
- if (collection[i].equals(element))
- return collection[i];
- } else {
- if (collection[i].equals(element))
- return collection[i];
- }
- return null;
- }
-
- /**
- * Create a root container.
- *
- * @param rootDelta the root delta.
- * @param input the view input.
- * @param organizers the breakpoint organizers.
- * @param oldContainer the old container, use to determine whether a new breakpoint should be expanded.
- * @param the breakpoint manager.
- */
- private BreakpointContainer createRootContainer(ModelDelta rootDelta, AbstractBreakpointManagerInput input,
- IBreakpointOrganizer[] organizers, IBreakpointManager bpManager) {
-
- IBreakpoint[] breakpoints = filterBreakpoints(input, bpManager.getBreakpoints());
- BreakpointContainer container = new BreakpointContainer(organizers, fComparator);
- container.initDefaultContainers(rootDelta);
-
- for (int i = 0; i < breakpoints.length; ++i) {
- container.addBreakpoint(breakpoints[i], rootDelta);
- }
-
- return container;
- }
- }
-
- private class InputDataMap extends LinkedHashMap {
- private static final long serialVersionUID = 1L;
-
- public InputDataMap() {
- super(1, (float)0.75, true);
- }
-
- protected boolean removeEldestEntry(java.util.Map.Entry arg0) {
- InputData data = (InputData)arg0.getValue();
- return size() > getMaxInputsCache() && data.fProxies.isEmpty();
- }
- }
-
- private class PresentationContextListener implements IPropertyChangeListener {
- final private IPresentationContext fContext;
-
- PresentationContextListener(IPresentationContext context) {
- fContext = context;
- fContext.addPropertyChangeListener(this);
- }
-
- public void propertyChange(PropertyChangeEvent event) {
- contextPropertyChanged(fContext, event);
- }
- }
-
- /**
- * Scheduling rule to make sure that breakpoint manager listener updates
- * are process serially.
- */
- private ISchedulingRule fBreakpointsListenerSchedulingRule = new ISchedulingRule() {
-
- public boolean isConflicting(ISchedulingRule rule) {
- return rule == this;
- }
-
- public boolean contains(ISchedulingRule rule) {
- return rule == this;
- }
- };
-
- // debug flags
- public static boolean DEBUG_BREAKPOINT_DELTAS = false;
-
- static {
- DEBUG_BREAKPOINT_DELTAS = DebugUIPlugin.DEBUG && "true".equals( //$NON-NLS-1$
- Platform.getDebugOption("org.eclipse.debug.ui/debug/viewers/breakpointDeltas")); //$NON-NLS-1$
- }
-
- /**
- * A map of input to info data cache
- */
- final private Map fInputToData = Collections.synchronizedMap(new InputDataMap());
-
- /**
- * Flag indicating whether the content provider is currently a breakpoints listener.
- */
- private boolean fIsBreakpointListener = false;
-
- /**
- * A map of presetnation context listeners.
- */
- final private Map fContextListeners = Collections.synchronizedMap(new HashMap());
-
- /**
- * The breakpoint manager.
- */
- final private IBreakpointManager fBpManager;
-
- /**
- * Constructor.
- */
- protected AbstractBreakpointManagerContentProvider() {
- fBpManager = DebugPlugin.getDefault().getBreakpointManager();
- }
-
- /**
- * Sub-classes is required to implements this method to filter the breakpoints.
- *
- * @param input the breakpoint manager input.
- * @param breakpoints the list of breakpoint to filter.
- * @return the filtered list of breakpoint based on the input.
- */
- protected abstract IBreakpoint[] filterBreakpoints(AbstractBreakpointManagerInput input, IBreakpoint[] breakpoints);
-
- /**
- * Sub-classes is required to implements this method, to determine whether the breakpoint is supported by the selection.
- *
- * @param ss the selection of the debug elements.
- * @param breakpoint the breakpoint.
- * @return true if supported.
- */
- protected abstract boolean supportsBreakpoint(IStructuredSelection ss, IBreakpoint breakpoint);
-
- /**
- * Maximum number of breakpoint manager input objects that this provider
- * will cache data for. This method is called once upon class creation
- * when setting up the data cache. Sub-classes may override to provide
- * a custom setting.
- *
- * @return Maximum data cache size
- */
- protected int getMaxInputsCache() {
- return 2;
- }
-
- /**
- * Handles the property changed events in presentation contexts.
- * Sub-classes may override to perform additional handling.
- *
- * @param presentation Presentation context that changed.
- */
- protected void contextPropertyChanged(IPresentationContext presentation, PropertyChangeEvent event) {
- if (IBreakpointUIConstants.PROP_BREAKPOINTS_ORGANIZERS.equals(event.getProperty())) {
- IBreakpointOrganizer[] organizers = (IBreakpointOrganizer[])event.getNewValue();
- InputData[] contextDatas = getContextInputDatas(presentation);
- for (int i = 0; i < contextDatas.length; i++) {
- contextDatas[i].setOrganizers(organizers);
- }
- }
- else if ( IBreakpointUIConstants.PROP_BREAKPOINTS_FILTER_SELECTION.equals(event.getProperty()) )
- {
- IStructuredSelection selection = null;
-
- if (Boolean.TRUE.equals(event.getNewValue()) ) {
- selection = getActiveContextStructredSelection(presentation);
- }
- setFilterSelection(presentation, selection);
- }
- else if ( IBreakpointUIConstants.PROP_BREAKPOINTS_TRACK_SELECTION.equals(event.getProperty()) )
- {
- IStructuredSelection selection = null;
-
- if (Boolean.TRUE.equals(event.getNewValue()) ) {
- selection = getActiveContextStructredSelection(presentation);
- }
- trackSelection(presentation, selection);
- }
- else if ( IBreakpointUIConstants.PROP_BREAKPOINTS_ACTIVE_DEBUG_CONTEXT.equals(event.getProperty()) )
- {
- IStructuredSelection selection = getActiveContextStructredSelection(presentation);
-
- if (Boolean.TRUE.equals(presentation.getProperty(IBreakpointUIConstants.PROP_BREAKPOINTS_FILTER_SELECTION)) ) {
- setFilterSelection(presentation, selection);
- }
-
- if (Boolean.TRUE.equals(presentation.getProperty(IBreakpointUIConstants.PROP_BREAKPOINTS_TRACK_SELECTION)) ) {
- trackSelection(presentation, selection);
- }
- }
- }
-
- private void setFilterSelection(IPresentationContext context, IStructuredSelection selection) {
- InputData[] contextDatas = getContextInputDatas(context);
- for (int i = 0; i < contextDatas.length; i++) {
- contextDatas[i].setFilterSelection(selection);
- }
- }
-
- private void trackSelection(IPresentationContext context, IStructuredSelection selection) {
- if (selection.size() != 1) {
- return;
- }
- Object firstElement = selection.getFirstElement();
- if (firstElement == null) {
- return;
- }
- IThread thread = null;
- if (firstElement instanceof IStackFrame) {
- thread = ((IStackFrame) firstElement).getThread();
- } else if (firstElement instanceof IThread) {
- thread = (IThread) firstElement;
- } else {
- return;
- }
-
- IBreakpoint[] breakpoints = thread.getBreakpoints();
-
- if (breakpoints != null && breakpoints.length != 0) {
- InputData[] contextDatas = getContextInputDatas(context);
- for (int i = 0; i < contextDatas.length; i++) {
- contextDatas[i].trackSelection(breakpoints);
- }
- }
- }
-
- private IStructuredSelection getActiveContextStructredSelection(IPresentationContext presentation) {
- Object activeContext = presentation.getProperty(IBreakpointUIConstants.PROP_BREAKPOINTS_ACTIVE_DEBUG_CONTEXT);
- if (activeContext instanceof IStructuredSelection) {
- return (IStructuredSelection)activeContext;
- }
- return StructuredSelection.EMPTY;
- }
-
- private InputData[] getContextInputDatas(IPresentationContext context) {
- List list = new ArrayList(fInputToData.size());
- synchronized (fInputToData) {
- for (Iterator itr = fInputToData.values().iterator(); itr.hasNext();) {
- InputData data = (InputData)itr.next();
- if (context.equals( data.fInput.getContext() )) {
- list.add(data);
- }
- }
- }
- return (InputData[]) list.toArray(new InputData[list.size()]);
- }
-
- /**
- * Handles the event when a presentation context is dispoed.
- * Sub-classes may override to perform additional cleanup.
- *
- * @param context Presetnation context that was disposed.
- */
- protected void contextDisposed(IPresentationContext context) {
- synchronized (fInputToData) {
- for (Iterator itr = fInputToData.entrySet().iterator(); itr.hasNext();) {
- Map.Entry entry = (Map.Entry)itr.next();
- IPresentationContext entryContext = ((AbstractBreakpointManagerInput)entry.getKey()).getContext();
- if (context.equals(entryContext)) {
- itr.remove();
- }
- }
- }
-
- // Remove the context listener.
- PresentationContextListener listener = (PresentationContextListener)fContextListeners.remove(context);
- if (listener != null) {
- context.removePropertyChangeListener(listener);
- }
- }
-
- /**
- * Register the breakpoint manager input with this content provider.
- *
- * @param input the breakpoint manager input to register.
- * @param proxy the model proxy of the input.
- * @param organizers the breakpoint organizer, can be <code>null</code>.
- * @param selectionFilter the selection filter, can be <code>null</code>.
- * @param comparator the element comparator.
- */
- public void registerModelProxy(AbstractBreakpointManagerInput input, AbstractModelProxy proxy) {
- synchronized(this) {
- if (!fIsBreakpointListener) {
- fBpManager.addBreakpointListener(this);
- fIsBreakpointListener = true;
- }
- }
-
- getInputData(input).proxyInstalled(proxy);
- }
-
- /**
- * Unregister the breakpoint manager input with this content provider.
- *
- * @param input the breakpoint manager input to unregister.
- */
- public void unregisterModelProxy(AbstractBreakpointManagerInput input, AbstractModelProxy proxy) {
- getInputData(input).proxyDisposed(proxy);
-
- if (fInputToData.isEmpty()) {
- synchronized(this) {
- if (fIsBreakpointListener) {
- fBpManager.removeBreakpointListener(this);
- fIsBreakpointListener = false;
- }
- }
- }
- }
-
- private InputData getInputData(AbstractBreakpointManagerInput input) {
- InputData data = null;
- synchronized (fInputToData) {
- data = (InputData)fInputToData.get(input);
- if (data == null) {
- data = new InputData(input);
- fInputToData.put(input, data);
- }
- }
-
- // Also make sure that we're listening to the presentation context properties
- synchronized (fContextListeners) {
- IPresentationContext context = input.getContext();
- if ( !Boolean.TRUE.equals(context.getProperty(IPresentationContext.PROPERTY_DISPOSED)) &&
- !fContextListeners.containsKey(context) )
- {
- fContextListeners.put(context, new PresentationContextListener(context));
- }
- }
-
- return data;
- }
-
- /**
- * Returns the model proxy for the input.
- *
- * @param input the input.
- * @return the model proxy.
- */
- private List getModelProxies(AbstractBreakpointManagerInput input) {
- InputData data = getInputData(input);
- return data != null ? data.fProxies : null;
- }
-
- /**
- * Returns the selection filter for the input.
- *
- * @param input the selection.
- */
- protected IStructuredSelection getSelectionFilter(Object input) {
- if (input instanceof AbstractBreakpointManagerInput) {
- IPresentationContext presentation = ((AbstractBreakpointManagerInput)input).getContext();
-
- if ( Boolean.TRUE.equals(presentation.getProperty(IBreakpointUIConstants.PROP_BREAKPOINTS_FILTER_SELECTION)) ) {
- Object activeContext = presentation.getProperty(IBreakpointUIConstants.PROP_BREAKPOINTS_ACTIVE_DEBUG_CONTEXT);
- if (activeContext instanceof IStructuredSelection) {
- return (IStructuredSelection)activeContext;
- }
- }
- }
- return null;
- }
-
- /**
- * Fire model change event for the input.
- *
- * @param input the input.
- * @param delta the model delta.
- * @param debugReason the debug string.
- */
- protected void fireModelChanged(AbstractBreakpointManagerInput input, IModelDelta delta, String debugReason) {
- List proxies = getModelProxies(input);
-
- if (DEBUG_BREAKPOINT_DELTAS && proxies.size() > 0) {
- System.out.println("FIRE BREAKPOINT DELTA (" + debugReason + ")\n" + delta.toString()); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- for (int i = 0; i < proxies.size(); i++) {
- ((AbstractModelProxy)proxies.get(i)).fireModelChanged(delta);
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.debug.internal.ui.model.elements.ElementContentProvider#supportsContextId(java.lang.String)
- */
- protected boolean supportsContextId(String id) {
- return id.equals(IDebugUIConstants.ID_BREAKPOINT_VIEW);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.debug.internal.ui.model.elements.ElementContentProvider#getChildCount(java.lang.Object, org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext, org.eclipse.debug.internal.ui.viewers.model.provisional.IViewerUpdate)
- */
- protected int getChildCount(Object element, IPresentationContext context, IViewerUpdate monitor) throws CoreException {
- Object input = monitor.getViewerInput();
- if (input instanceof AbstractBreakpointManagerInput) {
- AbstractBreakpointManagerInput bpManagerInput = (AbstractBreakpointManagerInput)input;
- return getInputData(bpManagerInput).fContainer.getChildren().length;
- }
- return 0;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.debug.internal.ui.model.elements.ElementContentProvider#getChildren(java.lang.Object, int, int, org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext, org.eclipse.debug.internal.ui.viewers.model.provisional.IViewerUpdate)
- */
- protected Object[] getChildren(Object parent, int index, int length, IPresentationContext context, IViewerUpdate monitor) throws CoreException {
- Object input = monitor.getViewerInput();
- if (input instanceof AbstractBreakpointManagerInput) {
- AbstractBreakpointManagerInput bpManagerInput = (AbstractBreakpointManagerInput)input;
- Object[] children = getInputData(bpManagerInput).fContainer.getChildren();
- return getElements(children, index, length);
- }
-
- return EMPTY;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.debug.core.IBreakpointsListener#breakpointsAdded(org.eclipse.debug.core.model.IBreakpoint[])
- */
- public void breakpointsAdded(final IBreakpoint[] breakpoints) {
- new Job("Breakpoints View Update Job") { //$NON-NLS-1$
- {
- setSystem(true);
- setRule(fBreakpointsListenerSchedulingRule);
- }
-
- protected IStatus run(IProgressMonitor monitor) {
- InputData[] datas = (InputData[])fInputToData.values().toArray(new InputData[0]);
- for (int i = 0; i < datas.length; i++) {
- datas[i].breakpointsAdded(breakpoints);
- }
- return Status.OK_STATUS;
- }
- }.schedule();
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.debug.core.IBreakpointsListener#breakpointsRemoved(org.eclipse.debug.core.model.IBreakpoint[], org.eclipse.core.resources.IMarkerDelta[])
- */
- public void breakpointsRemoved(final IBreakpoint[] breakpoints, IMarkerDelta[] deltas) {
- new Job("Breakpoints View Update Job") { //$NON-NLS-1$
- {
- setSystem(true);
- setRule(fBreakpointsListenerSchedulingRule);
- }
-
- protected IStatus run(IProgressMonitor monitor) {
- InputData[] datas = (InputData[])fInputToData.values().toArray(new InputData[0]);
- for (int i = 0; i < datas.length; i++) {
- datas[i].breakpointsRemoved(breakpoints);
- }
- return Status.OK_STATUS;
- }
- }.schedule();
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.debug.core.IBreakpointsListener#breakpointsChanged(org.eclipse.debug.core.model.IBreakpoint[], org.eclipse.core.resources.IMarkerDelta[])
- */
- public void breakpointsChanged(final IBreakpoint[] breakpoints, IMarkerDelta[] deltas) {
- new Job("Breakpoints View Update Job") { //$NON-NLS-1$
- {
- setSystem(true);
- setRule(fBreakpointsListenerSchedulingRule);
- }
-
- protected IStatus run(IProgressMonitor monitor) {
- InputData[] datas = (InputData[])fInputToData.values().toArray(new InputData[0]);
- for (int i = 0; i < datas.length; i++) {
- datas[i].breakpointsChanged(breakpoints);
- }
- return Status.OK_STATUS;
- }
- }.schedule();
- }
- /**
- * Appends the model delta flags to child containers that contains the breakpoint.
- *
- * @param parent the parent container.
- * @param parentDelta the parent model delta.
- * @param flags the model delta flags.
- * @param breakpoint the breakpoint to search in the children containers.
- */
- private void appendModelDelta(BreakpointContainer parent, ModelDelta parentDelta, int flags, IBreakpoint breakpoint) {
- BreakpointContainer[] containers = parent.getContainers();
-
- if (parent.contains(breakpoint)) {
- if ((containers.length != 0)) {
- for (int i = 0; i < containers.length; ++i) {
- ModelDelta nodeDelta = parentDelta.addNode(containers[i], IModelDelta.STATE);
- appendModelDelta(containers[i], nodeDelta, flags, breakpoint);
- }
- } else {
- parentDelta.addNode(breakpoint, flags);
- }
- }
- }
-
- /**
- * Appends the model delta to the first found element in the model delta tree.
- *
- * @param parentDelta the parent delta
- * @param element the element to search
- * @param flags the delta flags
- */
- private void appendModelDeltaToElement(IModelDelta parentDelta, Object element, int flags) {
- if (element.equals(parentDelta.getElement())) {
- ((ModelDelta) parentDelta).setFlags(parentDelta.getFlags() | flags);
- return;
- }
-
- IModelDelta[] childDeltas = parentDelta.getChildDeltas();
- for (int i = 0; i < childDeltas.length; ++i) {
- if (element.equals(childDeltas[i].getElement())) {
- ((ModelDelta) childDeltas[i]).setFlags(childDeltas[i].getFlags() | flags);
- return;
- }
-
- appendModelDeltaToElement(childDeltas[i], element, flags);
- }
- }
-}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/BreakpointManagerContentProvider.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/BreakpointManagerContentProvider.java
index 6949b8a9c..d2a98f2ae 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/BreakpointManagerContentProvider.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/BreakpointManagerContentProvider.java
@@ -1,107 +1,1096 @@
-/*****************************************************************
- * Copyright (c) 2009 Texas Instruments 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:
- * Patrick Chuong (Texas Instruments) - Initial API and implementation (Bug 238956)
- *****************************************************************/
-package org.eclipse.debug.internal.ui.model.elements;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.debug.core.ILaunch;
-import org.eclipse.debug.core.model.IBreakpoint;
-import org.eclipse.debug.core.model.IDebugElement;
-import org.eclipse.debug.core.model.IDebugTarget;
-import org.eclipse.debug.core.model.IProcess;
-import org.eclipse.debug.internal.ui.elements.adapters.AbstractBreakpointManagerInput;
-import org.eclipse.jface.viewers.IStructuredSelection;
-
-/**
- * Breakpoint manager content provider.
- *
- * @since 3.6
- */
-public class BreakpointManagerContentProvider extends AbstractBreakpointManagerContentProvider {
- /*
- * (non-Javadoc)
- * @see org.eclipse.debug.internal.ui.model.elements.AbstractBreakpointManagerContentProvider#supportsBreakpoint(org.eclipse.jface.viewers.IStructuredSelection, org.eclipse.debug.core.model.IBreakpoint)
- */
- protected boolean supportsBreakpoint(IStructuredSelection ss, IBreakpoint breakpoint) {
- return supportsBreakpoint(getDebugTargets(ss), breakpoint);
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.debug.internal.ui.model.elements.AbstractBreakpointManagerContentProvider#filterBreakpointsByInput(org.eclipse.debug.internal.ui.elements.adapters.AbstractBreakpointManagerInput, org.eclipse.debug.core.model.IBreakpoint[])
- */
- protected IBreakpoint[] filterBreakpoints(AbstractBreakpointManagerInput input, IBreakpoint[] breakpoints) {
- IStructuredSelection selectionFilter = getSelectionFilter(input);
- if (selectionFilter != null && !selectionFilter.isEmpty()) {
- List targets = getDebugTargets(selectionFilter);
- ArrayList retVal = new ArrayList();
- if (targets != null) {
- for (int i = 0; i < breakpoints.length; ++i) {
- if (supportsBreakpoint(targets, breakpoints[i]))
- retVal.add(breakpoints[i]);
- }
- }
- return (IBreakpoint[]) retVal.toArray(new IBreakpoint[retVal.size()]);
- } else {
- return breakpoints;
- }
- }
-
- /**
- * Returns true if the breakpoint contains in one of the targets.
- *
- * @param targets a list of <code>IDebugTarget</code> objects.
- * @param breakpoint the breakpoint.
- * @return true if breakpoint contains in the list of targets.
- */
- protected boolean supportsBreakpoint(List targets, IBreakpoint breakpoint) {
- boolean exist = targets.size() == 0 ? true : false;
- for (int i = 0; !exist && i < targets.size(); ++i) {
- IDebugTarget target = (IDebugTarget) targets.get(i);
- exist |= target.supportsBreakpoint(breakpoint);
- }
- return exist;
- }
-
- /**
- * Returns the list of IDebugTarget for the selection.
- *
- * @param ss the selection.
- * @return list of IDebugTarget object.
- */
- protected List getDebugTargets(IStructuredSelection ss) {
- List debugTargets = new ArrayList(2);
- if (ss != null) {
- Iterator i = ss.iterator();
- while (i.hasNext()) {
- Object next = i.next();
- if (next instanceof IDebugElement) {
- debugTargets.add(((IDebugElement)next).getDebugTarget());
- } else if (next instanceof ILaunch) {
- IDebugTarget[] targets = ((ILaunch)next).getDebugTargets();
- for (int j = 0; j < targets.length; j++) {
- debugTargets.add(targets[j]);
- }
- } else if (next instanceof IProcess) {
- IDebugTarget target = (IDebugTarget)((IProcess)next).getAdapter(IDebugTarget.class);
- if (target != null) {
- debugTargets.add(target);
- }
- }
- }
- }
- return debugTargets;
- }
-
-
-}
+/*****************************************************************
+ * Copyright (c) 2009, 2010 Texas Instruments 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:
+ * Patrick Chuong (Texas Instruments) - Initial API and implementation (Bug 238956)
+ * IBM Corporation - ongoing enhancements and bug fixing
+ * Wind River Systems - ongoing enhancements and bug fixing
+ *****************************************************************/
+package org.eclipse.debug.internal.ui.model.elements;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.eclipse.core.resources.IMarkerDelta;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.ISchedulingRule;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.core.IBreakpointManager;
+import org.eclipse.debug.core.IBreakpointsListener;
+import org.eclipse.debug.core.ILaunch;
+import org.eclipse.debug.core.model.IBreakpoint;
+import org.eclipse.debug.core.model.IDebugElement;
+import org.eclipse.debug.core.model.IDebugTarget;
+import org.eclipse.debug.core.model.IProcess;
+import org.eclipse.debug.core.model.IStackFrame;
+import org.eclipse.debug.core.model.IThread;
+import org.eclipse.debug.internal.ui.DebugUIPlugin;
+import org.eclipse.debug.internal.ui.breakpoints.provisional.IBreakpointOrganizer;
+import org.eclipse.debug.internal.ui.breakpoints.provisional.IBreakpointUIConstants;
+import org.eclipse.debug.internal.ui.elements.adapters.DefaultBreakpointsViewInput;
+import org.eclipse.debug.internal.ui.viewers.model.provisional.IModelDelta;
+import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext;
+import org.eclipse.debug.internal.ui.viewers.model.provisional.IViewerUpdate;
+import org.eclipse.debug.internal.ui.viewers.model.provisional.ModelDelta;
+import org.eclipse.debug.internal.ui.viewers.update.BreakpointManagerProxy;
+import org.eclipse.debug.internal.ui.views.breakpoints.BreakpointContainer;
+import org.eclipse.debug.internal.ui.views.breakpoints.ElementComparator;
+import org.eclipse.debug.ui.DebugUITools;
+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.util.IPropertyChangeListener;
+import org.eclipse.jface.util.PropertyChangeEvent;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.ui.IWorkbenchWindow;
+
+/**
+ * This class provides breakpoint content for the breakpoint manager.
+ *
+ * @since 3.6
+ */
+public class BreakpointManagerContentProvider extends ElementContentProvider
+ implements IBreakpointsListener {
+
+ /**
+ * Breakpoint input data. Contains all input specific data.
+ *
+ * @since 3.6
+ */
+ private class InputData {
+ /**
+ * Breakpoint manager input
+ */
+ final private DefaultBreakpointsViewInput fInput;
+
+ /**
+ * Model proxy of the input
+ */
+ final private List/*<AbstractModelProxy>*/ fProxies = new ArrayList(1);
+
+ /**
+ * Element comparator, use to compare the ordering of elements for the model
+ * <br/> Note: We assume that the comparator does not change.
+ */
+ private ElementComparator fComparator;
+
+ /**
+ * The breakpoint root container.<br/>
+ * Note: The final qualifier guarantees that fContainer will be
+ * initialized before the class is accessed on other threads.
+ */
+ final private BreakpointContainer fContainer;
+
+ /**
+ * Known current breakpoint organizers.
+ */
+ private IBreakpointOrganizer[] fOrganizers;
+
+ private IStructuredSelection fDebugContext = StructuredSelection.EMPTY;
+
+ private IPropertyChangeListener fOrganizersListener = new IPropertyChangeListener() {
+ public void propertyChange(PropertyChangeEvent event) {
+ // For any property changes in breakpiont organizers, refresh the containers.
+ updateContainers();
+ }
+ };
+
+ private IPropertyChangeListener fPresentationContextListener = new IPropertyChangeListener() {
+ public void propertyChange(PropertyChangeEvent event) {
+ presentationPropertyChanged(event);
+ }
+ };
+
+ private IDebugContextListener fDebugContextListener = new IDebugContextListener() {
+ public void debugContextChanged(DebugContextEvent event) {
+ InputData.this.debugContextChanged(event);
+ }
+ };
+
+ /**
+ * Constructor
+ *
+ * @param input the breakpoint manager input
+ * @param proxy the model proxy
+ * @param filter the debug context selection
+ * @param comparator the element comparator
+ */
+ InputData(DefaultBreakpointsViewInput input) {
+ fInput = input;
+ fComparator = (ElementComparator)
+ input.getContext().getProperty(IBreakpointUIConstants.PROP_BREAKPOINTS_ELEMENT_COMPARATOR);
+
+ fOrganizers = (IBreakpointOrganizer[])
+ input.getContext().getProperty(IBreakpointUIConstants.PROP_BREAKPOINTS_ORGANIZERS);
+
+ // Create the initial container.
+ ModelDelta initialDelta = new ModelDelta(fInput, 0, IModelDelta.NO_CHANGE, -1);
+ IBreakpoint[] breakpoints = filterBreakpoints(
+ fInput, getSelectionFilter(fInput, getDebugContext()), fBpManager.getBreakpoints());
+ fContainer = createRootContainer(initialDelta, fInput, fOrganizers, breakpoints);
+
+ registerOrganizersListener(null, fOrganizers);
+ input.getContext().addPropertyChangeListener(fPresentationContextListener);
+
+ IWorkbenchWindow window = fInput.getContext().getWindow();
+ if (window != null) {
+ IDebugContextService debugContextService = DebugUITools.getDebugContextManager().getContextService(window);
+ ISelection debugContext = debugContextService.getActiveContext();
+ if (debugContext instanceof IStructuredSelection) {
+ synchronized(this) {
+ fDebugContext = (IStructuredSelection)debugContext;
+ }
+ }
+ debugContextService.addDebugContextListener(fDebugContextListener);
+ }
+ }
+
+ void dispose() {
+ // Unregister listener to breakpoint organizers.
+ IBreakpointOrganizer[] organizers;
+ synchronized(this) {
+ organizers = fOrganizers;
+ fOrganizers = null;
+ }
+ registerOrganizersListener(organizers, null);
+
+ // Unregister listener to presentation context.
+ fInput.getContext().removePropertyChangeListener(fPresentationContextListener);
+
+ // Unregister listener to debug context in window.
+ IWorkbenchWindow window = fInput.getContext().getWindow();
+ if (window != null) {
+ IDebugContextService debugContextService = DebugUITools.getDebugContextManager().getContextService(window);
+ debugContextService.removeDebugContextListener(fDebugContextListener);
+ }
+
+ }
+
+ void proxyInstalled(BreakpointManagerProxy proxy) {
+ ModelDelta rootDelta = null;
+ synchronized(this) {
+ fProxies.add(proxy);
+
+ // Generate an install delta
+
+ rootDelta = new ModelDelta(fInput, 0, IModelDelta.NO_CHANGE, -1);
+ buildInstallDelta(rootDelta, fContainer);
+
+ if (DEBUG_BREAKPOINT_DELTAS) {
+ System.out.println("PROXY INSTALLED (" + proxy + ")\n"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ proxy.postModelChanged(rootDelta, false);
+ }
+ }
+
+ synchronized void proxyDisposed(BreakpointManagerProxy proxy) {
+ fProxies.remove(proxy);
+ if (DEBUG_BREAKPOINT_DELTAS) {
+ System.out.println("PROXY DISPOSED (" + proxy + ")\n"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ }
+
+ synchronized BreakpointManagerProxy[] getProxies() {
+ return (BreakpointManagerProxy[])fProxies.toArray(new BreakpointManagerProxy[fProxies.size()]);
+ }
+
+ /**
+ * Change the breakpoint organizers for the root container.
+ *
+ * @param organizers the new organizers.
+ */
+ void setOrganizers(IBreakpointOrganizer[] organizers) {
+ IBreakpointOrganizer[] oldOrganizers = null;
+ synchronized(this) {
+ oldOrganizers = fOrganizers;
+ fOrganizers = organizers;
+ }
+ registerOrganizersListener(oldOrganizers, organizers);
+ updateContainers();
+ }
+
+ private void registerOrganizersListener(IBreakpointOrganizer[] oldOrganizers, IBreakpointOrganizer[] newOrganizers) {
+ if (oldOrganizers != null) {
+ for (int i = 0; i < oldOrganizers.length; i++) {
+ oldOrganizers[i].removePropertyChangeListener(fOrganizersListener);
+ }
+ }
+ if (newOrganizers != null) {
+ for (int i = 0; i < newOrganizers.length; i++) {
+ newOrganizers[i].addPropertyChangeListener(fOrganizersListener);
+ }
+ }
+ }
+
+ void updateContainers() {
+ IBreakpoint[] breakpoints = filterBreakpoints(
+ fInput, getSelectionFilter(fInput, getDebugContext()), fBpManager.getBreakpoints());
+
+ synchronized(this) {
+ ModelDelta delta = new ModelDelta(fInput, IModelDelta.NO_CHANGE);
+ // create a reference container, use for deleting elements and adding elements
+ ModelDelta dummyDelta = new ModelDelta(null, IModelDelta.NO_CHANGE);
+ BreakpointContainer refContainer = createRootContainer(dummyDelta, fInput, fOrganizers, breakpoints);
+
+ // delete the removed elements
+ deleteRemovedElements(fContainer, refContainer, delta);
+
+ // adjust the old organizer with the reference organizer
+ BreakpointContainer.copyOrganizers(fContainer, refContainer);
+
+ // insert the added elements
+ IBreakpoint newBreakpoint = insertAddedElements(fContainer, refContainer, delta);
+ delta.setChildCount(fContainer.getChildren().length);
+
+ // select the new breakpoint
+ if (newBreakpoint != null) {
+ appendModelDeltaToElement(delta, newBreakpoint, IModelDelta.SELECT);
+ }
+ if (DEBUG_BREAKPOINT_DELTAS) {
+ System.out.println("POST BREAKPOINT DELTA (setOrganizers)\n"); //$NON-NLS-1$
+ }
+ postModelChanged(delta, false);
+ }
+ }
+
+ private synchronized IStructuredSelection getDebugContext() {
+ return fDebugContext;
+ }
+
+ /**
+ * Handles the property changed events in presentation contexts.
+ * Sub-classes may override to perform additional handling.
+ *
+ * @param presentation Presentation context that changed.
+ */
+ private void presentationPropertyChanged(PropertyChangeEvent event) {
+ if (IPresentationContext.PROPERTY_DISPOSED.equals(event.getProperty())) {
+ contextDisposed(fInput.getContext());
+ }
+ if (IBreakpointUIConstants.PROP_BREAKPOINTS_ORGANIZERS.equals(event.getProperty())) {
+ IBreakpointOrganizer[] organizers = (IBreakpointOrganizer[])event.getNewValue();
+ setOrganizers(organizers);
+ }
+ else if ( IBreakpointUIConstants.PROP_BREAKPOINTS_FILTER_SELECTION.equals(event.getProperty()) )
+ {
+ IStructuredSelection selection = null;
+
+ if (Boolean.TRUE.equals(event.getNewValue()) ) {
+ selection = getDebugContext();
+ }
+ setFilterSelection(selection);
+ }
+ else if ( IBreakpointUIConstants.PROP_BREAKPOINTS_TRACK_SELECTION.equals(event.getProperty()) )
+ {
+ IStructuredSelection selection = null;
+
+ if (Boolean.TRUE.equals(event.getNewValue()) ) {
+ selection = getDebugContext();
+ }
+ trackSelection(selection);
+ }
+ }
+
+ private void debugContextChanged(DebugContextEvent event) {
+ IStructuredSelection newContext;
+ if (event.getContext() instanceof IStructuredSelection) {
+ newContext = (IStructuredSelection)event.getContext();
+ } else {
+ newContext = StructuredSelection.EMPTY;
+ }
+
+ synchronized(this) {
+ fDebugContext = newContext;
+ }
+
+ if (Boolean.TRUE.equals(fInput.getContext().getProperty(IBreakpointUIConstants.PROP_BREAKPOINTS_FILTER_SELECTION)) ) {
+ setFilterSelection(newContext);
+ }
+
+ if (Boolean.TRUE.equals(fInput.getContext().getProperty(IBreakpointUIConstants.PROP_BREAKPOINTS_TRACK_SELECTION)) ) {
+ trackSelection(newContext);
+ }
+ }
+
+
+ private void setFilterSelection(IStructuredSelection ss) {
+ ModelDelta delta = new ModelDelta(fInput, IModelDelta.NO_CHANGE);
+ boolean changed = false;
+
+ // calculate supported breakpoints outside of the synchronized section.
+ IBreakpoint[] allBreakpoints = fBpManager.getBreakpoints();
+ boolean[] supportedBreakpoints = new boolean[allBreakpoints.length];
+ for (int i = 0; i < allBreakpoints.length; ++i) {
+ supportedBreakpoints[i] = supportsBreakpoint(ss, allBreakpoints[i]);
+ }
+
+ synchronized(this) {
+ Set existingBreakpoints = new HashSet(Arrays.asList(fContainer.getBreakpoints()));
+
+ for (int i = 0; i < allBreakpoints.length; ++i) {
+ boolean contain = existingBreakpoints.contains(allBreakpoints[i]);
+
+ if (supportedBreakpoints[i]) {
+ if (!contain) {
+ fContainer.addBreakpoint(allBreakpoints[i], delta);
+ changed = true;
+ }
+ } else {
+ if (contain) {
+ fContainer.removeBreakpoint(allBreakpoints[i], delta);
+ changed = true;
+ }
+
+ }
+
+ }
+
+ if (changed) {
+ if (DEBUG_BREAKPOINT_DELTAS) {
+ System.out.println("POST BREAKPOINT DELTA (setFilterSelection)\n"); //$NON-NLS-1$
+ }
+ postModelChanged(delta, false);
+ }
+ }
+ }
+
+
+ private void trackSelection(IStructuredSelection selection) {
+ if (selection == null || selection.size() != 1) {
+ return;
+ }
+
+ Iterator iter = selection.iterator();
+ Object firstElement = iter.next();
+ if (firstElement == null || iter.hasNext()) {
+ return;
+ }
+ IThread thread = null;
+ if (firstElement instanceof IStackFrame) {
+ thread = ((IStackFrame) firstElement).getThread();
+ } else if (firstElement instanceof IThread) {
+ thread = (IThread) firstElement;
+ } else {
+ return;
+ }
+
+ IBreakpoint[] breakpoints = thread.getBreakpoints();
+ Set bpsSet = new HashSet(breakpoints.length * 4/3);
+ for (int i = 0; i< breakpoints.length; i++) {
+ bpsSet.add(breakpoints[i]);
+ }
+
+ ModelDelta delta = new ModelDelta(fInput, IModelDelta.NO_CHANGE);
+ synchronized (this) {
+ if (buildTrackSelectionDelta(delta, fContainer, bpsSet)) {
+ if (DEBUG_BREAKPOINT_DELTAS) {
+ System.out.println("POST BREAKPOINT DELTA (trackSelection)\n"); //$NON-NLS-1$
+ }
+ BreakpointManagerProxy[] proxies = getProxies();
+ for (int i = 0; i < proxies.length; i++) {
+ proxies[i].postModelChanged(delta, true);
+ }
+ }
+ }
+
+ }
+
+ /**
+ * Recursive function to build the model delta to select a breakpoint
+ * corresponding to the active debug context selection.
+ *
+ * @param delta Delta node to build on
+ * @param container Container element to build delta for.
+ * @param breakpoints Breakpoint set to be selected.
+ * @return whether we found a breakpoint to select
+ */
+ private boolean buildTrackSelectionDelta(ModelDelta delta, BreakpointContainer container, Set breakpoints) {
+ Object[] children = container.getChildren();
+ delta.setChildCount(children.length);
+ for (int i = 0; i < children.length; i++) {
+ ModelDelta childDelta = delta.addNode(children[i], i, IModelDelta.NO_CHANGE);
+ if (children[i] instanceof BreakpointContainer) {
+ BreakpointContainer childContainer = (BreakpointContainer)children[i];
+ boolean containsBP = false;
+ IBreakpoint[] containerBPs = childContainer.getBreakpoints();
+ for (int j = 0; j < containerBPs.length; j++) {
+ if (breakpoints.contains(containerBPs[j])) {
+ containsBP = true;
+ break;
+ }
+ }
+ if (containsBP && buildTrackSelectionDelta(childDelta, childContainer, breakpoints) ) {
+ return true;
+ }
+ } else if (children[i] instanceof IBreakpoint &&
+ breakpoints.contains(children[i]))
+ {
+ childDelta.setFlags(IModelDelta.SELECT | IModelDelta.EXPAND);
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Helper method to add breakpoints to the given input.
+ *
+ * @param data the input to add the breakpoints
+ * @param breakpoints the breakpoints
+ */
+ void breakpointsAdded(IBreakpoint[] breakpoints) {
+ IBreakpoint[] filteredBreakpoints = filterBreakpoints(
+ fInput, getSelectionFilter(fInput, getDebugContext()), breakpoints);
+
+ synchronized (this) {
+ ModelDelta delta = new ModelDelta(fInput, 0, IModelDelta.NO_CHANGE, -1);
+ for (int i = 0; i < filteredBreakpoints.length; ++i) {
+ fContainer.addBreakpoint(filteredBreakpoints[i], delta);
+ }
+ delta.setChildCount(fContainer.getChildren().length);
+
+ // select the breakpoint
+ if (filteredBreakpoints.length > 0) {
+ appendModelDeltaToElement(delta, filteredBreakpoints[0], IModelDelta.SELECT);
+ }
+
+ if (DEBUG_BREAKPOINT_DELTAS) {
+ System.out.println("POST BREAKPOINT DELTA (breakpointsAddedInput)\n"); //$NON-NLS-1$
+ }
+ postModelChanged(delta, false);
+ }
+ }
+
+ /**
+ * Helper method to remove breakpoints from a given input.
+ *
+ * @param data the input to add the breakpoints
+ * @param breakpoints the breakpoints
+ */
+ void breakpointsRemoved(IBreakpoint[] breakpoints) {
+ IBreakpoint[] filteredBreakpoints = filterBreakpoints(
+ fInput, getSelectionFilter(fInput, getDebugContext()), breakpoints);
+
+ synchronized (this) {
+ ModelDelta delta = new ModelDelta(fInput, IModelDelta.NO_CHANGE);
+ for (int i = 0; i < filteredBreakpoints.length; ++i) {
+ fContainer.removeBreakpoint(filteredBreakpoints[i], delta);
+ }
+
+ if (DEBUG_BREAKPOINT_DELTAS) {
+ System.out.println("POST BREAKPOINT DELTA (breakpointsRemovedInput)\n"); //$NON-NLS-1$
+ }
+ postModelChanged(delta, false);
+ }
+ }
+
+ void breakpointsChanged(IBreakpoint[] breakpoints) {
+
+
+ IBreakpoint[] filteredBreakpoints = filterBreakpoints(
+ fInput, getSelectionFilter(fInput, getDebugContext()), breakpoints);
+
+ synchronized (this) {
+ ModelDelta delta = new ModelDelta(fInput, IModelDelta.NO_CHANGE);
+
+ // If the change caused a breakpoint to be added (installed) or remove (un-installed) update accordingly.
+ List removed = new ArrayList();
+ List added = new ArrayList();
+ List filteredAsList = Arrays.asList(filteredBreakpoints);
+ for (int i = 0; i < breakpoints.length; i++) {
+ IBreakpoint bp = breakpoints[i];
+ boolean oldContainedBp = fContainer.contains(bp);
+ boolean newContained = filteredAsList.contains(bp);
+ if (oldContainedBp && !newContained) {
+ removed.add(bp);
+ } else if (!oldContainedBp && newContained) {
+ added.add(bp);
+ }
+ }
+ if (!added.isEmpty()) {
+ breakpointsAdded((IBreakpoint[]) added.toArray(new IBreakpoint[added.size()]));
+ }
+ if (!removed.isEmpty()) {
+ breakpointsRemoved((IBreakpoint[]) removed.toArray(new IBreakpoint[removed.size()]));
+ }
+ for (int i = 0; i < filteredBreakpoints.length; ++i)
+ appendModelDelta(fContainer, delta, IModelDelta.STATE | IModelDelta.CONTENT, filteredBreakpoints[i]); // content flag triggers detail refresh
+
+ if (DEBUG_BREAKPOINT_DELTAS) {
+ System.out.println("POST BREAKPOINT DELTA (breakpointsChanged)\n"); //$NON-NLS-1$
+ }
+ postModelChanged(delta, false);
+ }
+ }
+
+
+ /**
+ * Recursive function to build the model delta to install breakpoint
+ * model proxies for all breakpoints and breakpoint containers.
+ *
+ * @param delta Delta node to build on
+ * @param container Container element to build delta for.
+ */
+ private void buildInstallDelta(ModelDelta delta, BreakpointContainer container) {
+ Object[] children = container.getChildren();
+ delta.setChildCount(children.length);
+ for (int i = 0; i < children.length; i++) {
+ ModelDelta childDelta = delta.addNode(children[i], i, IModelDelta.NO_CHANGE);
+ if (children[i] instanceof BreakpointContainer) {
+ childDelta.setFlags(IModelDelta.INSTALL);
+ buildInstallDelta(childDelta, (BreakpointContainer)children[i]);
+ } else if (children[i] instanceof IBreakpoint) {
+ childDelta.setFlags(IModelDelta.INSTALL);
+ }
+ }
+ }
+
+
+ /**
+ * Insert elements from the reference container to an existing container.
+ *
+ * @param container the existing container to insert the new elements.
+ * @param refContainer the reference container to compare elements that are added.
+ * @param containerDelta the delta of the existing container.
+ */
+ private IBreakpoint insertAddedElements(BreakpointContainer container, BreakpointContainer refContainer, ModelDelta containerDelta) {
+ IBreakpoint newBreakpoint = null;
+
+ Object[] children = container.getChildren();
+ Object[] refChildren = refContainer.getChildren();
+
+
+ for (int i = 0; i < refChildren.length; ++i) {
+ Object element = getElement(children, refChildren[i]);
+
+ // if a child of refContainer doesn't exist in container, than insert it to container
+ // - if the reference child is a container, than copy the reference child container to container
+ // - otherwise (Breakpoint), add the breakpoint to container
+ if (element == null) {
+ if (refChildren[i] instanceof BreakpointContainer) {
+ BreakpointContainer.addChildContainer(container, (BreakpointContainer) refChildren[i], containerDelta);
+ } else {
+ BreakpointContainer.addBreakpoint(container, (IBreakpoint) refChildren[i], containerDelta);
+ if (newBreakpoint == null)
+ newBreakpoint = (IBreakpoint) refChildren[i];
+ }
+
+ // if a child exist in container, than recursively search into container. And also update the organizer of
+ // of container to the one in the refContainer's child.
+ } else if (element instanceof BreakpointContainer) {
+ int index = Arrays.asList(children).indexOf(element);
+ ModelDelta childDelta = containerDelta.addNode(element, index, IModelDelta.STATE, -1);
+ BreakpointContainer.copyOrganizers((BreakpointContainer) element, (BreakpointContainer) refChildren[i]);
+ newBreakpoint = insertAddedElements((BreakpointContainer) element, (BreakpointContainer) refChildren[i], childDelta);
+ childDelta.setChildCount(((BreakpointContainer) element).getChildren().length);
+ }
+ }
+
+ return newBreakpoint;
+ }
+
+ /**
+ * Delete elements from existing container that doesn't exist in the reference container.
+ *
+ * @param container the existing container to delete the removed elements.
+ * @param refContainer the reference container to compare elements that are removed.
+ * @param containerDelta the delta of the existing container.
+ */
+ private void deleteRemovedElements(BreakpointContainer container, BreakpointContainer refContainer, ModelDelta containerDelta) {
+ Object[] children = container.getChildren();
+ Object[] refChildren = refContainer.getChildren();
+
+ // if a child of container doesn't exist in refContainer, than remove it from container
+ for (int i = 0; i < children.length; ++i) {
+ Object element = getElement(refChildren, children[i]);
+
+ if (element == null) {
+ if (children[i] instanceof BreakpointContainer) {
+ BreakpointContainer.removeAll((BreakpointContainer) children[i], containerDelta);
+ } else {
+ BreakpointContainer.removeBreakpoint(container, (IBreakpoint) children[i], containerDelta);
+ }
+ } else if (element instanceof BreakpointContainer){
+
+ ModelDelta childDelta = containerDelta.addNode(children[i], IModelDelta.STATE);
+ deleteRemovedElements((BreakpointContainer) children[i], (BreakpointContainer) element, childDelta);
+ }
+ }
+ }
+
+ /**
+ * Get the element that is in the collection.
+ *
+ * @param collection the collection of elements.
+ * @param element the element to search.
+ * @return if element exist in collection, than it is returned, otherwise <code>null</code> is returned.
+ * @see insertAddedElements
+ * @see deleteRemovedElements
+ */
+ private Object getElement(Object[] collection, Object element) {
+ for (int i = 0; i < collection.length; ++i)
+ if (collection[i] instanceof BreakpointContainer && element instanceof BreakpointContainer) {
+ if (collection[i].equals(element))
+ return collection[i];
+ } else {
+ if (collection[i].equals(element))
+ return collection[i];
+ }
+ return null;
+ }
+
+ /**
+ * Create a root container.
+ *
+ * @param rootDelta the root delta.
+ * @param input the view input.
+ * @param organizers the breakpoint organizers.
+ * @param oldContainer the old container, use to determine whether a new breakpoint should be expanded.
+ * @param the breakpoint manager.
+ */
+ private BreakpointContainer createRootContainer(
+ ModelDelta rootDelta, DefaultBreakpointsViewInput input,
+ IBreakpointOrganizer[] organizers, IBreakpoint[] breakpoints)
+ {
+
+ BreakpointContainer container = new BreakpointContainer(organizers, fComparator);
+ container.initDefaultContainers(rootDelta);
+
+ for (int i = 0; i < breakpoints.length; ++i) {
+ container.addBreakpoint(breakpoints[i], rootDelta);
+ }
+
+ return container;
+ }
+
+ /**
+ * Fire model change event for the input.
+ *
+ * @param input the input.
+ * @param delta the model delta.
+ * @param debugReason the debug string.
+ */
+ synchronized private void postModelChanged(final IModelDelta delta, boolean select) {
+ for (int i = 0; fProxies != null && i < fProxies.size(); i++) {
+ ((BreakpointManagerProxy)fProxies.get(i)).postModelChanged(delta, select);
+ }
+ }
+
+
+ }
+
+ private class InputDataMap extends LinkedHashMap {
+ private static final long serialVersionUID = 1L;
+
+ public InputDataMap() {
+ super(1, (float)0.75, true);
+ }
+
+ protected boolean removeEldestEntry(java.util.Map.Entry arg0) {
+ InputData data = (InputData)arg0.getValue();
+ if (size() > getMaxInputsCache() && data.fProxies.isEmpty()) {
+ data.dispose();
+ return true;
+ }
+ return false;
+ }
+ }
+
+ /**
+ * Scheduling rule to make sure that breakpoint manager listener updates
+ * are process serially.
+ */
+ private ISchedulingRule fBreakpointsListenerSchedulingRule = new ISchedulingRule() {
+
+ public boolean isConflicting(ISchedulingRule rule) {
+ return rule == this;
+ }
+
+ public boolean contains(ISchedulingRule rule) {
+ return rule == this;
+ }
+ };
+
+ // debug flags
+ public static boolean DEBUG_BREAKPOINT_DELTAS = false;
+
+ static {
+ DEBUG_BREAKPOINT_DELTAS = DebugUIPlugin.DEBUG && "true".equals( //$NON-NLS-1$
+ Platform.getDebugOption("org.eclipse.debug.ui/debug/viewers/breakpointDeltas")); //$NON-NLS-1$
+ }
+
+ /**
+ * A map of input to info data cache
+ */
+ final private Map fInputToData = Collections.synchronizedMap(new InputDataMap());
+
+ /**
+ * Flag indicating whether the content provider is currently a breakpoints listener.
+ */
+ private boolean fIsBreakpointListener = false;
+
+ /**
+ * The breakpoint manager.
+ */
+ final private IBreakpointManager fBpManager = DebugPlugin.getDefault().getBreakpointManager();
+
+ /**
+ * Sub-classes may override this method to filter the breakpoints.
+ *
+ * @param input the breakpoint manager input.
+ * @param breakpoints the list of breakpoint to filter.
+ * @return the filtered list of breakpoint based on the input.
+ */
+ protected IBreakpoint[] filterBreakpoints(DefaultBreakpointsViewInput input, IStructuredSelection selectionFilter, IBreakpoint[] breakpoints) {
+ if (selectionFilter != null && !selectionFilter.isEmpty()) {
+ List targets = getDebugTargets(selectionFilter);
+ ArrayList retVal = new ArrayList();
+ if (targets != null) {
+ for (int i = 0; i < breakpoints.length; ++i) {
+ if (supportsBreakpoint(targets, breakpoints[i]))
+ retVal.add(breakpoints[i]);
+ }
+ }
+ return (IBreakpoint[]) retVal.toArray(new IBreakpoint[retVal.size()]);
+ } else {
+ return breakpoints;
+ }
+ }
+
+ /**
+ * Sub-classes may override this to determine whether the breakpoint is supported by the selection.
+ *
+ * @param ss the selection of the debug elements.
+ * @param breakpoint the breakpoint.
+ * @return true if supported.
+ */
+ protected boolean supportsBreakpoint(IStructuredSelection ss, IBreakpoint breakpoint) {
+ return supportsBreakpoint(getDebugTargets(ss), breakpoint);
+ }
+
+ /**
+ * Returns true if the breakpoint contains in one of the targets.
+ *
+ * @param targets a list of <code>IDebugTarget</code> objects.
+ * @param breakpoint the breakpoint.
+ * @return true if breakpoint contains in the list of targets.
+ */
+ protected boolean supportsBreakpoint(List targets, IBreakpoint breakpoint) {
+ boolean exist = targets.size() == 0 ? true : false;
+ for (int i = 0; !exist && i < targets.size(); ++i) {
+ IDebugTarget target = (IDebugTarget) targets.get(i);
+ exist |= target.supportsBreakpoint(breakpoint);
+ }
+ return exist;
+ }
+
+ /**
+ * Returns the list of IDebugTarget for the selection.
+ *
+ * @param ss the selection.
+ * @return list of IDebugTarget object.
+ */
+ protected List getDebugTargets(IStructuredSelection ss) {
+ List debugTargets = new ArrayList(2);
+ if (ss != null) {
+ Iterator i = ss.iterator();
+ while (i.hasNext()) {
+ Object next = i.next();
+ if (next instanceof IDebugElement) {
+ debugTargets.add(((IDebugElement)next).getDebugTarget());
+ } else if (next instanceof ILaunch) {
+ IDebugTarget[] targets = ((ILaunch)next).getDebugTargets();
+ for (int j = 0; j < targets.length; j++) {
+ debugTargets.add(targets[j]);
+ }
+ } else if (next instanceof IProcess) {
+ IDebugTarget target = (IDebugTarget)((IProcess)next).getAdapter(IDebugTarget.class);
+ if (target != null) {
+ debugTargets.add(target);
+ }
+ }
+ }
+ }
+ return debugTargets;
+ }
+
+
+ /**
+ * Maximum number of breakpoint manager input objects that this provider
+ * will cache data for. This method is called once upon class creation
+ * when setting up the data cache. Sub-classes may override to provide
+ * a custom setting.
+ *
+ * @return Maximum data cache size
+ */
+ protected int getMaxInputsCache() {
+ return 2;
+ }
+
+ /**
+ * Handles the event when a presentation context is dispoed.
+ * Sub-classes may override to perform additional cleanup.
+ *
+ * @param context Presetnation context that was disposed.
+ */
+ protected void contextDisposed(IPresentationContext context) {
+ List removed = new ArrayList(1);
+ synchronized (fInputToData) {
+ for (Iterator itr = fInputToData.entrySet().iterator(); itr.hasNext();) {
+ Map.Entry entry = (Map.Entry)itr.next();
+ IPresentationContext entryContext = ((DefaultBreakpointsViewInput)entry.getKey()).getContext();
+ if (context.equals(entryContext)) {
+ removed.add(entry.getValue());
+ itr.remove();
+ }
+ }
+ }
+
+ // Dispose the removed input datas
+ for (int i = 0; i < removed.size(); i++) {
+ ((InputData)removed.get(i)).dispose();
+ }
+ }
+
+ /**
+ * Register the breakpoint manager input with this content provider.
+ *
+ * @param input the breakpoint manager input to register.
+ * @param proxy the model proxy of the input.
+ * @param organizers the breakpoint organizer, can be <code>null</code>.
+ * @param selectionFilter the selection filter, can be <code>null</code>.
+ * @param comparator the element comparator.
+ */
+ public void registerModelProxy(DefaultBreakpointsViewInput input, BreakpointManagerProxy proxy) {
+ synchronized(this) {
+ if (!fIsBreakpointListener) {
+ fBpManager.addBreakpointListener(this);
+ fIsBreakpointListener = true;
+ }
+ }
+ InputData inputData = getInputData(input);
+ if (inputData != null) {
+ inputData.proxyInstalled(proxy);
+ }
+ }
+
+ /**
+ * Unregister the breakpoint manager input with this content provider.
+ *
+ * @param input the breakpoint manager input to unregister.
+ */
+ public void unregisterModelProxy(DefaultBreakpointsViewInput input, BreakpointManagerProxy proxy) {
+ InputData inputData = (InputData)fInputToData.get(input);
+ if (inputData != null) {
+ inputData.proxyDisposed(proxy);
+
+ if (fInputToData.isEmpty()) {
+ synchronized(this) {
+ if (fIsBreakpointListener) {
+ fBpManager.removeBreakpointListener(this);
+ fIsBreakpointListener = false;
+ }
+ }
+ }
+ }
+ }
+
+ private InputData getInputData(DefaultBreakpointsViewInput input) {
+ if (Boolean.TRUE.equals(input.getContext().getProperty(IPresentationContext.PROPERTY_DISPOSED)) ) {
+ return null;
+ }
+
+ InputData data = null;
+ synchronized (fInputToData) {
+ data = (InputData)fInputToData.get(input);
+ if (data == null) {
+ data = new InputData(input);
+ fInputToData.put(input, data);
+ }
+ }
+ return data;
+ }
+
+ /**
+ * Returns the selection filter for the input.
+ *
+ * @param input the selection.
+ */
+ protected IStructuredSelection getSelectionFilter(Object input, IStructuredSelection debugContext) {
+ if (input instanceof DefaultBreakpointsViewInput) {
+ IPresentationContext presentation = ((DefaultBreakpointsViewInput)input).getContext();
+ if ( Boolean.TRUE.equals(presentation.getProperty(IBreakpointUIConstants.PROP_BREAKPOINTS_FILTER_SELECTION)) ) {
+ return debugContext;
+ }
+ }
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.internal.ui.model.elements.ElementContentProvider#supportsContextId(java.lang.String)
+ */
+ protected boolean supportsContextId(String id) {
+ return id.equals(IDebugUIConstants.ID_BREAKPOINT_VIEW);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.internal.ui.model.elements.ElementContentProvider#getChildCount(java.lang.Object, org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext, org.eclipse.debug.internal.ui.viewers.model.provisional.IViewerUpdate)
+ */
+ protected int getChildCount(Object element, IPresentationContext context, IViewerUpdate monitor) throws CoreException {
+ Object input = monitor.getViewerInput();
+ if (input instanceof DefaultBreakpointsViewInput) {
+ DefaultBreakpointsViewInput bpManagerInput = (DefaultBreakpointsViewInput)input;
+ InputData inputData = getInputData(bpManagerInput);
+ if (inputData != null) {
+ return inputData.fContainer.getChildren().length;
+ }
+ }
+ return 0;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.internal.ui.model.elements.ElementContentProvider#getChildren(java.lang.Object, int, int, org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext, org.eclipse.debug.internal.ui.viewers.model.provisional.IViewerUpdate)
+ */
+ protected Object[] getChildren(Object parent, int index, int length, IPresentationContext context, IViewerUpdate monitor) throws CoreException {
+ Object input = monitor.getViewerInput();
+ if (input instanceof DefaultBreakpointsViewInput) {
+ DefaultBreakpointsViewInput bpManagerInput = (DefaultBreakpointsViewInput)input;
+ InputData inputData = getInputData(bpManagerInput);
+ if (inputData != null) {
+ Object[] children = inputData.fContainer.getChildren();
+ return getElements(children, index, length);
+ }
+ }
+
+ return EMPTY;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.debug.core.IBreakpointsListener#breakpointsAdded(org.eclipse.debug.core.model.IBreakpoint[])
+ */
+ public void breakpointsAdded(final IBreakpoint[] breakpoints) {
+ new Job("Breakpoints View Update Job") { //$NON-NLS-1$
+ {
+ setSystem(true);
+ setRule(fBreakpointsListenerSchedulingRule);
+ }
+
+ protected IStatus run(IProgressMonitor monitor) {
+ InputData[] datas = (InputData[])fInputToData.values().toArray(new InputData[0]);
+ for (int i = 0; i < datas.length; i++) {
+ datas[i].breakpointsAdded(breakpoints);
+ }
+ return Status.OK_STATUS;
+ }
+ }.schedule();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.debug.core.IBreakpointsListener#breakpointsRemoved(org.eclipse.debug.core.model.IBreakpoint[], org.eclipse.core.resources.IMarkerDelta[])
+ */
+ public void breakpointsRemoved(final IBreakpoint[] breakpoints, IMarkerDelta[] deltas) {
+ new Job("Breakpoints View Update Job") { //$NON-NLS-1$
+ {
+ setSystem(true);
+ setRule(fBreakpointsListenerSchedulingRule);
+ }
+
+ protected IStatus run(IProgressMonitor monitor) {
+ InputData[] datas = (InputData[])fInputToData.values().toArray(new InputData[0]);
+ for (int i = 0; i < datas.length; i++) {
+ datas[i].breakpointsRemoved(breakpoints);
+ }
+ return Status.OK_STATUS;
+ }
+ }.schedule();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.debug.core.IBreakpointsListener#breakpointsChanged(org.eclipse.debug.core.model.IBreakpoint[], org.eclipse.core.resources.IMarkerDelta[])
+ */
+ public void breakpointsChanged(final IBreakpoint[] breakpoints, IMarkerDelta[] deltas) {
+ new Job("Breakpoints View Update Job") { //$NON-NLS-1$
+ {
+ setSystem(true);
+ setRule(fBreakpointsListenerSchedulingRule);
+ }
+
+ protected IStatus run(IProgressMonitor monitor) {
+ InputData[] datas = (InputData[])fInputToData.values().toArray(new InputData[0]);
+ for (int i = 0; i < datas.length; i++) {
+ datas[i].breakpointsChanged(breakpoints);
+ }
+ return Status.OK_STATUS;
+ }
+ }.schedule();
+ }
+ /**
+ * Appends the model delta flags to child containers that contains the breakpoint.
+ *
+ * @param parent the parent container.
+ * @param parentDelta the parent model delta.
+ * @param flags the model delta flags.
+ * @param breakpoint the breakpoint to search in the children containers.
+ */
+ private void appendModelDelta(BreakpointContainer parent, ModelDelta parentDelta, int flags, IBreakpoint breakpoint) {
+ BreakpointContainer[] containers = parent.getContainers();
+
+ if (parent.contains(breakpoint)) {
+ if ((containers.length != 0)) {
+ for (int i = 0; i < containers.length; ++i) {
+ ModelDelta nodeDelta = parentDelta.addNode(containers[i], IModelDelta.STATE);
+ appendModelDelta(containers[i], nodeDelta, flags, breakpoint);
+ }
+ } else {
+ parentDelta.addNode(breakpoint, flags);
+ }
+ }
+ }
+
+ /**
+ * Appends the model delta to the first found element in the model delta tree.
+ *
+ * @param parentDelta the parent delta
+ * @param element the element to search
+ * @param flags the delta flags
+ */
+ private void appendModelDeltaToElement(IModelDelta parentDelta, Object element, int flags) {
+ if (element.equals(parentDelta.getElement())) {
+ ((ModelDelta) parentDelta).setFlags(parentDelta.getFlags() | flags);
+ return;
+ }
+
+ IModelDelta[] childDeltas = parentDelta.getChildDeltas();
+ for (int i = 0; i < childDeltas.length; ++i) {
+ if (element.equals(childDeltas[i].getElement())) {
+ ((ModelDelta) childDeltas[i]).setFlags(childDeltas[i].getFlags() | flags);
+ return;
+ }
+
+ appendModelDeltaToElement(childDeltas[i], element, flags);
+ }
+ }
+}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/PartPresentationContext.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/PartPresentationContext.java
index 9ecf2ee7a..8a295b8e3 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/PartPresentationContext.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/PartPresentationContext.java
@@ -17,23 +17,21 @@ import org.eclipse.ui.IWorkbenchPart;
* A presentation context tied to a part.
*
* @since 3.3
+ * @deprecated getPart() is now supported by IPresentationContext itself.
*/
public class PartPresentationContext extends PresentationContext {
- private IWorkbenchPart fPart;
-
/**
* Constructs a part presentation context.
*
* @param part part
*/
public PartPresentationContext(IWorkbenchPart part) {
- super(part.getSite().getId());
- fPart = part;
+ super(part);
}
public IWorkbenchPart getPart() {
- return fPart;
+ return super.getPart();
}
}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/ModelContentProvider.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/ModelContentProvider.java
index 0ed8a4af5..e6da77ef3 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/ModelContentProvider.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/ModelContentProvider.java
@@ -56,6 +56,7 @@ import org.eclipse.jface.viewers.IContentProvider;
import org.eclipse.jface.viewers.TreePath;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerFilter;
+import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.IMemento;
import org.eclipse.ui.XMLMemento;
import org.eclipse.ui.progress.UIJob;
@@ -1252,31 +1253,51 @@ abstract class ModelContentProvider implements IContentProvider, IModelChangedLi
* #modelChanged
* (org.eclipse.debug.internal.ui.viewers.provisional.IModelDelta)
*/
- public synchronized void modelChanged(final IModelDelta delta, final IModelProxy proxy) {
- if (fViewer != null && !proxy.isDisposed()) {
- WorkbenchJob job = new WorkbenchJob(fViewer.getDisplay(), "process model delta") { //$NON-NLS-1$
- public IStatus runInUIThread(IProgressMonitor monitor) {
- if (!proxy.isDisposed()) {
- if (DEBUG_DELTAS && DEBUG_TEST_PRESENTATION_ID(getPresentationContext())) {
- DebugUIPlugin.debug("RECEIVED DELTA: " + delta.toString()); //$NON-NLS-1$
- }
-
- updateModel(delta, getModelDeltaMask());
+ public void modelChanged(final IModelDelta delta, final IModelProxy proxy) {
+ Display display = null;
- // Call model listeners after updating the viewer model.
- Object[] listeners = fModelListeners.getListeners();
- for (int i = 0; i < listeners.length; i++) {
- ((IModelChangedListener) listeners[i]).modelChanged(delta, proxy);
- }
+ // Check if the viewer is still available, i.e. if the content provider
+ // is not disposed.
+ synchronized(this) {
+ if (fViewer != null && !proxy.isDisposed()) {
+ display = fViewer.getDisplay();
+ }
+ }
+ if (display != null) {
+ // If we're in display thread, process the delta immediately to
+ // avoid "skid" in processing events.
+ if (Thread.currentThread().equals(display.getThread())) {
+ doModelChanged(delta, proxy);
+ }
+ else {
+ WorkbenchJob job = new WorkbenchJob(fViewer.getDisplay(), "process model delta") { //$NON-NLS-1$
+ public IStatus runInUIThread(IProgressMonitor monitor) {
+ doModelChanged(delta, proxy);
+ return Status.OK_STATUS;
}
- return Status.OK_STATUS;
- }
- };
- job.setSystem(true);
- job.schedule();
+ };
+ job.setSystem(true);
+ job.schedule();
+ }
}
}
+ private void doModelChanged(IModelDelta delta, IModelProxy proxy) {
+ if (!proxy.isDisposed()) {
+ if (DEBUG_DELTAS && DEBUG_TEST_PRESENTATION_ID(getPresentationContext())) {
+ DebugUIPlugin.debug("RECEIVED DELTA: " + delta.toString()); //$NON-NLS-1$
+ }
+
+ updateModel(delta, getModelDeltaMask());
+
+ // Call model listeners after updating the viewer model.
+ Object[] listeners = fModelListeners.getListeners();
+ for (int i = 0; i < listeners.length; i++) {
+ ((IModelChangedListener) listeners[i]).modelChanged(delta, proxy);
+ }
+ }
+ }
+
/**
* @see ITreeModelContentProvider#setModelDeltaMask(int)
*/
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/provisional/IPresentationContext.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/provisional/IPresentationContext.java
index f8ef91019..c9b2d16ec 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/provisional/IPresentationContext.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/provisional/IPresentationContext.java
@@ -12,6 +12,8 @@
package org.eclipse.debug.internal.ui.viewers.model.provisional;
import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.IWorkbenchWindow;
/**
* Context in which an asynchronous request has been made.
@@ -106,4 +108,24 @@ public interface IPresentationContext {
*/
public String[] getProperties();
+ /**
+ * Returns the part that this presentation context is associated with.
+ * May return <code>null</code> if the presentation is not associated
+ * with a part.
+ *
+ * @return IWorkbenchPart or <code>null</code>
+ * @since 3.6
+ */
+ public IWorkbenchPart getPart();
+
+ /**
+ * Returns the window that this presentation context is associated with.
+ * May return <code>null</code> if the presentation is not associated
+ * with a window.
+ *
+ * @return IWorkbenchWindow or <code>null</code>
+ * @since 3.6
+ */
+ public IWorkbenchWindow getWindow();
+
}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/provisional/PresentationContext.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/provisional/PresentationContext.java
index 47fd310c8..a4171884e 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/provisional/PresentationContext.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/provisional/PresentationContext.java
@@ -25,6 +25,8 @@ import org.eclipse.jface.util.SafeRunnable;
import org.eclipse.ui.IElementFactory;
import org.eclipse.ui.IMemento;
import org.eclipse.ui.IPersistableElement;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PlatformUI;
/**
@@ -42,17 +44,57 @@ public class PresentationContext implements IPresentationContext {
private static final String INTEGER = "INTEGER"; //$NON-NLS-1$
private static final String PERSISTABLE = "PERSISTABLE"; //$NON-NLS-1$
- private String fId;
- private ListenerList fListeners = new ListenerList();
- private Map fProperties = new HashMap();
-
+ final private String fId;
+ final private ListenerList fListeners = new ListenerList();
+ final private Map fProperties = new HashMap();
+ final private IWorkbenchWindow fWindow;
+ final private IWorkbenchPart fPart;
+
/**
* Constructs a presentation context for the given id.
*
* @param id presentation context id
*/
public PresentationContext(String id) {
+ this (id, null, null);
+ }
+
+ /**
+ * Constructs a presentation context for the given id and window.
+ *
+ * @param id presentation context id
+ * @param window presentation context window, may be <code>null</code>
+ */
+ public PresentationContext(String id, IWorkbenchWindow window) {
+ this (id, window, null);
+ }
+
+ /**
+ * Constructs a presentation context for the given id and part.
+ * The presentation context window is derived from the part.
+ *
+ * @param id presentation context id
+ * @param part presentation context part, may be <code>null</code>
+ */
+ public PresentationContext(String id, IWorkbenchPart part) {
+ this (id, part.getSite().getWorkbenchWindow(), part);
+ }
+
+ /**
+ * Constructs a presentation context for the given id and part.
+ * The presentation context id and window are derived from the part.
+ *
+ * @param id presentation context id
+ * @param part presentation context part, can NOT be <code>null</code>
+ */
+ public PresentationContext(IWorkbenchPart part) {
+ this (part.getSite().getId(), part.getSite().getWorkbenchWindow(), part);
+ }
+
+ private PresentationContext(String id, IWorkbenchWindow window, IWorkbenchPart part) {
fId = id;
+ fWindow = window;
+ fPart = part;
}
/* (non-Javadoc)
@@ -246,6 +288,14 @@ public class PresentationContext implements IPresentationContext {
return (String[]) keys.toArray(new String[keys.size()]);
}
}
+
+ public IWorkbenchPart getPart() {
+ return fPart;
+ }
+
+ public IWorkbenchWindow getWindow() {
+ return fWindow;
+ }
}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/BreakpointManagerProxy.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/BreakpointManagerProxy.java
index 29a72545c..b4e481db8 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/BreakpointManagerProxy.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/BreakpointManagerProxy.java
@@ -7,16 +7,28 @@
*
* Contributors:
* Patrick Chuong (Texas Instruments) - Initial API and implementation (Bug 238956)
+ * Wind River Systems - ongoing enhancements and bug fixing
*****************************************************************/
package org.eclipse.debug.internal.ui.viewers.update;
-import org.eclipse.debug.internal.ui.elements.adapters.AbstractBreakpointManagerInput;
-import org.eclipse.debug.internal.ui.model.elements.AbstractBreakpointManagerContentProvider;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.debug.internal.ui.elements.adapters.DefaultBreakpointsViewInput;
+import org.eclipse.debug.internal.ui.model.elements.BreakpointManagerContentProvider;
import org.eclipse.debug.internal.ui.viewers.model.ViewerAdapterService;
import org.eclipse.debug.internal.ui.viewers.model.provisional.IElementContentProvider;
+import org.eclipse.debug.internal.ui.viewers.model.provisional.IModelDelta;
import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext;
import org.eclipse.debug.internal.ui.viewers.provisional.AbstractModelProxy;
import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.swt.widgets.Widget;
+import org.eclipse.ui.progress.WorkbenchJob;
/**
* Breakpoint manager model proxy.
@@ -27,14 +39,38 @@ public class BreakpointManagerProxy extends AbstractModelProxy {
/**
* The breakpoint manager content provider for this model proxy
*/
- protected AbstractBreakpointManagerContentProvider fProvider;
+ final private BreakpointManagerContentProvider fProvider;
/**
* The breakpoint manager input for this model proxy
*/
- protected AbstractBreakpointManagerInput fInput;
+ final private DefaultBreakpointsViewInput fInput;
/**
+ * Job to fire posted deltas.
+ */
+ private Job fFireModelChangedJob;
+
+ /**
+ * Object used for describing a posted delta.
+ */
+ private static class DeltaInfo {
+ final boolean fSelect;
+ final IModelDelta fDelta;
+
+ DeltaInfo(boolean selectDelta, IModelDelta delta) {
+ fSelect = selectDelta;
+ fDelta = delta;
+ }
+ }
+
+ /**
+ * List of posted deltas ready to be fired.
+ */
+ private List/*<DeltaInfo>*/ fPendingDeltas = new LinkedList();
+
+
+ /**
* Constructor.
*
* @param input the breakpoint manager input
@@ -43,15 +79,19 @@ public class BreakpointManagerProxy extends AbstractModelProxy {
public BreakpointManagerProxy(Object input, IPresentationContext context) {
super();
- if (input instanceof AbstractBreakpointManagerInput) {
- fInput = (AbstractBreakpointManagerInput) input;
+ DefaultBreakpointsViewInput bpmInput = null;
+ BreakpointManagerContentProvider bpmProvider = null;
+ if (input instanceof DefaultBreakpointsViewInput) {
+ bpmInput = (DefaultBreakpointsViewInput) input;
// cache the required data and pass to the provider when this model is installed
IElementContentProvider provider = ViewerAdapterService.getContentProvider(input);
- if (provider instanceof AbstractBreakpointManagerContentProvider) {
- fProvider = (AbstractBreakpointManagerContentProvider) provider;
+ if (provider instanceof BreakpointManagerContentProvider) {
+ bpmProvider = (BreakpointManagerContentProvider) provider;
}
}
+ fInput = bpmInput;
+ fProvider = bpmProvider;
}
/*
@@ -69,10 +109,75 @@ public class BreakpointManagerProxy extends AbstractModelProxy {
* (non-Javadoc)
* @see org.eclipse.debug.internal.ui.viewers.provisional.AbstractModelProxy#dispose()
*/
- public synchronized void dispose() {
- if (fProvider != null) {
- fProvider.unregisterModelProxy(fInput, this);
- }
+ public void dispose() {
+ fProvider.unregisterModelProxy(fInput, this);
+ synchronized(this) {
+ if (fFireModelChangedJob != null) {
+ fFireModelChangedJob.cancel();
+ fFireModelChangedJob = null;
+ }
+ fPendingDeltas.clear();
+ }
+
super.dispose();
}
+
+ /**
+ * Posts a given delta to be fired by the proxy. Posting a delta places it
+ * in a queue which is later emptied by a job that fires the deltas.
+ * <p>
+ * If the delta is used only to select a breakpiont and does not change the
+ * viewer content, the caller should set the <code>select</code> parameter
+ * to <code>true</code>. When a select delta is added to the delta queue,
+ * any previous select deltas are removed. Also a select delta is fired
+ * after a brief delay to avoid flooding the viewer with upates.
+ *
+ * @param delta Delta to be posted to the viewer.
+ * @param select Flag indicating that the delta is only to change the
+ * viewer selection.
+ */
+ public synchronized void postModelChanged(IModelDelta delta, boolean select) {
+ // Check for proxy being disposed.
+ if (isDisposed()) {
+ return;
+ }
+ // Check for viewer being disposed.
+ Widget viewerControl = getViewer().getControl();
+ if (viewerControl == null) {
+ return;
+ }
+
+ // If we are processing a select delta, remove the previous select delta.
+ if (select) {
+ for (Iterator itr = fPendingDeltas.iterator(); itr.hasNext(); ) {
+ if ( ((DeltaInfo)itr.next()).fSelect ) {
+ itr.remove();
+ }
+ }
+ }
+ fPendingDeltas.add(new DeltaInfo(select, delta));
+
+ if (fFireModelChangedJob == null) {
+ fFireModelChangedJob = new WorkbenchJob(viewerControl.getDisplay(), "Select Breakpoint Job") { //$NON-NLS-1$
+ {
+ setSystem(true);
+ }
+
+ public IStatus runInUIThread(IProgressMonitor monitor) {
+ Object[] deltas;
+ synchronized(BreakpointManagerProxy.this) {
+ deltas = fPendingDeltas.toArray();
+ fPendingDeltas.clear();
+ fFireModelChangedJob = null;
+ }
+ for (int i = 0; i < deltas.length; i++) {
+ fireModelChanged( ((DeltaInfo)deltas[i]).fDelta );
+ }
+ return Status.OK_STATUS;
+ }
+ };
+ fFireModelChangedJob.schedule(select ? 100 : 0);
+ }
+ }
+
}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/DefaultModelProxyFactory.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/DefaultModelProxyFactory.java
index 26f0ea3f9..3a2e0ea56 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/DefaultModelProxyFactory.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/DefaultModelProxyFactory.java
@@ -23,7 +23,7 @@ import org.eclipse.debug.core.model.IProcess;
import org.eclipse.debug.core.model.IStackFrame;
import org.eclipse.debug.core.model.IWatchExpression;
import org.eclipse.debug.internal.ui.breakpoints.provisional.IBreakpointContainer;
-import org.eclipse.debug.internal.ui.elements.adapters.DefaultBreakpointManagerInput;
+import org.eclipse.debug.internal.ui.elements.adapters.DefaultBreakpointsViewInput;
import org.eclipse.debug.internal.ui.memory.provisional.AbstractAsyncTableRendering;
import org.eclipse.debug.internal.ui.memory.provisional.MemoryViewPresentationContext;
import org.eclipse.debug.internal.ui.viewers.model.provisional.IModelProxy;
@@ -75,7 +75,7 @@ public class DefaultModelProxyFactory implements IModelProxyFactory {
return new MemoryRetrievalProxy((IMemoryBlockRetrieval)element);
}
if (IDebugUIConstants.ID_BREAKPOINT_VIEW.equals(id)) {
- if (element instanceof DefaultBreakpointManagerInput) {
+ if (element instanceof DefaultBreakpointsViewInput) {
return new BreakpointManagerProxy(element, context);
} else if (element instanceof IBreakpoint) {
return new BreakpointProxy((IBreakpoint)element);
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/DebugModelPresentationContext.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/DebugModelPresentationContext.java
index 5b4f63d85..8c02cd0ca 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/DebugModelPresentationContext.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/DebugModelPresentationContext.java
@@ -12,6 +12,7 @@ package org.eclipse.debug.internal.ui.views;
import org.eclipse.debug.internal.ui.viewers.model.provisional.PresentationContext;
import org.eclipse.debug.ui.IDebugModelPresentation;
+import org.eclipse.ui.IWorkbenchPart;
/**
* A presentation context that has a debug model presentation.
@@ -27,10 +28,11 @@ public class DebugModelPresentationContext extends PresentationContext {
* specified model presentation.
*
* @param id context id
+ * @param part workbench view
* @param presentation debug model presentation
*/
- public DebugModelPresentationContext(String id, IDebugModelPresentation presentation) {
- super(id);
+ public DebugModelPresentationContext(String id, IWorkbenchPart part, IDebugModelPresentation presentation) {
+ super(id, part);
fPresentation = presentation;
}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/breakpoints/BreakpointsView.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/breakpoints/BreakpointsView.java
index eb89cadac..1cc941ddc 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/breakpoints/BreakpointsView.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/breakpoints/BreakpointsView.java
@@ -22,8 +22,6 @@ import org.eclipse.core.runtime.IStatus;
import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.IBreakpointManagerListener;
import org.eclipse.debug.core.model.IBreakpoint;
-import org.eclipse.debug.core.model.IStackFrame;
-import org.eclipse.debug.core.model.IThread;
import org.eclipse.debug.internal.ui.DebugUIPlugin;
import org.eclipse.debug.internal.ui.IDebugHelpContextIds;
import org.eclipse.debug.internal.ui.VariablesViewModelPresentation;
@@ -36,7 +34,7 @@ import org.eclipse.debug.internal.ui.actions.breakpoints.SkipAllBreakpointsActio
import org.eclipse.debug.internal.ui.breakpoints.provisional.IBreakpointContainer;
import org.eclipse.debug.internal.ui.breakpoints.provisional.IBreakpointOrganizer;
import org.eclipse.debug.internal.ui.breakpoints.provisional.IBreakpointUIConstants;
-import org.eclipse.debug.internal.ui.elements.adapters.DefaultBreakpointManagerInput;
+import org.eclipse.debug.internal.ui.elements.adapters.DefaultBreakpointsViewInput;
import org.eclipse.debug.internal.ui.preferences.IDebugPreferenceConstants;
import org.eclipse.debug.internal.ui.viewers.model.ITreeModelViewer;
import org.eclipse.debug.internal.ui.viewers.model.provisional.IModelDelta;
@@ -74,7 +72,6 @@ import org.eclipse.swt.widgets.TreeItem;
import org.eclipse.ui.IMemento;
import org.eclipse.ui.ISharedImages;
import org.eclipse.ui.IWorkbenchActionConstants;
-import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.actions.ActionFactory;
import org.eclipse.ui.actions.SelectionListenerAction;
@@ -268,10 +265,9 @@ public class BreakpointsView extends VariablesView implements IBreakpointManager
*/
protected void contextActivated(ISelection selection) {
IPresentationContext presentationContext = getTreeModelViewer().getPresentationContext();
- presentationContext.setProperty(IBreakpointUIConstants.PROP_BREAKPOINTS_ACTIVE_DEBUG_CONTEXT, selection);
if (selection == null || selection.isEmpty()) {
- Object input = new DefaultBreakpointManagerInput(getTreeModelViewer().getPresentationContext());
+ Object input = new DefaultBreakpointsViewInput(presentationContext);
super.contextActivated(new StructuredSelection(input));
} else {
super.contextActivated(selection);
@@ -316,7 +312,7 @@ public class BreakpointsView extends VariablesView implements IBreakpointManager
if ( (status == null || status.isOK()) && update.getElement() != null) {
setViewerInput(update.getInputElement());
} else {
- setViewerInput(new DefaultBreakpointManagerInput(getTreeModelViewer().getPresentationContext()));
+ setViewerInput(new DefaultBreakpointsViewInput(getTreeModelViewer().getPresentationContext()));
}
}
@@ -428,35 +424,6 @@ public class BreakpointsView extends VariablesView implements IBreakpointManager
super.saveViewerState(memento);
}
- /*
- * (non-Javadoc)
- * @see org.eclipse.ui.ISelectionListener#selectionChanged(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.ISelection)
- */
- public void selectionChanged(IWorkbenchPart part, ISelection sel) {
- if (sel.isEmpty() || !isTrackingSelection()) {
- return;
- }
- IStructuredSelection selection = (IStructuredSelection) sel;
- Iterator iter = selection.iterator();
- Object firstElement = iter.next();
- if (firstElement == null || iter.hasNext()) {
- return;
- }
- IThread thread = null;
- if (firstElement instanceof IStackFrame) {
- thread = ((IStackFrame) firstElement).getThread();
- } else if (firstElement instanceof IThread) {
- thread = (IThread) firstElement;
- } else {
- return;
- }
-
- IBreakpoint[] breakpoints = thread.getBreakpoints();
- Viewer viewer = getViewer();
- if (viewer != null)
- viewer.setSelection(new StructuredSelection(breakpoints), true);
- }
-
/**
* Preserves the selection.
*
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/launch/DebugElementAdapterFactory.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/launch/DebugElementAdapterFactory.java
index 3d491d5e2..3c13a0a41 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/launch/DebugElementAdapterFactory.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/launch/DebugElementAdapterFactory.java
@@ -31,7 +31,7 @@ import org.eclipse.debug.core.model.IVariable;
import org.eclipse.debug.core.model.IWatchExpression;
import org.eclipse.debug.internal.ui.breakpoints.provisional.IBreakpointContainer;
import org.eclipse.debug.internal.ui.elements.adapters.AsynchronousDebugLabelAdapter;
-import org.eclipse.debug.internal.ui.elements.adapters.DefaultBreakpointManagerInput;
+import org.eclipse.debug.internal.ui.elements.adapters.DefaultBreakpointsViewInput;
import org.eclipse.debug.internal.ui.elements.adapters.DefaultViewerInputProvider;
import org.eclipse.debug.internal.ui.elements.adapters.MemoryBlockContentAdapter;
import org.eclipse.debug.internal.ui.elements.adapters.MemoryBlockLabelAdapter;
@@ -193,7 +193,7 @@ public class DebugElementAdapterFactory implements IAdapterFactory {
if (adaptableObject instanceof IMemoryBlock) {
return fgCPMemoryBlock;
}
- if (adaptableObject instanceof DefaultBreakpointManagerInput) {
+ if (adaptableObject instanceof DefaultBreakpointsViewInput) {
return fgCPBreakpointManager;
}
if (adaptableObject instanceof IBreakpoint) {
@@ -240,7 +240,7 @@ public class DebugElementAdapterFactory implements IAdapterFactory {
adaptableObject instanceof IStackFrame || adaptableObject instanceof IExpressionManager ||
adaptableObject instanceof IExpression || adaptableObject instanceof IMemoryBlockRetrieval ||
adaptableObject instanceof IMemoryBlock ||
- adaptableObject instanceof DefaultBreakpointManagerInput ||
+ adaptableObject instanceof DefaultBreakpointsViewInput ||
adaptableObject instanceof IBreakpoint ||
adaptableObject instanceof IBreakpointContainer)
return fgModelProxyFactoryAdapter;
@@ -289,7 +289,7 @@ public class DebugElementAdapterFactory implements IAdapterFactory {
if (adaptableObject instanceof IBreakpointContainer) {
return fgMPBreakpointContainer;
}
- if (adaptableObject instanceof DefaultBreakpointManagerInput) {
+ if (adaptableObject instanceof DefaultBreakpointsViewInput) {
return fgMPBreakpointManagerInput;
}
}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/launch/LaunchView.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/launch/LaunchView.java
index adf60b1ee..44de3ddaa 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/launch/LaunchView.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/launch/LaunchView.java
@@ -776,7 +776,7 @@ public class LaunchView extends AbstractDebugView implements ISelectionChangedLi
*/
protected Viewer createViewer(Composite parent) {
fPresentation = new DelegatingModelPresentation();
- fPresentationContext = new DebugModelPresentationContext(IDebugUIConstants.ID_DEBUG_VIEW, fPresentation);
+ fPresentationContext = new DebugModelPresentationContext(IDebugUIConstants.ID_DEBUG_VIEW, this, fPresentation);
TreeModelViewer viewer = new TreeModelViewer(parent,
SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.VIRTUAL,
fPresentationContext);
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/MemoryViewTreeModelContentProvider.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/MemoryViewTreeModelContentProvider.java
index 0cd6802a4..dbfda90f9 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/MemoryViewTreeModelContentProvider.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/MemoryViewTreeModelContentProvider.java
@@ -14,7 +14,6 @@ package org.eclipse.debug.internal.ui.views.memory;
import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.model.IMemoryBlock;
import org.eclipse.debug.core.model.IMemoryBlockRetrieval;
-import org.eclipse.debug.internal.ui.viewers.PartPresentationContext;
import org.eclipse.debug.internal.ui.viewers.model.TreeModelContentProvider;
import org.eclipse.debug.internal.ui.viewers.model.provisional.IModelDelta;
import org.eclipse.debug.internal.ui.viewers.model.provisional.TreeModelViewer;
@@ -35,11 +34,8 @@ public class MemoryViewTreeModelContentProvider extends
if ((flags & IModelDelta.ADDED) != 0) {
if (node.getElement() instanceof IMemoryBlock) {
if ((flags & IModelDelta.SELECT) != 0) {
- PartPresentationContext context = (PartPresentationContext) viewer
- .getPresentationContext();
- if (context.getPart() instanceof MemoryView) {
- MemoryView view = (MemoryView) context
- .getPart();
+ if (getPresentationContext() instanceof MemoryView) {
+ MemoryView view = (MemoryView) getPresentationContext().getPart();
if (view.isPinMBDisplay()) {
// turn off select if the view is currently
// pinned
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 189877f91..7066b2385 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
@@ -641,7 +641,7 @@ public class VariablesView extends AbstractDebugView implements IDebugContextLis
protected TreeModelViewer createTreeViewer(Composite parent) {
int style = getViewerStyle();
- fPresentationContext = new DebugModelPresentationContext(getPresentationContextId(), fModelPresentation);
+ fPresentationContext = new DebugModelPresentationContext(getPresentationContextId(), this, fModelPresentation);
final TreeModelViewer variablesViewer = new TreeModelViewer(parent, style, fPresentationContext);
variablesViewer.getControl().addFocusListener(new FocusAdapter() {
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/InspectPopupDialog.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/InspectPopupDialog.java
index 3c1eaa5fe..b88a0ccd1 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/InspectPopupDialog.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/InspectPopupDialog.java
@@ -101,7 +101,7 @@ public class InspectPopupDialog extends DebugPopup {
fSashForm.setLayoutData(new GridData(GridData.FILL_BOTH));
VariablesView view = getViewToEmulate();
- fContext = new PresentationContext(IDebugUIConstants.ID_VARIABLE_VIEW);
+ fContext = new PresentationContext(IDebugUIConstants.ID_VARIABLE_VIEW, view);
if (view != null) {
// copy over properties
IPresentationContext copy = ((TreeModelViewer)view.getViewer()).getPresentationContext();

Back to the top