mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-07 17:56:01 +02:00
Bug 173792: Modules view needs to catch up with 3.3M5. Cleanup.
This commit is contained in:
parent
a6e6bc11d3
commit
7124b790a6
6 changed files with 0 additions and 741 deletions
|
@ -1,182 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2004, 2006 QNX Software Systems and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* QNX Software Systems - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.debug.internal.ui.views;
|
||||
|
||||
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.AbstractTreeViewer;
|
||||
import org.eclipse.jface.viewers.TreePath;
|
||||
import org.eclipse.jface.viewers.TreeSelection;
|
||||
import org.eclipse.jface.viewers.TreeViewer;
|
||||
import org.eclipse.swt.widgets.TreeItem;
|
||||
|
||||
/**
|
||||
* The abstract superclass for mementos of the expanded and
|
||||
* selected items in a tree viewer.
|
||||
*/
|
||||
public abstract class AbstractViewerState {
|
||||
|
||||
// paths to expanded elements
|
||||
private List fSavedExpansion = null;
|
||||
private IPath[] fSelection;
|
||||
|
||||
/**
|
||||
* Constructs a memento for the given viewer.
|
||||
*/
|
||||
public AbstractViewerState(TreeViewer viewer) {
|
||||
saveState(viewer);
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves the current state of the given viewer into
|
||||
* this memento.
|
||||
*
|
||||
* @param viewer viewer of which to save the state
|
||||
*/
|
||||
public void saveState(TreeViewer viewer) {
|
||||
List expanded = new ArrayList();
|
||||
fSavedExpansion = null;
|
||||
TreeItem[] items = viewer.getTree().getItems();
|
||||
try {
|
||||
for (int i = 0; i < items.length; i++) {
|
||||
collectExpandedItems(items[i], expanded);
|
||||
}
|
||||
if (expanded.size() > 0) {
|
||||
fSavedExpansion = expanded;
|
||||
}
|
||||
} 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]);
|
||||
if (fSelection[i] == null) {
|
||||
fSelection = null;
|
||||
return;
|
||||
}
|
||||
}
|
||||
} catch (DebugException e) {
|
||||
fSelection = null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
* path denote parent items, and the last segment is the name of
|
||||
* the given item.
|
||||
*
|
||||
* @param item tree item to encode
|
||||
* @return path encoding the given item
|
||||
* @throws DebugException if unable to generate a path
|
||||
*/
|
||||
protected abstract IPath encodeElement(TreeItem item) throws DebugException;
|
||||
|
||||
/**
|
||||
* Restores the state of the given viewer to this memento's
|
||||
* saved state.
|
||||
*
|
||||
* @param viewer viewer to which state is restored
|
||||
*/
|
||||
public void restoreState(TreeViewer 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 {
|
||||
TreePath treePath = decodePath(path, viewer);
|
||||
if (treePath != null) {
|
||||
viewer.expandToLevel( new TreeSelection(new TreePath[] { treePath }), AbstractTreeViewer.ALL_LEVELS);
|
||||
|
||||
if (treePath.getSegmentCount()-1 != path.segmentCount()) {
|
||||
expansionComplete = false;
|
||||
}
|
||||
} else {
|
||||
expansionComplete =false;
|
||||
}
|
||||
} catch (DebugException e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (expansionComplete) {
|
||||
fSavedExpansion = null;
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an element in the given viewer that corresponds to the given
|
||||
* path, or <code>null</code> if none.
|
||||
*
|
||||
* @param path encoded element path
|
||||
* @param viewer viewer to search for the element in
|
||||
* @return element represented by the path, or <code>null</code> if none
|
||||
* @throws DebugException if unable to locate a variable
|
||||
*/
|
||||
protected abstract TreePath decodePath(IPath path, TreeViewer viewer) throws DebugException;
|
||||
|
||||
}
|
|
@ -1,97 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2000, 2005 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM Corporation - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.debug.internal.ui.views;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import org.eclipse.jface.viewers.DecoratingLabelProvider;
|
||||
import org.eclipse.jface.viewers.ILabelProvider;
|
||||
import org.eclipse.jface.viewers.StructuredViewer;
|
||||
|
||||
/**
|
||||
* A label provider which receives notification of labels computed in
|
||||
* the background by a LaunchViewLabelDecorator.
|
||||
*/
|
||||
public class DebugViewDecoratingLabelProvider extends DecoratingLabelProvider {
|
||||
|
||||
/**
|
||||
* A map of text computed for elements. Items are added to this map
|
||||
* when notification is received that text has been computed for an element
|
||||
* and they are removed the first time the text is returned for an
|
||||
* element.
|
||||
* key: Object the element
|
||||
* value: String the label text
|
||||
*/
|
||||
private Map computedText= new HashMap();
|
||||
private StructuredViewer viewer= null;
|
||||
private boolean disposed= false;
|
||||
|
||||
/**
|
||||
* @see DecoratingLabelProvider#DecoratingLabelProvider(org.eclipse.jface.viewers.ILabelProvider, org.eclipse.jface.viewers.ILabelDecorator)
|
||||
*/
|
||||
public DebugViewDecoratingLabelProvider(StructuredViewer viewer, ILabelProvider provider, DebugViewLabelDecorator decorator) {
|
||||
super(provider, decorator);
|
||||
decorator.setLabelProvider(this);
|
||||
this.viewer= viewer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Notifies this label provider that the given text was computed
|
||||
* for the given element. The given text will be returned the next
|
||||
* time its text is requested.
|
||||
*
|
||||
* @param element the element whose label was computed
|
||||
* @param text the label
|
||||
*/
|
||||
public void textComputed(Object element, String text) {
|
||||
computedText.put(element, text);
|
||||
}
|
||||
|
||||
/**
|
||||
* Labels have been computed for the given block of elements.
|
||||
* This method tells the label provider to update the
|
||||
* given elements in the view.
|
||||
*
|
||||
* @param elements the elements which have had their text computed
|
||||
*/
|
||||
public void labelsComputed(Object[] elements) {
|
||||
if (!disposed) {
|
||||
viewer.update(elements, null);
|
||||
}
|
||||
for (int i = 0; i < elements.length; i++) {
|
||||
computedText.remove(elements[i]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the stored text computed by the background decorator
|
||||
* or delegates to the decorating label provider to compute text.
|
||||
* The stored value is not cleared - the value is cleared when
|
||||
* #lablesComputed(...) has completed the update of its elements.
|
||||
*
|
||||
* @see DecoratingLabelProvider#getText(java.lang.Object)
|
||||
*/
|
||||
public String getText(Object element) {
|
||||
String text= (String) computedText.get(element);
|
||||
if (text != null) {
|
||||
return text;
|
||||
}
|
||||
return super.getText(element);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.viewers.IBaseLabelProvider#dispose()
|
||||
*/
|
||||
public void dispose() {
|
||||
disposed= true;
|
||||
super.dispose();
|
||||
}
|
||||
}
|
|
@ -1,127 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2000, 2005 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM Corporation - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.debug.internal.ui.views;
|
||||
|
||||
import org.eclipse.debug.ui.IDebugModelPresentation;
|
||||
import org.eclipse.jface.viewers.IColorProvider;
|
||||
import org.eclipse.jface.viewers.IFontProvider;
|
||||
import org.eclipse.jface.viewers.ILabelProvider;
|
||||
import org.eclipse.jface.viewers.ILabelProviderListener;
|
||||
import org.eclipse.swt.graphics.Color;
|
||||
import org.eclipse.swt.graphics.Font;
|
||||
import org.eclipse.swt.graphics.Image;
|
||||
|
||||
/**
|
||||
* A label provider that provide interim text labels. When queried for text, the label provider
|
||||
* returns a default string ("<pending...>"). When queried for images, the label provider
|
||||
* queries a debug model presentation. This label provider is intended to be passed to
|
||||
* a <code>DebugViewDecoratingLabelProvider</code>.
|
||||
*/
|
||||
public class DebugViewInterimLabelProvider implements ILabelProvider, IColorProvider, IFontProvider {
|
||||
|
||||
/**
|
||||
* The text label returned by this label provider (value: "...").
|
||||
*/
|
||||
public final static String PENDING_LABEL= "..."; //$NON-NLS-1$
|
||||
|
||||
/**
|
||||
* The debug model presentation used for computing images.
|
||||
*/
|
||||
protected IDebugModelPresentation presentation;
|
||||
|
||||
/**
|
||||
* Creates a new interim label provider with the given model presentation.
|
||||
*
|
||||
* @param presentation the model presentation to use for computing images
|
||||
*/
|
||||
public DebugViewInterimLabelProvider(IDebugModelPresentation presentation) {
|
||||
this.presentation= presentation;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the debug model presentation used by this label provider
|
||||
* to compute images.
|
||||
*
|
||||
* @return this label provider's model presentation
|
||||
*/
|
||||
public IDebugModelPresentation getPresentation() {
|
||||
return presentation;
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.viewers.ILabelProvider#getImage(java.lang.Object)
|
||||
*/
|
||||
public Image getImage(Object element) {
|
||||
return presentation.getImage(element);
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.viewers.ILabelProvider#getText(java.lang.Object)
|
||||
*/
|
||||
public String getText(Object element) {
|
||||
return DebugViewInterimLabelProvider.PENDING_LABEL;
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.viewers.IBaseLabelProvider#addListener(org.eclipse.jface.viewers.ILabelProviderListener)
|
||||
*/
|
||||
public void addListener(ILabelProviderListener listener) {
|
||||
presentation.addListener(listener);
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.viewers.IBaseLabelProvider#dispose()
|
||||
*/
|
||||
public void dispose() {
|
||||
presentation.dispose();
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.viewers.IBaseLabelProvider#isLabelProperty(java.lang.Object, java.lang.String)
|
||||
*/
|
||||
public boolean isLabelProperty(Object element, String property) {
|
||||
return presentation.isLabelProperty(element, property);
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.viewers.IBaseLabelProvider#removeListener(org.eclipse.jface.viewers.ILabelProviderListener)
|
||||
*/
|
||||
public void removeListener(ILabelProviderListener listener) {
|
||||
presentation.removeListener(listener);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.viewers.IColorProvider#getForeground(java.lang.Object)
|
||||
*/
|
||||
public Color getForeground(Object element) {
|
||||
if (presentation instanceof IColorProvider) {
|
||||
IColorProvider colorProvider = (IColorProvider) presentation;
|
||||
return colorProvider.getForeground(element);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.viewers.IColorProvider#getBackground(java.lang.Object)
|
||||
*/
|
||||
public Color getBackground(Object element) {
|
||||
if (presentation instanceof IColorProvider) {
|
||||
IColorProvider colorProvider = (IColorProvider) presentation;
|
||||
return colorProvider.getBackground(element);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.viewers.IFontProvider#getFont(java.lang.Object)
|
||||
*/
|
||||
public Font getFont(Object element) {
|
||||
if (presentation instanceof IFontProvider) {
|
||||
IFontProvider fontProvider = (IFontProvider) presentation;
|
||||
return fontProvider.getFont(element);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -1,199 +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;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Vector;
|
||||
import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
import org.eclipse.core.runtime.Status;
|
||||
import org.eclipse.core.runtime.jobs.ISchedulingRule;
|
||||
import org.eclipse.core.runtime.jobs.Job;
|
||||
import org.eclipse.debug.core.DebugEvent;
|
||||
import org.eclipse.debug.core.DebugPlugin;
|
||||
import org.eclipse.debug.core.IDebugEventSetListener;
|
||||
import org.eclipse.debug.ui.IDebugModelPresentation;
|
||||
import org.eclipse.jface.viewers.ILabelDecorator;
|
||||
import org.eclipse.jface.viewers.LabelProvider;
|
||||
import org.eclipse.swt.graphics.Image;
|
||||
|
||||
/**
|
||||
* A label decorator which computes text for debug elements
|
||||
* in the background and updates them asynchronously.
|
||||
*/
|
||||
public class DebugViewLabelDecorator extends LabelProvider implements ILabelDecorator, IDebugEventSetListener {
|
||||
|
||||
/**
|
||||
* The presentation used to compute text.
|
||||
*/
|
||||
private IDebugModelPresentation fPresentation;
|
||||
|
||||
/**
|
||||
* The label provider notified when text is computed.
|
||||
*/
|
||||
protected DebugViewDecoratingLabelProvider fLabelProvider;
|
||||
|
||||
/**
|
||||
* The job which will be executed next. All new label requests
|
||||
* are appended to this job.
|
||||
*/
|
||||
protected LabelJob fNextJob = null;
|
||||
|
||||
/**
|
||||
* Constructor for DebugViewLabelDecorator.
|
||||
*/
|
||||
public DebugViewLabelDecorator( IDebugModelPresentation presentation ) {
|
||||
fPresentation = presentation;
|
||||
DebugPlugin.getDefault().addDebugEventListener( this );
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the label provider which will be notified when a
|
||||
* label has been computed in the background.
|
||||
*
|
||||
* @param labelProvider the label provider to notify when text
|
||||
* is computed
|
||||
*/
|
||||
public void setLabelProvider( DebugViewDecoratingLabelProvider labelProvider ) {
|
||||
fLabelProvider = labelProvider;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.viewers.ILabelDecorator#decorateImage(org.eclipse.swt.graphics.Image, java.lang.Object)
|
||||
*/
|
||||
public Image decorateImage( Image image, Object element ) {
|
||||
return image;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.viewers.ILabelDecorator#decorateText(java.lang.String, java.lang.Object)
|
||||
*/
|
||||
public String decorateText( String text, final Object element ) {
|
||||
computeText( element );
|
||||
return text;
|
||||
}
|
||||
|
||||
public void computeText( Object element ) {
|
||||
synchronized( this ) {
|
||||
if ( fNextJob == null ) {
|
||||
fNextJob = new LabelJob( "Debug", fPresentation ); //$NON-NLS-1$
|
||||
}
|
||||
fNextJob.computeText( element );
|
||||
}
|
||||
}
|
||||
|
||||
public void labelsComputed( final Object[] computedElements ) {
|
||||
CDebugUIPlugin.getStandardDisplay().asyncExec(
|
||||
new Runnable() {
|
||||
|
||||
public void run() {
|
||||
fLabelProvider.labelsComputed( computedElements );
|
||||
}
|
||||
} );
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.debug.core.IDebugEventSetListener#handleDebugEvents(org.eclipse.debug.core.DebugEvent[])
|
||||
*/
|
||||
public void handleDebugEvents( DebugEvent[] events ) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.eclipse.jface.viewers.IBaseLabelProvider#dispose()
|
||||
*/
|
||||
public void dispose() {
|
||||
super.dispose();
|
||||
DebugPlugin.getDefault().removeDebugEventListener( this );
|
||||
}
|
||||
|
||||
/**
|
||||
* A job which computes text for a queue of elements. The job's label
|
||||
* decorator is notified when text has been computed for some number
|
||||
* of elements.
|
||||
*/
|
||||
protected class LabelJob extends Job implements ISchedulingRule {
|
||||
|
||||
private Vector fElementQueue = new Vector();
|
||||
private IDebugModelPresentation fJobPresentation;
|
||||
|
||||
/**
|
||||
* Creates a new job with the given name which will use the given
|
||||
* presentation to compute labels in the background
|
||||
* @param name the job's name
|
||||
* @param presentation the presentation to use for label
|
||||
* computation
|
||||
*/
|
||||
public LabelJob( String name, IDebugModelPresentation presentation ) {
|
||||
super( name );
|
||||
fJobPresentation = presentation;
|
||||
setSystem( true );
|
||||
}
|
||||
|
||||
/**
|
||||
* Queues up the given element to have its text computed.
|
||||
* @param element the element whose text should be computed
|
||||
* in this background job
|
||||
*/
|
||||
public void computeText( Object element ) {
|
||||
if ( !fElementQueue.contains( element ) ) {
|
||||
fElementQueue.add( element );
|
||||
}
|
||||
schedule();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.core.internal.jobs.InternalJob#run(org.eclipse.core.runtime.IProgressMonitor)
|
||||
*/
|
||||
public IStatus run( IProgressMonitor monitor ) {
|
||||
int numElements = fElementQueue.size();
|
||||
monitor.beginTask( MessageFormat.format( "Fetching {0} labels", new String[]{ Integer.toString( numElements ) } ), numElements ); //$NON-NLS-1$
|
||||
while( !fElementQueue.isEmpty() && !monitor.isCanceled() ) {
|
||||
StringBuffer message = new StringBuffer( MessageFormat.format( "Fetching {0} labels", new String[]{ Integer.toString( fElementQueue.size() ) } ) ); //$NON-NLS-1$
|
||||
message.append( MessageFormat.format( " ({0} pending)", new String[]{ Integer.toString( fNextJob.fElementQueue.size() ) } ) ); //$NON-NLS-1$
|
||||
monitor.setTaskName( message.toString() );
|
||||
int blockSize = 10;
|
||||
if ( fElementQueue.size() < blockSize ) {
|
||||
blockSize = fElementQueue.size();
|
||||
}
|
||||
final List computedElements = new ArrayList();
|
||||
for( int i = 0; i < blockSize; i++ ) {
|
||||
Object element = fElementQueue.remove( 0 );
|
||||
if ( element == null ) {
|
||||
break;
|
||||
}
|
||||
fLabelProvider.textComputed( element, fJobPresentation.getText( element ) );
|
||||
computedElements.add( element );
|
||||
}
|
||||
labelsComputed( computedElements.toArray() );
|
||||
monitor.worked( computedElements.size() );
|
||||
}
|
||||
monitor.done();
|
||||
return Status.OK_STATUS;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.core.runtime.jobs.ISchedulingRule#contains(org.eclipse.core.runtime.jobs.ISchedulingRule)
|
||||
*/
|
||||
public boolean contains( ISchedulingRule rule ) {
|
||||
return (rule instanceof LabelJob) && fJobPresentation == ((LabelJob)rule).fJobPresentation;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.core.runtime.jobs.ISchedulingRule#isConflicting(org.eclipse.core.runtime.jobs.ISchedulingRule)
|
||||
*/
|
||||
public boolean isConflicting( ISchedulingRule rule ) {
|
||||
return (rule instanceof LabelJob) && fJobPresentation == ((LabelJob)rule).fJobPresentation;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -27,7 +27,6 @@ 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.AbstractViewerState;
|
||||
import org.eclipse.cdt.debug.internal.ui.views.IDebugExceptionHandler;
|
||||
import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
|
||||
import org.eclipse.cdt.debug.ui.ICDebugUIConstants;
|
||||
|
@ -864,57 +863,6 @@ public class ModulesView extends AbstractDebugView implements IDebugContextListe
|
|||
fImageCache.clear();
|
||||
}
|
||||
|
||||
// protected void restoreState() {
|
||||
// ModulesViewer viewer = (ModulesViewer)getViewer();
|
||||
// if ( viewer != null ) {
|
||||
// Object context = viewer.getInput();
|
||||
// if ( context != null ) {
|
||||
// AbstractViewerState state = getCachedViewerState( context );
|
||||
// if ( state == null ) {
|
||||
// // attempt to restore selection/expansion based on last
|
||||
// // frame
|
||||
// state = fLastState;
|
||||
// }
|
||||
// if ( state != null ) {
|
||||
// state.restoreState( viewer );
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
/**
|
||||
* 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 ) {
|
||||
if ( !isAvailable() || !isVisible() ) {
|
||||
return;
|
||||
|
|
|
@ -1,84 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2004, 2006 QNX Software Systems and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* QNX Software Systems - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.debug.internal.ui.views.modules;
|
||||
|
||||
import 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.TreePath;
|
||||
import org.eclipse.jface.viewers.TreeViewer;
|
||||
import org.eclipse.swt.widgets.Tree;
|
||||
import org.eclipse.swt.widgets.TreeItem;
|
||||
|
||||
/**
|
||||
* Memento of the expanded and selected items in a modules viewer.
|
||||
*/
|
||||
public class ModulesViewerState extends AbstractViewerState {
|
||||
|
||||
/**
|
||||
* Constructor for ModulesViewerState.
|
||||
*/
|
||||
public ModulesViewerState( TreeViewer viewer ) {
|
||||
super( viewer );
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.debug.internal.ui.views.AbstractViewerState#encodeElement(org.eclipse.swt.widgets.TreeItem)
|
||||
*/
|
||||
protected IPath encodeElement( TreeItem item ) throws DebugException {
|
||||
StringBuffer path = new StringBuffer( item.getText() );
|
||||
TreeItem parent = item.getParentItem();
|
||||
while( parent != null ) {
|
||||
path.insert( 0, parent.getText() + IPath.SEPARATOR );
|
||||
parent = parent.getParentItem();
|
||||
}
|
||||
return new Path( path.toString() );
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.debug.internal.ui.views.AbstractViewerState#decodePath(org.eclipse.core.runtime.IPath, org.eclipse.debug.internal.ui.model.viewers.AsynchronousTreeModelViewer)
|
||||
*/
|
||||
protected TreePath decodePath( IPath path, TreeViewer viewer ) throws DebugException {
|
||||
String[] names = path.segments();
|
||||
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++ ) {
|
||||
String name = names[i];
|
||||
TreeItem item = findItem( name, items );
|
||||
if ( item != null ) {
|
||||
pathFound = true;
|
||||
elements.add( item.getData() );
|
||||
items = item.getItems();
|
||||
}
|
||||
}
|
||||
if ( pathFound ) {
|
||||
return new TreePath( elements.toArray() );
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
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