mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 14:42:11 +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
|
||||
Bug 109526: Support Eclipse-LazyStart and deprecate Eclipse-AutoStart.
|
||||
* MANIFEST.MF
|
||||
|
|
|
@ -24,6 +24,7 @@ public interface ICDebugTarget extends IDebugTarget,
|
|||
IResumeWithoutSignal,
|
||||
ICDebugElement,
|
||||
ISteppingModeTarget,
|
||||
IModuleRetrieval,
|
||||
ITargetProperties {
|
||||
|
||||
/**
|
||||
|
@ -64,30 +65,6 @@ public interface ICDebugTarget extends IDebugTarget,
|
|||
*/
|
||||
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
|
||||
*
|
||||
|
|
|
@ -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();
|
||||
if ( adapter.equals( ICDebugTarget.class ) )
|
||||
return getDebugTarget();
|
||||
if ( adapter.equals( IDebugTarget.class ) )
|
||||
return getDebugTarget();
|
||||
// See bug #100261
|
||||
if ( adapter.equals( IMemoryBlockRetrieval.class ) )
|
||||
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.IExecFileInfo;
|
||||
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.IRegisterDescriptor;
|
||||
import org.eclipse.cdt.debug.core.sourcelookup.CDirectorySourceContainer;
|
||||
|
@ -765,6 +766,8 @@ public class CDebugTarget extends CDebugElement implements ICDebugTarget, ICDIEv
|
|||
return getMemoryBlockRetrieval();
|
||||
if ( adapter.equals( IMemoryBlockRetrieval.class ) )
|
||||
return getMemoryBlockRetrieval();
|
||||
if ( adapter.equals( IModuleRetrieval.class ) )
|
||||
return getModuleManager();
|
||||
return super.getAdapter( adapter );
|
||||
}
|
||||
|
||||
|
@ -1591,30 +1594,6 @@ public class CDebugTarget extends CDebugElement implements ICDebugTarget, ICDIEv
|
|||
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 ) {
|
||||
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.ICDISharedLibrary;
|
||||
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.core.runtime.IStatus;
|
||||
import org.eclipse.core.runtime.MultiStatus;
|
||||
import org.eclipse.core.runtime.PlatformObject;
|
||||
import org.eclipse.core.runtime.Status;
|
||||
import org.eclipse.debug.core.DebugEvent;
|
||||
import org.eclipse.debug.core.DebugException;
|
||||
|
@ -27,7 +29,7 @@ import org.eclipse.debug.core.DebugException;
|
|||
/**
|
||||
* 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.
|
||||
|
@ -47,15 +49,15 @@ public class CModuleManager {
|
|||
fModules = new ArrayList( 5 );
|
||||
}
|
||||
|
||||
public boolean hasModules() {
|
||||
public boolean hasModules() throws DebugException {
|
||||
return !fModules.isEmpty();
|
||||
}
|
||||
|
||||
public ICModule[] getModules() {
|
||||
public ICModule[] getModules() throws DebugException {
|
||||
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$
|
||||
Iterator it = fModules.iterator();
|
||||
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
|
||||
HTMLTextPresenter implements DefaultInformationControl.IInformationPresenterExtension
|
||||
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.CDebugUtils;
|
||||
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.core.runtime.IStatus;
|
||||
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()
|
||||
*/
|
||||
protected void doAction() throws DebugException {
|
||||
final ICDebugTarget target = getDebugTarget( getView().getViewer().getInput() );
|
||||
ICDebugTarget target = getDebugTarget( getView().getViewer().getInput() );
|
||||
if ( target != null ) {
|
||||
DebugPlugin.getDefault().asyncExec(
|
||||
new Runnable() {
|
||||
|
||||
public void run() {
|
||||
try {
|
||||
target.loadSymbolsForAllModules();
|
||||
final IModuleRetrieval mr = (IModuleRetrieval)target.getAdapter( IModuleRetrieval.class );
|
||||
if ( mr != null ) {
|
||||
DebugPlugin.getDefault().asyncExec(
|
||||
new Runnable() {
|
||||
|
||||
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.
|
||||
* 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
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
*
|
||||
* Contributors:
|
||||
* QNX Software Systems - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
***********************************************************************/
|
||||
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.jface.viewers.StructuredSelection;
|
||||
import org.eclipse.jface.viewers.TreeViewer;
|
||||
import org.eclipse.debug.internal.ui.viewers.AsynchronousTreeViewer;
|
||||
import org.eclipse.debug.internal.ui.viewers.TreePath;
|
||||
import org.eclipse.debug.internal.ui.viewers.TreeSelection;
|
||||
import org.eclipse.swt.widgets.TreeItem;
|
||||
|
||||
/**
|
||||
|
@ -24,15 +27,14 @@ import org.eclipse.swt.widgets.TreeItem;
|
|||
public abstract class AbstractViewerState {
|
||||
|
||||
// paths to expanded elements
|
||||
private List fExpandedElements = null;
|
||||
// paths to selected elements
|
||||
private IPath[] fSelection = null;
|
||||
private List fSavedExpansion = null;
|
||||
private IPath[] fSelection;
|
||||
|
||||
/**
|
||||
* Constructs a memento for the given viewer.
|
||||
*/
|
||||
public AbstractViewerState( TreeViewer viewer ) {
|
||||
saveState( viewer );
|
||||
public AbstractViewerState(AsynchronousTreeViewer viewer) {
|
||||
saveState(viewer);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -41,42 +43,60 @@ public abstract class AbstractViewerState {
|
|||
*
|
||||
* @param viewer viewer of which to save the state
|
||||
*/
|
||||
public void saveState( TreeViewer viewer ) {
|
||||
public void saveState(AsynchronousTreeViewer viewer) {
|
||||
List expanded = new ArrayList();
|
||||
fExpandedElements = null;
|
||||
fSavedExpansion = null;
|
||||
TreeItem[] items = viewer.getTree().getItems();
|
||||
try {
|
||||
for( int i = 0; i < items.length; i++ ) {
|
||||
collectExandedItems( items[i], expanded );
|
||||
for (int i = 0; i < items.length; i++) {
|
||||
collectExpandedItems(items[i], expanded);
|
||||
}
|
||||
if ( expanded.size() > 0 ) {
|
||||
fExpandedElements = expanded;
|
||||
if (expanded.size() > 0) {
|
||||
fSavedExpansion = expanded;
|
||||
}
|
||||
}
|
||||
catch( DebugException e ) {
|
||||
fExpandedElements = null;
|
||||
} catch (DebugException e) {
|
||||
fSavedExpansion = null;
|
||||
}
|
||||
TreeItem[] selection = viewer.getTree().getSelection();
|
||||
fSelection = new IPath[selection.length];
|
||||
try {
|
||||
for( int i = 0; i < selection.length; i++ ) {
|
||||
fSelection[i] = encodeElement( selection[i] );
|
||||
}
|
||||
}
|
||||
catch( DebugException e ) {
|
||||
fSelection = null;
|
||||
for (int i = 0; i < selection.length; i++) {
|
||||
fSelection[i] = encodeElement(selection[i]);
|
||||
if (fSelection[i] == null) {
|
||||
fSelection = null;
|
||||
return;
|
||||
}
|
||||
}
|
||||
} catch (DebugException e) {
|
||||
fSelection = null;
|
||||
}
|
||||
}
|
||||
|
||||
protected void collectExandedItems( TreeItem item, List expanded ) throws DebugException {
|
||||
if ( item.getExpanded() ) {
|
||||
expanded.add( encodeElement( item ) );
|
||||
TreeItem[] items = item.getItems();
|
||||
for( int i = 0; i < items.length; i++ ) {
|
||||
collectExandedItems( items[i], expanded );
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Collects paths to expanded children of the given element and returns
|
||||
* whether any paths were expanded.
|
||||
*
|
||||
* @param item item to collect expanded paths for
|
||||
* @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
|
||||
|
@ -87,7 +107,7 @@ public abstract class AbstractViewerState {
|
|||
* @return path encoding the given item
|
||||
* @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
|
||||
|
@ -95,41 +115,56 @@ public abstract class AbstractViewerState {
|
|||
*
|
||||
* @param viewer viewer to which state is restored
|
||||
*/
|
||||
public void restoreState( TreeViewer viewer ) {
|
||||
if ( fExpandedElements != null ) {
|
||||
List expansion = new ArrayList( fExpandedElements.size() );
|
||||
for( int i = 0; i < fExpandedElements.size(); i++ ) {
|
||||
IPath path = (IPath)fExpandedElements.get( i );
|
||||
if ( path != null ) {
|
||||
Object obj;
|
||||
public void restoreState(AsynchronousTreeViewer viewer) {
|
||||
boolean expansionComplete = true;
|
||||
if (fSavedExpansion != null && fSavedExpansion.size() > 0) {
|
||||
for (int i = 0; i < fSavedExpansion.size(); i++) {
|
||||
IPath path = (IPath) fSavedExpansion.get(i);
|
||||
if (path != null) {
|
||||
try {
|
||||
obj = decodePath( path, viewer );
|
||||
if ( obj != null ) {
|
||||
expansion.add( obj );
|
||||
TreePath treePath = decodePath(path, viewer);
|
||||
if (treePath != null) {
|
||||
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 ( 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 ) {
|
||||
}
|
||||
if (expansionComplete) {
|
||||
fSavedExpansion = null;
|
||||
}
|
||||
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
|
||||
* @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 org.eclipse.cdt.core.IAddress;
|
||||
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.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.IInternalCDebugUIConstants;
|
||||
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.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.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.ListenerList;
|
||||
import org.eclipse.debug.core.DebugException;
|
||||
import org.eclipse.debug.core.DebugPlugin;
|
||||
import org.eclipse.debug.core.model.IValue;
|
||||
import org.eclipse.debug.ui.IDebugModelPresentation;
|
||||
import org.eclipse.debug.internal.ui.contexts.DebugContextManager;
|
||||
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.IValueDetailListener;
|
||||
import org.eclipse.jface.action.IAction;
|
||||
import org.eclipse.jface.action.IMenuListener;
|
||||
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.SourceViewerConfiguration;
|
||||
import org.eclipse.jface.util.IPropertyChangeListener;
|
||||
import org.eclipse.jface.util.ListenerList;
|
||||
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.ISelectionChangedListener;
|
||||
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.TreeViewer;
|
||||
import org.eclipse.jface.viewers.Viewer;
|
||||
import org.eclipse.swt.SWT;
|
||||
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.Menu;
|
||||
import org.eclipse.ui.IActionBars;
|
||||
import org.eclipse.ui.IEditorInput;
|
||||
import org.eclipse.ui.IMemento;
|
||||
import org.eclipse.ui.INullSelectionListener;
|
||||
import org.eclipse.ui.ISelectionListener;
|
||||
import org.eclipse.ui.IViewPart;
|
||||
import org.eclipse.ui.IViewSite;
|
||||
import org.eclipse.ui.IWorkbenchActionConstants;
|
||||
import org.eclipse.ui.IWorkbenchPart;
|
||||
import org.eclipse.ui.PartInitException;
|
||||
import org.eclipse.ui.actions.ActionFactory;
|
||||
import org.eclipse.ui.console.actions.TextViewerAction;
|
||||
import org.eclipse.ui.model.IWorkbenchAdapter;
|
||||
import org.eclipse.ui.texteditor.IUpdate;
|
||||
import org.eclipse.ui.texteditor.IWorkbenchActionDefinitionIds;
|
||||
|
||||
/**
|
||||
* Displays the modules currently loaded by the process being debugged.
|
||||
*/
|
||||
public class ModulesView extends AbstractDebugEventHandlerView implements 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;
|
||||
}
|
||||
}
|
||||
public class ModulesView extends AbstractDebugView implements IDebugContextListener, IDebugExceptionHandler, IPropertyChangeListener, ISelectionListener, INullSelectionListener {
|
||||
|
||||
/**
|
||||
* 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,
|
||||
* 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
|
||||
|
@ -336,7 +219,9 @@ public class ModulesView extends AbstractDebugEventHandlerView implements IDebug
|
|||
* @see org.eclipse.debug.ui.AbstractDebugView#createViewer(org.eclipse.swt.widgets.Composite)
|
||||
*/
|
||||
protected Viewer createViewer( Composite parent ) {
|
||||
TreeViewer viewer = createTreeViewer( parent );
|
||||
ModulesViewer viewer = (ModulesViewer)createTreeViewer( parent );
|
||||
viewer.setContext( new PresentationContext( this ) );
|
||||
|
||||
createDetailsViewer();
|
||||
getSashForm().setMaximizedControl( viewer.getControl() );
|
||||
|
||||
|
@ -418,58 +303,80 @@ public class ModulesView extends AbstractDebugEventHandlerView implements IDebug
|
|||
if ( selection == null )
|
||||
setViewerInput( new StructuredSelection() );
|
||||
else if ( selection instanceof IStructuredSelection )
|
||||
setViewerInput( (IStructuredSelection)selection );
|
||||
setViewerInput( selection );
|
||||
}
|
||||
|
||||
protected void setViewerInput( IStructuredSelection ssel ) {
|
||||
ICDebugTarget target = null;
|
||||
if ( ssel.size() == 1 ) {
|
||||
Object input = ssel.getFirstElement();
|
||||
if ( input instanceof ICDebugElement ) {
|
||||
target = (ICDebugTarget)((ICDebugElement)input).getDebugTarget();
|
||||
}
|
||||
protected void setViewerInput( Object context ) {
|
||||
IModuleRetrieval mr = null;
|
||||
if ( context instanceof IAdaptable ) {
|
||||
ICDebugTarget target = (ICDebugTarget)((IAdaptable)context).getAdapter( ICDebugTarget.class );
|
||||
if ( target != null )
|
||||
mr = (IModuleRetrieval)target.getAdapter( IModuleRetrieval.class );
|
||||
}
|
||||
|
||||
Object current = getViewer().getInput();
|
||||
if ( current == null && target == null ) {
|
||||
if ( current == null && mr == null ) {
|
||||
return;
|
||||
}
|
||||
if ( current != null && current.equals( target ) ) {
|
||||
if ( current != null && current.equals( mr ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( current != null ) {
|
||||
// save state
|
||||
fLastState = getViewerState();
|
||||
fSelectionStates.put( current, fLastState );
|
||||
}
|
||||
cacheViewerState( current, fLastState );
|
||||
}
|
||||
|
||||
showViewer();
|
||||
getViewer().setInput( target );
|
||||
getViewer().setInput( mr );
|
||||
restoreState();
|
||||
|
||||
// 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() );
|
||||
}
|
||||
}
|
||||
//
|
||||
// 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 TreeViewer createTreeViewer( Composite parent ) {
|
||||
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 ) );
|
||||
// add tree viewer
|
||||
final TreeViewer modulesViewer = new ModulesViewer( getSashForm(), SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL );
|
||||
modulesViewer.setContentProvider( createContentProvider() );
|
||||
modulesViewer.setLabelProvider( createLabelProvider( modulesViewer ) );
|
||||
modulesViewer.setUseHashlookup( true );
|
||||
final ModulesViewer modulesViewer = new ModulesViewer( getSashForm(), SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL, this );
|
||||
modulesViewer.setUseHashlookup( false );
|
||||
modulesViewer.getControl().addFocusListener( new FocusAdapter() {
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
@ -483,9 +390,9 @@ public class ModulesView extends AbstractDebugEventHandlerView implements IDebug
|
|||
modulesViewer.addPostSelectionChangedListener( getTreeSelectionChangedListener() );
|
||||
getModulesViewSelectionProvider().setUnderlyingSelectionProvider( modulesViewer );
|
||||
getSite().setSelectionProvider( getModulesViewSelectionProvider() );
|
||||
// listen to selection in debug view
|
||||
getSite().getPage().addSelectionListener( IDebugUIConstants.ID_DEBUG_VIEW, this );
|
||||
setEventHandler( createEventHandler() );
|
||||
|
||||
// listen to debug context
|
||||
DebugContextManager.getDefault().addDebugContextListener(this, getSite().getWorkbenchWindow());
|
||||
return modulesViewer;
|
||||
}
|
||||
|
||||
|
@ -537,24 +444,24 @@ public class ModulesView extends AbstractDebugEventHandlerView implements IDebug
|
|||
fSashForm = sashForm;
|
||||
}
|
||||
|
||||
protected IContentProvider createContentProvider() {
|
||||
ModulesViewContentProvider cp = new ModulesViewContentProvider();
|
||||
cp.setExceptionHandler( this );
|
||||
return cp;
|
||||
}
|
||||
|
||||
protected IBaseLabelProvider createLabelProvider( StructuredViewer viewer ) {
|
||||
// return new DebugViewDecoratingLabelProvider( viewer, new DebugViewInterimLabelProvider( getModelPresentation() ), new DebugViewLabelDecorator( getModelPresentation() ) );
|
||||
return getModelPresentation();
|
||||
}
|
||||
|
||||
protected IDebugModelPresentation getModelPresentation() {
|
||||
if ( fModelPresentation == null ) {
|
||||
fModelPresentation = new ModulesViewModelPresentation();
|
||||
}
|
||||
return fModelPresentation;
|
||||
}
|
||||
|
||||
// protected IContentProvider createContentProvider() {
|
||||
// ModulesViewContentProvider cp = new ModulesViewContentProvider();
|
||||
// cp.setExceptionHandler( this );
|
||||
// return cp;
|
||||
// }
|
||||
//
|
||||
// protected IBaseLabelProvider createLabelProvider( StructuredViewer viewer ) {
|
||||
//// return new DebugViewDecoratingLabelProvider( viewer, new DebugViewInterimLabelProvider( getModelPresentation() ), new DebugViewLabelDecorator( getModelPresentation() ) );
|
||||
// return getModelPresentation();
|
||||
// }
|
||||
//
|
||||
// protected IDebugModelPresentation getModelPresentation() {
|
||||
// if ( fModelPresentation == null ) {
|
||||
// fModelPresentation = new ModulesViewModelPresentation();
|
||||
// }
|
||||
// return fModelPresentation;
|
||||
// }
|
||||
//
|
||||
protected ModulesViewSelectionProvider getModulesViewSelectionProvider() {
|
||||
return fSelectionProvider;
|
||||
}
|
||||
|
@ -671,10 +578,6 @@ public class ModulesView extends AbstractDebugEventHandlerView implements IDebug
|
|||
return fDetailDocument;
|
||||
}
|
||||
|
||||
protected AbstractDebugEventHandler createEventHandler() {
|
||||
return new ModulesViewEventHandler( this );
|
||||
}
|
||||
|
||||
protected void updateSelectionDependentActions() {
|
||||
}
|
||||
|
||||
|
@ -686,7 +589,7 @@ public class ModulesView extends AbstractDebugEventHandlerView implements IDebug
|
|||
}
|
||||
|
||||
protected void createDetailContextMenu( Control menuControl ) {
|
||||
MenuManager menuMgr = new MenuManager(); //$NON-NLS-1$
|
||||
MenuManager menuMgr = new MenuManager();
|
||||
menuMgr.setRemoveAllWhenShown( true );
|
||||
menuMgr.addMenuListener( new IMenuListener() {
|
||||
|
||||
|
@ -886,11 +789,8 @@ public class ModulesView extends AbstractDebugEventHandlerView implements IDebug
|
|||
*/
|
||||
protected void becomesVisible() {
|
||||
super.becomesVisible();
|
||||
IViewPart part = getSite().getPage().findView( IDebugUIConstants.ID_DEBUG_VIEW );
|
||||
if ( part != null ) {
|
||||
ISelection selection = getSite().getPage().getSelection( IDebugUIConstants.ID_DEBUG_VIEW );
|
||||
selectionChanged( part, selection );
|
||||
}
|
||||
ISelection selection = DebugContextManager.getDefault().getActiveContext( getSite().getWorkbenchWindow() );
|
||||
contextActivated( selection, null );
|
||||
}
|
||||
|
||||
private void computeDetail( final Object element ) {
|
||||
|
@ -1018,4 +918,70 @@ public class ModulesView extends AbstractDebugEventHandlerView implements IDebug
|
|||
}
|
||||
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
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -11,60 +11,65 @@
|
|||
package org.eclipse.cdt.debug.internal.ui.views.modules;
|
||||
|
||||
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.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.
|
||||
*/
|
||||
public ModulesViewEventHandler( AbstractDebugView view ) {
|
||||
super( view );
|
||||
public ModulesViewEventHandler( AbstractModelProxy proxy ) {
|
||||
super( proxy );
|
||||
}
|
||||
|
||||
/* (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 ) {
|
||||
for ( int i = 0; i < events.length; i++ ) {
|
||||
DebugEvent event = events[i];
|
||||
switch( event.getKind() ) {
|
||||
case DebugEvent.CREATE:
|
||||
case DebugEvent.TERMINATE:
|
||||
if ( event.getSource() instanceof IDebugTarget || event.getSource() instanceof ICModule )
|
||||
refresh();
|
||||
break;
|
||||
case DebugEvent.CHANGE :
|
||||
if ( event.getSource() instanceof ICModule )
|
||||
refresh( event.getSource() );
|
||||
break;
|
||||
}
|
||||
protected boolean handlesEvent( DebugEvent event ) {
|
||||
if ( event.getKind() == DebugEvent.CREATE ||
|
||||
event.getKind() == DebugEvent.TERMINATE ||
|
||||
event.getKind() == DebugEvent.CHANGE )
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.debug.internal.ui.viewers.update.DebugEventHandler#handleChange(org.eclipse.debug.core.DebugEvent)
|
||||
*/
|
||||
protected void handleChange( DebugEvent event ) {
|
||||
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)
|
||||
* @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() {
|
||||
if ( isAvailable() ) {
|
||||
getView().showViewer();
|
||||
getTreeViewer().refresh();
|
||||
protected void handleTerminate( DebugEvent event ) {
|
||||
if ( event.getSource() instanceof IDebugTarget ) {
|
||||
refreshRoot( event );
|
||||
}
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @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() );
|
||||
else if ( event.getSource() instanceof ICModule ) {
|
||||
fireDelta( new ModelDelta( event.getSource(), IModelDelta.REMOVED ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -10,45 +10,108 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.cdt.debug.internal.ui.views.modules;
|
||||
|
||||
import org.eclipse.jface.viewers.ISelection;
|
||||
import org.eclipse.jface.viewers.TreeViewer;
|
||||
import org.eclipse.cdt.debug.core.model.ICDebugTarget;
|
||||
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.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 {
|
||||
|
||||
/**
|
||||
* Constructor for ModulesViewer.
|
||||
*/
|
||||
public ModulesViewer( Composite parent ) {
|
||||
super( parent );
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.debug.internal.ui.viewers.IModelProxyFactory#createModelProxy(java.lang.Object, org.eclipse.debug.internal.ui.viewers.IPresentationContext)
|
||||
*/
|
||||
public IModelProxy createModelProxy( Object element, IPresentationContext context ) {
|
||||
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.
|
||||
*/
|
||||
public ModulesViewer( Composite parent, int style ) {
|
||||
public ModulesViewer( Composite parent, int style, ModulesView view ) {
|
||||
super( parent, style );
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor for ModulesViewer.
|
||||
*/
|
||||
public ModulesViewer( Tree tree ) {
|
||||
super( tree );
|
||||
fView = view;
|
||||
fRestoreJob.setSystem( true );
|
||||
}
|
||||
|
||||
/* (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() {
|
||||
super.refresh();
|
||||
ISelection selection = getSelection();
|
||||
if ( !selection.isEmpty() ) {
|
||||
setSelection( selection );
|
||||
protected void updateComplete( IAsynchronousRequestMonitor update ) {
|
||||
super.updateComplete( update );
|
||||
if ( fView != null ) {
|
||||
fRestoreJob.schedule( 100 );
|
||||
}
|
||||
}
|
||||
|
||||
/* (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;
|
||||
|
||||
import org.eclipse.cdt.core.model.ICElement;
|
||||
import org.eclipse.cdt.debug.core.model.ICModule;
|
||||
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.jface.viewers.ITreeContentProvider;
|
||||
import org.eclipse.jface.viewers.TreeViewer;
|
||||
import org.eclipse.debug.internal.ui.viewers.AsynchronousTreeViewer;
|
||||
import org.eclipse.debug.internal.ui.viewers.TreePath;
|
||||
import org.eclipse.swt.widgets.Tree;
|
||||
import org.eclipse.swt.widgets.TreeItem;
|
||||
|
||||
/**
|
||||
|
@ -28,7 +29,7 @@ public class ModulesViewerState extends AbstractViewerState {
|
|||
/**
|
||||
* Constructor for ModulesViewerState.
|
||||
*/
|
||||
public ModulesViewerState( TreeViewer viewer ) {
|
||||
public ModulesViewerState( AsynchronousTreeViewer 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)
|
||||
*/
|
||||
protected IPath encodeElement( TreeItem item ) throws DebugException {
|
||||
String name = getTreeItemName( item );
|
||||
IPath path = new Path( name );
|
||||
StringBuffer path = new StringBuffer( item.getText() );
|
||||
TreeItem parent = item.getParentItem();
|
||||
while( parent != null ) {
|
||||
name = getTreeItemName( parent );
|
||||
path = new Path( name ).append( path );
|
||||
path.insert( 0, parent.getText() + IPath.SEPARATOR );
|
||||
parent = parent.getParentItem();
|
||||
}
|
||||
return path;
|
||||
return new Path( path.toString() );
|
||||
}
|
||||
|
||||
/* (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 {
|
||||
ITreeContentProvider contentProvider = (ITreeContentProvider)viewer.getContentProvider();
|
||||
protected TreePath decodePath( IPath path, AsynchronousTreeViewer viewer ) throws DebugException {
|
||||
String[] names = path.segments();
|
||||
Object parent = viewer.getInput();
|
||||
Object element = null;
|
||||
Tree tree = viewer.getTree();
|
||||
TreeItem[] items = tree.getItems();
|
||||
List elements = new ArrayList();
|
||||
elements.add( viewer.getInput() );
|
||||
boolean pathFound = false;
|
||||
for( int i = 0; i < names.length; i++ ) {
|
||||
element = null;
|
||||
Object[] children = contentProvider.getChildren( parent );
|
||||
for( int j = 0; j < children.length; j++ ) {
|
||||
String name = getElementName( children[j] );
|
||||
if ( names[i].equals( name ) ) {
|
||||
element = children[j];
|
||||
break;
|
||||
}
|
||||
String name = names[i];
|
||||
TreeItem item = findItem( name, items );
|
||||
if ( item != null ) {
|
||||
pathFound = true;
|
||||
elements.add( item.getData() );
|
||||
items = item.getItems();
|
||||
}
|
||||
if ( element == null ) {
|
||||
return null;
|
||||
}
|
||||
parent = element;
|
||||
}
|
||||
return element;
|
||||
if ( pathFound ) {
|
||||
return new TreePath( elements.toArray() );
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private String getTreeItemName( TreeItem item ) {
|
||||
Object data = item.getData();
|
||||
String name = null;
|
||||
if ( data instanceof ICModule ) {
|
||||
name = ((ICModule)data).getName();
|
||||
}
|
||||
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();
|
||||
private TreeItem findItem( String name, TreeItem[] items ) {
|
||||
for( int i = 0; i < items.length; i++ ) {
|
||||
TreeItem item = items[i];
|
||||
if ( item.getText().equals( name ) ) {
|
||||
return item;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue