1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-29 20:05:35 +02:00

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
This commit is contained in:
Alain Magloire 2004-08-25 20:43:37 +00:00
parent 48ce308451
commit 3083b4d98c
5 changed files with 76 additions and 19 deletions

View file

@ -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 2004-08-25 Chris Wiebe
Got rid of little 'C' icons on the editor preference pages Got rid of little 'C' icons on the editor preference pages

View file

@ -19,8 +19,6 @@ 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.IInclude; 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.IParent;
import org.eclipse.cdt.core.model.ISourceReference; import org.eclipse.cdt.core.model.ISourceReference;
import org.eclipse.cdt.core.model.ISourceRoot; import org.eclipse.cdt.core.model.ISourceRoot;
@ -173,10 +171,6 @@ public class BaseCElementContentProvider implements ITreeContentProvider {
} }
return getTranslationUnitChildren(tu); 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) { } else if (element instanceof ISourceReference && element instanceof IParent) {
return ((IParent)element).getChildren(); return ((IParent)element).getChildren();
} else if (element instanceof IProject) { } else if (element instanceof IProject) {

View file

@ -11,15 +11,19 @@
package org.eclipse.cdt.internal.ui.cview; package org.eclipse.cdt.internal.ui.cview;
import java.util.ArrayList;
import org.eclipse.cdt.core.model.CModelException; import org.eclipse.cdt.core.model.CModelException;
import org.eclipse.cdt.core.model.IArchive; import org.eclipse.cdt.core.model.IArchive;
import org.eclipse.cdt.core.model.IArchiveContainer; import org.eclipse.cdt.core.model.IArchiveContainer;
import org.eclipse.cdt.core.model.IBinary; import org.eclipse.cdt.core.model.IBinary;
import org.eclipse.cdt.core.model.IBinaryContainer; 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.ICProject;
import org.eclipse.cdt.core.model.IIncludeReference; import org.eclipse.cdt.core.model.IIncludeReference;
import org.eclipse.cdt.core.model.ILibraryReference; import org.eclipse.cdt.core.model.ILibraryReference;
import org.eclipse.cdt.ui.CElementContentProvider; import org.eclipse.cdt.ui.CElementContentProvider;
import org.eclipse.core.runtime.IPath;
/** /**
* CViewContentProvider * CViewContentProvider
@ -51,9 +55,13 @@ public class CViewContentProvider extends CElementContentProvider {
if (element instanceof ICProject) { if (element instanceof ICProject) {
extras = getProjectChildren((ICProject)element); extras = getProjectChildren((ICProject)element);
} else if (element instanceof IBinaryContainer) { } else if (element instanceof IBinaryContainer) {
extras = getBinaries((IBinaryContainer)element); extras = getExecutables((IBinaryContainer)element);
} else if (element instanceof IArchiveContainer) { } else if (element instanceof IArchiveContainer) {
extras = getArchives((IArchiveContainer)element); 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) { } catch (CModelException e) {
extras = null; extras = null;
@ -64,6 +72,15 @@ public class CViewContentProvider extends CElementContentProvider {
return objs; 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 * @return
*/ */
@ -105,6 +122,23 @@ public class CViewContentProvider extends CElementContentProvider {
} }
return extras; 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) /* (non-Javadoc)
* @see org.eclipse.cdt.internal.ui.BaseCElementContentProvider#internalGetParent(java.lang.Object) * @see org.eclipse.cdt.internal.ui.BaseCElementContentProvider#internalGetParent(java.lang.Object)
*/ */
@ -148,6 +182,13 @@ public class CViewContentProvider extends CElementContentProvider {
} catch (CModelException e) { } catch (CModelException e) {
return false; 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); return super.hasChildren(element);
} }

View file

@ -13,7 +13,9 @@ package org.eclipse.cdt.internal.ui.cview;
import org.eclipse.cdt.core.model.IIncludeReference; import org.eclipse.cdt.core.model.IIncludeReference;
import org.eclipse.cdt.internal.ui.IAdornmentProvider; import org.eclipse.cdt.internal.ui.IAdornmentProvider;
import org.eclipse.cdt.internal.ui.StandardCElementLabelProvider; import org.eclipse.cdt.internal.ui.StandardCElementLabelProvider;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IPath;
import org.eclipse.swt.graphics.Image;
/* /*
* CViewLabelProvider * CViewLabelProvider
@ -51,7 +53,29 @@ public class CViewLabelProvider extends StandardCElementLabelProvider {
} }
return p.toString(); 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); 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);
}
} }

View file

@ -11,15 +11,12 @@
package org.eclipse.cdt.internal.ui.cview; package org.eclipse.cdt.internal.ui.cview;
import java.util.ArrayList;
import org.eclipse.cdt.core.model.CModelException; import org.eclipse.cdt.core.model.CModelException;
import org.eclipse.cdt.core.model.ICProject; import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.core.model.IIncludeReference; import org.eclipse.cdt.core.model.IIncludeReference;
import org.eclipse.cdt.internal.ui.CPluginImages; import org.eclipse.cdt.internal.ui.CPluginImages;
import org.eclipse.cdt.ui.CElementGrouping; 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.jface.resource.ImageDescriptor;
import org.eclipse.ui.model.IWorkbenchAdapter; import org.eclipse.ui.model.IWorkbenchAdapter;
@ -58,15 +55,7 @@ public class IncludeRefContainer extends CElementGrouping {
public Object[] getChildren(Object o) { public Object[] getChildren(Object o) {
try { try {
IIncludeReference[] references = fCProject.getIncludeReferences(); IIncludeReference[] references = fCProject.getIncludeReferences();
ArrayList list = new ArrayList(references.length); return references;
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();
} catch (CModelException e) { } catch (CModelException e) {
} }
return EMPTY; return EMPTY;