diff --git a/core/org.eclipse.cdt.ui/ChangeLog b/core/org.eclipse.cdt.ui/ChangeLog index 2e00be5d498..4187b050ea0 100644 --- a/core/org.eclipse.cdt.ui/ChangeLog +++ b/core/org.eclipse.cdt.ui/ChangeLog @@ -1,3 +1,12 @@ +2004-08-25 Alain Magloire + + Fix for 65761: Show all the include paths in the includes container. + + * src/org/eclipse/cdt/internal/ui/BaseCElementContentProvider.java + * src/org/eclipse/cdt/internal/ui/cview/CViewContentProvider.java + * src/org/eclipse/cdt/internal/ui/cview/CViewLabelProvider.java + * src/org/eclipse/cdt/internal/ui/cview/IncludeRefContainer.java + 2004-08-25 Chris Wiebe Got rid of little 'C' icons on the editor preference pages diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/BaseCElementContentProvider.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/BaseCElementContentProvider.java index ee75b245150..172b4617daf 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/BaseCElementContentProvider.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/BaseCElementContentProvider.java @@ -19,8 +19,6 @@ 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.IInclude; -import org.eclipse.cdt.core.model.IIncludeReference; -import org.eclipse.cdt.core.model.ILibraryReference; import org.eclipse.cdt.core.model.IParent; import org.eclipse.cdt.core.model.ISourceReference; import org.eclipse.cdt.core.model.ISourceRoot; @@ -173,10 +171,6 @@ public class BaseCElementContentProvider implements ITreeContentProvider { } return getTranslationUnitChildren(tu); } - } else if (element instanceof IIncludeReference) { - return ((IIncludeReference)element).getChildren(); - } else if (element instanceof ILibraryReference) { - return ((ILibraryReference)element).getChildren(); } else if (element instanceof ISourceReference && element instanceof IParent) { return ((IParent)element).getChildren(); } else if (element instanceof IProject) { diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CViewContentProvider.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CViewContentProvider.java index 78b5451d8ff..4d4c5a5a1f1 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CViewContentProvider.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CViewContentProvider.java @@ -11,15 +11,19 @@ package org.eclipse.cdt.internal.ui.cview; +import java.util.ArrayList; + import org.eclipse.cdt.core.model.CModelException; import org.eclipse.cdt.core.model.IArchive; import org.eclipse.cdt.core.model.IArchiveContainer; import org.eclipse.cdt.core.model.IBinary; import org.eclipse.cdt.core.model.IBinaryContainer; +import org.eclipse.cdt.core.model.ICElement; import org.eclipse.cdt.core.model.ICProject; import org.eclipse.cdt.core.model.IIncludeReference; import org.eclipse.cdt.core.model.ILibraryReference; import org.eclipse.cdt.ui.CElementContentProvider; +import org.eclipse.core.runtime.IPath; /** * CViewContentProvider @@ -51,9 +55,13 @@ public class CViewContentProvider extends CElementContentProvider { if (element instanceof ICProject) { extras = getProjectChildren((ICProject)element); } else if (element instanceof IBinaryContainer) { - extras = getBinaries((IBinaryContainer)element); + extras = getExecutables((IBinaryContainer)element); } else if (element instanceof IArchiveContainer) { extras = getArchives((IArchiveContainer)element); + } else if (element instanceof IIncludeReference) { + extras = getIncludeReferenceChildren((IIncludeReference)element); + } else if (element instanceof ILibraryReference) { + extras = ((ILibraryReference)element).getChildren(); } } catch (CModelException e) { extras = null; @@ -64,6 +72,15 @@ public class CViewContentProvider extends CElementContentProvider { return objs; } + public Object[] getIncludeReferenceChildren(IIncludeReference ref) throws CModelException { + IPath location = ref.getPath(); + IPath rootPath = ref.getCModel().getWorkspace().getRoot().getLocation(); + if (rootPath.isPrefixOf(location)) { + return NO_CHILDREN; + } + return ref.getChildren(); + } + /** * @return */ @@ -105,6 +122,23 @@ public class CViewContentProvider extends CElementContentProvider { } return extras; } + + protected IBinary[] getExecutables(IBinaryContainer container) throws CModelException { + ICElement[] celements = container.getChildren(); + ArrayList list = new ArrayList(celements.length); + for (int i = 0; i < celements.length; i++) { + if (celements[i] instanceof IBinary) { + IBinary bin = (IBinary)celements[i]; + if (bin.isExecutable() || bin.isSharedLib()) { + list.add(bin); + } + } + } + IBinary[] bins = new IBinary[list.size()]; + list.toArray(bins); + return bins; + } + /* (non-Javadoc) * @see org.eclipse.cdt.internal.ui.BaseCElementContentProvider#internalGetParent(java.lang.Object) */ @@ -148,6 +182,13 @@ public class CViewContentProvider extends CElementContentProvider { } catch (CModelException e) { return false; } + } else if (element instanceof IIncludeReference) { + IIncludeReference ref = (IIncludeReference)element; + IPath location = ref.getPath(); + IPath rootPath = ref.getCModel().getWorkspace().getRoot().getLocation(); + if (rootPath.isPrefixOf(location)) { + return false; + } } return super.hasChildren(element); } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CViewLabelProvider.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CViewLabelProvider.java index a0cf61b697c..c78476ce165 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CViewLabelProvider.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CViewLabelProvider.java @@ -13,7 +13,9 @@ package org.eclipse.cdt.internal.ui.cview; import org.eclipse.cdt.core.model.IIncludeReference; import org.eclipse.cdt.internal.ui.IAdornmentProvider; import org.eclipse.cdt.internal.ui.StandardCElementLabelProvider; +import org.eclipse.core.resources.IContainer; import org.eclipse.core.runtime.IPath; +import org.eclipse.swt.graphics.Image; /* * CViewLabelProvider @@ -51,7 +53,29 @@ public class CViewLabelProvider extends StandardCElementLabelProvider { } return p.toString(); } + IPath location = ref.getPath(); + IPath rootPath = ref.getCModel().getWorkspace().getRoot().getLocation(); + if (rootPath.isPrefixOf(location)) { + location = location.setDevice(null); + location = location.removeFirstSegments(rootPath.segmentCount()); + return location.toString(); + } } return super.getText(element); } + + /* (non-Javadoc) + * @see org.eclipse.jface.viewers.ILabelProvider#getImage(java.lang.Object) + */ + public Image getImage(Object element) { + if (element instanceof IIncludeReference) { + IIncludeReference reference = (IIncludeReference)element; + IPath path = reference.getPath(); + IContainer container = reference.getCModel().getWorkspace().getRoot().getContainerForLocation(path); + if (container != null && container.isAccessible()) { + return getImage(reference.getCProject()); + } + } + return super.getImage(element); + } } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/IncludeRefContainer.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/IncludeRefContainer.java index ed09c16e53c..45f7b54c093 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/IncludeRefContainer.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/IncludeRefContainer.java @@ -11,15 +11,12 @@ package org.eclipse.cdt.internal.ui.cview; -import java.util.ArrayList; import org.eclipse.cdt.core.model.CModelException; import org.eclipse.cdt.core.model.ICProject; import org.eclipse.cdt.core.model.IIncludeReference; import org.eclipse.cdt.internal.ui.CPluginImages; import org.eclipse.cdt.ui.CElementGrouping; -import org.eclipse.core.resources.IContainer; -import org.eclipse.core.runtime.IPath; import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.ui.model.IWorkbenchAdapter; @@ -58,15 +55,7 @@ public class IncludeRefContainer extends CElementGrouping { public Object[] getChildren(Object o) { try { IIncludeReference[] references = fCProject.getIncludeReferences(); - ArrayList list = new ArrayList(references.length); - for (int i = 0; i < references.length; i++) { - IPath path = references[i].getPath(); - IContainer container = references[i].getCModel().getWorkspace().getRoot().getContainerForLocation(path); - if (container == null || !container.isAccessible()) { - list.add(references[i]); - } - } - return list.toArray(); + return references; } catch (CModelException e) { } return EMPTY;