mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-01 21:35:40 +02:00
2004-09-15 Chris Wiebe
fixed element navigation problems * browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/CBrowsingContentProvider.java * browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/CBrowsingElementFilter.java * browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/CBrowsingLabelProvider.java * browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/CBrowsingMessages.properties * browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/CBrowsingPart.java * browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/CBrowsingViewerSorter.java * browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/LexicalSortingAction.java * browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/MembersView.java * browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/MembersViewContentProvider.java * browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/NamespacesView.java * browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/NamespacesViewContentProvider.java * browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/NamespacesViewLabelProvider.java * browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/ProjectsView.java * browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/ProjectsViewContentProvider.java * browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/TypeInfoSorter.java * browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/TypesView.java * browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/TypesViewContentProvider.java * browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/TypesViewLabelProvider.java * browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/OpenTypeHierarchyUtil.java * browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/TypeHierarchyViewPart.java
This commit is contained in:
parent
e550ac872f
commit
0c9232916e
24 changed files with 434 additions and 493 deletions
|
@ -1,3 +1,27 @@
|
||||||
|
2004-09-15 Chris Wiebe
|
||||||
|
|
||||||
|
fixed element navigation problems
|
||||||
|
* browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/CBrowsingContentProvider.java
|
||||||
|
* browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/CBrowsingElementFilter.java
|
||||||
|
* browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/CBrowsingLabelProvider.java
|
||||||
|
* browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/CBrowsingMessages.properties
|
||||||
|
* browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/CBrowsingPart.java
|
||||||
|
* browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/CBrowsingViewerSorter.java
|
||||||
|
* browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/LexicalSortingAction.java
|
||||||
|
* browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/MembersView.java
|
||||||
|
* browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/MembersViewContentProvider.java
|
||||||
|
* browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/NamespacesView.java
|
||||||
|
* browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/NamespacesViewContentProvider.java
|
||||||
|
* browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/NamespacesViewLabelProvider.java
|
||||||
|
* browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/ProjectsView.java
|
||||||
|
* browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/ProjectsViewContentProvider.java
|
||||||
|
* browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/TypeInfoSorter.java
|
||||||
|
* browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/TypesView.java
|
||||||
|
* browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/TypesViewContentProvider.java
|
||||||
|
* browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/TypesViewLabelProvider.java
|
||||||
|
* browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/OpenTypeHierarchyUtil.java
|
||||||
|
* browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/TypeHierarchyViewPart.java
|
||||||
|
|
||||||
2004-09-02 Chris Wiebe
|
2004-09-02 Chris Wiebe
|
||||||
|
|
||||||
fix editor/view selection problems
|
fix editor/view selection problems
|
||||||
|
|
|
@ -26,6 +26,15 @@ import org.eclipse.swt.widgets.Display;
|
||||||
public abstract class CBrowsingContentProvider extends BaseCElementContentProvider
|
public abstract class CBrowsingContentProvider extends BaseCElementContentProvider
|
||||||
implements ITreeContentProvider, ITypeCacheChangedListener {
|
implements ITreeContentProvider, ITypeCacheChangedListener {
|
||||||
|
|
||||||
|
public static final Object CONTENT_CANCELLED = new Object();
|
||||||
|
public static final Object CONTENT_ERROR = new Object();
|
||||||
|
public static final Object CONTENT_EMPTY = new Object();
|
||||||
|
|
||||||
|
protected static final Object[] ERROR_NO_CHILDREN = new Object[] { CONTENT_ERROR };
|
||||||
|
protected static final Object[] ERROR_CANCELLED = new Object[] { CONTENT_CANCELLED };
|
||||||
|
protected static final Object[] EMPTY_CHILDREN = NO_CHILDREN;
|
||||||
|
protected static final Object[] INVALID_INPUT = NO_CHILDREN;
|
||||||
|
|
||||||
protected StructuredViewer fViewer;
|
protected StructuredViewer fViewer;
|
||||||
protected Object fInput;
|
protected Object fInput;
|
||||||
protected CBrowsingPart fBrowsingPart;
|
protected CBrowsingPart fBrowsingPart;
|
||||||
|
|
|
@ -0,0 +1,24 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* 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 Common Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/cpl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* QNX Software Systems - initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.internal.ui.browser.cbrowsing;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.browser.ITypeInfo;
|
||||||
|
import org.eclipse.cdt.internal.ui.filters.NonCElementFilter;
|
||||||
|
import org.eclipse.jface.viewers.Viewer;
|
||||||
|
|
||||||
|
public class CBrowsingElementFilter extends NonCElementFilter {
|
||||||
|
|
||||||
|
public boolean select(Viewer viewer, Object parent, Object element) {
|
||||||
|
if (element instanceof ITypeInfo)
|
||||||
|
return true;
|
||||||
|
return super.select(viewer, parent, element);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,44 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* 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 Common Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/cpl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* QNX Software Systems - initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.internal.ui.browser.cbrowsing;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.internal.ui.viewsupport.AppearanceAwareLabelProvider;
|
||||||
|
import org.eclipse.cdt.internal.ui.viewsupport.CElementImageProvider;
|
||||||
|
import org.eclipse.cdt.internal.ui.viewsupport.CElementLabels;
|
||||||
|
import org.eclipse.swt.graphics.Image;
|
||||||
|
|
||||||
|
class CBrowsingLabelProvider extends AppearanceAwareLabelProvider {
|
||||||
|
|
||||||
|
private static final int TEXTFLAGS = DEFAULT_TEXTFLAGS | CElementLabels.F_APP_TYPE_SIGNATURE;
|
||||||
|
private static final int IMAGEFLAGS = DEFAULT_IMAGEFLAGS | CElementImageProvider.SMALL_ICONS;
|
||||||
|
|
||||||
|
CBrowsingLabelProvider() {
|
||||||
|
super(TEXTFLAGS, IMAGEFLAGS);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Image getImage(Object element) {
|
||||||
|
if (element == CBrowsingContentProvider.CONTENT_ERROR) {
|
||||||
|
return null;
|
||||||
|
} else if (element == CBrowsingContentProvider.CONTENT_CANCELLED) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return super.getImage(element);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getText(Object element) {
|
||||||
|
if (element == CBrowsingContentProvider.CONTENT_ERROR) {
|
||||||
|
return CBrowsingMessages.getString("CBrowsingLabelProvider.errorNoItems"); //$NON-NLS-1$
|
||||||
|
} else if (element == CBrowsingContentProvider.CONTENT_CANCELLED) {
|
||||||
|
return CBrowsingMessages.getString("CBrowsingLabelProvider.errorCancelled"); //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
return super.getText(element);
|
||||||
|
}
|
||||||
|
}
|
|
@ -26,3 +26,6 @@ StatusBar.concat= {0}, {1}
|
||||||
|
|
||||||
ClassPathContainer.unbound_label={0} (unbound)
|
ClassPathContainer.unbound_label={0} (unbound)
|
||||||
ClassPathContainer.unknown_label={0} (unknown)
|
ClassPathContainer.unknown_label={0} (unknown)
|
||||||
|
|
||||||
|
CBrowsingLabelProvider.errorNoItems= Unable to retrieve type information
|
||||||
|
CBrowsingLabelProvider.errorCancelled= Cancelled
|
||||||
|
|
|
@ -20,6 +20,7 @@ import org.eclipse.cdt.core.browser.AllTypesCache;
|
||||||
import org.eclipse.cdt.core.browser.ITypeInfo;
|
import org.eclipse.cdt.core.browser.ITypeInfo;
|
||||||
import org.eclipse.cdt.core.browser.ITypeReference;
|
import org.eclipse.cdt.core.browser.ITypeReference;
|
||||||
import org.eclipse.cdt.core.browser.TypeSearchScope;
|
import org.eclipse.cdt.core.browser.TypeSearchScope;
|
||||||
|
import org.eclipse.cdt.core.browser.TypeUtil;
|
||||||
import org.eclipse.cdt.core.model.CModelException;
|
import org.eclipse.cdt.core.model.CModelException;
|
||||||
import org.eclipse.cdt.core.model.CoreModel;
|
import org.eclipse.cdt.core.model.CoreModel;
|
||||||
import org.eclipse.cdt.core.model.ICElement;
|
import org.eclipse.cdt.core.model.ICElement;
|
||||||
|
@ -36,6 +37,7 @@ import org.eclipse.cdt.internal.ui.util.ExceptionHandler;
|
||||||
import org.eclipse.cdt.internal.ui.viewsupport.AppearanceAwareLabelProvider;
|
import org.eclipse.cdt.internal.ui.viewsupport.AppearanceAwareLabelProvider;
|
||||||
import org.eclipse.cdt.internal.ui.viewsupport.CElementLabels;
|
import org.eclipse.cdt.internal.ui.viewsupport.CElementLabels;
|
||||||
import org.eclipse.cdt.internal.ui.viewsupport.IViewPartInputProvider;
|
import org.eclipse.cdt.internal.ui.viewsupport.IViewPartInputProvider;
|
||||||
|
import org.eclipse.cdt.internal.ui.viewsupport.StatusBarUpdater;
|
||||||
import org.eclipse.cdt.internal.ui.workingsets.WorkingSetFilterActionGroup;
|
import org.eclipse.cdt.internal.ui.workingsets.WorkingSetFilterActionGroup;
|
||||||
import org.eclipse.cdt.ui.CElementLabelProvider;
|
import org.eclipse.cdt.ui.CElementLabelProvider;
|
||||||
import org.eclipse.cdt.ui.CUIPlugin;
|
import org.eclipse.cdt.ui.CUIPlugin;
|
||||||
|
@ -61,6 +63,7 @@ import org.eclipse.jface.util.Assert;
|
||||||
import org.eclipse.jface.util.IPropertyChangeListener;
|
import org.eclipse.jface.util.IPropertyChangeListener;
|
||||||
import org.eclipse.jface.util.PropertyChangeEvent;
|
import org.eclipse.jface.util.PropertyChangeEvent;
|
||||||
import org.eclipse.jface.viewers.IContentProvider;
|
import org.eclipse.jface.viewers.IContentProvider;
|
||||||
|
import org.eclipse.jface.viewers.IElementComparer;
|
||||||
import org.eclipse.jface.viewers.ILabelProvider;
|
import org.eclipse.jface.viewers.ILabelProvider;
|
||||||
import org.eclipse.jface.viewers.IOpenListener;
|
import org.eclipse.jface.viewers.IOpenListener;
|
||||||
import org.eclipse.jface.viewers.ISelection;
|
import org.eclipse.jface.viewers.ISelection;
|
||||||
|
@ -72,6 +75,7 @@ import org.eclipse.jface.viewers.OpenEvent;
|
||||||
import org.eclipse.jface.viewers.SelectionChangedEvent;
|
import org.eclipse.jface.viewers.SelectionChangedEvent;
|
||||||
import org.eclipse.jface.viewers.StructuredSelection;
|
import org.eclipse.jface.viewers.StructuredSelection;
|
||||||
import org.eclipse.jface.viewers.StructuredViewer;
|
import org.eclipse.jface.viewers.StructuredViewer;
|
||||||
|
import org.eclipse.jface.viewers.ViewerSorter;
|
||||||
import org.eclipse.swt.SWT;
|
import org.eclipse.swt.SWT;
|
||||||
import org.eclipse.swt.events.KeyAdapter;
|
import org.eclipse.swt.events.KeyAdapter;
|
||||||
import org.eclipse.swt.events.KeyEvent;
|
import org.eclipse.swt.events.KeyEvent;
|
||||||
|
@ -303,7 +307,9 @@ public abstract class CBrowsingPart extends ViewPart implements IMenuListener, I
|
||||||
fLabelProvider= createLabelProvider();
|
fLabelProvider= createLabelProvider();
|
||||||
fViewer.setLabelProvider(fLabelProvider);
|
fViewer.setLabelProvider(fLabelProvider);
|
||||||
|
|
||||||
fViewer.setSorter(createTypeInfoSorter());
|
fViewer.setSorter(createViewerSorter());
|
||||||
|
fViewer.setComparer(createElementComparer());
|
||||||
|
|
||||||
fViewer.setUseHashlookup(true);
|
fViewer.setUseHashlookup(true);
|
||||||
fTitleProvider= createTitleProvider();
|
fTitleProvider= createTitleProvider();
|
||||||
|
|
||||||
|
@ -380,10 +386,6 @@ public abstract class CBrowsingPart extends ViewPart implements IMenuListener, I
|
||||||
// return new DecoratingCLabelProvider(provider);
|
// return new DecoratingCLabelProvider(provider);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
protected TypeInfoSorter createTypeInfoSorter() {
|
|
||||||
return new TypeInfoSorter();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected StatusBarUpdater createStatusBarUpdater(IStatusLineManager slManager) {
|
protected StatusBarUpdater createStatusBarUpdater(IStatusLineManager slManager) {
|
||||||
return new StatusBarUpdater(slManager);
|
return new StatusBarUpdater(slManager);
|
||||||
}
|
}
|
||||||
|
@ -658,9 +660,12 @@ public abstract class CBrowsingPart extends ViewPart implements IMenuListener, I
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean isProjectSourceRoot(ISourceRoot root) {
|
protected boolean isProjectSourceRoot(ISourceRoot root) {
|
||||||
IResource resource= root.getResource();
|
if (root != null) {
|
||||||
|
IResource resource = root.getResource();
|
||||||
return (resource instanceof IProject);
|
return (resource instanceof IProject);
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Answers if the given <code>element</code> is a valid
|
* Answers if the given <code>element</code> is a valid
|
||||||
|
@ -873,6 +878,12 @@ public abstract class CBrowsingPart extends ViewPart implements IMenuListener, I
|
||||||
|
|
||||||
protected abstract LabelProvider createLabelProvider();
|
protected abstract LabelProvider createLabelProvider();
|
||||||
|
|
||||||
|
protected abstract ViewerSorter createViewerSorter();
|
||||||
|
|
||||||
|
protected IElementComparer createElementComparer() {
|
||||||
|
return new CBrowsingElementComparer();
|
||||||
|
}
|
||||||
|
|
||||||
protected ILabelProvider createTitleProvider() {
|
protected ILabelProvider createTitleProvider() {
|
||||||
return new CElementLabelProvider(CElementLabelProvider.SHOW_BASICS | CElementLabelProvider.SHOW_SMALL_ICONS);
|
return new CElementLabelProvider(CElementLabelProvider.SHOW_BASICS | CElementLabelProvider.SHOW_SMALL_ICONS);
|
||||||
}
|
}
|
||||||
|
@ -1268,6 +1279,26 @@ public abstract class CBrowsingPart extends ViewPart implements IMenuListener, I
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected ICElement getTypeForTU(ITranslationUnit tu) {
|
||||||
|
tu = (ITranslationUnit) getSuitableElement(tu);
|
||||||
|
|
||||||
|
// // Use primary type if possible
|
||||||
|
// IType primaryType= cu.findPrimaryType();
|
||||||
|
// if (primaryType != null)
|
||||||
|
// return primaryType;
|
||||||
|
|
||||||
|
// Use first top-level type
|
||||||
|
try {
|
||||||
|
ICElement[] types = TypeUtil.getTypes(tu);
|
||||||
|
if (types.length > 0)
|
||||||
|
return types[0];
|
||||||
|
else
|
||||||
|
return null;
|
||||||
|
} catch (CModelException ex) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected final Object getSingleElementFromSelection(ISelection selection) {
|
protected final Object getSingleElementFromSelection(ISelection selection) {
|
||||||
if (!(selection instanceof StructuredSelection) || selection.isEmpty())
|
if (!(selection instanceof StructuredSelection) || selection.isEmpty())
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* 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 Common Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/cpl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* QNX Software Systems - initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.internal.ui.browser.cbrowsing;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.ui.CElementSorter;
|
||||||
|
|
||||||
|
public class CBrowsingViewerSorter extends CElementSorter {
|
||||||
|
|
||||||
|
public CBrowsingViewerSorter() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,57 +0,0 @@
|
||||||
/*******************************************************************************
|
|
||||||
* Copyright (c) 2000, 2004 IBM Corporation and others.
|
|
||||||
* All rights reserved. This program and the accompanying materials
|
|
||||||
* are made available under the terms of the Common Public License v1.0
|
|
||||||
* which accompanies this distribution, and is available at
|
|
||||||
* http://www.eclipse.org/legal/cpl-v10.html
|
|
||||||
*
|
|
||||||
* Contributors:
|
|
||||||
* IBM Corporation - initial API and implementation
|
|
||||||
*******************************************************************************/
|
|
||||||
package org.eclipse.cdt.internal.ui.browser.cbrowsing;
|
|
||||||
|
|
||||||
import org.eclipse.swt.widgets.Control;
|
|
||||||
|
|
||||||
import org.eclipse.jface.util.Assert;
|
|
||||||
import org.eclipse.jface.viewers.StructuredViewer;
|
|
||||||
|
|
||||||
import org.eclipse.core.resources.IResourceChangeEvent;
|
|
||||||
import org.eclipse.core.resources.IResourceChangeListener;
|
|
||||||
import org.eclipse.core.resources.IResourceDelta;
|
|
||||||
|
|
||||||
|
|
||||||
public class FilterUpdater implements IResourceChangeListener {
|
|
||||||
|
|
||||||
private StructuredViewer fViewer;
|
|
||||||
|
|
||||||
public FilterUpdater(StructuredViewer viewer) {
|
|
||||||
Assert.isNotNull(viewer);
|
|
||||||
fViewer= viewer;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.core.resources.IResourceChangeListener#resourceChanged(org.eclipse.core.resources.IResourceChangeEvent)
|
|
||||||
*/
|
|
||||||
public void resourceChanged(IResourceChangeEvent event) {
|
|
||||||
IResourceDelta delta= event.getDelta();
|
|
||||||
if (delta == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
IResourceDelta[] projDeltas = delta.getAffectedChildren(IResourceDelta.CHANGED);
|
|
||||||
for (int i= 0; i < projDeltas.length; i++) {
|
|
||||||
IResourceDelta pDelta= projDeltas[i];
|
|
||||||
if ((pDelta.getFlags() & IResourceDelta.DESCRIPTION) != 0) {
|
|
||||||
final Control ctrl= fViewer.getControl();
|
|
||||||
if (ctrl != null && !ctrl.isDisposed()) {
|
|
||||||
// async is needed due to bug 33783
|
|
||||||
ctrl.getDisplay().asyncExec(new Runnable() {
|
|
||||||
public void run() {
|
|
||||||
if (!ctrl.isDisposed())
|
|
||||||
fViewer.refresh(false);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -23,7 +23,7 @@ import org.eclipse.ui.help.WorkbenchHelp;
|
||||||
* which should be renamed to MemberActionsGroup
|
* which should be renamed to MemberActionsGroup
|
||||||
*/
|
*/
|
||||||
public class LexicalSortingAction extends Action {
|
public class LexicalSortingAction extends Action {
|
||||||
private TypeInfoSorter fSorter= new TypeInfoSorter();
|
private CBrowsingViewerSorter fSorter= new CBrowsingViewerSorter();
|
||||||
private StructuredViewer fViewer;
|
private StructuredViewer fViewer;
|
||||||
private String fPreferenceKey;
|
private String fPreferenceKey;
|
||||||
|
|
||||||
|
|
|
@ -16,11 +16,10 @@ import org.eclipse.cdt.core.browser.TypeUtil;
|
||||||
import org.eclipse.cdt.core.model.ICElement;
|
import org.eclipse.cdt.core.model.ICElement;
|
||||||
import org.eclipse.cdt.core.model.ICModel;
|
import org.eclipse.cdt.core.model.ICModel;
|
||||||
import org.eclipse.cdt.core.model.ICProject;
|
import org.eclipse.cdt.core.model.ICProject;
|
||||||
|
import org.eclipse.cdt.core.model.INamespace;
|
||||||
import org.eclipse.cdt.core.model.ISourceRoot;
|
import org.eclipse.cdt.core.model.ISourceRoot;
|
||||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||||
import org.eclipse.cdt.internal.ui.ICHelpContextIds;
|
import org.eclipse.cdt.internal.ui.ICHelpContextIds;
|
||||||
import org.eclipse.cdt.internal.ui.viewsupport.AppearanceAwareLabelProvider;
|
|
||||||
import org.eclipse.cdt.internal.ui.viewsupport.CElementLabels;
|
|
||||||
import org.eclipse.cdt.ui.CUIPlugin;
|
import org.eclipse.cdt.ui.CUIPlugin;
|
||||||
import org.eclipse.cdt.ui.PreferenceConstants;
|
import org.eclipse.cdt.ui.PreferenceConstants;
|
||||||
import org.eclipse.jface.action.IToolBarManager;
|
import org.eclipse.jface.action.IToolBarManager;
|
||||||
|
@ -33,6 +32,7 @@ import org.eclipse.jface.viewers.IStructuredSelection;
|
||||||
import org.eclipse.jface.viewers.LabelProvider;
|
import org.eclipse.jface.viewers.LabelProvider;
|
||||||
import org.eclipse.jface.viewers.StructuredViewer;
|
import org.eclipse.jface.viewers.StructuredViewer;
|
||||||
import org.eclipse.jface.viewers.TreeViewer;
|
import org.eclipse.jface.viewers.TreeViewer;
|
||||||
|
import org.eclipse.jface.viewers.ViewerSorter;
|
||||||
import org.eclipse.swt.SWT;
|
import org.eclipse.swt.SWT;
|
||||||
import org.eclipse.swt.widgets.Composite;
|
import org.eclipse.swt.widgets.Composite;
|
||||||
import org.eclipse.ui.IEditorPart;
|
import org.eclipse.ui.IEditorPart;
|
||||||
|
@ -72,10 +72,7 @@ public class MembersView extends CBrowsingPart implements IPropertyChangeListene
|
||||||
* @see org.eclipse.jface.viewers.ILabelProvider
|
* @see org.eclipse.jface.viewers.ILabelProvider
|
||||||
*/
|
*/
|
||||||
protected LabelProvider createLabelProvider() {
|
protected LabelProvider createLabelProvider() {
|
||||||
return new AppearanceAwareLabelProvider(
|
return new CBrowsingLabelProvider();
|
||||||
AppearanceAwareLabelProvider.DEFAULT_TEXTFLAGS | CElementLabels.F_APP_TYPE_SIGNATURE,
|
|
||||||
AppearanceAwareLabelProvider.DEFAULT_IMAGEFLAGS
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -102,6 +99,18 @@ public class MembersView extends CBrowsingPart implements IPropertyChangeListene
|
||||||
return viewer;
|
return viewer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected ViewerSorter createViewerSorter() {
|
||||||
|
return new CBrowsingViewerSorter();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds filters the viewer of this part.
|
||||||
|
*/
|
||||||
|
protected void addFilters() {
|
||||||
|
super.addFilters();
|
||||||
|
getViewer().addFilter(new CBrowsingElementFilter());
|
||||||
|
}
|
||||||
|
|
||||||
protected void fillToolBar(IToolBarManager tbm) {
|
protected void fillToolBar(IToolBarManager tbm) {
|
||||||
tbm.add(new LexicalSortingAction(getViewer(), CUIPlugin.ID_MEMBERS_VIEW));
|
tbm.add(new LexicalSortingAction(getViewer(), CUIPlugin.ID_MEMBERS_VIEW));
|
||||||
// fMemberFilterActionGroup.contributeToToolBar(tbm);
|
// fMemberFilterActionGroup.contributeToToolBar(tbm);
|
||||||
|
@ -215,9 +224,6 @@ public class MembersView extends CBrowsingPart implements IPropertyChangeListene
|
||||||
return new MembersViewContentProvider(this);
|
return new MembersViewContentProvider(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.internal.ui.browser.cbrowsing.CBrowsingPart#findInputForElement(java.lang.Object)
|
|
||||||
*/
|
|
||||||
protected Object findInputForElement(Object element) {
|
protected Object findInputForElement(Object element) {
|
||||||
if (element instanceof ICModel || element instanceof ICProject || element instanceof ISourceRoot) {
|
if (element instanceof ICModel || element instanceof ICProject || element instanceof ISourceRoot) {
|
||||||
return null;
|
return null;
|
||||||
|
@ -227,16 +233,25 @@ public class MembersView extends CBrowsingPart implements IPropertyChangeListene
|
||||||
return element;
|
return element;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (element instanceof ICElement && !(element instanceof ITranslationUnit)) {
|
if (element instanceof ICElement) {
|
||||||
ICElement parent = TypeUtil.getDeclaringContainerType((ICElement)element);
|
ICElement celem = (ICElement)element;
|
||||||
if (parent != null) {
|
if (!celem.exists())
|
||||||
ITypeInfo info = AllTypesCache.getTypeForElement(parent, true, true, null);
|
|
||||||
if (info != null)
|
|
||||||
return info;
|
|
||||||
}
|
|
||||||
return null;
|
return null;
|
||||||
}
|
|
||||||
|
|
||||||
|
if (TypeUtil.isDeclaringType(celem)) {
|
||||||
|
ICElement type= TypeUtil.getDeclaringType(celem);
|
||||||
|
if (type == null || type instanceof INamespace)
|
||||||
|
return AllTypesCache.getTypeForElement(celem, true, true, null);
|
||||||
|
else
|
||||||
|
return findInputForElement(type);
|
||||||
|
} else if (TypeUtil.isMemberType(celem)) {
|
||||||
|
return findInputForElement(TypeUtil.getDeclaringType(celem));
|
||||||
|
} else {
|
||||||
|
ITranslationUnit tu = TypeUtil.getTranslationUnit(celem);
|
||||||
|
if (tu != null)
|
||||||
|
return getTypeForTU(tu);
|
||||||
|
}
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,16 +10,17 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.ui.browser.cbrowsing;
|
package org.eclipse.cdt.internal.ui.browser.cbrowsing;
|
||||||
|
|
||||||
import java.util.Iterator;
|
|
||||||
|
|
||||||
import org.eclipse.cdt.core.browser.AllTypesCache;
|
import org.eclipse.cdt.core.browser.AllTypesCache;
|
||||||
import org.eclipse.cdt.core.browser.ITypeInfo;
|
import org.eclipse.cdt.core.browser.ITypeInfo;
|
||||||
|
import org.eclipse.cdt.core.browser.TypeUtil;
|
||||||
import org.eclipse.cdt.core.model.CModelException;
|
import org.eclipse.cdt.core.model.CModelException;
|
||||||
import org.eclipse.cdt.core.model.ICElement;
|
import org.eclipse.cdt.core.model.ICElement;
|
||||||
|
import org.eclipse.cdt.core.model.ICModel;
|
||||||
|
import org.eclipse.cdt.core.model.ICProject;
|
||||||
|
import org.eclipse.cdt.core.model.INamespace;
|
||||||
import org.eclipse.cdt.core.model.IParent;
|
import org.eclipse.cdt.core.model.IParent;
|
||||||
|
import org.eclipse.cdt.core.model.ISourceRoot;
|
||||||
import org.eclipse.cdt.ui.CUIPlugin;
|
import org.eclipse.cdt.ui.CUIPlugin;
|
||||||
import org.eclipse.jface.util.Assert;
|
|
||||||
import org.eclipse.jface.viewers.IStructuredSelection;
|
|
||||||
import org.eclipse.swt.widgets.Shell;
|
import org.eclipse.swt.widgets.Shell;
|
||||||
|
|
||||||
class MembersViewContentProvider extends CBrowsingContentProvider {
|
class MembersViewContentProvider extends CBrowsingContentProvider {
|
||||||
|
@ -61,48 +62,43 @@ class MembersViewContentProvider extends CBrowsingContentProvider {
|
||||||
*/
|
*/
|
||||||
public Object[] getChildren(Object element) {
|
public Object[] getChildren(Object element) {
|
||||||
if (element == null || (element instanceof ICElement && !((ICElement)element).exists())) {
|
if (element == null || (element instanceof ICElement && !((ICElement)element).exists())) {
|
||||||
return NO_CHILDREN;
|
return INVALID_INPUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
startReadInDisplayThread();
|
startReadInDisplayThread();
|
||||||
|
|
||||||
if (element instanceof IStructuredSelection) {
|
|
||||||
Assert.isLegal(false);
|
|
||||||
Object[] result= new Object[0];
|
|
||||||
Class clazz= null;
|
|
||||||
Iterator iter= ((IStructuredSelection)element).iterator();
|
|
||||||
while (iter.hasNext()) {
|
|
||||||
Object item= iter.next();
|
|
||||||
if (clazz == null)
|
|
||||||
clazz= item.getClass();
|
|
||||||
if (clazz == item.getClass())
|
|
||||||
result= concatenate(result, getChildren(item));
|
|
||||||
else
|
|
||||||
return NO_CHILDREN;
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (element instanceof ITypeInfo) {
|
if (element instanceof ITypeInfo) {
|
||||||
ITypeInfo info = (ITypeInfo) element;
|
ITypeInfo info = (ITypeInfo) element;
|
||||||
if (info.getCElementType() == ICElement.C_NAMESPACE) {
|
if (info.getCElementType() == ICElement.C_NAMESPACE) {
|
||||||
return NO_CHILDREN; // shouldn't get here...
|
return INVALID_INPUT; // shouldn't get here...
|
||||||
|
}
|
||||||
|
if (info.getCElementType() == ICElement.C_TYPEDEF) {
|
||||||
|
return EMPTY_CHILDREN;
|
||||||
}
|
}
|
||||||
ICElement elem = AllTypesCache.getElementForType(info, true, true, null);
|
ICElement elem = AllTypesCache.getElementForType(info, true, true, null);
|
||||||
if (elem != null && elem instanceof IParent) {
|
if (elem == null) {
|
||||||
return ((IParent)elem).getChildren();
|
return ERROR_NO_CHILDREN;
|
||||||
|
} else {
|
||||||
|
if (elem instanceof IParent) {
|
||||||
|
ICElement[] children = ((IParent)elem).getChildren();
|
||||||
|
if (children != null && children.length > 0)
|
||||||
|
return children;
|
||||||
|
}
|
||||||
|
return EMPTY_CHILDREN;
|
||||||
}
|
}
|
||||||
return NO_CHILDREN;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (element instanceof IParent) {
|
if (element instanceof IParent) {
|
||||||
return ((IParent)element).getChildren();
|
ICElement[] children = ((IParent)element).getChildren();
|
||||||
|
if (children != null && children.length > 0)
|
||||||
|
return children;
|
||||||
|
return EMPTY_CHILDREN;
|
||||||
}
|
}
|
||||||
|
|
||||||
return NO_CHILDREN;
|
return INVALID_INPUT;
|
||||||
} catch (CModelException e) {
|
} catch (CModelException e) {
|
||||||
return NO_CHILDREN;
|
return ERROR_CANCELLED;
|
||||||
} finally {
|
} finally {
|
||||||
finishedReadInDisplayThread();
|
finishedReadInDisplayThread();
|
||||||
}
|
}
|
||||||
|
@ -112,8 +108,7 @@ class MembersViewContentProvider extends CBrowsingContentProvider {
|
||||||
* @see org.eclipse.jface.viewers.ITreeContentProvider#getParent(java.lang.Object)
|
* @see org.eclipse.jface.viewers.ITreeContentProvider#getParent(java.lang.Object)
|
||||||
*/
|
*/
|
||||||
public Object getParent(Object element) {
|
public Object getParent(Object element) {
|
||||||
return fInput;
|
if (element instanceof ICModel || element instanceof ICProject || element instanceof ISourceRoot) {
|
||||||
/* if (element instanceof ICModel || element instanceof ICProject || element instanceof ISourceRoot) {
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -125,9 +120,16 @@ class MembersViewContentProvider extends CBrowsingContentProvider {
|
||||||
startReadInDisplayThread();
|
startReadInDisplayThread();
|
||||||
|
|
||||||
if (element instanceof ICElement) {
|
if (element instanceof ICElement) {
|
||||||
ICElement parent = ((ICElement)element).getParent();
|
ICElement celem = (ICElement)element;
|
||||||
if (parent != null)
|
if (TypeUtil.isMemberType(celem)) {
|
||||||
return AllTypesCache.getTypeForElement(parent, true, true, null);
|
ICElement parent = TypeUtil.getDeclaringType(celem);
|
||||||
|
if (parent == null || parent instanceof INamespace) {
|
||||||
|
ITypeInfo info = AllTypesCache.getTypeForElement(celem, true, true, null);
|
||||||
|
if (info != null)
|
||||||
|
return info.getEnclosingType();
|
||||||
|
}
|
||||||
|
return parent;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
@ -136,7 +138,7 @@ class MembersViewContentProvider extends CBrowsingContentProvider {
|
||||||
} finally {
|
} finally {
|
||||||
finishedReadInDisplayThread();
|
finishedReadInDisplayThread();
|
||||||
}
|
}
|
||||||
*/ }
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object)
|
* @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object)
|
||||||
|
|
|
@ -23,11 +23,11 @@ import org.eclipse.cdt.core.model.ITypeDef;
|
||||||
import org.eclipse.cdt.internal.ui.ICHelpContextIds;
|
import org.eclipse.cdt.internal.ui.ICHelpContextIds;
|
||||||
import org.eclipse.cdt.ui.CUIPlugin;
|
import org.eclipse.cdt.ui.CUIPlugin;
|
||||||
import org.eclipse.cdt.ui.PreferenceConstants;
|
import org.eclipse.cdt.ui.PreferenceConstants;
|
||||||
import org.eclipse.cdt.ui.browser.typeinfo.TypeInfoLabelProvider;
|
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
import org.eclipse.jface.viewers.IContentProvider;
|
import org.eclipse.jface.viewers.IContentProvider;
|
||||||
import org.eclipse.jface.viewers.LabelProvider;
|
import org.eclipse.jface.viewers.LabelProvider;
|
||||||
import org.eclipse.jface.viewers.StructuredViewer;
|
import org.eclipse.jface.viewers.StructuredViewer;
|
||||||
|
import org.eclipse.jface.viewers.ViewerSorter;
|
||||||
import org.eclipse.swt.SWT;
|
import org.eclipse.swt.SWT;
|
||||||
import org.eclipse.swt.widgets.Composite;
|
import org.eclipse.swt.widgets.Composite;
|
||||||
import org.eclipse.ui.IActionBars;
|
import org.eclipse.ui.IActionBars;
|
||||||
|
@ -45,7 +45,7 @@ public class NamespacesView extends CBrowsingPart {
|
||||||
* @see org.eclipse.jface.viewers.ILabelProvider
|
* @see org.eclipse.jface.viewers.ILabelProvider
|
||||||
*/
|
*/
|
||||||
protected LabelProvider createLabelProvider() {
|
protected LabelProvider createLabelProvider() {
|
||||||
return new TypeInfoLabelProvider(TypeInfoLabelProvider.SHOW_FULLY_QUALIFIED);
|
return new NamespacesViewLabelProvider();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -91,14 +91,16 @@ public class NamespacesView extends CBrowsingPart {
|
||||||
return new NamespacesViewContentProvider(this);
|
return new NamespacesViewContentProvider(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected ViewerSorter createViewerSorter() {
|
||||||
|
return new TypeInfoSorter();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds filters the viewer of this part.
|
* Adds filters the viewer of this part.
|
||||||
*/
|
*/
|
||||||
protected void addFilters() {
|
protected void addFilters() {
|
||||||
super.addFilters();
|
super.addFilters();
|
||||||
// getViewer().addFilter(new NonCElementFilter());
|
getViewer().addFilter(new CBrowsingElementFilter());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -11,7 +11,6 @@
|
||||||
package org.eclipse.cdt.internal.ui.browser.cbrowsing;
|
package org.eclipse.cdt.internal.ui.browser.cbrowsing;
|
||||||
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.util.Iterator;
|
|
||||||
|
|
||||||
import org.eclipse.cdt.core.browser.AllTypesCache;
|
import org.eclipse.cdt.core.browser.AllTypesCache;
|
||||||
import org.eclipse.cdt.core.browser.ITypeInfo;
|
import org.eclipse.cdt.core.browser.ITypeInfo;
|
||||||
|
@ -25,8 +24,6 @@ import org.eclipse.cdt.internal.ui.util.ExceptionHandler;
|
||||||
import org.eclipse.cdt.ui.CUIPlugin;
|
import org.eclipse.cdt.ui.CUIPlugin;
|
||||||
import org.eclipse.core.runtime.IProgressMonitor;
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
import org.eclipse.jface.operation.IRunnableWithProgress;
|
import org.eclipse.jface.operation.IRunnableWithProgress;
|
||||||
import org.eclipse.jface.util.Assert;
|
|
||||||
import org.eclipse.jface.viewers.IStructuredSelection;
|
|
||||||
import org.eclipse.swt.widgets.Shell;
|
import org.eclipse.swt.widgets.Shell;
|
||||||
import org.eclipse.ui.PlatformUI;
|
import org.eclipse.ui.PlatformUI;
|
||||||
import org.eclipse.ui.progress.IProgressService;
|
import org.eclipse.ui.progress.IProgressService;
|
||||||
|
@ -75,29 +72,12 @@ class NamespacesViewContentProvider extends CBrowsingContentProvider {
|
||||||
*/
|
*/
|
||||||
public Object[] getChildren(Object element) {
|
public Object[] getChildren(Object element) {
|
||||||
if (element == null || (element instanceof ICElement && !((ICElement)element).exists())) {
|
if (element == null || (element instanceof ICElement && !((ICElement)element).exists())) {
|
||||||
return NO_CHILDREN;
|
return INVALID_INPUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
startReadInDisplayThread();
|
startReadInDisplayThread();
|
||||||
|
|
||||||
if (element instanceof IStructuredSelection) {
|
|
||||||
Assert.isLegal(false);
|
|
||||||
Object[] result= new Object[0];
|
|
||||||
Class clazz= null;
|
|
||||||
Iterator iter= ((IStructuredSelection)element).iterator();
|
|
||||||
while (iter.hasNext()) {
|
|
||||||
Object item= iter.next();
|
|
||||||
if (clazz == null)
|
|
||||||
clazz= item.getClass();
|
|
||||||
if (clazz == item.getClass())
|
|
||||||
result= concatenate(result, getChildren(item));
|
|
||||||
else
|
|
||||||
return NO_CHILDREN;
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (element instanceof ICProject) {
|
if (element instanceof ICProject) {
|
||||||
TypeSearchScope scope = new TypeSearchScope();
|
TypeSearchScope scope = new TypeSearchScope();
|
||||||
scope.add((ICProject)element);
|
scope.add((ICProject)element);
|
||||||
|
@ -110,7 +90,7 @@ class NamespacesViewContentProvider extends CBrowsingContentProvider {
|
||||||
return getNamespaces(scope);
|
return getNamespaces(scope);
|
||||||
}
|
}
|
||||||
|
|
||||||
return NO_CHILDREN;
|
return INVALID_INPUT;
|
||||||
// } catch (CModelException e) {
|
// } catch (CModelException e) {
|
||||||
// return NO_CHILDREN;
|
// return NO_CHILDREN;
|
||||||
} finally {
|
} finally {
|
||||||
|
@ -172,13 +152,17 @@ class NamespacesViewContentProvider extends CBrowsingContentProvider {
|
||||||
String title = OpenTypeMessages.getString("OpenTypeAction.exception.title"); //$NON-NLS-1$
|
String title = OpenTypeMessages.getString("OpenTypeAction.exception.title"); //$NON-NLS-1$
|
||||||
String message = OpenTypeMessages.getString("OpenTypeAction.exception.message"); //$NON-NLS-1$
|
String message = OpenTypeMessages.getString("OpenTypeAction.exception.message"); //$NON-NLS-1$
|
||||||
ExceptionHandler.handle(e, title, message);
|
ExceptionHandler.handle(e, title, message);
|
||||||
return NO_CHILDREN;
|
return ERROR_CANCELLED;
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
// cancelled by user
|
// cancelled by user
|
||||||
return NO_CHILDREN;
|
return ERROR_CANCELLED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return AllTypesCache.getNamespaces(scope, true);
|
ITypeInfo[] namespaces = AllTypesCache.getNamespaces(scope, true);
|
||||||
|
if (namespaces != null && namespaces.length > 0) {
|
||||||
|
return namespaces;
|
||||||
|
}
|
||||||
|
return EMPTY_CHILDREN;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Shell getShell() {
|
protected Shell getShell() {
|
||||||
|
|
|
@ -0,0 +1,36 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* 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 Common Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/cpl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* QNX Software Systems - initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.internal.ui.browser.cbrowsing;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.browser.ITypeInfo;
|
||||||
|
import org.eclipse.cdt.ui.browser.typeinfo.TypeInfoLabelProvider;
|
||||||
|
import org.eclipse.swt.graphics.Image;
|
||||||
|
|
||||||
|
public class NamespacesViewLabelProvider extends CBrowsingLabelProvider {
|
||||||
|
|
||||||
|
protected static final TypeInfoLabelProvider fTypeInfoLabelProvider = new TypeInfoLabelProvider(TypeInfoLabelProvider.SHOW_FULLY_QUALIFIED);
|
||||||
|
|
||||||
|
public NamespacesViewLabelProvider() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Image getImage(Object element) {
|
||||||
|
if (element instanceof ITypeInfo)
|
||||||
|
return fTypeInfoLabelProvider.getImage(element);
|
||||||
|
return super.getImage(element);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getText(Object element) {
|
||||||
|
if (element instanceof ITypeInfo)
|
||||||
|
return fTypeInfoLabelProvider.getText(element);
|
||||||
|
return super.getText(element);
|
||||||
|
}
|
||||||
|
}
|
|
@ -23,8 +23,6 @@ import org.eclipse.cdt.core.model.IStructure;
|
||||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||||
import org.eclipse.cdt.core.model.ITypeDef;
|
import org.eclipse.cdt.core.model.ITypeDef;
|
||||||
import org.eclipse.cdt.internal.ui.ICHelpContextIds;
|
import org.eclipse.cdt.internal.ui.ICHelpContextIds;
|
||||||
import org.eclipse.cdt.internal.ui.viewsupport.AppearanceAwareLabelProvider;
|
|
||||||
import org.eclipse.cdt.internal.ui.viewsupport.CElementImageProvider;
|
|
||||||
import org.eclipse.cdt.ui.CUIPlugin;
|
import org.eclipse.cdt.ui.CUIPlugin;
|
||||||
import org.eclipse.cdt.ui.PreferenceConstants;
|
import org.eclipse.cdt.ui.PreferenceConstants;
|
||||||
import org.eclipse.jface.viewers.DoubleClickEvent;
|
import org.eclipse.jface.viewers.DoubleClickEvent;
|
||||||
|
@ -34,6 +32,7 @@ import org.eclipse.jface.viewers.IStructuredSelection;
|
||||||
import org.eclipse.jface.viewers.LabelProvider;
|
import org.eclipse.jface.viewers.LabelProvider;
|
||||||
import org.eclipse.jface.viewers.StructuredViewer;
|
import org.eclipse.jface.viewers.StructuredViewer;
|
||||||
import org.eclipse.jface.viewers.TreeViewer;
|
import org.eclipse.jface.viewers.TreeViewer;
|
||||||
|
import org.eclipse.jface.viewers.ViewerSorter;
|
||||||
import org.eclipse.swt.SWT;
|
import org.eclipse.swt.SWT;
|
||||||
import org.eclipse.swt.widgets.Composite;
|
import org.eclipse.swt.widgets.Composite;
|
||||||
import org.eclipse.ui.IPageLayout;
|
import org.eclipse.ui.IPageLayout;
|
||||||
|
@ -56,9 +55,19 @@ public class ProjectsView extends CBrowsingPart {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected LabelProvider createLabelProvider() {
|
protected LabelProvider createLabelProvider() {
|
||||||
return new AppearanceAwareLabelProvider(
|
return new CBrowsingLabelProvider();
|
||||||
AppearanceAwareLabelProvider.DEFAULT_TEXTFLAGS,
|
}
|
||||||
AppearanceAwareLabelProvider.DEFAULT_IMAGEFLAGS | CElementImageProvider.SMALL_ICONS );
|
|
||||||
|
protected ViewerSorter createViewerSorter() {
|
||||||
|
return new CBrowsingViewerSorter();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds filters the viewer of this part.
|
||||||
|
*/
|
||||||
|
protected void addFilters() {
|
||||||
|
super.addFilters();
|
||||||
|
getViewer().addFilter(new CBrowsingElementFilter());
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
|
|
@ -11,7 +11,6 @@
|
||||||
package org.eclipse.cdt.internal.ui.browser.cbrowsing;
|
package org.eclipse.cdt.internal.ui.browser.cbrowsing;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.model.CModelException;
|
import org.eclipse.cdt.core.model.CModelException;
|
||||||
|
@ -21,8 +20,6 @@ import org.eclipse.cdt.core.model.ICProject;
|
||||||
import org.eclipse.cdt.core.model.ISourceRoot;
|
import org.eclipse.cdt.core.model.ISourceRoot;
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
import org.eclipse.core.resources.IResource;
|
import org.eclipse.core.resources.IResource;
|
||||||
import org.eclipse.jface.util.Assert;
|
|
||||||
import org.eclipse.jface.viewers.IStructuredSelection;
|
|
||||||
|
|
||||||
class ProjectsViewContentProvider extends CBrowsingContentProvider {
|
class ProjectsViewContentProvider extends CBrowsingContentProvider {
|
||||||
|
|
||||||
|
@ -70,29 +67,12 @@ class ProjectsViewContentProvider extends CBrowsingContentProvider {
|
||||||
*/
|
*/
|
||||||
public Object[] getChildren(Object element) {
|
public Object[] getChildren(Object element) {
|
||||||
if (element == null || (element instanceof ICElement && !((ICElement)element).exists())) {
|
if (element == null || (element instanceof ICElement && !((ICElement)element).exists())) {
|
||||||
return NO_CHILDREN;
|
return INVALID_INPUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
startReadInDisplayThread();
|
startReadInDisplayThread();
|
||||||
|
|
||||||
if (element instanceof IStructuredSelection) {
|
|
||||||
Assert.isLegal(false);
|
|
||||||
Object[] result= new Object[0];
|
|
||||||
Class clazz= null;
|
|
||||||
Iterator iter= ((IStructuredSelection)element).iterator();
|
|
||||||
while (iter.hasNext()) {
|
|
||||||
Object item= iter.next();
|
|
||||||
if (clazz == null)
|
|
||||||
clazz= item.getClass();
|
|
||||||
if (clazz == item.getClass())
|
|
||||||
result= concatenate(result, getChildren(item));
|
|
||||||
else
|
|
||||||
return NO_CHILDREN;
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (element instanceof ICModel) {
|
if (element instanceof ICModel) {
|
||||||
ICModel cModel = (ICModel)element;
|
ICModel cModel = (ICModel)element;
|
||||||
return cModel.getCProjects();
|
return cModel.getCProjects();
|
||||||
|
@ -104,9 +84,9 @@ class ProjectsViewContentProvider extends CBrowsingContentProvider {
|
||||||
if (element instanceof ISourceRoot)
|
if (element instanceof ISourceRoot)
|
||||||
return NO_CHILDREN;
|
return NO_CHILDREN;
|
||||||
|
|
||||||
return NO_CHILDREN;
|
return INVALID_INPUT;
|
||||||
} catch (CModelException e) {
|
} catch (CModelException e) {
|
||||||
return NO_CHILDREN;
|
return ERROR_CANCELLED;
|
||||||
} finally {
|
} finally {
|
||||||
finishedReadInDisplayThread();
|
finishedReadInDisplayThread();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,92 +0,0 @@
|
||||||
/*******************************************************************************
|
|
||||||
* Copyright (c) 2000, 2004 IBM Corporation and others.
|
|
||||||
* All rights reserved. This program and the accompanying materials
|
|
||||||
* are made available under the terms of the Common Public License v1.0
|
|
||||||
* which accompanies this distribution, and is available at
|
|
||||||
* http://www.eclipse.org/legal/cpl-v10.html
|
|
||||||
*
|
|
||||||
* Contributors:
|
|
||||||
* IBM Corporation - initial API and implementation
|
|
||||||
*******************************************************************************/
|
|
||||||
package org.eclipse.cdt.internal.ui.browser.cbrowsing;
|
|
||||||
|
|
||||||
|
|
||||||
import org.eclipse.cdt.core.browser.ITypeInfo;
|
|
||||||
import org.eclipse.cdt.core.model.ICElement;
|
|
||||||
import org.eclipse.cdt.internal.ui.CUIMessages;
|
|
||||||
import org.eclipse.cdt.internal.ui.viewsupport.CElementLabels;
|
|
||||||
import org.eclipse.cdt.ui.browser.typeinfo.TypeInfoLabelProvider;
|
|
||||||
import org.eclipse.core.resources.IContainer;
|
|
||||||
import org.eclipse.core.resources.IResource;
|
|
||||||
|
|
||||||
import org.eclipse.jface.action.IStatusLineManager;
|
|
||||||
import org.eclipse.jface.viewers.ISelection;
|
|
||||||
import org.eclipse.jface.viewers.ISelectionChangedListener;
|
|
||||||
import org.eclipse.jface.viewers.IStructuredSelection;
|
|
||||||
import org.eclipse.jface.viewers.SelectionChangedEvent;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Add the <code>StatusBarUpdater</code> to your ViewPart to have the statusbar
|
|
||||||
* describing the selected elements.
|
|
||||||
*/
|
|
||||||
public class StatusBarUpdater implements ISelectionChangedListener {
|
|
||||||
|
|
||||||
private final int LABEL_FLAGS= CElementLabels.DEFAULT_QUALIFIED | CElementLabels.ROOT_POST_QUALIFIED | CElementLabels.APPEND_ROOT_PATH |
|
|
||||||
CElementLabels.M_PARAMETER_TYPES | CElementLabels.M_PARAMETER_NAMES | CElementLabels.M_APP_RETURNTYPE | CElementLabels.M_EXCEPTIONS |
|
|
||||||
CElementLabels.F_APP_TYPE_SIGNATURE;
|
|
||||||
|
|
||||||
private final TypeInfoLabelProvider fTypeInfoLabelProvider = new TypeInfoLabelProvider(TypeInfoLabelProvider.SHOW_FULLY_QUALIFIED + TypeInfoLabelProvider.SHOW_PATH);
|
|
||||||
|
|
||||||
private IStatusLineManager fStatusLineManager;
|
|
||||||
|
|
||||||
public StatusBarUpdater(IStatusLineManager statusLineManager) {
|
|
||||||
fStatusLineManager= statusLineManager;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* @see ISelectionChangedListener#selectionChanged
|
|
||||||
*/
|
|
||||||
public void selectionChanged(SelectionChangedEvent event) {
|
|
||||||
String statusBarMessage= formatMessage(event.getSelection());
|
|
||||||
fStatusLineManager.setMessage(statusBarMessage);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
protected String formatMessage(ISelection sel) {
|
|
||||||
if (sel instanceof IStructuredSelection && !sel.isEmpty()) {
|
|
||||||
IStructuredSelection selection= (IStructuredSelection) sel;
|
|
||||||
|
|
||||||
int nElements= selection.size();
|
|
||||||
if (nElements > 1) {
|
|
||||||
return CUIMessages.getFormattedString("StatusBarUpdater.num_elements_selected", String.valueOf(nElements)); //$NON-NLS-1$
|
|
||||||
} else {
|
|
||||||
Object elem= selection.getFirstElement();
|
|
||||||
if (elem instanceof ICElement) {
|
|
||||||
return formatCElementMessage((ICElement) elem);
|
|
||||||
} else if (elem instanceof ITypeInfo) {
|
|
||||||
return formatTypeInfoMessage((ITypeInfo) elem);
|
|
||||||
} else if (elem instanceof IResource) {
|
|
||||||
return formatResourceMessage((IResource) elem);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return ""; //$NON-NLS-1$
|
|
||||||
}
|
|
||||||
|
|
||||||
private String formatCElementMessage(ICElement element) {
|
|
||||||
return CElementLabels.getElementLabel(element, LABEL_FLAGS);
|
|
||||||
}
|
|
||||||
|
|
||||||
private String formatTypeInfoMessage(ITypeInfo info) {
|
|
||||||
return fTypeInfoLabelProvider.getText(info);
|
|
||||||
}
|
|
||||||
|
|
||||||
private String formatResourceMessage(IResource element) {
|
|
||||||
IContainer parent= element.getParent();
|
|
||||||
if (parent != null && parent.getType() != IResource.ROOT)
|
|
||||||
return element.getName() + CElementLabels.CONCAT_STRING + parent.getFullPath().makeRelative().toString();
|
|
||||||
else
|
|
||||||
return element.getName();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,129 +0,0 @@
|
||||||
/*******************************************************************************
|
|
||||||
* Copyright (c) 2000, 2004 IBM Corporation and others.
|
|
||||||
* All rights reserved. This program and the accompanying materials
|
|
||||||
* are made available under the terms of the Common Public License v1.0
|
|
||||||
* which accompanies this distribution, and is available at
|
|
||||||
* http://www.eclipse.org/legal/cpl-v10.html
|
|
||||||
*
|
|
||||||
* Contributors:
|
|
||||||
* IBM Corporation - initial API and implementation
|
|
||||||
*******************************************************************************/
|
|
||||||
package org.eclipse.cdt.internal.ui.browser.cbrowsing;
|
|
||||||
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import org.eclipse.core.resources.IStorage;
|
|
||||||
import org.eclipse.core.runtime.IPath;
|
|
||||||
|
|
||||||
import org.eclipse.swt.graphics.Image;
|
|
||||||
|
|
||||||
import org.eclipse.jface.resource.ImageDescriptor;
|
|
||||||
import org.eclipse.jface.viewers.LabelProvider;
|
|
||||||
|
|
||||||
import org.eclipse.ui.IEditorRegistry;
|
|
||||||
import org.eclipse.ui.IFileEditorMapping;
|
|
||||||
import org.eclipse.ui.PlatformUI;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Standard label provider for IStorage objects.
|
|
||||||
* Use this class when you want to present IStorage objects in a viewer.
|
|
||||||
*/
|
|
||||||
public class StorageLabelProvider extends LabelProvider {
|
|
||||||
|
|
||||||
private IEditorRegistry fEditorRegistry= PlatformUI.getWorkbench().getEditorRegistry();
|
|
||||||
private Map fJarImageMap= new HashMap(10);
|
|
||||||
private Image fDefaultImage;
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see ILabelProvider#getImage
|
|
||||||
*/
|
|
||||||
public Image getImage(Object element) {
|
|
||||||
if (element instanceof IStorage)
|
|
||||||
return getImageForJarEntry((IStorage)element);
|
|
||||||
|
|
||||||
return super.getImage(element);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see ILabelProvider#getText
|
|
||||||
*/
|
|
||||||
public String getText(Object element) {
|
|
||||||
if (element instanceof IStorage)
|
|
||||||
return ((IStorage)element).getName();
|
|
||||||
|
|
||||||
return super.getText(element);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see IBaseLabelProvider#dispose
|
|
||||||
*/
|
|
||||||
public void dispose() {
|
|
||||||
if (fJarImageMap != null) {
|
|
||||||
Iterator each= fJarImageMap.values().iterator();
|
|
||||||
while (each.hasNext()) {
|
|
||||||
Image image= (Image)each.next();
|
|
||||||
image.dispose();
|
|
||||||
}
|
|
||||||
fJarImageMap= null;
|
|
||||||
}
|
|
||||||
if (fDefaultImage != null)
|
|
||||||
fDefaultImage.dispose();
|
|
||||||
fDefaultImage= null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Gets and caches an image for a JarEntryFile.
|
|
||||||
* The image for a JarEntryFile is retrieved from the EditorRegistry.
|
|
||||||
*/
|
|
||||||
private Image getImageForJarEntry(IStorage element) {
|
|
||||||
if (fJarImageMap == null)
|
|
||||||
return getDefaultImage();
|
|
||||||
|
|
||||||
if (element == null || element.getName() == null)
|
|
||||||
return getDefaultImage();
|
|
||||||
|
|
||||||
// Try to find icon for full name
|
|
||||||
String name= element.getName();
|
|
||||||
Image image= (Image)fJarImageMap.get(name);
|
|
||||||
if (image != null)
|
|
||||||
return image;
|
|
||||||
IFileEditorMapping[] mappings= fEditorRegistry.getFileEditorMappings();
|
|
||||||
int i= 0;
|
|
||||||
while (i < mappings.length) {
|
|
||||||
if (mappings[i].getLabel().equals(name))
|
|
||||||
break;
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
String key= name;
|
|
||||||
if (i == mappings.length) {
|
|
||||||
// Try to find icon for extension
|
|
||||||
IPath path= element.getFullPath();
|
|
||||||
if (path == null)
|
|
||||||
return getDefaultImage();
|
|
||||||
key= path.getFileExtension();
|
|
||||||
if (key == null)
|
|
||||||
return getDefaultImage();
|
|
||||||
image= (Image)fJarImageMap.get(key);
|
|
||||||
if (image != null)
|
|
||||||
return image;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get the image from the editor registry
|
|
||||||
ImageDescriptor desc= fEditorRegistry.getImageDescriptor(name);
|
|
||||||
image= desc.createImage();
|
|
||||||
|
|
||||||
fJarImageMap.put(key, image);
|
|
||||||
|
|
||||||
return image;
|
|
||||||
}
|
|
||||||
|
|
||||||
private Image getDefaultImage() {
|
|
||||||
if (fDefaultImage == null)
|
|
||||||
fDefaultImage= fEditorRegistry.getImageDescriptor((String)null).createImage();
|
|
||||||
return fDefaultImage;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -8,64 +8,73 @@
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM Corporation - initial API and implementation
|
* IBM Corporation - initial API and implementation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
/*
|
|
||||||
* Created on May 18, 2004
|
|
||||||
*
|
|
||||||
* TODO To change the template for this generated file go to
|
|
||||||
* Window - Preferences - Java - Code Style - Code Templates
|
|
||||||
*/
|
|
||||||
package org.eclipse.cdt.internal.ui.browser.cbrowsing;
|
package org.eclipse.cdt.internal.ui.browser.cbrowsing;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.browser.ITypeInfo;
|
import org.eclipse.cdt.core.browser.ITypeInfo;
|
||||||
import org.eclipse.cdt.core.model.ICElement;
|
import org.eclipse.cdt.core.model.ICElement;
|
||||||
import org.eclipse.jface.viewers.Viewer;
|
import org.eclipse.jface.viewers.Viewer;
|
||||||
import org.eclipse.jface.viewers.ViewerSorter;
|
|
||||||
|
|
||||||
/**
|
public class TypeInfoSorter extends CBrowsingViewerSorter {
|
||||||
* A sorter to sort the file and the folders in the C viewer in the following order:
|
|
||||||
* 1 Project
|
public TypeInfoSorter() {
|
||||||
* 2 BinaryContainer
|
super();
|
||||||
* 3 ArchiveContainer
|
}
|
||||||
* 4 LibraryContainer
|
|
||||||
* 5 IncludeContainer
|
public int category (Object element) {
|
||||||
* 6 Source roots
|
if (element instanceof ITypeInfo) {
|
||||||
* 5 C Elements
|
ITypeInfo info = (ITypeInfo)element;
|
||||||
* 6 non C Elements
|
String name = info.getName();
|
||||||
*/
|
if (info.getCElementType() == ICElement.C_NAMESPACE) {
|
||||||
public class TypeInfoSorter extends ViewerSorter {
|
if (name.startsWith("__")) { //$NON-NLS-1$
|
||||||
|
return NAMESPACES_SYSTEM;
|
||||||
|
}
|
||||||
|
if (name.charAt(0) == '_') {
|
||||||
|
return NAMESPACES_RESERVED;
|
||||||
|
}
|
||||||
|
return NAMESPACES;
|
||||||
|
} else {
|
||||||
|
if (name.startsWith("__")) { //$NON-NLS-1$
|
||||||
|
return CELEMENTS_SYSTEM;
|
||||||
|
}
|
||||||
|
if (name.charAt(0) == '_') {
|
||||||
|
return CELEMENTS_RESERVED;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return CELEMENTS;
|
||||||
|
}
|
||||||
|
return super.category(element);
|
||||||
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.jface.viewers.ViewerSorter#compare(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
|
|
||||||
*/
|
|
||||||
public int compare(Viewer viewer, Object e1, Object e2) {
|
public int compare(Viewer viewer, Object e1, Object e2) {
|
||||||
if (e1 instanceof ITypeInfo) {
|
if (e1 instanceof ITypeInfo || e2 instanceof ITypeInfo) {
|
||||||
return compare((ITypeInfo)e1, e2);
|
int cat1 = category(e1);
|
||||||
} else if (e1 instanceof ICElement) {
|
int cat2 = category(e2);
|
||||||
return compare((ICElement)e1, e2);
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
// return getCollator().compare(name1, name2);
|
|
||||||
}
|
|
||||||
|
|
||||||
int compare(ITypeInfo t1, Object o2) {
|
if (cat1 != cat2)
|
||||||
if (o2 instanceof ITypeInfo) {
|
return cat1 - cat2;
|
||||||
ITypeInfo t2 = (ITypeInfo)o2;
|
|
||||||
return t1.compareTo(t2);
|
|
||||||
} else if (o2 instanceof ICElement) {
|
|
||||||
ICElement e2 = (ICElement)o2;
|
|
||||||
return getCollator().compare(t1.getName(), e2.getElementName());
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int compare(ICElement e1, Object o2) {
|
// cat1 == cat2
|
||||||
if (o2 instanceof ITypeInfo) {
|
|
||||||
ITypeInfo t2 = (ITypeInfo)o2;
|
if (cat1 == NAMESPACES || cat1 == CELEMENTS || cat1 == CELEMENTS_SYSTEM || cat1 == CELEMENTS_RESERVED) {
|
||||||
return getCollator().compare(e1.getElementName(), t2.getName());
|
String name1;
|
||||||
} else if (o2 instanceof ICElement) {
|
String name2;
|
||||||
ICElement e2 = (ICElement)o2;
|
if (e1 instanceof ICElement) {
|
||||||
return getCollator().compare(e1.getElementName(), e2.getElementName());
|
name1 = ((ICElement)e1).getElementName();
|
||||||
|
} else if (e1 instanceof ITypeInfo) {
|
||||||
|
name1 = ((ITypeInfo)e1).getName();
|
||||||
|
} else {
|
||||||
|
name1 = e1.toString();
|
||||||
}
|
}
|
||||||
return 0;
|
if (e2 instanceof ICElement) {
|
||||||
|
name2 = ((ICElement)e2).getElementName();
|
||||||
|
} else if (e2 instanceof ITypeInfo) {
|
||||||
|
name2 = ((ITypeInfo)e2).getName();
|
||||||
|
} else {
|
||||||
|
name2 = e2.toString();
|
||||||
|
}
|
||||||
|
return getCollator().compare(name1, name2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return super.compare(viewer, e1, e2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,6 +17,7 @@ import org.eclipse.cdt.core.model.ICElement;
|
||||||
import org.eclipse.cdt.core.model.ICModel;
|
import org.eclipse.cdt.core.model.ICModel;
|
||||||
import org.eclipse.cdt.core.model.ICProject;
|
import org.eclipse.cdt.core.model.ICProject;
|
||||||
import org.eclipse.cdt.core.model.IEnumeration;
|
import org.eclipse.cdt.core.model.IEnumeration;
|
||||||
|
import org.eclipse.cdt.core.model.INamespace;
|
||||||
import org.eclipse.cdt.core.model.ISourceRoot;
|
import org.eclipse.cdt.core.model.ISourceRoot;
|
||||||
import org.eclipse.cdt.core.model.IStructure;
|
import org.eclipse.cdt.core.model.IStructure;
|
||||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||||
|
@ -24,11 +25,11 @@ import org.eclipse.cdt.core.model.ITypeDef;
|
||||||
import org.eclipse.cdt.internal.ui.ICHelpContextIds;
|
import org.eclipse.cdt.internal.ui.ICHelpContextIds;
|
||||||
import org.eclipse.cdt.ui.CUIPlugin;
|
import org.eclipse.cdt.ui.CUIPlugin;
|
||||||
import org.eclipse.cdt.ui.PreferenceConstants;
|
import org.eclipse.cdt.ui.PreferenceConstants;
|
||||||
import org.eclipse.cdt.ui.browser.typeinfo.TypeInfoLabelProvider;
|
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
import org.eclipse.jface.viewers.IContentProvider;
|
import org.eclipse.jface.viewers.IContentProvider;
|
||||||
import org.eclipse.jface.viewers.LabelProvider;
|
import org.eclipse.jface.viewers.LabelProvider;
|
||||||
import org.eclipse.jface.viewers.StructuredViewer;
|
import org.eclipse.jface.viewers.StructuredViewer;
|
||||||
|
import org.eclipse.jface.viewers.ViewerSorter;
|
||||||
import org.eclipse.swt.SWT;
|
import org.eclipse.swt.SWT;
|
||||||
import org.eclipse.swt.widgets.Composite;
|
import org.eclipse.swt.widgets.Composite;
|
||||||
import org.eclipse.ui.IActionBars;
|
import org.eclipse.ui.IActionBars;
|
||||||
|
@ -46,7 +47,7 @@ public class TypesView extends CBrowsingPart {
|
||||||
* @see org.eclipse.jface.viewers.ILabelProvider
|
* @see org.eclipse.jface.viewers.ILabelProvider
|
||||||
*/
|
*/
|
||||||
protected LabelProvider createLabelProvider() {
|
protected LabelProvider createLabelProvider() {
|
||||||
return new TypeInfoLabelProvider(TypeInfoLabelProvider.SHOW_TYPE_ONLY);
|
return new TypesViewLabelProvider();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -92,14 +93,16 @@ public class TypesView extends CBrowsingPart {
|
||||||
return new TypesViewContentProvider(this);
|
return new TypesViewContentProvider(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected ViewerSorter createViewerSorter() {
|
||||||
|
return new TypeInfoSorter();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds filters the viewer of this part.
|
* Adds filters the viewer of this part.
|
||||||
*/
|
*/
|
||||||
protected void addFilters() {
|
protected void addFilters() {
|
||||||
super.addFilters();
|
super.addFilters();
|
||||||
// getViewer().addFilter(new NonCElementFilter());
|
getViewer().addFilter(new CBrowsingElementFilter());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -179,14 +182,17 @@ public class TypesView extends CBrowsingPart {
|
||||||
} else if (celem.getElementType() == ICElement.C_NAMESPACE) {
|
} else if (celem.getElementType() == ICElement.C_NAMESPACE) {
|
||||||
return AllTypesCache.getTypeForElement(celem, true, true, null);
|
return AllTypesCache.getTypeForElement(celem, true, true, null);
|
||||||
} else {
|
} else {
|
||||||
ICElement parent = TypeUtil.getDeclaringContainerType(celem);
|
ICElement parent = TypeUtil.getDeclaringType(celem);
|
||||||
if (parent != null) {
|
if (parent instanceof INamespace) {
|
||||||
|
return AllTypesCache.getTypeForElement(parent, true, true, null);
|
||||||
|
} else if (parent != null) {
|
||||||
ITypeInfo info = AllTypesCache.getTypeForElement(parent, true, true, null);
|
ITypeInfo info = AllTypesCache.getTypeForElement(parent, true, true, null);
|
||||||
if (info != null)
|
if (info != null)
|
||||||
return info.getEnclosingNamespace(true);
|
return info.getEnclosingNamespace(true);
|
||||||
}
|
}
|
||||||
|
IProject project = celem.getCProject().getProject();
|
||||||
|
return AllTypesCache.getGlobalNamespace(project);
|
||||||
}
|
}
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (element instanceof ITypeInfo) {
|
if (element instanceof ITypeInfo) {
|
||||||
|
|
|
@ -10,12 +10,8 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.ui.browser.cbrowsing;
|
package org.eclipse.cdt.internal.ui.browser.cbrowsing;
|
||||||
|
|
||||||
import java.util.Iterator;
|
|
||||||
|
|
||||||
import org.eclipse.cdt.core.browser.ITypeInfo;
|
import org.eclipse.cdt.core.browser.ITypeInfo;
|
||||||
import org.eclipse.cdt.core.model.ICElement;
|
import org.eclipse.cdt.core.model.ICElement;
|
||||||
import org.eclipse.jface.util.Assert;
|
|
||||||
import org.eclipse.jface.viewers.IStructuredSelection;
|
|
||||||
|
|
||||||
class TypesViewContentProvider extends CBrowsingContentProvider {
|
class TypesViewContentProvider extends CBrowsingContentProvider {
|
||||||
|
|
||||||
|
@ -52,39 +48,26 @@ class TypesViewContentProvider extends CBrowsingContentProvider {
|
||||||
*/
|
*/
|
||||||
public Object[] getChildren(Object element) {
|
public Object[] getChildren(Object element) {
|
||||||
if (element == null || (element instanceof ITypeInfo && !((ITypeInfo)element).exists())) {
|
if (element == null || (element instanceof ITypeInfo && !((ITypeInfo)element).exists())) {
|
||||||
return NO_CHILDREN;
|
return INVALID_INPUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
startReadInDisplayThread();
|
startReadInDisplayThread();
|
||||||
|
|
||||||
if (element instanceof IStructuredSelection) {
|
|
||||||
Assert.isLegal(false);
|
|
||||||
Object[] result= new Object[0];
|
|
||||||
Class clazz= null;
|
|
||||||
Iterator iter= ((IStructuredSelection)element).iterator();
|
|
||||||
while (iter.hasNext()) {
|
|
||||||
Object item= iter.next();
|
|
||||||
if (clazz == null)
|
|
||||||
clazz= item.getClass();
|
|
||||||
if (clazz == item.getClass())
|
|
||||||
result= concatenate(result, getChildren(item));
|
|
||||||
else
|
|
||||||
return NO_CHILDREN;
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (element instanceof ITypeInfo) {
|
if (element instanceof ITypeInfo) {
|
||||||
ITypeInfo info = (ITypeInfo)element;
|
ITypeInfo info = (ITypeInfo)element;
|
||||||
final int kinds[] = { ICElement.C_CLASS, ICElement.C_STRUCT,
|
final int kinds[] = { ICElement.C_CLASS, ICElement.C_STRUCT,
|
||||||
ICElement.C_UNION, ICElement.C_ENUMERATION,
|
ICElement.C_UNION, ICElement.C_ENUMERATION,
|
||||||
ICElement.C_TYPEDEF};
|
ICElement.C_TYPEDEF};
|
||||||
//TODO this should be a prefs option
|
//TODO this should be a prefs option
|
||||||
return info.getEnclosedTypes(kinds);
|
ITypeInfo[] children = info.getEnclosedTypes(kinds);
|
||||||
|
if (children != null && children.length > 0) {
|
||||||
|
return children;
|
||||||
|
}
|
||||||
|
return EMPTY_CHILDREN;
|
||||||
}
|
}
|
||||||
|
|
||||||
return NO_CHILDREN;
|
return INVALID_INPUT;
|
||||||
// } catch (CModelException e) {
|
// } catch (CModelException e) {
|
||||||
// return NO_CHILDREN;
|
// return NO_CHILDREN;
|
||||||
} finally {
|
} finally {
|
||||||
|
|
|
@ -0,0 +1,36 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* 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 Common Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/cpl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* QNX Software Systems - initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.internal.ui.browser.cbrowsing;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.browser.ITypeInfo;
|
||||||
|
import org.eclipse.cdt.ui.browser.typeinfo.TypeInfoLabelProvider;
|
||||||
|
import org.eclipse.swt.graphics.Image;
|
||||||
|
|
||||||
|
public class TypesViewLabelProvider extends CBrowsingLabelProvider {
|
||||||
|
|
||||||
|
protected static final TypeInfoLabelProvider fTypeInfoLabelProvider = new TypeInfoLabelProvider(TypeInfoLabelProvider.SHOW_TYPE_ONLY);
|
||||||
|
|
||||||
|
public TypesViewLabelProvider() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Image getImage(Object element) {
|
||||||
|
if (element instanceof ITypeInfo)
|
||||||
|
return fTypeInfoLabelProvider.getImage(element);
|
||||||
|
return super.getImage(element);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getText(Object element) {
|
||||||
|
if (element instanceof ITypeInfo)
|
||||||
|
return fTypeInfoLabelProvider.getText(element);
|
||||||
|
return super.getText(element);
|
||||||
|
}
|
||||||
|
}
|
|
@ -143,7 +143,7 @@ public class OpenTypeHierarchyUtil {
|
||||||
if (!(input instanceof ICElement)) {
|
if (!(input instanceof ICElement)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
// try {
|
try {
|
||||||
ICElement elem= (ICElement) input;
|
ICElement elem= (ICElement) input;
|
||||||
switch (elem.getElementType()) {
|
switch (elem.getElementType()) {
|
||||||
case ICElement.C_METHOD:
|
case ICElement.C_METHOD:
|
||||||
|
@ -168,9 +168,9 @@ public class OpenTypeHierarchyUtil {
|
||||||
case ICElement.C_PROJECT:
|
case ICElement.C_PROJECT:
|
||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
// } catch (CModelException e) {
|
} catch (CModelException e) {
|
||||||
// CUIPlugin.getDefault().log(e);
|
CUIPlugin.getDefault().log(e);
|
||||||
// }
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,12 +25,12 @@ import org.eclipse.cdt.internal.ui.ICHelpContextIds;
|
||||||
import org.eclipse.cdt.internal.ui.IContextMenuConstants;
|
import org.eclipse.cdt.internal.ui.IContextMenuConstants;
|
||||||
import org.eclipse.cdt.internal.ui.actions.CompositeActionGroup;
|
import org.eclipse.cdt.internal.ui.actions.CompositeActionGroup;
|
||||||
import org.eclipse.cdt.internal.ui.actions.SelectAllAction;
|
import org.eclipse.cdt.internal.ui.actions.SelectAllAction;
|
||||||
import org.eclipse.cdt.internal.ui.browser.cbrowsing.StatusBarUpdater;
|
|
||||||
import org.eclipse.cdt.internal.ui.util.EditorUtility;
|
import org.eclipse.cdt.internal.ui.util.EditorUtility;
|
||||||
import org.eclipse.cdt.internal.ui.util.ExceptionHandler;
|
import org.eclipse.cdt.internal.ui.util.ExceptionHandler;
|
||||||
import org.eclipse.cdt.internal.ui.viewsupport.CElementLabels;
|
import org.eclipse.cdt.internal.ui.viewsupport.CElementLabels;
|
||||||
import org.eclipse.cdt.internal.ui.viewsupport.CUILabelProvider;
|
import org.eclipse.cdt.internal.ui.viewsupport.CUILabelProvider;
|
||||||
import org.eclipse.cdt.internal.ui.viewsupport.IViewPartInputProvider;
|
import org.eclipse.cdt.internal.ui.viewsupport.IViewPartInputProvider;
|
||||||
|
import org.eclipse.cdt.internal.ui.viewsupport.StatusBarUpdater;
|
||||||
import org.eclipse.cdt.internal.ui.workingsets.WorkingSetFilterActionGroup;
|
import org.eclipse.cdt.internal.ui.workingsets.WorkingSetFilterActionGroup;
|
||||||
import org.eclipse.cdt.ui.CUIPlugin;
|
import org.eclipse.cdt.ui.CUIPlugin;
|
||||||
import org.eclipse.cdt.ui.PreferenceConstants;
|
import org.eclipse.cdt.ui.PreferenceConstants;
|
||||||
|
@ -1513,8 +1513,8 @@ public class TypeHierarchyViewPart extends ViewPart implements ITypeHierarchyVie
|
||||||
ICElement elem= (ICElement)editor.getEditorInput().getAdapter(ICElement.class);
|
ICElement elem= (ICElement)editor.getEditorInput().getAdapter(ICElement.class);
|
||||||
TypeHierarchyViewer currentViewer= getCurrentViewer();
|
TypeHierarchyViewer currentViewer= getCurrentViewer();
|
||||||
if (elem instanceof ITranslationUnit) {
|
if (elem instanceof ITranslationUnit) {
|
||||||
// ICElement[] allTypes= ((ITranslationUnit)elem).getAllTypes();
|
try {
|
||||||
ICElement[] allTypes= TypeUtil.getTypes(elem);
|
ICElement[] allTypes= TypeUtil.getAllTypes((ITranslationUnit)elem);
|
||||||
for (int i= 0; i < allTypes.length; i++) {
|
for (int i= 0; i < allTypes.length; i++) {
|
||||||
if (currentViewer.isElementShown(allTypes[i])) {
|
if (currentViewer.isElementShown(allTypes[i])) {
|
||||||
internalSelectType(allTypes[i], true);
|
internalSelectType(allTypes[i], true);
|
||||||
|
@ -1522,6 +1522,8 @@ public class TypeHierarchyViewPart extends ViewPart implements ITypeHierarchyVie
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} catch (CModelException e) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue