Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDarin Wright2006-10-06 16:08:00 +0000
committerDarin Wright2006-10-06 16:08:00 +0000
commit2cfc2df6e3454c63fd8a47938baf008a24ee8d42 (patch)
treeed78b3da7e2f01319e2bedc403b8a94e4ddefdf8
parente952247a62ff5015a9b397dcb69bf3d26fe68180 (diff)
downloadeclipse.platform.debug-2cfc2df6e3454c63fd8a47938baf008a24ee8d42.tar.gz
eclipse.platform.debug-2cfc2df6e3454c63fd8a47938baf008a24ee8d42.tar.xz
eclipse.platform.debug-2cfc2df6e3454c63fd8a47938baf008a24ee8d42.zip
Bug 153500 Asynchronous model viewer
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/DebugElementLabelProvider.java69
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/DebugModelPresentationContext.java41
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/launch/DebugElementHelper.java87
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/launch/LaunchView.java12
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/VariablesView.java7
5 files changed, 159 insertions, 57 deletions
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/DebugElementLabelProvider.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/DebugElementLabelProvider.java
index 421413df4..087f10114 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/DebugElementLabelProvider.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/DebugElementLabelProvider.java
@@ -10,69 +10,27 @@
*******************************************************************************/
package org.eclipse.debug.internal.ui.model.elements;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Map.Entry;
-
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.model.ILabelUpdate;
import org.eclipse.debug.internal.ui.viewers.provisional.IPresentationContext;
+import org.eclipse.debug.internal.ui.views.DebugModelPresentationContext;
import org.eclipse.debug.internal.ui.views.launch.DebugElementHelper;
-import org.eclipse.debug.ui.IDebugModelPresentation;
-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;
/**
* @since 3.3
*/
public class DebugElementLabelProvider extends ElementLabelProvider {
-
- /* (non-Javadoc)
- * @see org.eclipse.debug.internal.ui.model.elements.ElementContentProvider#retrieveLabel(org.eclipse.debug.internal.ui.model.ILabelUpdate)
- */
- protected void retrieveLabel(ILabelUpdate update) throws CoreException {
- DelegatingModelPresentation presentation = DebugElementHelper.getPresentation();
- // 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.
- Object element = update.getElement();
- IPresentationContext context = update.getPresentationContext();
- if (element instanceof IDebugElement && context.getPart() instanceof IDebugView) {
- IWorkbenchPart part = context.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.retrieveLabel(update);
- return;
- }
- }
- }
- }
- super.retrieveLabel(update);
- }
/* (non-Javadoc)
* @see org.eclipse.debug.internal.ui.model.elements.ElementContentProvider#getLabel(java.lang.Object, org.eclipse.debug.internal.ui.viewers.provisional.IPresentationContext, java.lang.String)
*/
protected String getLabel(Object element, IPresentationContext presentationContext, String columnId) throws CoreException {
+ if (presentationContext instanceof DebugModelPresentationContext) {
+ DebugModelPresentationContext debugContext = (DebugModelPresentationContext) presentationContext;
+ return debugContext.getModelPresentation().getText(element);
+ }
return DebugElementHelper.getLabel(element);
}
@@ -80,6 +38,10 @@ public class DebugElementLabelProvider extends ElementLabelProvider {
* @see org.eclipse.debug.internal.ui.model.elements.ElementContentProvider#getBackground(java.lang.Object, org.eclipse.debug.internal.ui.viewers.provisional.IPresentationContext, java.lang.String)
*/
protected RGB getBackground(Object element, IPresentationContext presentationContext, String columnId) throws CoreException {
+ if (presentationContext instanceof DebugModelPresentationContext) {
+ DebugModelPresentationContext debugContext = (DebugModelPresentationContext) presentationContext;
+ return DebugElementHelper.getBackground(element, debugContext.getModelPresentation());
+ }
return DebugElementHelper.getBackground(element);
}
@@ -87,6 +49,11 @@ public class DebugElementLabelProvider extends ElementLabelProvider {
* @see org.eclipse.debug.internal.ui.model.elements.ElementContentProvider#getFontDatas(java.lang.Object, org.eclipse.debug.internal.ui.viewers.provisional.IPresentationContext, java.lang.String)
*/
protected FontData getFontData(Object element, IPresentationContext presentationContext, String columnId) throws CoreException {
+ if (presentationContext instanceof DebugModelPresentationContext) {
+ DebugModelPresentationContext debugContext = (DebugModelPresentationContext) presentationContext;
+ return DebugElementHelper.getFont(element, debugContext.getModelPresentation());
+
+ }
return DebugElementHelper.getFont(element);
}
@@ -94,6 +61,10 @@ public class DebugElementLabelProvider extends ElementLabelProvider {
* @see org.eclipse.debug.internal.ui.model.elements.ElementContentProvider#getForeground(java.lang.Object, org.eclipse.debug.internal.ui.viewers.provisional.IPresentationContext, java.lang.String)
*/
protected RGB getForeground(Object element, IPresentationContext presentationContext, String columnId) throws CoreException {
+ if (presentationContext instanceof DebugModelPresentationContext) {
+ DebugModelPresentationContext debugContext = (DebugModelPresentationContext) presentationContext;
+ return DebugElementHelper.getForeground(element, debugContext.getModelPresentation());
+ }
return DebugElementHelper.getForeground(element);
}
@@ -101,6 +72,10 @@ public class DebugElementLabelProvider extends ElementLabelProvider {
* @see org.eclipse.debug.internal.ui.model.elements.ElementContentProvider#getImageDescriptor(java.lang.Object, org.eclipse.debug.internal.ui.viewers.provisional.IPresentationContext, java.lang.String)
*/
protected ImageDescriptor getImageDescriptor(Object element, IPresentationContext presentationContext, String columnId) throws CoreException {
+ if (presentationContext instanceof DebugModelPresentationContext) {
+ DebugModelPresentationContext debugContext = (DebugModelPresentationContext) presentationContext;
+ return DebugElementHelper.getImageDescriptor(element, debugContext.getModelPresentation());
+ }
return DebugElementHelper.getImageDescriptor(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
new file mode 100644
index 000000000..412645c78
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/DebugModelPresentationContext.java
@@ -0,0 +1,41 @@
+/*******************************************************************************
+ * Copyright (c) 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.debug.internal.ui.views;
+
+import org.eclipse.debug.internal.ui.viewers.PresentationContext;
+import org.eclipse.debug.ui.IDebugModelPresentation;
+
+/**
+ * A presentation context that has a debug model presentation.
+ *
+ * @since 3.3
+ */
+public class DebugModelPresentationContext extends PresentationContext {
+
+ private IDebugModelPresentation fPresentation;
+
+ /**
+ * Constructs a presentation context for the given id using the
+ * specified model presentation.
+ *
+ * @param id context id
+ * @param presentation debug model presentation
+ */
+ public DebugModelPresentationContext(String id, IDebugModelPresentation presentation) {
+ super(id);
+ fPresentation = presentation;
+ }
+
+ public IDebugModelPresentation getModelPresentation() {
+ return fPresentation;
+ }
+
+}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/launch/DebugElementHelper.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/launch/DebugElementHelper.java
index 5a0721888..27f4f0188 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/launch/DebugElementHelper.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/launch/DebugElementHelper.java
@@ -14,7 +14,10 @@ import java.util.HashMap;
import java.util.Map;
import org.eclipse.debug.internal.ui.DelegatingModelPresentation;
+import org.eclipse.debug.ui.IDebugModelPresentation;
import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.IColorProvider;
+import org.eclipse.jface.viewers.IFontProvider;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.FontData;
@@ -62,6 +65,18 @@ public class DebugElementHelper {
return getImageDescriptor(image);
}
+ /**
+ * Returns an image descriptor for the given debug element.
+ *
+ * @param presentation presentation to obtain image from
+ * @param object object for which an image descriptor is required
+ * @since 3.3
+ */
+ public static ImageDescriptor getImageDescriptor(Object object, IDebugModelPresentation presentation) {
+ Image image = presentation.getImage(object);
+ return getImageDescriptor(image);
+ }
+
public static ImageDescriptor getImageDescriptor(Image image)
{
if (image != null) {
@@ -111,6 +126,30 @@ public class DebugElementHelper {
}
return null;
}
+
+ /**
+ * Returns the RGB of the foreground color for the given element, or
+ * <code>null</code> if none.
+ *
+ * @param element object for which a foreground color is required
+ * @param presentation presentation to obtain color from
+ * @return the RGB of the foreground color for the given element, or
+ * <code>null</code> if none
+ * @since 3.3
+ */
+ public static RGB getForeground(Object element, IDebugModelPresentation presentation) {
+ Color color = null;
+ if (presentation instanceof IColorProvider) {
+ IColorProvider colorProvider = (IColorProvider) presentation;
+ color = colorProvider.getForeground(element);
+ } else {
+ color = getPresentation().getForeground(element);
+ }
+ if (color != null) {
+ return color.getRGB();
+ }
+ return null;
+ }
/**
* Returns the RGB of the background color for the given element, or
@@ -127,6 +166,30 @@ public class DebugElementHelper {
}
return null;
}
+
+ /**
+ * Returns the RGB of the background color for the given element, or
+ * <code>null</code> if none.
+ *
+ * @param element object for which a background color is required
+ * @param presentation presentation to use to retrieve color
+ * @return the RGB of the background color for the given element, or
+ * <code>null</code> if none
+ * @since 3.3
+ */
+ public static RGB getBackground(Object element, IDebugModelPresentation presentation) {
+ Color color = null;
+ if (presentation instanceof IColorProvider) {
+ IColorProvider colorProvider = (IColorProvider) presentation;
+ color = colorProvider.getBackground(element);
+ } else {
+ color = getPresentation().getBackground(element);
+ }
+ if (color != null) {
+ return color.getRGB();
+ }
+ return null;
+ }
/**
* Returns the font data for the given element, or
@@ -143,4 +206,28 @@ public class DebugElementHelper {
}
return null;
}
+
+ /**
+ * Returns the font data for the given element, or
+ * <code>null</code> if none.
+ *
+ * @param element object for which font data is required
+ * @param presentation presentation to obtain font from
+ * @return the font data for the given element, or
+ * <code>null</code> if none
+ * @since 3.3
+ */
+ public static FontData getFont(Object element, IDebugModelPresentation presentation) {
+ Font font = null;
+ if (presentation instanceof IFontProvider) {
+ IFontProvider provider = (IFontProvider) presentation;
+ font = provider.getFont(element);
+ } else {
+ font = getPresentation().getFont(element);
+ }
+ if (font != null) {
+ return font.getFontData()[0];
+ }
+ return null;
+ }
}
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 e235e1a9b..7341c6e88 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
@@ -51,10 +51,9 @@ import org.eclipse.debug.internal.ui.model.viewers.TreeModelViewer;
import org.eclipse.debug.internal.ui.sourcelookup.EditSourceLookupPathAction;
import org.eclipse.debug.internal.ui.sourcelookup.LookupSourceAction;
import org.eclipse.debug.internal.ui.viewers.AsynchronousTreeViewer;
-import org.eclipse.debug.internal.ui.viewers.PresentationContext;
+import org.eclipse.debug.internal.ui.views.DebugModelPresentationContext;
import org.eclipse.debug.internal.ui.views.DebugUIViewsMessages;
import org.eclipse.debug.ui.AbstractDebugView;
-import org.eclipse.debug.ui.IDebugEditorPresentation;
import org.eclipse.debug.ui.IDebugModelPresentation;
import org.eclipse.debug.ui.IDebugUIConstants;
import org.eclipse.jface.action.GroupMarker;
@@ -127,7 +126,7 @@ public class LaunchView extends AbstractDebugView implements ISelectionChangedLi
/**
* Editor presentation or <code>null</code> if none
*/
- private IDebugEditorPresentation fEditorPresentation = null;
+ private IDebugModelPresentation fPresentation = null;
private EditLaunchConfigurationAction fEditConfigAction = null;
private AddToFavoritesAction fAddToFavoritesAction = null;
@@ -287,9 +286,10 @@ public class LaunchView extends AbstractDebugView implements ISelectionChangedLi
* @see org.eclipse.debug.ui.AbstractDebugView#createViewer(org.eclipse.swt.widgets.Composite)
*/
protected Viewer createViewer(Composite parent) {
+ fPresentation = new DelegatingModelPresentation();
TreeModelViewer viewer = new TreeModelViewer(parent,
SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER | SWT.VIRTUAL,
- new PresentationContext(this));
+ new DebugModelPresentationContext(IDebugUIConstants.ID_DEBUG_VIEW, fPresentation));
viewer.addSelectionChangedListener(this);
viewer.getControl().addKeyListener(new KeyAdapter() {
@@ -299,8 +299,6 @@ public class LaunchView extends AbstractDebugView implements ISelectionChangedLi
}
}
});
- final DelegatingModelPresentation presentation = new DelegatingModelPresentation();
- fEditorPresentation = presentation;
// add my viewer as a selection provider, so selective re-launch works
getSite().setSelectionProvider(viewer);
viewer.setInput(DebugPlugin.getDefault().getLaunchManager());
@@ -565,7 +563,7 @@ public class LaunchView extends AbstractDebugView implements ISelectionChangedLi
* @see org.eclipse.debug.ui.IDebugView#getPresentation(java.lang.String)
*/
public IDebugModelPresentation getPresentation(String id) {
- return ((DelegatingModelPresentation)fEditorPresentation).getPresentation(id);
+ return ((DelegatingModelPresentation)fPresentation).getPresentation(id);
}
/* (non-Javadoc)
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 25567a157..481b6e66e 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
@@ -52,12 +52,12 @@ import org.eclipse.debug.internal.ui.contexts.provisional.IDebugContextListener;
import org.eclipse.debug.internal.ui.model.viewers.IViewerUpdateListener;
import org.eclipse.debug.internal.ui.model.viewers.TreeModelViewer;
import org.eclipse.debug.internal.ui.preferences.IDebugPreferenceConstants;
-import org.eclipse.debug.internal.ui.viewers.PresentationContext;
import org.eclipse.debug.internal.ui.viewers.provisional.IAsynchronousRequestMonitor;
import org.eclipse.debug.internal.ui.viewers.provisional.IModelChangedListener;
import org.eclipse.debug.internal.ui.viewers.provisional.IModelDelta;
import org.eclipse.debug.internal.ui.viewers.provisional.IModelDeltaVisitor;
import org.eclipse.debug.internal.ui.viewers.provisional.IPresentationContext;
+import org.eclipse.debug.internal.ui.views.DebugModelPresentationContext;
import org.eclipse.debug.internal.ui.views.IDebugExceptionHandler;
import org.eclipse.debug.ui.AbstractDebugView;
import org.eclipse.debug.ui.IDebugModelPresentation;
@@ -748,7 +748,8 @@ public class VariablesView extends AbstractDebugView implements IDebugContextLis
// add tree viewer
int style = getViewerStyle();
- final TreeModelViewer variablesViewer = new TreeModelViewer(fSashForm, style, new PresentationContext(this));
+ final TreeModelViewer variablesViewer = new TreeModelViewer(fSashForm, style,
+ new DebugModelPresentationContext(IDebugUIConstants.ID_VARIABLE_VIEW, fModelPresentation));
variablesViewer.getControl().addFocusListener(new FocusAdapter() {
/* (non-Javadoc)
* @see org.eclipse.swt.events.FocusListener#focusGained(FocusEvent)
@@ -1508,7 +1509,7 @@ public class VariablesView extends AbstractDebugView implements IDebugContextLis
* Sets whether logical structures are being displayed
*/
public void setShowLogicalStructure(boolean flag) {
- getPresentationContext().setProperty(PRESENTATION_SHOW_LOGICAL_STRUCTURES, Boolean.TRUE);
+ getPresentationContext().setProperty(PRESENTATION_SHOW_LOGICAL_STRUCTURES, Boolean.valueOf(flag));
}
/**

Back to the top