mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-08 02:06:01 +02:00
Bug 122336: Use the asynchronous tree viewer in the Modules view.
This commit is contained in:
parent
c8b246f974
commit
f4fc48f7ce
16 changed files with 644 additions and 596 deletions
|
@ -1,3 +1,13 @@
|
||||||
|
2005-12-29 Mikhail Khodjaiants
|
||||||
|
Bug 122336: Use the asynchronous tree viewer in the Modules view.
|
||||||
|
Grouped the modules-related methods of ICDebugTarget under the
|
||||||
|
new IModuleRetrieval interface.
|
||||||
|
* ICDebugTarget.java
|
||||||
|
+ IModuleRetrieval.java
|
||||||
|
* CDebugElement.java
|
||||||
|
* CDebugTarget.java
|
||||||
|
* CModuleManager.java
|
||||||
|
|
||||||
2005-12-27 Mikhail Khodjaiants
|
2005-12-27 Mikhail Khodjaiants
|
||||||
Bug 109526: Support Eclipse-LazyStart and deprecate Eclipse-AutoStart.
|
Bug 109526: Support Eclipse-LazyStart and deprecate Eclipse-AutoStart.
|
||||||
* MANIFEST.MF
|
* MANIFEST.MF
|
||||||
|
|
|
@ -24,6 +24,7 @@ public interface ICDebugTarget extends IDebugTarget,
|
||||||
IResumeWithoutSignal,
|
IResumeWithoutSignal,
|
||||||
ICDebugElement,
|
ICDebugElement,
|
||||||
ISteppingModeTarget,
|
ISteppingModeTarget,
|
||||||
|
IModuleRetrieval,
|
||||||
ITargetProperties {
|
ITargetProperties {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -64,30 +65,6 @@ public interface ICDebugTarget extends IDebugTarget,
|
||||||
*/
|
*/
|
||||||
public boolean isPostMortem();
|
public boolean isPostMortem();
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns whether there are modules currently loaded in this debug target.
|
|
||||||
*
|
|
||||||
* @return whether there are modules currently loaded in this debug target
|
|
||||||
*
|
|
||||||
* @throws DebugException
|
|
||||||
*/
|
|
||||||
public boolean hasModules() throws DebugException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the array of the currently loaded modules.
|
|
||||||
*
|
|
||||||
* @return the array of the currently loaded modules
|
|
||||||
* @throws DebugException if this method fails. Reasons include:
|
|
||||||
*/
|
|
||||||
public ICModule[] getModules() throws DebugException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Load symbols for all currently loaded modules.
|
|
||||||
*
|
|
||||||
* @throws DebugException if this method fails. Reasons include:
|
|
||||||
*/
|
|
||||||
public void loadSymbolsForAllModules() throws DebugException;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the list of descriptors of the target registers
|
* Returns the list of descriptors of the target registers
|
||||||
*
|
*
|
||||||
|
|
|
@ -0,0 +1,43 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2004 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.core.model;
|
||||||
|
|
||||||
|
import org.eclipse.debug.core.DebugException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Comment for .
|
||||||
|
*/
|
||||||
|
public interface IModuleRetrieval {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns whether there are modules currently loaded in this debug target.
|
||||||
|
*
|
||||||
|
* @return whether there are modules currently loaded in this debug target
|
||||||
|
*
|
||||||
|
* @throws DebugException
|
||||||
|
*/
|
||||||
|
public boolean hasModules() throws DebugException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the array of the currently loaded modules.
|
||||||
|
*
|
||||||
|
* @return the array of the currently loaded modules
|
||||||
|
* @throws DebugException if this method fails. Reasons include:
|
||||||
|
*/
|
||||||
|
public ICModule[] getModules() throws DebugException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Load symbols for all currently loaded modules.
|
||||||
|
*
|
||||||
|
* @throws DebugException if this method fails. Reasons include:
|
||||||
|
*/
|
||||||
|
public void loadSymbolsForAllModules() throws DebugException;
|
||||||
|
}
|
|
@ -302,6 +302,8 @@ abstract public class CDebugElement extends PlatformObject implements ICDebugEle
|
||||||
return getCDISession();
|
return getCDISession();
|
||||||
if ( adapter.equals( ICDebugTarget.class ) )
|
if ( adapter.equals( ICDebugTarget.class ) )
|
||||||
return getDebugTarget();
|
return getDebugTarget();
|
||||||
|
if ( adapter.equals( IDebugTarget.class ) )
|
||||||
|
return getDebugTarget();
|
||||||
// See bug #100261
|
// See bug #100261
|
||||||
if ( adapter.equals( IMemoryBlockRetrieval.class ) )
|
if ( adapter.equals( IMemoryBlockRetrieval.class ) )
|
||||||
return getDebugTarget().getAdapter( adapter );
|
return getDebugTarget().getAdapter( adapter );
|
||||||
|
|
|
@ -73,6 +73,7 @@ import org.eclipse.cdt.debug.core.model.IDebuggerProcessSupport;
|
||||||
import org.eclipse.cdt.debug.core.model.IDisassembly;
|
import org.eclipse.cdt.debug.core.model.IDisassembly;
|
||||||
import org.eclipse.cdt.debug.core.model.IExecFileInfo;
|
import org.eclipse.cdt.debug.core.model.IExecFileInfo;
|
||||||
import org.eclipse.cdt.debug.core.model.IGlobalVariableDescriptor;
|
import org.eclipse.cdt.debug.core.model.IGlobalVariableDescriptor;
|
||||||
|
import org.eclipse.cdt.debug.core.model.IModuleRetrieval;
|
||||||
import org.eclipse.cdt.debug.core.model.IPersistableRegisterGroup;
|
import org.eclipse.cdt.debug.core.model.IPersistableRegisterGroup;
|
||||||
import org.eclipse.cdt.debug.core.model.IRegisterDescriptor;
|
import org.eclipse.cdt.debug.core.model.IRegisterDescriptor;
|
||||||
import org.eclipse.cdt.debug.core.sourcelookup.CDirectorySourceContainer;
|
import org.eclipse.cdt.debug.core.sourcelookup.CDirectorySourceContainer;
|
||||||
|
@ -765,6 +766,8 @@ public class CDebugTarget extends CDebugElement implements ICDebugTarget, ICDIEv
|
||||||
return getMemoryBlockRetrieval();
|
return getMemoryBlockRetrieval();
|
||||||
if ( adapter.equals( IMemoryBlockRetrieval.class ) )
|
if ( adapter.equals( IMemoryBlockRetrieval.class ) )
|
||||||
return getMemoryBlockRetrieval();
|
return getMemoryBlockRetrieval();
|
||||||
|
if ( adapter.equals( IModuleRetrieval.class ) )
|
||||||
|
return getModuleManager();
|
||||||
return super.getAdapter( adapter );
|
return super.getAdapter( adapter );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1591,30 +1594,6 @@ public class CDebugTarget extends CDebugElement implements ICDebugTarget, ICDIEv
|
||||||
return CVariableFactory.createGlobalVariable( this, info, vo );
|
return CVariableFactory.createGlobalVariable( this, info, vo );
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.debug.core.model.ICDebugTarget#hasModules()
|
|
||||||
*/
|
|
||||||
public boolean hasModules() throws DebugException {
|
|
||||||
CModuleManager mm = getModuleManager();
|
|
||||||
return ( mm != null ) ? mm.hasModules() : false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.debug.core.model.ICDebugTarget#getModules()
|
|
||||||
*/
|
|
||||||
public ICModule[] getModules() throws DebugException {
|
|
||||||
CModuleManager mm = getModuleManager();
|
|
||||||
return ( mm != null ) ? mm.getModules() : new ICModule[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.debug.core.model.ICDebugTarget#loadSymbolsForAllModules()
|
|
||||||
*/
|
|
||||||
public void loadSymbolsForAllModules() throws DebugException {
|
|
||||||
CModuleManager mm = getModuleManager();
|
|
||||||
mm.loadSymbolsForAll();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void sourceContainersChanged( ISourceLookupDirector director ) {
|
public void sourceContainersChanged( ISourceLookupDirector director ) {
|
||||||
setSourceLookupPath( director.getSourceContainers() );
|
setSourceLookupPath( director.getSourceContainers() );
|
||||||
}
|
}
|
||||||
|
@ -1713,4 +1692,24 @@ public class CDebugTarget extends CDebugElement implements ICDebugTarget, ICDIEv
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean hasModules() throws DebugException {
|
||||||
|
CModuleManager mm = getModuleManager();
|
||||||
|
if ( mm != null )
|
||||||
|
return mm.hasModules();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ICModule[] getModules() throws DebugException {
|
||||||
|
CModuleManager mm = getModuleManager();
|
||||||
|
if ( mm != null )
|
||||||
|
return mm.getModules();
|
||||||
|
return new ICModule[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
public void loadSymbolsForAllModules() throws DebugException {
|
||||||
|
CModuleManager mm = getModuleManager();
|
||||||
|
if ( mm != null )
|
||||||
|
mm.loadSymbolsForAllModules();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,9 +17,11 @@ import org.eclipse.cdt.debug.core.CDIDebugModel;
|
||||||
import org.eclipse.cdt.debug.core.cdi.model.ICDIObject;
|
import org.eclipse.cdt.debug.core.cdi.model.ICDIObject;
|
||||||
import org.eclipse.cdt.debug.core.cdi.model.ICDISharedLibrary;
|
import org.eclipse.cdt.debug.core.cdi.model.ICDISharedLibrary;
|
||||||
import org.eclipse.cdt.debug.core.model.ICModule;
|
import org.eclipse.cdt.debug.core.model.ICModule;
|
||||||
|
import org.eclipse.cdt.debug.core.model.IModuleRetrieval;
|
||||||
import org.eclipse.cdt.debug.internal.core.ICDebugInternalConstants;
|
import org.eclipse.cdt.debug.internal.core.ICDebugInternalConstants;
|
||||||
import org.eclipse.core.runtime.IStatus;
|
import org.eclipse.core.runtime.IStatus;
|
||||||
import org.eclipse.core.runtime.MultiStatus;
|
import org.eclipse.core.runtime.MultiStatus;
|
||||||
|
import org.eclipse.core.runtime.PlatformObject;
|
||||||
import org.eclipse.core.runtime.Status;
|
import org.eclipse.core.runtime.Status;
|
||||||
import org.eclipse.debug.core.DebugEvent;
|
import org.eclipse.debug.core.DebugEvent;
|
||||||
import org.eclipse.debug.core.DebugException;
|
import org.eclipse.debug.core.DebugException;
|
||||||
|
@ -27,7 +29,7 @@ import org.eclipse.debug.core.DebugException;
|
||||||
/**
|
/**
|
||||||
* Manages the modules loaded on this debug target.
|
* Manages the modules loaded on this debug target.
|
||||||
*/
|
*/
|
||||||
public class CModuleManager {
|
public class CModuleManager extends PlatformObject implements IModuleRetrieval {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The debug target associated with this manager.
|
* The debug target associated with this manager.
|
||||||
|
@ -47,15 +49,15 @@ public class CModuleManager {
|
||||||
fModules = new ArrayList( 5 );
|
fModules = new ArrayList( 5 );
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasModules() {
|
public boolean hasModules() throws DebugException {
|
||||||
return !fModules.isEmpty();
|
return !fModules.isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
public ICModule[] getModules() {
|
public ICModule[] getModules() throws DebugException {
|
||||||
return (ICModule[])fModules.toArray( new ICModule[fModules.size()] );
|
return (ICModule[])fModules.toArray( new ICModule[fModules.size()] );
|
||||||
}
|
}
|
||||||
|
|
||||||
public void loadSymbolsForAll() throws DebugException {
|
public void loadSymbolsForAllModules() throws DebugException {
|
||||||
MultiStatus ms = new MultiStatus( CDIDebugModel.getPluginIdentifier(), ICDebugInternalConstants.STATUS_CODE_ERROR, CoreModelMessages.getString( "CModuleManager.0" ), null ); //$NON-NLS-1$
|
MultiStatus ms = new MultiStatus( CDIDebugModel.getPluginIdentifier(), ICDebugInternalConstants.STATUS_CODE_ERROR, CoreModelMessages.getString( "CModuleManager.0" ), null ); //$NON-NLS-1$
|
||||||
Iterator it = fModules.iterator();
|
Iterator it = fModules.iterator();
|
||||||
while( it.hasNext() ) {
|
while( it.hasNext() ) {
|
||||||
|
|
|
@ -1,3 +1,15 @@
|
||||||
|
2005-12-29 Mikhail Khodjaiants
|
||||||
|
Bug 122336: Use the asynchronous tree viewer in the Modules view.
|
||||||
|
* LoadSymbolsForAllActionDelegate.java
|
||||||
|
* AbstractViewerState.java
|
||||||
|
* ModulesView.java
|
||||||
|
- ModulesViewContentProvider.java
|
||||||
|
* ModulesViewer.java
|
||||||
|
* ModulesViewerState.java
|
||||||
|
* ModulesViewEventHandler.java
|
||||||
|
+ ModulesViewModelProxy.java
|
||||||
|
+ ModuleTreeContentAdapter.java
|
||||||
|
|
||||||
2005-12-27 Mikhail Khodjaiants
|
2005-12-27 Mikhail Khodjaiants
|
||||||
HTMLTextPresenter implements DefaultInformationControl.IInformationPresenterExtension
|
HTMLTextPresenter implements DefaultInformationControl.IInformationPresenterExtension
|
||||||
instead of deprecated DefaultInformationControl.IInformationPresenter.
|
instead of deprecated DefaultInformationControl.IInformationPresenter.
|
||||||
|
|
|
@ -13,6 +13,7 @@ package org.eclipse.cdt.debug.internal.ui.actions;
|
||||||
import org.eclipse.cdt.debug.core.CDIDebugModel;
|
import org.eclipse.cdt.debug.core.CDIDebugModel;
|
||||||
import org.eclipse.cdt.debug.core.CDebugUtils;
|
import org.eclipse.cdt.debug.core.CDebugUtils;
|
||||||
import org.eclipse.cdt.debug.core.model.ICDebugTarget;
|
import org.eclipse.cdt.debug.core.model.ICDebugTarget;
|
||||||
|
import org.eclipse.cdt.debug.core.model.IModuleRetrieval;
|
||||||
import org.eclipse.cdt.debug.internal.core.ICDebugInternalConstants;
|
import org.eclipse.cdt.debug.internal.core.ICDebugInternalConstants;
|
||||||
import org.eclipse.core.runtime.IStatus;
|
import org.eclipse.core.runtime.IStatus;
|
||||||
import org.eclipse.core.runtime.MultiStatus;
|
import org.eclipse.core.runtime.MultiStatus;
|
||||||
|
@ -46,20 +47,23 @@ public class LoadSymbolsForAllActionDelegate extends AbstractViewActionDelegate
|
||||||
* @see org.eclipse.cdt.debug.internal.ui.actions.AbstractViewActionDelegate#doAction()
|
* @see org.eclipse.cdt.debug.internal.ui.actions.AbstractViewActionDelegate#doAction()
|
||||||
*/
|
*/
|
||||||
protected void doAction() throws DebugException {
|
protected void doAction() throws DebugException {
|
||||||
final ICDebugTarget target = getDebugTarget( getView().getViewer().getInput() );
|
ICDebugTarget target = getDebugTarget( getView().getViewer().getInput() );
|
||||||
if ( target != null ) {
|
if ( target != null ) {
|
||||||
DebugPlugin.getDefault().asyncExec(
|
final IModuleRetrieval mr = (IModuleRetrieval)target.getAdapter( IModuleRetrieval.class );
|
||||||
new Runnable() {
|
if ( mr != null ) {
|
||||||
|
DebugPlugin.getDefault().asyncExec(
|
||||||
public void run() {
|
new Runnable() {
|
||||||
try {
|
|
||||||
target.loadSymbolsForAllModules();
|
public void run() {
|
||||||
|
try {
|
||||||
|
mr.loadSymbolsForAllModules();
|
||||||
|
}
|
||||||
|
catch( DebugException e ) {
|
||||||
|
failed( e );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch( DebugException e ) {
|
} );
|
||||||
failed( e );
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
} );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,20 +1,23 @@
|
||||||
/*******************************************************************************
|
/**********************************************************************
|
||||||
* Copyright (c) 2004, 2005 QNX Software Systems and others.
|
* Copyright (c) 2004, 2005 QNX Software Systems and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* QNX Software Systems - Initial API and implementation
|
* QNX Software Systems - Initial API and implementation
|
||||||
*******************************************************************************/
|
***********************************************************************/
|
||||||
package org.eclipse.cdt.debug.internal.ui.views;
|
package org.eclipse.cdt.debug.internal.ui.views;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.eclipse.core.runtime.IPath;
|
import org.eclipse.core.runtime.IPath;
|
||||||
import org.eclipse.debug.core.DebugException;
|
import org.eclipse.debug.core.DebugException;
|
||||||
import org.eclipse.jface.viewers.StructuredSelection;
|
import org.eclipse.debug.internal.ui.viewers.AsynchronousTreeViewer;
|
||||||
import org.eclipse.jface.viewers.TreeViewer;
|
import org.eclipse.debug.internal.ui.viewers.TreePath;
|
||||||
|
import org.eclipse.debug.internal.ui.viewers.TreeSelection;
|
||||||
import org.eclipse.swt.widgets.TreeItem;
|
import org.eclipse.swt.widgets.TreeItem;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -24,15 +27,14 @@ import org.eclipse.swt.widgets.TreeItem;
|
||||||
public abstract class AbstractViewerState {
|
public abstract class AbstractViewerState {
|
||||||
|
|
||||||
// paths to expanded elements
|
// paths to expanded elements
|
||||||
private List fExpandedElements = null;
|
private List fSavedExpansion = null;
|
||||||
// paths to selected elements
|
private IPath[] fSelection;
|
||||||
private IPath[] fSelection = null;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs a memento for the given viewer.
|
* Constructs a memento for the given viewer.
|
||||||
*/
|
*/
|
||||||
public AbstractViewerState( TreeViewer viewer ) {
|
public AbstractViewerState(AsynchronousTreeViewer viewer) {
|
||||||
saveState( viewer );
|
saveState(viewer);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -41,42 +43,60 @@ public abstract class AbstractViewerState {
|
||||||
*
|
*
|
||||||
* @param viewer viewer of which to save the state
|
* @param viewer viewer of which to save the state
|
||||||
*/
|
*/
|
||||||
public void saveState( TreeViewer viewer ) {
|
public void saveState(AsynchronousTreeViewer viewer) {
|
||||||
List expanded = new ArrayList();
|
List expanded = new ArrayList();
|
||||||
fExpandedElements = null;
|
fSavedExpansion = null;
|
||||||
TreeItem[] items = viewer.getTree().getItems();
|
TreeItem[] items = viewer.getTree().getItems();
|
||||||
try {
|
try {
|
||||||
for( int i = 0; i < items.length; i++ ) {
|
for (int i = 0; i < items.length; i++) {
|
||||||
collectExandedItems( items[i], expanded );
|
collectExpandedItems(items[i], expanded);
|
||||||
}
|
}
|
||||||
if ( expanded.size() > 0 ) {
|
if (expanded.size() > 0) {
|
||||||
fExpandedElements = expanded;
|
fSavedExpansion = expanded;
|
||||||
}
|
}
|
||||||
}
|
} catch (DebugException e) {
|
||||||
catch( DebugException e ) {
|
fSavedExpansion = null;
|
||||||
fExpandedElements = null;
|
|
||||||
}
|
}
|
||||||
TreeItem[] selection = viewer.getTree().getSelection();
|
TreeItem[] selection = viewer.getTree().getSelection();
|
||||||
fSelection = new IPath[selection.length];
|
fSelection = new IPath[selection.length];
|
||||||
try {
|
try {
|
||||||
for( int i = 0; i < selection.length; i++ ) {
|
for (int i = 0; i < selection.length; i++) {
|
||||||
fSelection[i] = encodeElement( selection[i] );
|
fSelection[i] = encodeElement(selection[i]);
|
||||||
}
|
if (fSelection[i] == null) {
|
||||||
}
|
fSelection = null;
|
||||||
catch( DebugException e ) {
|
return;
|
||||||
fSelection = null;
|
}
|
||||||
|
}
|
||||||
|
} catch (DebugException e) {
|
||||||
|
fSelection = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void collectExandedItems( TreeItem item, List expanded ) throws DebugException {
|
/**
|
||||||
if ( item.getExpanded() ) {
|
* Collects paths to expanded children of the given element and returns
|
||||||
expanded.add( encodeElement( item ) );
|
* whether any paths were expanded.
|
||||||
TreeItem[] items = item.getItems();
|
*
|
||||||
for( int i = 0; i < items.length; i++ ) {
|
* @param item item to collect expanded paths for
|
||||||
collectExandedItems( items[i], expanded );
|
* @param expanded list to add to
|
||||||
}
|
* @return whether any paths were found expanded
|
||||||
}
|
* @throws DebugException
|
||||||
}
|
*/
|
||||||
|
protected boolean collectExpandedItems(TreeItem item, List expanded) throws DebugException {
|
||||||
|
if (item.getExpanded()) {
|
||||||
|
boolean childExpanded = false;
|
||||||
|
TreeItem[] items = item.getItems();
|
||||||
|
for (int i = 0; i < items.length; i++) {
|
||||||
|
childExpanded = collectExpandedItems(items[i], expanded) || childExpanded;
|
||||||
|
}
|
||||||
|
if (!childExpanded) {
|
||||||
|
IPath path = encodeElement(item);
|
||||||
|
expanded.add(path);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs a path representing the given tree item. The segments in the
|
* Constructs a path representing the given tree item. The segments in the
|
||||||
|
@ -87,7 +107,7 @@ public abstract class AbstractViewerState {
|
||||||
* @return path encoding the given item
|
* @return path encoding the given item
|
||||||
* @throws DebugException if unable to generate a path
|
* @throws DebugException if unable to generate a path
|
||||||
*/
|
*/
|
||||||
protected abstract IPath encodeElement( TreeItem item ) throws DebugException;
|
protected abstract IPath encodeElement(TreeItem item) throws DebugException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Restores the state of the given viewer to this memento's
|
* Restores the state of the given viewer to this memento's
|
||||||
|
@ -95,41 +115,56 @@ public abstract class AbstractViewerState {
|
||||||
*
|
*
|
||||||
* @param viewer viewer to which state is restored
|
* @param viewer viewer to which state is restored
|
||||||
*/
|
*/
|
||||||
public void restoreState( TreeViewer viewer ) {
|
public void restoreState(AsynchronousTreeViewer viewer) {
|
||||||
if ( fExpandedElements != null ) {
|
boolean expansionComplete = true;
|
||||||
List expansion = new ArrayList( fExpandedElements.size() );
|
if (fSavedExpansion != null && fSavedExpansion.size() > 0) {
|
||||||
for( int i = 0; i < fExpandedElements.size(); i++ ) {
|
for (int i = 0; i < fSavedExpansion.size(); i++) {
|
||||||
IPath path = (IPath)fExpandedElements.get( i );
|
IPath path = (IPath) fSavedExpansion.get(i);
|
||||||
if ( path != null ) {
|
if (path != null) {
|
||||||
Object obj;
|
|
||||||
try {
|
try {
|
||||||
obj = decodePath( path, viewer );
|
TreePath treePath = decodePath(path, viewer);
|
||||||
if ( obj != null ) {
|
if (treePath != null) {
|
||||||
expansion.add( obj );
|
viewer.expand(new TreeSelection(new TreePath[] { treePath }));
|
||||||
|
|
||||||
|
if (treePath.getSegmentCount()-1 != path.segmentCount()) {
|
||||||
|
expansionComplete = false;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
expansionComplete =false;
|
||||||
}
|
}
|
||||||
}
|
} catch (DebugException e) {
|
||||||
catch( DebugException e ) {
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
viewer.setExpandedElements( expansion.toArray() );
|
if (expansionComplete) {
|
||||||
}
|
fSavedExpansion = null;
|
||||||
if ( fSelection != null ) {
|
|
||||||
List selection = new ArrayList( fSelection.length );
|
|
||||||
for( int i = 0; i < fSelection.length; i++ ) {
|
|
||||||
IPath path = fSelection[i];
|
|
||||||
Object obj;
|
|
||||||
try {
|
|
||||||
obj = decodePath( path, viewer );
|
|
||||||
if ( obj != null ) {
|
|
||||||
selection.add( obj );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch( DebugException e ) {
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
viewer.setSelection( new StructuredSelection( selection ) );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boolean selectionComplete = true;
|
||||||
|
if (fSelection != null && fSelection.length > 0) {
|
||||||
|
List selection = new ArrayList(fSelection.length);
|
||||||
|
for (int i = 0; i < fSelection.length; i++) {
|
||||||
|
IPath path = fSelection[i];
|
||||||
|
TreePath obj;
|
||||||
|
try {
|
||||||
|
obj = decodePath(path, viewer);
|
||||||
|
if (obj != null && obj.getSegmentCount()-1 == path.segmentCount()) {
|
||||||
|
selection.add(obj);
|
||||||
|
} else {
|
||||||
|
selectionComplete = false;
|
||||||
|
}
|
||||||
|
} catch (DebugException e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (selection.size() > 0) {
|
||||||
|
TreePath[] treePaths = (TreePath[]) selection.toArray(new TreePath[0]);
|
||||||
|
viewer.setSelection(new TreeSelection(treePaths));
|
||||||
|
}
|
||||||
|
if (selectionComplete) {
|
||||||
|
fSelection = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -141,5 +176,6 @@ public abstract class AbstractViewerState {
|
||||||
* @return element represented by the path, or <code>null</code> if none
|
* @return element represented by the path, or <code>null</code> if none
|
||||||
* @throws DebugException if unable to locate a variable
|
* @throws DebugException if unable to locate a variable
|
||||||
*/
|
*/
|
||||||
protected abstract Object decodePath( IPath path, TreeViewer viewer ) throws DebugException;
|
protected abstract TreePath decodePath(IPath path, AsynchronousTreeViewer viewer) throws DebugException;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,80 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2004 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.cdt.core.model.CModelException;
|
||||||
|
import org.eclipse.cdt.core.model.IBinary;
|
||||||
|
import org.eclipse.cdt.core.model.IParent;
|
||||||
|
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.viewers.AsynchronousTreeContentAdapter;
|
||||||
|
import org.eclipse.debug.internal.ui.viewers.IPresentationContext;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Comment for .
|
||||||
|
*/
|
||||||
|
public class ModuleTreeContentAdapter extends AsynchronousTreeContentAdapter {
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.debug.internal.ui.viewers.AsynchronousTreeContentAdapter#getChildren(java.lang.Object, org.eclipse.debug.internal.ui.viewers.IPresentationContext)
|
||||||
|
*/
|
||||||
|
protected Object[] getChildren( Object parent, IPresentationContext context ) throws CoreException {
|
||||||
|
if ( parent instanceof IModuleRetrieval ) {
|
||||||
|
return ((IModuleRetrieval)parent).getModules();
|
||||||
|
}
|
||||||
|
else if ( parent instanceof ICModule ) {
|
||||||
|
IBinary binary = (IBinary)((ICModule)parent).getAdapter( IBinary.class );
|
||||||
|
if ( binary != null ) {
|
||||||
|
try {
|
||||||
|
return binary.getChildren();
|
||||||
|
}
|
||||||
|
catch( CModelException e ) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if ( parent instanceof IParent ) {
|
||||||
|
try {
|
||||||
|
return ((IParent)parent).getChildren();
|
||||||
|
}
|
||||||
|
catch( CModelException e ) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
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 );
|
||||||
|
}
|
||||||
|
}
|
|
@ -15,27 +15,26 @@ import java.util.Iterator;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import org.eclipse.cdt.core.IAddress;
|
import org.eclipse.cdt.core.IAddress;
|
||||||
import org.eclipse.cdt.core.model.ICElement;
|
import org.eclipse.cdt.core.model.ICElement;
|
||||||
import org.eclipse.cdt.debug.core.model.ICDebugElement;
|
|
||||||
import org.eclipse.cdt.debug.core.model.ICDebugTarget;
|
import org.eclipse.cdt.debug.core.model.ICDebugTarget;
|
||||||
import org.eclipse.cdt.debug.core.model.ICModule;
|
import org.eclipse.cdt.debug.core.model.ICModule;
|
||||||
import org.eclipse.cdt.debug.internal.ui.CDebugModelPresentation;
|
import org.eclipse.cdt.debug.core.model.IModuleRetrieval;
|
||||||
import org.eclipse.cdt.debug.internal.ui.ICDebugHelpContextIds;
|
import org.eclipse.cdt.debug.internal.ui.ICDebugHelpContextIds;
|
||||||
import org.eclipse.cdt.debug.internal.ui.IInternalCDebugUIConstants;
|
import org.eclipse.cdt.debug.internal.ui.IInternalCDebugUIConstants;
|
||||||
import org.eclipse.cdt.debug.internal.ui.actions.ToggleDetailPaneAction;
|
import org.eclipse.cdt.debug.internal.ui.actions.ToggleDetailPaneAction;
|
||||||
import org.eclipse.cdt.debug.internal.ui.preferences.ICDebugPreferenceConstants;
|
import org.eclipse.cdt.debug.internal.ui.preferences.ICDebugPreferenceConstants;
|
||||||
import org.eclipse.cdt.debug.internal.ui.views.AbstractDebugEventHandler;
|
|
||||||
import org.eclipse.cdt.debug.internal.ui.views.AbstractDebugEventHandlerView;
|
|
||||||
import org.eclipse.cdt.debug.internal.ui.views.AbstractViewerState;
|
import org.eclipse.cdt.debug.internal.ui.views.AbstractViewerState;
|
||||||
import org.eclipse.cdt.debug.internal.ui.views.IDebugExceptionHandler;
|
import org.eclipse.cdt.debug.internal.ui.views.IDebugExceptionHandler;
|
||||||
import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
|
import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
|
||||||
import org.eclipse.cdt.debug.ui.ICDebugUIConstants;
|
import org.eclipse.cdt.debug.ui.ICDebugUIConstants;
|
||||||
import org.eclipse.core.runtime.IAdaptable;
|
import org.eclipse.core.runtime.IAdaptable;
|
||||||
|
import org.eclipse.core.runtime.ListenerList;
|
||||||
import org.eclipse.debug.core.DebugException;
|
import org.eclipse.debug.core.DebugException;
|
||||||
import org.eclipse.debug.core.DebugPlugin;
|
import org.eclipse.debug.core.DebugPlugin;
|
||||||
import org.eclipse.debug.core.model.IValue;
|
import org.eclipse.debug.internal.ui.contexts.DebugContextManager;
|
||||||
import org.eclipse.debug.ui.IDebugModelPresentation;
|
import org.eclipse.debug.internal.ui.contexts.IDebugContextListener;
|
||||||
|
import org.eclipse.debug.internal.ui.viewers.PresentationContext;
|
||||||
|
import org.eclipse.debug.ui.AbstractDebugView;
|
||||||
import org.eclipse.debug.ui.IDebugUIConstants;
|
import org.eclipse.debug.ui.IDebugUIConstants;
|
||||||
import org.eclipse.debug.ui.IValueDetailListener;
|
|
||||||
import org.eclipse.jface.action.IAction;
|
import org.eclipse.jface.action.IAction;
|
||||||
import org.eclipse.jface.action.IMenuListener;
|
import org.eclipse.jface.action.IMenuListener;
|
||||||
import org.eclipse.jface.action.IMenuManager;
|
import org.eclipse.jface.action.IMenuManager;
|
||||||
|
@ -54,19 +53,13 @@ import org.eclipse.jface.text.source.ISourceViewer;
|
||||||
import org.eclipse.jface.text.source.SourceViewer;
|
import org.eclipse.jface.text.source.SourceViewer;
|
||||||
import org.eclipse.jface.text.source.SourceViewerConfiguration;
|
import org.eclipse.jface.text.source.SourceViewerConfiguration;
|
||||||
import org.eclipse.jface.util.IPropertyChangeListener;
|
import org.eclipse.jface.util.IPropertyChangeListener;
|
||||||
import org.eclipse.jface.util.ListenerList;
|
|
||||||
import org.eclipse.jface.util.PropertyChangeEvent;
|
import org.eclipse.jface.util.PropertyChangeEvent;
|
||||||
import org.eclipse.jface.viewers.IBaseLabelProvider;
|
|
||||||
import org.eclipse.jface.viewers.IContentProvider;
|
|
||||||
import org.eclipse.jface.viewers.ILabelProviderListener;
|
|
||||||
import org.eclipse.jface.viewers.ISelection;
|
import org.eclipse.jface.viewers.ISelection;
|
||||||
import org.eclipse.jface.viewers.ISelectionChangedListener;
|
import org.eclipse.jface.viewers.ISelectionChangedListener;
|
||||||
import org.eclipse.jface.viewers.ISelectionProvider;
|
import org.eclipse.jface.viewers.ISelectionProvider;
|
||||||
import org.eclipse.jface.viewers.IStructuredSelection;
|
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||||
import org.eclipse.jface.viewers.SelectionChangedEvent;
|
import org.eclipse.jface.viewers.SelectionChangedEvent;
|
||||||
import org.eclipse.jface.viewers.StructuredSelection;
|
import org.eclipse.jface.viewers.StructuredSelection;
|
||||||
import org.eclipse.jface.viewers.StructuredViewer;
|
|
||||||
import org.eclipse.jface.viewers.TreeViewer;
|
|
||||||
import org.eclipse.jface.viewers.Viewer;
|
import org.eclipse.jface.viewers.Viewer;
|
||||||
import org.eclipse.swt.SWT;
|
import org.eclipse.swt.SWT;
|
||||||
import org.eclipse.swt.custom.SashForm;
|
import org.eclipse.swt.custom.SashForm;
|
||||||
|
@ -82,132 +75,22 @@ import org.eclipse.swt.widgets.Composite;
|
||||||
import org.eclipse.swt.widgets.Control;
|
import org.eclipse.swt.widgets.Control;
|
||||||
import org.eclipse.swt.widgets.Menu;
|
import org.eclipse.swt.widgets.Menu;
|
||||||
import org.eclipse.ui.IActionBars;
|
import org.eclipse.ui.IActionBars;
|
||||||
import org.eclipse.ui.IEditorInput;
|
|
||||||
import org.eclipse.ui.IMemento;
|
import org.eclipse.ui.IMemento;
|
||||||
import org.eclipse.ui.INullSelectionListener;
|
import org.eclipse.ui.INullSelectionListener;
|
||||||
import org.eclipse.ui.ISelectionListener;
|
import org.eclipse.ui.ISelectionListener;
|
||||||
import org.eclipse.ui.IViewPart;
|
|
||||||
import org.eclipse.ui.IViewSite;
|
import org.eclipse.ui.IViewSite;
|
||||||
import org.eclipse.ui.IWorkbenchActionConstants;
|
import org.eclipse.ui.IWorkbenchActionConstants;
|
||||||
import org.eclipse.ui.IWorkbenchPart;
|
import org.eclipse.ui.IWorkbenchPart;
|
||||||
import org.eclipse.ui.PartInitException;
|
import org.eclipse.ui.PartInitException;
|
||||||
import org.eclipse.ui.actions.ActionFactory;
|
import org.eclipse.ui.actions.ActionFactory;
|
||||||
import org.eclipse.ui.console.actions.TextViewerAction;
|
import org.eclipse.ui.console.actions.TextViewerAction;
|
||||||
import org.eclipse.ui.model.IWorkbenchAdapter;
|
|
||||||
import org.eclipse.ui.texteditor.IUpdate;
|
import org.eclipse.ui.texteditor.IUpdate;
|
||||||
import org.eclipse.ui.texteditor.IWorkbenchActionDefinitionIds;
|
import org.eclipse.ui.texteditor.IWorkbenchActionDefinitionIds;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Displays the modules currently loaded by the process being debugged.
|
* Displays the modules currently loaded by the process being debugged.
|
||||||
*/
|
*/
|
||||||
public class ModulesView extends AbstractDebugEventHandlerView implements IDebugExceptionHandler, IPropertyChangeListener, ISelectionListener, INullSelectionListener {
|
public class ModulesView extends AbstractDebugView implements IDebugContextListener, IDebugExceptionHandler, IPropertyChangeListener, ISelectionListener, INullSelectionListener {
|
||||||
|
|
||||||
|
|
||||||
class ModulesViewModelPresentation implements IDebugModelPresentation {
|
|
||||||
|
|
||||||
private CDebugModelPresentation fDelegate;
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.debug.ui.IDebugModelPresentation#setAttribute(java.lang.String, java.lang.Object)
|
|
||||||
*/
|
|
||||||
public void setAttribute( String attribute, Object value ) {
|
|
||||||
getModelPresentation().setAttribute( attribute, value );
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.jface.viewers.ILabelProvider#getImage(java.lang.Object)
|
|
||||||
*/
|
|
||||||
public Image getImage( Object element ) {
|
|
||||||
Image image = getModelPresentation().getImage( element );
|
|
||||||
if ( image == null ) {
|
|
||||||
if ( element instanceof IAdaptable ) {
|
|
||||||
IWorkbenchAdapter de = (IWorkbenchAdapter)((IAdaptable)element).getAdapter( IWorkbenchAdapter.class );
|
|
||||||
if ( de != null ) {
|
|
||||||
ImageDescriptor descriptor = de.getImageDescriptor( element );
|
|
||||||
if ( descriptor != null ) {
|
|
||||||
image = ModulesView.this.getImage( descriptor );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return image;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.jface.viewers.ILabelProvider#getText(java.lang.Object)
|
|
||||||
*/
|
|
||||||
public String getText( Object element ) {
|
|
||||||
String text = getModelPresentation().getText( element );
|
|
||||||
if ( text == null ) {
|
|
||||||
if ( element instanceof IAdaptable ) {
|
|
||||||
IWorkbenchAdapter de = (IWorkbenchAdapter)((IAdaptable)element).getAdapter( IWorkbenchAdapter.class );
|
|
||||||
if ( de != null ) {
|
|
||||||
text = de.getLabel( element );
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
text = element.toString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ( element instanceof ICModule ) {
|
|
||||||
ICModule module = (ICModule)element;
|
|
||||||
text += ( module.areSymbolsLoaded() ) ? ModulesMessages.getString( "ModulesView.11" ) : ModulesMessages.getString( "ModulesView.12" ); //$NON-NLS-1$ //$NON-NLS-2$
|
|
||||||
}
|
|
||||||
return text;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.debug.ui.IDebugModelPresentation#computeDetail(org.eclipse.debug.core.model.IValue, org.eclipse.debug.ui.IValueDetailListener)
|
|
||||||
*/
|
|
||||||
public void computeDetail( IValue value, IValueDetailListener listener ) {
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.debug.ui.ISourcePresentation#getEditorInput(java.lang.Object)
|
|
||||||
*/
|
|
||||||
public IEditorInput getEditorInput( Object element ) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.debug.ui.ISourcePresentation#getEditorId(org.eclipse.ui.IEditorInput, java.lang.Object)
|
|
||||||
*/
|
|
||||||
public String getEditorId( IEditorInput input, Object element ) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.jface.viewers.IBaseLabelProvider#addListener(org.eclipse.jface.viewers.ILabelProviderListener)
|
|
||||||
*/
|
|
||||||
public void addListener( ILabelProviderListener listener ) {
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.jface.viewers.IBaseLabelProvider#dispose()
|
|
||||||
*/
|
|
||||||
public void dispose() {
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.jface.viewers.IBaseLabelProvider#isLabelProperty(java.lang.Object, java.lang.String)
|
|
||||||
*/
|
|
||||||
public boolean isLabelProperty( Object element, String property ) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.jface.viewers.IBaseLabelProvider#removeListener(org.eclipse.jface.viewers.ILabelProviderListener)
|
|
||||||
*/
|
|
||||||
public void removeListener( ILabelProviderListener listener ) {
|
|
||||||
}
|
|
||||||
|
|
||||||
private CDebugModelPresentation getModelPresentation() {
|
|
||||||
if ( fDelegate == null ) {
|
|
||||||
fDelegate = CDebugModelPresentation.getDefault();
|
|
||||||
}
|
|
||||||
return fDelegate;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Internal interface for a cursor listener. I.e. aggregation
|
* Internal interface for a cursor listener. I.e. aggregation
|
||||||
|
@ -297,7 +180,7 @@ public class ModulesView extends AbstractDebugEventHandlerView implements IDebug
|
||||||
* The model presentation used as the label provider for the tree viewer,
|
* The model presentation used as the label provider for the tree viewer,
|
||||||
* and also as the detail information provider for the detail pane.
|
* and also as the detail information provider for the detail pane.
|
||||||
*/
|
*/
|
||||||
private IDebugModelPresentation fModelPresentation;
|
// private IDebugModelPresentation fModelPresentation;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remembers which viewer (tree viewer or details viewer) had focus, so we
|
* Remembers which viewer (tree viewer or details viewer) had focus, so we
|
||||||
|
@ -336,7 +219,9 @@ public class ModulesView extends AbstractDebugEventHandlerView implements IDebug
|
||||||
* @see org.eclipse.debug.ui.AbstractDebugView#createViewer(org.eclipse.swt.widgets.Composite)
|
* @see org.eclipse.debug.ui.AbstractDebugView#createViewer(org.eclipse.swt.widgets.Composite)
|
||||||
*/
|
*/
|
||||||
protected Viewer createViewer( Composite parent ) {
|
protected Viewer createViewer( Composite parent ) {
|
||||||
TreeViewer viewer = createTreeViewer( parent );
|
ModulesViewer viewer = (ModulesViewer)createTreeViewer( parent );
|
||||||
|
viewer.setContext( new PresentationContext( this ) );
|
||||||
|
|
||||||
createDetailsViewer();
|
createDetailsViewer();
|
||||||
getSashForm().setMaximizedControl( viewer.getControl() );
|
getSashForm().setMaximizedControl( viewer.getControl() );
|
||||||
|
|
||||||
|
@ -418,58 +303,80 @@ public class ModulesView extends AbstractDebugEventHandlerView implements IDebug
|
||||||
if ( selection == null )
|
if ( selection == null )
|
||||||
setViewerInput( new StructuredSelection() );
|
setViewerInput( new StructuredSelection() );
|
||||||
else if ( selection instanceof IStructuredSelection )
|
else if ( selection instanceof IStructuredSelection )
|
||||||
setViewerInput( (IStructuredSelection)selection );
|
setViewerInput( selection );
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void setViewerInput( IStructuredSelection ssel ) {
|
protected void setViewerInput( Object context ) {
|
||||||
ICDebugTarget target = null;
|
IModuleRetrieval mr = null;
|
||||||
if ( ssel.size() == 1 ) {
|
if ( context instanceof IAdaptable ) {
|
||||||
Object input = ssel.getFirstElement();
|
ICDebugTarget target = (ICDebugTarget)((IAdaptable)context).getAdapter( ICDebugTarget.class );
|
||||||
if ( input instanceof ICDebugElement ) {
|
if ( target != null )
|
||||||
target = (ICDebugTarget)((ICDebugElement)input).getDebugTarget();
|
mr = (IModuleRetrieval)target.getAdapter( IModuleRetrieval.class );
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Object current = getViewer().getInput();
|
Object current = getViewer().getInput();
|
||||||
if ( current == null && target == null ) {
|
if ( current == null && mr == null ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if ( current != null && current.equals( target ) ) {
|
if ( current != null && current.equals( mr ) ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( current != null ) {
|
if ( current != null ) {
|
||||||
// save state
|
// save state
|
||||||
fLastState = getViewerState();
|
fLastState = getViewerState();
|
||||||
fSelectionStates.put( current, fLastState );
|
cacheViewerState( current, fLastState );
|
||||||
}
|
}
|
||||||
|
|
||||||
showViewer();
|
showViewer();
|
||||||
getViewer().setInput( target );
|
getViewer().setInput( mr );
|
||||||
|
restoreState();
|
||||||
|
|
||||||
// restore state
|
//
|
||||||
if ( target != null ) {
|
// ICDebugTarget target = null;
|
||||||
AbstractViewerState state = (AbstractViewerState)fSelectionStates.get( target );
|
// if ( ssel.size() == 1 ) {
|
||||||
if ( state == null ) {
|
// Object input = ssel.getFirstElement();
|
||||||
// attempt to restore selection/expansion based on last target
|
// if ( input instanceof ICDebugElement ) {
|
||||||
state = fLastState;
|
// target = (ICDebugTarget)((ICDebugElement)input).getDebugTarget();
|
||||||
}
|
// }
|
||||||
if ( state != null ) {
|
// }
|
||||||
state.restoreState( getModulesViewer() );
|
//
|
||||||
}
|
// 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 TreeViewer createTreeViewer( Composite parent ) {
|
protected Viewer createTreeViewer( Composite parent ) {
|
||||||
CDebugUIPlugin.getDefault().getPreferenceStore().addPropertyChangeListener( this );
|
CDebugUIPlugin.getDefault().getPreferenceStore().addPropertyChangeListener( this );
|
||||||
JFaceResources.getFontRegistry().addListener( this );
|
JFaceResources.getFontRegistry().addListener( this );
|
||||||
// create the sash form that will contain the tree viewer & text viewer
|
// create the sash form that will contain the tree viewer & text viewer
|
||||||
setSashForm( new SashForm( parent, SWT.NONE ) );
|
setSashForm( new SashForm( parent, SWT.NONE ) );
|
||||||
// add tree viewer
|
// add tree viewer
|
||||||
final TreeViewer modulesViewer = new ModulesViewer( getSashForm(), SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL );
|
final ModulesViewer modulesViewer = new ModulesViewer( getSashForm(), SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL, this );
|
||||||
modulesViewer.setContentProvider( createContentProvider() );
|
modulesViewer.setUseHashlookup( false );
|
||||||
modulesViewer.setLabelProvider( createLabelProvider( modulesViewer ) );
|
|
||||||
modulesViewer.setUseHashlookup( true );
|
|
||||||
modulesViewer.getControl().addFocusListener( new FocusAdapter() {
|
modulesViewer.getControl().addFocusListener( new FocusAdapter() {
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
@ -483,9 +390,9 @@ public class ModulesView extends AbstractDebugEventHandlerView implements IDebug
|
||||||
modulesViewer.addPostSelectionChangedListener( getTreeSelectionChangedListener() );
|
modulesViewer.addPostSelectionChangedListener( getTreeSelectionChangedListener() );
|
||||||
getModulesViewSelectionProvider().setUnderlyingSelectionProvider( modulesViewer );
|
getModulesViewSelectionProvider().setUnderlyingSelectionProvider( modulesViewer );
|
||||||
getSite().setSelectionProvider( getModulesViewSelectionProvider() );
|
getSite().setSelectionProvider( getModulesViewSelectionProvider() );
|
||||||
// listen to selection in debug view
|
|
||||||
getSite().getPage().addSelectionListener( IDebugUIConstants.ID_DEBUG_VIEW, this );
|
// listen to debug context
|
||||||
setEventHandler( createEventHandler() );
|
DebugContextManager.getDefault().addDebugContextListener(this, getSite().getWorkbenchWindow());
|
||||||
return modulesViewer;
|
return modulesViewer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -537,24 +444,24 @@ public class ModulesView extends AbstractDebugEventHandlerView implements IDebug
|
||||||
fSashForm = sashForm;
|
fSashForm = sashForm;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected IContentProvider createContentProvider() {
|
// protected IContentProvider createContentProvider() {
|
||||||
ModulesViewContentProvider cp = new ModulesViewContentProvider();
|
// ModulesViewContentProvider cp = new ModulesViewContentProvider();
|
||||||
cp.setExceptionHandler( this );
|
// cp.setExceptionHandler( this );
|
||||||
return cp;
|
// return cp;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
protected IBaseLabelProvider createLabelProvider( StructuredViewer viewer ) {
|
// protected IBaseLabelProvider createLabelProvider( StructuredViewer viewer ) {
|
||||||
// return new DebugViewDecoratingLabelProvider( viewer, new DebugViewInterimLabelProvider( getModelPresentation() ), new DebugViewLabelDecorator( getModelPresentation() ) );
|
//// return new DebugViewDecoratingLabelProvider( viewer, new DebugViewInterimLabelProvider( getModelPresentation() ), new DebugViewLabelDecorator( getModelPresentation() ) );
|
||||||
return getModelPresentation();
|
// return getModelPresentation();
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
protected IDebugModelPresentation getModelPresentation() {
|
// protected IDebugModelPresentation getModelPresentation() {
|
||||||
if ( fModelPresentation == null ) {
|
// if ( fModelPresentation == null ) {
|
||||||
fModelPresentation = new ModulesViewModelPresentation();
|
// fModelPresentation = new ModulesViewModelPresentation();
|
||||||
}
|
// }
|
||||||
return fModelPresentation;
|
// return fModelPresentation;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
protected ModulesViewSelectionProvider getModulesViewSelectionProvider() {
|
protected ModulesViewSelectionProvider getModulesViewSelectionProvider() {
|
||||||
return fSelectionProvider;
|
return fSelectionProvider;
|
||||||
}
|
}
|
||||||
|
@ -671,10 +578,6 @@ public class ModulesView extends AbstractDebugEventHandlerView implements IDebug
|
||||||
return fDetailDocument;
|
return fDetailDocument;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected AbstractDebugEventHandler createEventHandler() {
|
|
||||||
return new ModulesViewEventHandler( this );
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void updateSelectionDependentActions() {
|
protected void updateSelectionDependentActions() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -686,7 +589,7 @@ public class ModulesView extends AbstractDebugEventHandlerView implements IDebug
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void createDetailContextMenu( Control menuControl ) {
|
protected void createDetailContextMenu( Control menuControl ) {
|
||||||
MenuManager menuMgr = new MenuManager(); //$NON-NLS-1$
|
MenuManager menuMgr = new MenuManager();
|
||||||
menuMgr.setRemoveAllWhenShown( true );
|
menuMgr.setRemoveAllWhenShown( true );
|
||||||
menuMgr.addMenuListener( new IMenuListener() {
|
menuMgr.addMenuListener( new IMenuListener() {
|
||||||
|
|
||||||
|
@ -886,11 +789,8 @@ public class ModulesView extends AbstractDebugEventHandlerView implements IDebug
|
||||||
*/
|
*/
|
||||||
protected void becomesVisible() {
|
protected void becomesVisible() {
|
||||||
super.becomesVisible();
|
super.becomesVisible();
|
||||||
IViewPart part = getSite().getPage().findView( IDebugUIConstants.ID_DEBUG_VIEW );
|
ISelection selection = DebugContextManager.getDefault().getActiveContext( getSite().getWorkbenchWindow() );
|
||||||
if ( part != null ) {
|
contextActivated( selection, null );
|
||||||
ISelection selection = getSite().getPage().getSelection( IDebugUIConstants.ID_DEBUG_VIEW );
|
|
||||||
selectionChanged( part, selection );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void computeDetail( final Object element ) {
|
private void computeDetail( final Object element ) {
|
||||||
|
@ -1018,4 +918,70 @@ public class ModulesView extends AbstractDebugEventHandlerView implements IDebug
|
||||||
}
|
}
|
||||||
fImageCache.clear();
|
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 );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Caches the given viewer state for the given viewer input.
|
||||||
|
*
|
||||||
|
* @param input viewer input
|
||||||
|
* @param state viewer state
|
||||||
|
*/
|
||||||
|
protected void cacheViewerState( Object input, AbstractViewerState state ) {
|
||||||
|
// generate a key for the input based on its hashcode, we don't
|
||||||
|
// want to maintain reference real model objects preventing GCs.
|
||||||
|
fSelectionStates.put( generateKey( input ), state );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generate a key for an input object.
|
||||||
|
*
|
||||||
|
* @param input
|
||||||
|
* @return key
|
||||||
|
*/
|
||||||
|
protected Object generateKey( Object input ) {
|
||||||
|
return new Integer( input.hashCode() );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the cached viewer state for the given viewer input or
|
||||||
|
* <code>null</code> if none.
|
||||||
|
*
|
||||||
|
* @param input viewer input
|
||||||
|
* @return viewer state or <code>null</code>
|
||||||
|
*/
|
||||||
|
protected AbstractViewerState getCachedViewerState( Object input ) {
|
||||||
|
return (AbstractViewerState)fSelectionStates.get( generateKey( input ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
public void contextActivated( ISelection selection, IWorkbenchPart part ) {
|
||||||
|
if ( !isAvailable() || !isVisible() ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if ( selection instanceof IStructuredSelection ) {
|
||||||
|
setViewerInput( ((IStructuredSelection)selection).getFirstElement() );
|
||||||
|
}
|
||||||
|
showViewer();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void contextChanged( ISelection selection, IWorkbenchPart part ) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,171 +0,0 @@
|
||||||
/*******************************************************************************
|
|
||||||
* Copyright (c) 2004, 2005 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 java.util.HashMap;
|
|
||||||
import org.eclipse.cdt.core.model.CModelException;
|
|
||||||
import org.eclipse.cdt.core.model.IBinary;
|
|
||||||
import org.eclipse.cdt.core.model.IParent;
|
|
||||||
import org.eclipse.cdt.debug.core.model.ICDebugTarget;
|
|
||||||
import org.eclipse.cdt.debug.core.model.ICModule;
|
|
||||||
import org.eclipse.cdt.debug.internal.ui.views.IDebugExceptionHandler;
|
|
||||||
import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
|
|
||||||
import org.eclipse.debug.core.DebugException;
|
|
||||||
import org.eclipse.jface.viewers.ITreeContentProvider;
|
|
||||||
import org.eclipse.jface.viewers.Viewer;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Provides content for the Modules view.
|
|
||||||
*/
|
|
||||||
public class ModulesViewContentProvider implements ITreeContentProvider {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A table that maps children to their parent element such that this
|
|
||||||
* content provider can walk back up the parent chain.
|
|
||||||
*/
|
|
||||||
private HashMap fParentCache;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Handler for exceptions as content is retrieved
|
|
||||||
*/
|
|
||||||
private IDebugExceptionHandler fExceptionHandler;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor for ModulesViewContentProvider.
|
|
||||||
*/
|
|
||||||
public ModulesViewContentProvider() {
|
|
||||||
setParentCache( new HashMap( 10 ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.jface.viewers.ITreeContentProvider#getChildren(java.lang.Object)
|
|
||||||
*/
|
|
||||||
public Object[] getChildren( Object parent ) {
|
|
||||||
if ( parent instanceof ICDebugTarget ) {
|
|
||||||
Object[] children = null;
|
|
||||||
ICDebugTarget target = (ICDebugTarget)parent;
|
|
||||||
try {
|
|
||||||
if ( target != null )
|
|
||||||
children = target.getModules();
|
|
||||||
if ( children != null ) {
|
|
||||||
cache( parent, children );
|
|
||||||
return children;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch( DebugException e ) {
|
|
||||||
if ( getExceptionHandler() != null )
|
|
||||||
getExceptionHandler().handleException( e );
|
|
||||||
else
|
|
||||||
CDebugUIPlugin.log( e );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if ( parent instanceof ICModule ) {
|
|
||||||
IBinary binary = (IBinary)((ICModule)parent).getAdapter( IBinary.class );
|
|
||||||
if ( binary != null ) {
|
|
||||||
try {
|
|
||||||
return binary.getChildren();
|
|
||||||
}
|
|
||||||
catch( CModelException e ) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if ( parent instanceof IParent ) {
|
|
||||||
try {
|
|
||||||
return ((IParent)parent).getChildren();
|
|
||||||
}
|
|
||||||
catch( CModelException e ) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return new Object[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.jface.viewers.ITreeContentProvider#getParent(java.lang.Object)
|
|
||||||
*/
|
|
||||||
public Object getParent( Object element ) {
|
|
||||||
return getParentCache().get( element );
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.jface.viewers.ITreeContentProvider#hasChildren(java.lang.Object)
|
|
||||||
*/
|
|
||||||
public boolean hasChildren( Object parent ) {
|
|
||||||
if ( parent instanceof ICDebugTarget ) {
|
|
||||||
try {
|
|
||||||
ICDebugTarget target = (ICDebugTarget)parent;
|
|
||||||
return target.hasModules();
|
|
||||||
}
|
|
||||||
catch( DebugException e ) {
|
|
||||||
CDebugUIPlugin.log( e );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if ( parent instanceof ICModule ) {
|
|
||||||
IBinary binary = (IBinary)((ICModule)parent).getAdapter( IBinary.class );
|
|
||||||
if ( binary != null ) {
|
|
||||||
return binary.hasChildren();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if ( parent instanceof IParent ) {
|
|
||||||
return ((IParent)parent).hasChildren();
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object)
|
|
||||||
*/
|
|
||||||
public Object[] getElements( Object inputElement ) {
|
|
||||||
return getChildren( inputElement );
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.jface.viewers.IContentProvider#dispose()
|
|
||||||
*/
|
|
||||||
public void dispose() {
|
|
||||||
setParentCache( null );
|
|
||||||
setExceptionHandler( null );
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
|
|
||||||
*/
|
|
||||||
public void inputChanged( Viewer viewer, Object oldInput, Object newInput ) {
|
|
||||||
clearCache();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void setExceptionHandler( IDebugExceptionHandler handler ) {
|
|
||||||
fExceptionHandler = handler;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected IDebugExceptionHandler getExceptionHandler() {
|
|
||||||
return fExceptionHandler;
|
|
||||||
}
|
|
||||||
|
|
||||||
private HashMap getParentCache() {
|
|
||||||
return fParentCache;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setParentCache( HashMap parentCache ) {
|
|
||||||
fParentCache = parentCache;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void cache( Object parent, Object[] children ) {
|
|
||||||
for ( int i = 0; i < children.length; i++ ) {
|
|
||||||
getParentCache().put( children[i], parent );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void clearCache() {
|
|
||||||
if ( getParentCache() != null ) {
|
|
||||||
getParentCache().clear();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2004, 2005 QNX Software Systems and others.
|
* Copyright (c) 2004 QNX Software Systems and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -11,60 +11,65 @@
|
||||||
package org.eclipse.cdt.debug.internal.ui.views.modules;
|
package org.eclipse.cdt.debug.internal.ui.views.modules;
|
||||||
|
|
||||||
import org.eclipse.cdt.debug.core.model.ICModule;
|
import org.eclipse.cdt.debug.core.model.ICModule;
|
||||||
import org.eclipse.cdt.debug.internal.ui.views.AbstractDebugEventHandler;
|
|
||||||
import org.eclipse.debug.core.DebugEvent;
|
import org.eclipse.debug.core.DebugEvent;
|
||||||
import org.eclipse.debug.core.model.IDebugTarget;
|
import org.eclipse.debug.core.model.IDebugTarget;
|
||||||
import org.eclipse.debug.ui.AbstractDebugView;
|
import org.eclipse.debug.internal.ui.viewers.AbstractModelProxy;
|
||||||
|
import org.eclipse.debug.internal.ui.viewers.IModelDelta;
|
||||||
|
import org.eclipse.debug.internal.ui.viewers.update.DebugEventHandler;
|
||||||
|
import org.eclipse.debug.internal.ui.viewers.update.ModelDelta;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates the Modules view.
|
* Comment for .
|
||||||
*/
|
*/
|
||||||
public class ModulesViewEventHandler extends AbstractDebugEventHandler {
|
public class ModulesViewEventHandler extends DebugEventHandler {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor for ModulesViewEventHandler.
|
* Constructor for ModulesViewEventHandler.
|
||||||
*/
|
*/
|
||||||
public ModulesViewEventHandler( AbstractDebugView view ) {
|
public ModulesViewEventHandler( AbstractModelProxy proxy ) {
|
||||||
super( view );
|
super( proxy );
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.debug.internal.ui.views.AbstractDebugEventHandler#doHandleDebugEvents(org.eclipse.debug.core.DebugEvent[])
|
* @see org.eclipse.debug.internal.ui.viewers.update.DebugEventHandler#handlesEvent(org.eclipse.debug.core.DebugEvent)
|
||||||
*/
|
*/
|
||||||
protected void doHandleDebugEvents( DebugEvent[] events ) {
|
protected boolean handlesEvent( DebugEvent event ) {
|
||||||
for ( int i = 0; i < events.length; i++ ) {
|
if ( event.getKind() == DebugEvent.CREATE ||
|
||||||
DebugEvent event = events[i];
|
event.getKind() == DebugEvent.TERMINATE ||
|
||||||
switch( event.getKind() ) {
|
event.getKind() == DebugEvent.CHANGE )
|
||||||
case DebugEvent.CREATE:
|
return true;
|
||||||
case DebugEvent.TERMINATE:
|
return false;
|
||||||
if ( event.getSource() instanceof IDebugTarget || event.getSource() instanceof ICModule )
|
}
|
||||||
refresh();
|
|
||||||
break;
|
/* (non-Javadoc)
|
||||||
case DebugEvent.CHANGE :
|
* @see org.eclipse.debug.internal.ui.viewers.update.DebugEventHandler#handleChange(org.eclipse.debug.core.DebugEvent)
|
||||||
if ( event.getSource() instanceof ICModule )
|
*/
|
||||||
refresh( event.getSource() );
|
protected void handleChange( DebugEvent event ) {
|
||||||
break;
|
if ( event.getSource() instanceof ICModule )
|
||||||
}
|
fireDelta( new ModelDelta( event.getSource(), IModelDelta.CHANGED | IModelDelta.STATE ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.debug.internal.ui.viewers.update.DebugEventHandler#handleCreate(org.eclipse.debug.core.DebugEvent)
|
||||||
|
*/
|
||||||
|
protected void handleCreate( DebugEvent event ) {
|
||||||
|
if ( event.getSource() instanceof IDebugTarget ) {
|
||||||
|
refreshRoot( event );
|
||||||
|
}
|
||||||
|
else if ( event.getSource() instanceof ICModule ) {
|
||||||
|
fireDelta( new ModelDelta( event.getSource(), IModelDelta.ADDED ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.debug.internal.ui.views.AbstractDebugEventHandler#refresh()
|
* @see org.eclipse.debug.internal.ui.viewers.update.DebugEventHandler#handleTerminate(org.eclipse.debug.core.DebugEvent)
|
||||||
*/
|
*/
|
||||||
public void refresh() {
|
protected void handleTerminate( DebugEvent event ) {
|
||||||
if ( isAvailable() ) {
|
if ( event.getSource() instanceof IDebugTarget ) {
|
||||||
getView().showViewer();
|
refreshRoot( event );
|
||||||
getTreeViewer().refresh();
|
|
||||||
}
|
}
|
||||||
}
|
else if ( event.getSource() instanceof ICModule ) {
|
||||||
/* (non-Javadoc)
|
fireDelta( new ModelDelta( event.getSource(), IModelDelta.REMOVED ) );
|
||||||
* @see org.eclipse.cdt.debug.internal.ui.views.AbstractDebugEventHandler#refresh(java.lang.Object)
|
|
||||||
*/
|
|
||||||
protected void refresh( Object element ) {
|
|
||||||
if ( isAvailable() ) {
|
|
||||||
getView().showViewer();
|
|
||||||
getTreeViewer().refresh( element );
|
|
||||||
getTreeViewer().setSelection( getTreeViewer().getSelection() );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,34 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2004 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.debug.internal.ui.viewers.update.DebugEventHandler;
|
||||||
|
import org.eclipse.debug.internal.ui.viewers.update.EventHandlerModelProxy;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Default update for modules view.
|
||||||
|
*/
|
||||||
|
public class ModulesViewModelProxy extends EventHandlerModelProxy {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor for ModulesViewModelProxy.
|
||||||
|
*/
|
||||||
|
public ModulesViewModelProxy() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.debug.internal.ui.viewers.update.EventHandlerModelProxy#createEventHandlers()
|
||||||
|
*/
|
||||||
|
protected DebugEventHandler[] createEventHandlers() {
|
||||||
|
return new DebugEventHandler[] { new ModulesViewEventHandler( this ) };
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2004, 2005 QNX Software Systems and others.
|
* Copyright (c) 2004 QNX Software Systems and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -10,45 +10,108 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.debug.internal.ui.views.modules;
|
package org.eclipse.cdt.debug.internal.ui.views.modules;
|
||||||
|
|
||||||
import org.eclipse.jface.viewers.ISelection;
|
import org.eclipse.cdt.debug.core.model.ICDebugTarget;
|
||||||
import org.eclipse.jface.viewers.TreeViewer;
|
import org.eclipse.cdt.debug.ui.ICDebugUIConstants;
|
||||||
|
import org.eclipse.core.runtime.IAdaptable;
|
||||||
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
|
import org.eclipse.core.runtime.IStatus;
|
||||||
|
import org.eclipse.core.runtime.Status;
|
||||||
|
import org.eclipse.debug.internal.ui.elements.adapters.AsynchronousDebugLabelAdapter;
|
||||||
|
import org.eclipse.debug.internal.ui.viewers.AsynchronousTreeViewer;
|
||||||
|
import org.eclipse.debug.internal.ui.viewers.IAsynchronousLabelAdapter;
|
||||||
|
import org.eclipse.debug.internal.ui.viewers.IAsynchronousRequestMonitor;
|
||||||
|
import org.eclipse.debug.internal.ui.viewers.IAsynchronousTreeContentAdapter;
|
||||||
|
import org.eclipse.debug.internal.ui.viewers.IModelProxy;
|
||||||
|
import org.eclipse.debug.internal.ui.viewers.IModelProxyFactory;
|
||||||
|
import org.eclipse.debug.internal.ui.viewers.IPresentationContext;
|
||||||
import org.eclipse.swt.widgets.Composite;
|
import org.eclipse.swt.widgets.Composite;
|
||||||
import org.eclipse.swt.widgets.Tree;
|
import org.eclipse.ui.IWorkbenchPart;
|
||||||
|
import org.eclipse.ui.progress.UIJob;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The modules viewer used by the Modules view.
|
* Asynchronous viewer used by the Modules view.
|
||||||
*/
|
*/
|
||||||
public class ModulesViewer extends TreeViewer {
|
public class ModulesViewer extends AsynchronousTreeViewer {
|
||||||
|
|
||||||
|
static class ModuleProxyFactory implements IModelProxyFactory {
|
||||||
|
|
||||||
/**
|
/* (non-Javadoc)
|
||||||
* Constructor for ModulesViewer.
|
* @see org.eclipse.debug.internal.ui.viewers.IModelProxyFactory#createModelProxy(java.lang.Object, org.eclipse.debug.internal.ui.viewers.IPresentationContext)
|
||||||
*/
|
*/
|
||||||
public ModulesViewer( Composite parent ) {
|
public IModelProxy createModelProxy( Object element, IPresentationContext context ) {
|
||||||
super( parent );
|
IWorkbenchPart part = context.getPart();
|
||||||
|
if ( part != null ) {
|
||||||
|
String id = part.getSite().getId();
|
||||||
|
if ( ICDebugUIConstants.ID_MODULES_VIEW.equals( id ) ) {
|
||||||
|
if ( element instanceof IAdaptable ) {
|
||||||
|
ICDebugTarget target = (ICDebugTarget)((IAdaptable)element).getAdapter( ICDebugTarget.class );
|
||||||
|
if ( target != null )
|
||||||
|
return new ModulesViewModelProxy();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static IAsynchronousLabelAdapter fgModuleLabelAdapter = new AsynchronousDebugLabelAdapter();
|
||||||
|
private static IAsynchronousTreeContentAdapter fgModuleTreeContentAdapter = new ModuleTreeContentAdapter();
|
||||||
|
private static IModelProxyFactory fgModuleProxyFactory = new ModuleProxyFactory();
|
||||||
|
|
||||||
|
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.
|
* Constructor for ModulesViewer.
|
||||||
*/
|
*/
|
||||||
public ModulesViewer( Composite parent, int style ) {
|
public ModulesViewer( Composite parent, int style, ModulesView view ) {
|
||||||
super( parent, style );
|
super( parent, style );
|
||||||
}
|
fView = view;
|
||||||
|
fRestoreJob.setSystem( true );
|
||||||
/**
|
|
||||||
* Constructor for ModulesViewer.
|
|
||||||
*/
|
|
||||||
public ModulesViewer( Tree tree ) {
|
|
||||||
super( tree );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.jface.viewers.Viewer#refresh()
|
* @see org.eclipse.debug.internal.ui.viewers.AsynchronousViewer#updateComplete(org.eclipse.debug.internal.ui.viewers.IAsynchronousRequestMonitor)
|
||||||
*/
|
*/
|
||||||
public void refresh() {
|
protected void updateComplete( IAsynchronousRequestMonitor update ) {
|
||||||
super.refresh();
|
super.updateComplete( update );
|
||||||
ISelection selection = getSelection();
|
if ( fView != null ) {
|
||||||
if ( !selection.isEmpty() ) {
|
fRestoreJob.schedule( 100 );
|
||||||
setSelection( selection );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.debug.internal.ui.viewers.AsynchronousViewer#handlePresentationFailure(org.eclipse.debug.internal.ui.viewers.IAsynchronousRequestMonitor, org.eclipse.core.runtime.IStatus)
|
||||||
|
*/
|
||||||
|
protected void handlePresentationFailure( IAsynchronousRequestMonitor update, IStatus status ) {
|
||||||
|
fView.showMessage( status.getMessage() );
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.debug.internal.ui.viewers.AsynchronousTreeViewer#getTreeContentAdapter(java.lang.Object)
|
||||||
|
*/
|
||||||
|
protected IAsynchronousTreeContentAdapter getTreeContentAdapter( Object element ) {
|
||||||
|
return fgModuleTreeContentAdapter;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.debug.internal.ui.viewers.AsynchronousViewer#getLabelAdapter(java.lang.Object)
|
||||||
|
*/
|
||||||
|
protected IAsynchronousLabelAdapter getLabelAdapter( Object element ) {
|
||||||
|
return fgModuleLabelAdapter;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.debug.internal.ui.viewers.AsynchronousViewer#getModelProxyFactoryAdapter(java.lang.Object)
|
||||||
|
*/
|
||||||
|
protected IModelProxyFactory getModelProxyFactoryAdapter( Object element ) {
|
||||||
|
return fgModuleProxyFactory;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,14 +10,15 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.debug.internal.ui.views.modules;
|
package org.eclipse.cdt.debug.internal.ui.views.modules;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.model.ICElement;
|
import java.util.ArrayList;
|
||||||
import org.eclipse.cdt.debug.core.model.ICModule;
|
import java.util.List;
|
||||||
import org.eclipse.cdt.debug.internal.ui.views.AbstractViewerState;
|
import org.eclipse.cdt.debug.internal.ui.views.AbstractViewerState;
|
||||||
import org.eclipse.core.runtime.IPath;
|
import org.eclipse.core.runtime.IPath;
|
||||||
import org.eclipse.core.runtime.Path;
|
import org.eclipse.core.runtime.Path;
|
||||||
import org.eclipse.debug.core.DebugException;
|
import org.eclipse.debug.core.DebugException;
|
||||||
import org.eclipse.jface.viewers.ITreeContentProvider;
|
import org.eclipse.debug.internal.ui.viewers.AsynchronousTreeViewer;
|
||||||
import org.eclipse.jface.viewers.TreeViewer;
|
import org.eclipse.debug.internal.ui.viewers.TreePath;
|
||||||
|
import org.eclipse.swt.widgets.Tree;
|
||||||
import org.eclipse.swt.widgets.TreeItem;
|
import org.eclipse.swt.widgets.TreeItem;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -28,7 +29,7 @@ public class ModulesViewerState extends AbstractViewerState {
|
||||||
/**
|
/**
|
||||||
* Constructor for ModulesViewerState.
|
* Constructor for ModulesViewerState.
|
||||||
*/
|
*/
|
||||||
public ModulesViewerState( TreeViewer viewer ) {
|
public ModulesViewerState( AsynchronousTreeViewer viewer ) {
|
||||||
super( viewer );
|
super( viewer );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,61 +37,46 @@ public class ModulesViewerState extends AbstractViewerState {
|
||||||
* @see org.eclipse.cdt.debug.internal.ui.views.AbstractViewerState#encodeElement(org.eclipse.swt.widgets.TreeItem)
|
* @see org.eclipse.cdt.debug.internal.ui.views.AbstractViewerState#encodeElement(org.eclipse.swt.widgets.TreeItem)
|
||||||
*/
|
*/
|
||||||
protected IPath encodeElement( TreeItem item ) throws DebugException {
|
protected IPath encodeElement( TreeItem item ) throws DebugException {
|
||||||
String name = getTreeItemName( item );
|
StringBuffer path = new StringBuffer( item.getText() );
|
||||||
IPath path = new Path( name );
|
|
||||||
TreeItem parent = item.getParentItem();
|
TreeItem parent = item.getParentItem();
|
||||||
while( parent != null ) {
|
while( parent != null ) {
|
||||||
name = getTreeItemName( parent );
|
path.insert( 0, parent.getText() + IPath.SEPARATOR );
|
||||||
path = new Path( name ).append( path );
|
|
||||||
parent = parent.getParentItem();
|
parent = parent.getParentItem();
|
||||||
}
|
}
|
||||||
return path;
|
return new Path( path.toString() );
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.debug.internal.ui.views.AbstractViewerState#decodePath(org.eclipse.core.runtime.IPath, org.eclipse.jface.viewers.TreeViewer)
|
* @see org.eclipse.cdt.debug.internal.ui.views.AbstractViewerState#decodePath(org.eclipse.core.runtime.IPath, org.eclipse.debug.internal.ui.viewers.AsynchronousTreeViewer)
|
||||||
*/
|
*/
|
||||||
protected Object decodePath( IPath path, TreeViewer viewer ) throws DebugException {
|
protected TreePath decodePath( IPath path, AsynchronousTreeViewer viewer ) throws DebugException {
|
||||||
ITreeContentProvider contentProvider = (ITreeContentProvider)viewer.getContentProvider();
|
|
||||||
String[] names = path.segments();
|
String[] names = path.segments();
|
||||||
Object parent = viewer.getInput();
|
Tree tree = viewer.getTree();
|
||||||
Object element = null;
|
TreeItem[] items = tree.getItems();
|
||||||
|
List elements = new ArrayList();
|
||||||
|
elements.add( viewer.getInput() );
|
||||||
|
boolean pathFound = false;
|
||||||
for( int i = 0; i < names.length; i++ ) {
|
for( int i = 0; i < names.length; i++ ) {
|
||||||
element = null;
|
String name = names[i];
|
||||||
Object[] children = contentProvider.getChildren( parent );
|
TreeItem item = findItem( name, items );
|
||||||
for( int j = 0; j < children.length; j++ ) {
|
if ( item != null ) {
|
||||||
String name = getElementName( children[j] );
|
pathFound = true;
|
||||||
if ( names[i].equals( name ) ) {
|
elements.add( item.getData() );
|
||||||
element = children[j];
|
items = item.getItems();
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if ( element == null ) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
parent = element;
|
|
||||||
}
|
}
|
||||||
return element;
|
if ( pathFound ) {
|
||||||
|
return new TreePath( elements.toArray() );
|
||||||
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getTreeItemName( TreeItem item ) {
|
private TreeItem findItem( String name, TreeItem[] items ) {
|
||||||
Object data = item.getData();
|
for( int i = 0; i < items.length; i++ ) {
|
||||||
String name = null;
|
TreeItem item = items[i];
|
||||||
if ( data instanceof ICModule ) {
|
if ( item.getText().equals( name ) ) {
|
||||||
name = ((ICModule)data).getName();
|
return item;
|
||||||
}
|
}
|
||||||
else if ( data instanceof ICElement ) {
|
|
||||||
name = ((ICElement)data).getElementName();
|
|
||||||
}
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
private String getElementName( Object element ) {
|
|
||||||
if ( element instanceof ICModule ) {
|
|
||||||
return ((ICModule)element).getName();
|
|
||||||
}
|
|
||||||
if ( element instanceof ICElement ) {
|
|
||||||
return ((ICElement)element).getElementName();
|
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue