Skip to main content
aboutsummaryrefslogtreecommitdiffstats
path: root/debug
diff options
context:
space:
mode:
authorMikhail Khodjaiants2007-02-11 23:13:08 +0000
committerMikhail Khodjaiants2007-02-11 23:13:08 +0000
commit7ad15395485c5beca465b2bda1277b36fc2a1aa7 (patch)
treecc85310c47ec702dba9e9d4c64c4f7a538691439 /debug
parent9c9d0844d95abcdfdbeed142f4ebc54ebc9d3b82 (diff)
downloadorg.eclipse.cdt-7ad15395485c5beca465b2bda1277b36fc2a1aa7.tar.gz
org.eclipse.cdt-7ad15395485c5beca465b2bda1277b36fc2a1aa7.tar.xz
org.eclipse.cdt-7ad15395485c5beca465b2bda1277b36fc2a1aa7.zip
Bug 173792: Modules view needs to catch up with 3.3M5. Replaced ModulesViewer by ModelTreeViewer and ModuleContentAdapter by ModuleContentProvider.
Diffstat (limited to 'debug')
-rw-r--r--debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/elements/adapters/CDebugElementAdapterFactory.java16
-rw-r--r--debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/AbstractViewerState.java14
-rw-r--r--debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/modules/ModuleContentProvider.java (renamed from debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/modules/ModuleContentAdapter.java)62
-rw-r--r--debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/modules/ModulesView.java273
-rw-r--r--debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/modules/ModulesViewer.java68
-rw-r--r--debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/modules/ModulesViewerState.java7
6 files changed, 194 insertions, 246 deletions
diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/elements/adapters/CDebugElementAdapterFactory.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/elements/adapters/CDebugElementAdapterFactory.java
index 3507796399f..aa196d972d0 100644
--- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/elements/adapters/CDebugElementAdapterFactory.java
+++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/elements/adapters/CDebugElementAdapterFactory.java
@@ -13,11 +13,11 @@ package org.eclipse.cdt.debug.internal.ui.elements.adapters;
import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.debug.core.model.ICModule;
import org.eclipse.cdt.debug.core.model.IModuleRetrieval;
-import org.eclipse.cdt.debug.internal.ui.views.modules.ModuleContentAdapter;
+import org.eclipse.cdt.debug.internal.ui.views.modules.ModuleContentProvider;
import org.eclipse.cdt.debug.internal.ui.views.modules.ModuleProxyFactory;
import org.eclipse.core.runtime.IAdapterFactory;
+import org.eclipse.debug.internal.ui.viewers.model.provisional.IElementContentProvider;
import org.eclipse.debug.internal.ui.viewers.model.provisional.IModelProxyFactoryAdapter;
-import org.eclipse.debug.internal.ui.viewers.provisional.IAsynchronousContentAdapter;
import org.eclipse.debug.internal.ui.viewers.provisional.IAsynchronousLabelAdapter;
/**
@@ -26,7 +26,7 @@ import org.eclipse.debug.internal.ui.viewers.provisional.IAsynchronousLabelAdapt
public class CDebugElementAdapterFactory implements IAdapterFactory {
// private static IAsynchronousLabelAdapter fgModuleLabelAdapter = new AsynchronousDebugLabelAdapter();
- private static IAsynchronousContentAdapter fgModuleContentAdapter = new ModuleContentAdapter();
+ private static IElementContentProvider fgModuleContentProvider = new ModuleContentProvider();
private static IModelProxyFactoryAdapter fgModuleProxyFactory = new ModuleProxyFactory();
@@ -37,15 +37,15 @@ public class CDebugElementAdapterFactory implements IAdapterFactory {
if ( adapterType.isInstance( adaptableObject ) ) {
return adaptableObject;
}
- if ( adapterType.equals( IAsynchronousContentAdapter.class ) ) {
+ if ( adapterType.equals( IElementContentProvider.class ) ) {
if ( adaptableObject instanceof IModuleRetrieval ) {
- return fgModuleContentAdapter;
+ return fgModuleContentProvider;
}
if ( adaptableObject instanceof ICModule ) {
- return fgModuleContentAdapter;
+ return fgModuleContentProvider;
}
if ( adaptableObject instanceof ICElement ) {
- return fgModuleContentAdapter;
+ return fgModuleContentProvider;
}
}
if ( adapterType.equals( IModelProxyFactoryAdapter.class ) ) {
@@ -61,7 +61,7 @@ public class CDebugElementAdapterFactory implements IAdapterFactory {
*/
public Class[] getAdapterList() {
return new Class[] {
- IAsynchronousContentAdapter.class,
+ IElementContentProvider.class,
IAsynchronousLabelAdapter.class,
IModelProxyFactoryAdapter.class
};
diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/AbstractViewerState.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/AbstractViewerState.java
index 1aa8f5b01db..7f39274a601 100644
--- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/AbstractViewerState.java
+++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/AbstractViewerState.java
@@ -12,11 +12,13 @@ package org.eclipse.cdt.debug.internal.ui.views;
import java.util.ArrayList;
import java.util.List;
+
import org.eclipse.core.runtime.IPath;
import org.eclipse.debug.core.DebugException;
-import org.eclipse.debug.internal.ui.viewers.AsynchronousTreeViewer;
+import org.eclipse.jface.viewers.AbstractTreeViewer;
import org.eclipse.jface.viewers.TreePath;
import org.eclipse.jface.viewers.TreeSelection;
+import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.swt.widgets.TreeItem;
/**
@@ -32,7 +34,7 @@ public abstract class AbstractViewerState {
/**
* Constructs a memento for the given viewer.
*/
- public AbstractViewerState(AsynchronousTreeViewer viewer) {
+ public AbstractViewerState(TreeViewer viewer) {
saveState(viewer);
}
@@ -42,7 +44,7 @@ public abstract class AbstractViewerState {
*
* @param viewer viewer of which to save the state
*/
- public void saveState(AsynchronousTreeViewer viewer) {
+ public void saveState(TreeViewer viewer) {
List expanded = new ArrayList();
fSavedExpansion = null;
TreeItem[] items = viewer.getTree().getItems();
@@ -114,7 +116,7 @@ public abstract class AbstractViewerState {
*
* @param viewer viewer to which state is restored
*/
- public void restoreState(AsynchronousTreeViewer viewer) {
+ public void restoreState(TreeViewer viewer) {
boolean expansionComplete = true;
if (fSavedExpansion != null && fSavedExpansion.size() > 0) {
for (int i = 0; i < fSavedExpansion.size(); i++) {
@@ -123,7 +125,7 @@ public abstract class AbstractViewerState {
try {
TreePath treePath = decodePath(path, viewer);
if (treePath != null) {
- viewer.expand(new TreeSelection(new TreePath[] { treePath }));
+ viewer.expandToLevel( new TreeSelection(new TreePath[] { treePath }), AbstractTreeViewer.ALL_LEVELS);
if (treePath.getSegmentCount()-1 != path.segmentCount()) {
expansionComplete = false;
@@ -175,6 +177,6 @@ public abstract class AbstractViewerState {
* @return element represented by the path, or <code>null</code> if none
* @throws DebugException if unable to locate a variable
*/
- protected abstract TreePath decodePath(IPath path, AsynchronousTreeViewer viewer) throws DebugException;
+ protected abstract TreePath decodePath(IPath path, TreeViewer viewer) throws DebugException;
}
diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/modules/ModuleContentAdapter.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/modules/ModuleContentProvider.java
index 806732a0cbe..bfe8659e962 100644
--- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/modules/ModuleContentAdapter.java
+++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/modules/ModuleContentProvider.java
@@ -1,12 +1,12 @@
/*******************************************************************************
- * Copyright (c) 2004, 2006 QNX Software Systems and others.
+ * Copyright (c) 2007 ARM 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:
- * QNX Software Systems - Initial API and implementation
+ * ARM - Initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.debug.internal.ui.views.modules;
@@ -17,18 +17,34 @@ import org.eclipse.cdt.debug.core.model.ICModule;
import org.eclipse.cdt.debug.core.model.IModuleRetrieval;
import org.eclipse.cdt.debug.ui.ICDebugUIConstants;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.debug.internal.ui.model.elements.ElementContentProvider;
import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext;
-import org.eclipse.debug.internal.ui.viewers.provisional.AsynchronousContentAdapter;
-
-/**
- * Comment for .
- */
-public class ModuleContentAdapter extends AsynchronousContentAdapter {
+import org.eclipse.debug.internal.ui.viewers.model.provisional.IViewerUpdate;
+
+public class ModuleContentProvider extends ElementContentProvider {
/* (non-Javadoc)
- * @see org.eclipse.debug.internal.ui.viewers.provisional.AsynchronousContentAdapter#getChildren(java.lang.Object, org.eclipse.debug.internal.ui.viewers.provisional.IPresentationContext)
+ * @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 Object[] getChildren( Object parent, IPresentationContext context ) throws CoreException {
+ protected int getChildCount( Object element, IPresentationContext context, IViewerUpdate monitor ) throws CoreException {
+ return getAllChildren( element, context ).length;
+ }
+
+ /* (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 {
+ return getElements( getAllChildren( parent, context ), index, length );
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.internal.ui.model.elements.ElementContentProvider#supportsContextId(java.lang.String)
+ */
+ protected boolean supportsContextId( String id ) {
+ return ICDebugUIConstants.ID_MODULES_VIEW.equals( id );
+ }
+
+ protected Object[] getAllChildren( Object parent, IPresentationContext context ) throws CoreException {
if ( parent instanceof IModuleRetrieval ) {
return ((IModuleRetrieval)parent).getModules();
}
@@ -51,30 +67,4 @@ public class ModuleContentAdapter extends AsynchronousContentAdapter {
}
return EMPTY;
}
-
- /* (non-Javadoc)
- * @see org.eclipse.debug.internal.ui.viewers.AsynchronousTreeContentAdapter#hasChildren(java.lang.Object, org.eclipse.debug.internal.ui.viewers.IPresentationContext)
- */
- protected boolean hasChildren( Object element, IPresentationContext context ) throws CoreException {
- if ( element instanceof IModuleRetrieval ) {
- return ((IModuleRetrieval)element).hasModules();
- }
- else if ( element instanceof ICModule ) {
- IBinary binary = (IBinary)((ICModule)element).getAdapter( IBinary.class );
- if ( binary != null ) {
- return binary.hasChildren();
- }
- }
- else if ( element instanceof IParent ) {
- return ((IParent)element).hasChildren();
- }
- return false;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.debug.internal.ui.viewers.AsynchronousTreeContentAdapter#supportsPartId(java.lang.String)
- */
- protected boolean supportsPartId( String id ) {
- return ICDebugUIConstants.ID_MODULES_VIEW.equals( id );
- }
}
diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/modules/ModulesView.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/modules/ModulesView.java
index fe90d9f897b..2e86af42086 100644
--- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/modules/ModulesView.java
+++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/modules/ModulesView.java
@@ -27,18 +27,26 @@ import org.eclipse.cdt.debug.internal.ui.views.IDebugExceptionHandler;
import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
import org.eclipse.cdt.debug.ui.ICDebugUIConstants;
import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.ListenerList;
import org.eclipse.debug.core.DebugException;
import org.eclipse.debug.core.DebugPlugin;
-import org.eclipse.debug.internal.ui.contexts.DebugContextManager;
+import org.eclipse.debug.internal.ui.viewers.model.provisional.IModelChangedListener;
+import org.eclipse.debug.internal.ui.viewers.model.provisional.IModelDelta;
+import org.eclipse.debug.internal.ui.viewers.model.provisional.IModelProxy;
+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.IViewerUpdateListener;
import org.eclipse.debug.internal.ui.viewers.model.provisional.PresentationContext;
+import org.eclipse.debug.internal.ui.viewers.model.provisional.TreeModelViewer;
import org.eclipse.debug.ui.AbstractDebugView;
-import org.eclipse.debug.ui.IDebugUIConstants;
+import org.eclipse.debug.ui.DebugUITools;
import org.eclipse.debug.ui.contexts.DebugContextEvent;
import org.eclipse.debug.ui.contexts.IDebugContextListener;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.action.IMenuListener;
import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.IStatusLineManager;
import org.eclipse.jface.action.IToolBarManager;
import org.eclipse.jface.action.MenuManager;
import org.eclipse.jface.action.Separator;
@@ -61,6 +69,7 @@ import org.eclipse.jface.viewers.ISelectionProvider;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.StructuredViewer;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.SashForm;
@@ -74,14 +83,16 @@ import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.ui.IActionBars;
import org.eclipse.ui.IMemento;
-import org.eclipse.ui.INullSelectionListener;
-import org.eclipse.ui.ISelectionListener;
+import org.eclipse.ui.IPerspectiveDescriptor;
+import org.eclipse.ui.IPerspectiveListener;
import org.eclipse.ui.IViewSite;
import org.eclipse.ui.IWorkbenchActionConstants;
-import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.actions.ActionFactory;
import org.eclipse.ui.console.actions.TextViewerAction;
@@ -91,7 +102,7 @@ import org.eclipse.ui.texteditor.IWorkbenchActionDefinitionIds;
/**
* Displays the modules currently loaded by the process being debugged.
*/
-public class ModulesView extends AbstractDebugView implements IDebugContextListener, IDebugExceptionHandler, IPropertyChangeListener, ISelectionListener, INullSelectionListener {
+public class ModulesView extends AbstractDebugView implements IDebugContextListener, IDebugExceptionHandler, IPropertyChangeListener, IPerspectiveListener, IModelChangedListener, IViewerUpdateListener {
/**
* Internal interface for a cursor listener. I.e. aggregation
@@ -100,7 +111,6 @@ public class ModulesView extends AbstractDebugView implements IDebugContextListe
interface ICursorListener extends MouseListener, KeyListener {
}
-
/**
* The selection provider for the modules view changes depending on whether
* the variables viewer or detail pane source viewer have focus. This "super"
@@ -174,15 +184,10 @@ public class ModulesView extends AbstractDebugView implements IDebugContextListe
private IDocument fDetailDocument;
/**
- * Selection provider for this view.
- */
- private ModulesViewSelectionProvider fSelectionProvider = new ModulesViewSelectionProvider();
-
- /**
- * The model presentation used as the label provider for the tree viewer,
- * and also as the detail information provider for the detail pane.
+ * Stores whether the tree viewer was the last control to have focus in the
+ * view. Used to give focus to the correct component if the user leaves the view.
*/
-// private IDebugModelPresentation fModelPresentation;
+ private boolean fTreeHasFocus = true;
/**
* Remembers which viewer (tree viewer or details viewer) had focus, so we
@@ -213,16 +218,20 @@ public class ModulesView extends AbstractDebugView implements IDebugContextListe
private HashMap fSelectionStates = new HashMap( 10 );
- private AbstractViewerState fLastState = null;
-
private HashMap fImageCache = new HashMap( 10 );
/* (non-Javadoc)
* @see org.eclipse.debug.ui.AbstractDebugView#createViewer(org.eclipse.swt.widgets.Composite)
*/
protected Viewer createViewer( Composite parent ) {
- ModulesViewer viewer = (ModulesViewer)createTreeViewer( parent );
- viewer.setContext( new PresentationContext( ICDebugUIConstants.ID_MODULES_VIEW ) );
+
+ // create the sash form that will contain the tree viewer & text viewer
+ setSashForm( new SashForm( parent, SWT.NONE ) );
+
+ CDebugUIPlugin.getDefault().getPreferenceStore().addPropertyChangeListener( this );
+ JFaceResources.getFontRegistry().addListener( this );
+
+ TreeModelViewer viewer = createTreeViewer( getSashForm() );
createDetailsViewer();
getSashForm().setMaximizedControl( viewer.getControl() );
@@ -235,6 +244,9 @@ public class ModulesView extends AbstractDebugView implements IDebugContextListe
}
setDetailPaneOrientation( orientation );
+ viewer.addModelChangedListener( this );
+ viewer.addViewerUpdateListener( this );
+
return viewer;
}
@@ -296,18 +308,6 @@ public class ModulesView extends AbstractDebugView implements IDebugContextListe
}
}
- /* (non-Javadoc)
- * @see org.eclipse.ui.ISelectionListener#selectionChanged(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.ISelection)
- */
- public void selectionChanged( IWorkbenchPart part, ISelection selection ) {
- if ( !isAvailable() || !isVisible() )
- return;
- if ( selection == null )
- setViewerInput( new StructuredSelection() );
- else if ( selection instanceof IStructuredSelection )
- setViewerInput( selection );
- }
-
protected void setViewerInput( Object context ) {
IModuleRetrieval mr = null;
if ( context instanceof IAdaptable ) {
@@ -315,6 +315,10 @@ public class ModulesView extends AbstractDebugView implements IDebugContextListe
if ( target != null )
mr = (IModuleRetrieval)target.getAdapter( IModuleRetrieval.class );
}
+
+ if ( context == null ) {
+ clearDetails();
+ }
Object current = getViewer().getInput();
if ( current == null && mr == null ) {
return;
@@ -322,78 +326,37 @@ public class ModulesView extends AbstractDebugView implements IDebugContextListe
if ( current != null && current.equals( mr ) ) {
return;
}
- if ( current != null ) {
- // save state
- fLastState = getViewerState();
- cacheViewerState( current, fLastState );
- }
showViewer();
getViewer().setInput( mr );
- restoreState();
-
-//
-// ICDebugTarget target = null;
-// if ( ssel.size() == 1 ) {
-// Object input = ssel.getFirstElement();
-// if ( input instanceof ICDebugElement ) {
-// target = (ICDebugTarget)((ICDebugElement)input).getDebugTarget();
-// }
-// }
-//
-// Object current = getViewer().getInput();
-// if ( current == null && target == null ) {
-// return;
-// }
-// if ( current != null && current.equals( target ) ) {
-// return;
-// }
-//
-// if ( current != null ) {
-// // save state
-// fLastState = getViewerState();
-// cacheViewerState( current, fLastState );
-// }
-//
-// showViewer();
-// getViewer().setInput( target );
-//
-// // restore state
-// if ( target != null ) {
-// AbstractViewerState state = (AbstractViewerState)fSelectionStates.get( target );
-// if ( state == null ) {
-// // attempt to restore selection/expansion based on last target
-// state = fLastState;
-// }
-// if ( state != null ) {
-// state.restoreState( getModulesViewer() );
-// }
-// }
}
- protected Viewer createTreeViewer( Composite parent ) {
- CDebugUIPlugin.getDefault().getPreferenceStore().addPropertyChangeListener( this );
- JFaceResources.getFontRegistry().addListener( this );
- // create the sash form that will contain the tree viewer & text viewer
- setSashForm( new SashForm( parent, SWT.NONE ) );
+ protected TreeModelViewer createTreeViewer( Composite parent ) {
// add tree viewer
- final ModulesViewer modulesViewer = new ModulesViewer( getSashForm(), this );
+ final TreeModelViewer modulesViewer = new TreeModelViewer( parent, SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL | SWT.VIRTUAL | SWT.FULL_SELECTION, getPresentationContext() );
modulesViewer.getControl().addFocusListener( new FocusAdapter() {
/* (non-Javadoc)
* @see org.eclipse.swt.events.FocusListener#focusGained(org.eclipse.swt.events.FocusEvent)
*/
public void focusGained( FocusEvent e ) {
- getModulesViewSelectionProvider().setUnderlyingSelectionProvider( modulesViewer );
- setFocusViewer( getModulesViewer() );
+ fTreeHasFocus = true;
+ getSite().setSelectionProvider( modulesViewer );
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.swt.events.FocusAdapter#focusLost(org.eclipse.swt.events.FocusEvent)
+ */
+ public void focusLost( FocusEvent e ) {
+ getSite().setSelectionProvider( null );
}
} );
+
+ getSite().setSelectionProvider( modulesViewer );
modulesViewer.addPostSelectionChangedListener( getTreeSelectionChangedListener() );
- getModulesViewSelectionProvider().setUnderlyingSelectionProvider( modulesViewer );
- getSite().setSelectionProvider( getModulesViewSelectionProvider() );
// listen to debug context
- DebugContextManager.getDefault().addDebugContextListener(this);
+ DebugUITools.getDebugContextManager().getContextService( getSite().getWorkbenchWindow() ).addDebugContextListener( this );
return modulesViewer;
}
@@ -403,6 +366,13 @@ public class ModulesView extends AbstractDebugView implements IDebugContextListe
protected void createDetailsViewer() {
// Create & configure a SourceViewer
SourceViewer detailsViewer = new SourceViewer( getSashForm(), null, SWT.V_SCROLL | SWT.H_SCROLL );
+ Listener activateListener = new Listener() {
+
+ public void handleEvent( Event event ) {
+ fTreeHasFocus = false;
+ }
+ };
+ detailsViewer.getControl().addListener( SWT.Activate, activateListener );
setDetailViewer( detailsViewer );
detailsViewer.setDocument( getDetailDocument() );
detailsViewer.getTextWidget().setFont( JFaceResources.getFont( IInternalCDebugUIConstants.DETAIL_PANE_FONT ) );
@@ -419,7 +389,6 @@ public class ModulesView extends AbstractDebugView implements IDebugContextListe
* @see org.eclipse.swt.events.FocusListener#focusGained(org.eclipse.swt.events.FocusEvent)
*/
public void focusGained( FocusEvent e ) {
- getModulesViewSelectionProvider().setUnderlyingSelectionProvider( getDetailViewer().getSelectionProvider() );
setFocusViewer( (Viewer)getDetailViewer() );
}
} );
@@ -463,12 +432,8 @@ public class ModulesView extends AbstractDebugView implements IDebugContextListe
// return fModelPresentation;
// }
//
- protected ModulesViewSelectionProvider getModulesViewSelectionProvider() {
- return fSelectionProvider;
- }
-
- protected ModulesViewer getModulesViewer() {
- return (ModulesViewer)getViewer();
+ protected TreeModelViewer getModulesViewer() {
+ return (TreeModelViewer)getViewer();
}
protected void setFocusViewer( Viewer viewer ) {
@@ -489,7 +454,7 @@ public class ModulesView extends AbstractDebugView implements IDebugContextListe
public void selectionChanged( SelectionChangedEvent event ) {
if ( event.getSelectionProvider().equals( getModulesViewer() ) ) {
- getModulesViewSelectionProvider().fireSelectionChanged( event );
+ clearStatusLine();
// if the detail pane is not visible, don't waste time retrieving details
if ( getSashForm().getMaximizedControl() == getViewer().getControl() ) {
return;
@@ -541,10 +506,6 @@ public class ModulesView extends AbstractDebugView implements IDebugContextListe
fDetailSelectionChangedListener = new ISelectionChangedListener() {
public void selectionChanged( SelectionChangedEvent event ) {
- if ( event.getSelectionProvider().equals( getModulesViewSelectionProvider().getUnderlyingSelectionProvider() ) ) {
- getModulesViewSelectionProvider().fireSelectionChanged( event );
- updateSelectionDependentActions();
- }
}
};
}
@@ -711,7 +672,7 @@ public class ModulesView extends AbstractDebugView implements IDebugContextListe
* Make sure the currently selected item in the tree is visible.
*/
protected void revealTreeSelection() {
- ModulesViewer viewer = getModulesViewer();
+ StructuredViewer viewer = (StructuredViewer)getViewer();
if ( viewer != null ) {
ISelection selection = viewer.getSelection();
if ( selection instanceof IStructuredSelection ) {
@@ -768,6 +729,7 @@ public class ModulesView extends AbstractDebugView implements IDebugContextListe
setLastSashWeights( weights );
}
}
+ site.getWorkbenchWindow().addPerspectiveListener( this );
}
/* (non-Javadoc)
@@ -790,8 +752,8 @@ public class ModulesView extends AbstractDebugView implements IDebugContextListe
*/
protected void becomesVisible() {
super.becomesVisible();
- ISelection selection = DebugContextManager.getDefault().getContextService( getSite().getWorkbenchWindow() ).getActiveContext();
- contextActivated( selection, null );
+ ISelection selection = DebugUITools.getDebugContextManager().getContextService( getSite().getWorkbenchWindow() ).getActiveContext();
+ contextActivated( selection );
}
private void computeDetail( final Object element ) {
@@ -887,10 +849,15 @@ public class ModulesView extends AbstractDebugView implements IDebugContextListe
* @see org.eclipse.ui.IWorkbenchPart#dispose()
*/
public void dispose() {
- getSite().getPage().removeSelectionListener( IDebugUIConstants.ID_DEBUG_VIEW, this );
+ DebugUITools.getDebugContextManager().getContextService( getSite().getWorkbenchWindow() ).removeDebugContextListener( this );
+ getSite().getWorkbenchWindow().removePerspectiveListener( this );
CDebugUIPlugin.getDefault().getPreferenceStore().removePropertyChangeListener( this );
JFaceResources.getFontRegistry().removeListener( this );
- Viewer viewer = getViewer();
+ TreeModelViewer viewer = getModulesViewer();
+ if ( viewer != null ) {
+ viewer.removeModelChangedListener( this );
+ viewer.removeViewerUpdateListener( this );
+ }
if ( viewer != null ) {
getDetailDocument().removeDocumentListener( getDetailDocumentListener() );
}
@@ -898,9 +865,9 @@ public class ModulesView extends AbstractDebugView implements IDebugContextListe
super.dispose();
}
- private AbstractViewerState getViewerState() {
- return new ModulesViewerState( getModulesViewer() );
- }
+// private AbstractViewerState getViewerState() {
+// return new ModulesViewerState( getModulesViewer() );
+// }
protected Image getImage( ImageDescriptor desc ) {
Image image = (Image)fImageCache.get( desc );
@@ -919,23 +886,23 @@ public class ModulesView extends AbstractDebugView implements IDebugContextListe
fImageCache.clear();
}
- protected void restoreState() {
- ModulesViewer viewer = (ModulesViewer)getViewer();
- if ( viewer != null ) {
- Object context = viewer.getInput();
- if ( context != null ) {
- AbstractViewerState state = getCachedViewerState( context );
- if ( state == null ) {
- // attempt to restore selection/expansion based on last
- // frame
- state = fLastState;
- }
- if ( state != null ) {
- state.restoreState( viewer );
- }
- }
- }
- }
+// protected void restoreState() {
+// ModulesViewer viewer = (ModulesViewer)getViewer();
+// if ( viewer != null ) {
+// Object context = viewer.getInput();
+// if ( context != null ) {
+// AbstractViewerState state = getCachedViewerState( context );
+// if ( state == null ) {
+// // attempt to restore selection/expansion based on last
+// // frame
+// state = fLastState;
+// }
+// if ( state != null ) {
+// state.restoreState( viewer );
+// }
+// }
+// }
+// }
/**
* Caches the given viewer state for the given viewer input.
@@ -970,7 +937,7 @@ public class ModulesView extends AbstractDebugView implements IDebugContextListe
return (AbstractViewerState)fSelectionStates.get( generateKey( input ) );
}
- public void contextActivated( ISelection selection, IWorkbenchPart part ) {
+ public void contextActivated( ISelection selection ) {
if ( !isAvailable() || !isVisible() ) {
return;
}
@@ -980,8 +947,64 @@ public class ModulesView extends AbstractDebugView implements IDebugContextListe
showViewer();
}
- public void debugContextChanged(DebugContextEvent event) {
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.ui.contexts.IDebugContextListener#debugContextChanged(org.eclipse.debug.ui.contexts.DebugContextEvent)
+ */
+ public void debugContextChanged( DebugContextEvent event ) {
+ if ( (event.getFlags() & DebugContextEvent.ACTIVATED) > 0 ) {
+ contextActivated( event.getContext() );
+ }
+ }
+
+ private IPresentationContext getPresentationContext() {
+ return new PresentationContext( ICDebugUIConstants.ID_MODULES_VIEW );
+ }
+
+ private void clearDetails() {
+ getDetailDocument().set( "" ); //$NON-NLS-1$
+ }
+
+ public void perspectiveActivated( IWorkbenchPage page, IPerspectiveDescriptor perspective ) {
+ }
+
+ public void perspectiveChanged( IWorkbenchPage page, IPerspectiveDescriptor perspective, String changeId ) {
+ if ( changeId.equals( IWorkbenchPage.CHANGE_RESET ) ) {
+ setLastSashWeights( DEFAULT_SASH_WEIGHTS );
+ fSashForm.setWeights( DEFAULT_SASH_WEIGHTS );
+ }
+ }
+
+ public void modelChanged( IModelDelta delta, IModelProxy proxy ) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void updateComplete( IViewerUpdate update ) {
+ IStatus status = update.getStatus();
+ if ( !update.isCanceled() ) {
+ if ( status != null && status.getCode() != IStatus.OK ) {
+ showMessage( status.getMessage() );
+ }
+ else {
+ showViewer();
+ }
+ }
+ }
+
+ public void updateStarted( IViewerUpdate update ) {
+ }
+
+ public void viewerUpdatesBegin() {
// TODO Auto-generated method stub
+
+ }
+
+ public void viewerUpdatesComplete() {
}
+ protected void clearStatusLine() {
+ IStatusLineManager manager = getViewSite().getActionBars().getStatusLineManager();
+ manager.setErrorMessage( null );
+ manager.setMessage( null );
+ }
}
diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/modules/ModulesViewer.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/modules/ModulesViewer.java
deleted file mode 100644
index 4e65952906a..00000000000
--- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/modules/ModulesViewer.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2006 QNX Software Systems and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * QNX Software Systems - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.debug.internal.ui.views.modules;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.debug.internal.ui.viewers.AsynchronousTreeViewer;
-import org.eclipse.debug.ui.commands.IStatusMonitor;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.ui.progress.UIJob;
-
-/**
- * Asynchronous viewer used by the Modules view.
- */
-public class ModulesViewer extends AsynchronousTreeViewer {
-
- protected ModulesView fView;
-
- private UIJob fRestoreJob = new UIJob( "restore viewer state" ) { //$NON-NLS-1$
-
- public IStatus runInUIThread( IProgressMonitor monitor ) {
- fView.restoreState();
- return Status.OK_STATUS;
- }
- };
-
- /**
- * Constructor for ModulesViewer.
- */
- public ModulesViewer( Composite parent, ModulesView view ) {
- super( parent );
- fView = view;
- fRestoreJob.setSystem( true );
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.debug.internal.ui.model.viewers.AsynchronousModelViewer#updateComplete(org.eclipse.debug.internal.ui.viewers.provisional.IAsynchronousRequestMonitor)
- */
- protected void updateComplete( IStatusMonitor update ) {
- super.updateComplete( update );
- if ( fView != null ) {
- fRestoreJob.schedule( 100 );
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.debug.internal.ui.model.viewers.AsynchronousModelViewer#handlePresentationFailure(org.eclipse.debug.internal.ui.viewers.provisional.IAsynchronousRequestMonitor, org.eclipse.core.runtime.IStatus)
- */
- protected void handlePresentationFailure( IStatusMonitor update, IStatus status ) {
- fView.showMessage( status.getMessage() );
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.debug.internal.ui.viewers.AsynchronousTreeViewer#collapseAll()
- */
- public void collapseAll() {
- super.collapseAll();
- }
-}
diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/modules/ModulesViewerState.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/modules/ModulesViewerState.java
index 30baba30d55..23ff4f22120 100644
--- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/modules/ModulesViewerState.java
+++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/modules/ModulesViewerState.java
@@ -12,12 +12,13 @@ package org.eclipse.cdt.debug.internal.ui.views.modules;
import java.util.ArrayList;
import java.util.List;
+
import org.eclipse.cdt.debug.internal.ui.views.AbstractViewerState;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.eclipse.debug.core.DebugException;
-import org.eclipse.debug.internal.ui.viewers.AsynchronousTreeViewer;
import org.eclipse.jface.viewers.TreePath;
+import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.swt.widgets.Tree;
import org.eclipse.swt.widgets.TreeItem;
@@ -29,7 +30,7 @@ public class ModulesViewerState extends AbstractViewerState {
/**
* Constructor for ModulesViewerState.
*/
- public ModulesViewerState( AsynchronousTreeViewer viewer ) {
+ public ModulesViewerState( TreeViewer viewer ) {
super( viewer );
}
@@ -49,7 +50,7 @@ public class ModulesViewerState extends AbstractViewerState {
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.internal.ui.views.AbstractViewerState#decodePath(org.eclipse.core.runtime.IPath, org.eclipse.debug.internal.ui.model.viewers.AsynchronousTreeModelViewer)
*/
- protected TreePath decodePath( IPath path, AsynchronousTreeViewer viewer ) throws DebugException {
+ protected TreePath decodePath( IPath path, TreeViewer viewer ) throws DebugException {
String[] names = path.segments();
Tree tree = viewer.getTree();
TreeItem[] items = tree.getItems();

Back to the top