mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Show the Binary in the cview even if not an ICElement
This commit is contained in:
parent
b8a6e4e9f5
commit
f19ce7f75a
1 changed files with 59 additions and 39 deletions
|
@ -226,7 +226,7 @@ public class BaseCElementContentProvider implements ITreeContentProvider {
|
||||||
if (element instanceof ICElement) {
|
if (element instanceof ICElement) {
|
||||||
IResource res = ((ICElement)element).getResource();
|
IResource res = ((ICElement)element).getResource();
|
||||||
if (res != null) {
|
if (res != null) {
|
||||||
parent = internalGetParent(res.getParent());
|
parent = internalGetParent(res);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -264,12 +264,13 @@ public class BaseCElementContentProvider implements ITreeContentProvider {
|
||||||
try {
|
try {
|
||||||
Object[] nonC = cproject.getNonCResources();
|
Object[] nonC = cproject.getNonCResources();
|
||||||
if (nonC != null && nonC.length > 0) {
|
if (nonC != null && nonC.length > 0) {
|
||||||
objects = concatenate(objects, cproject.getNonCResources());
|
nonC = filterNonCResources(nonC, cproject);
|
||||||
|
objects = concatenate(objects, nonC);
|
||||||
}
|
}
|
||||||
} catch (CModelException e) {
|
} catch (CModelException e) {
|
||||||
//
|
//
|
||||||
}
|
}
|
||||||
//Object[] objects = getCResources((ICContainer)cproject);
|
|
||||||
IArchiveContainer archives = cproject.getArchiveContainer();
|
IArchiveContainer archives = cproject.getArchiveContainer();
|
||||||
if (archives.hasChildren()) {
|
if (archives.hasChildren()) {
|
||||||
objects = concatenate(objects, new Object[] {archives});
|
objects = concatenate(objects, new Object[] {archives});
|
||||||
|
@ -293,6 +294,9 @@ public class BaseCElementContentProvider implements ITreeContentProvider {
|
||||||
Object[] children = container.getChildren();
|
Object[] children = container.getChildren();
|
||||||
try {
|
try {
|
||||||
objects = container.getNonCResources();
|
objects = container.getNonCResources();
|
||||||
|
if (objects.length > 0) {
|
||||||
|
objects = filterNonCResources(objects, container.getCProject());
|
||||||
|
}
|
||||||
} catch (CModelException e) {
|
} catch (CModelException e) {
|
||||||
}
|
}
|
||||||
if (objects == null || objects.length == 0) {
|
if (objects == null || objects.length == 0) {
|
||||||
|
@ -302,52 +306,68 @@ public class BaseCElementContentProvider implements ITreeContentProvider {
|
||||||
}
|
}
|
||||||
|
|
||||||
private Object[] getResources(IFolder folder) {
|
private Object[] getResources(IFolder folder) {
|
||||||
|
ICProject cproject = CoreModel.getDefault().create(folder.getProject());
|
||||||
|
Object[] members = null;
|
||||||
try {
|
try {
|
||||||
ICProject cproject = CoreModel.getDefault().create(folder.getProject());
|
members = folder.members();
|
||||||
ICElement[] binaries = cproject.getBinaryContainer().getChildren();
|
} catch (CoreException e) {
|
||||||
ICElement[] archives = cproject.getArchiveContainer().getChildren();
|
//
|
||||||
Object[] members = folder.members();
|
}
|
||||||
List nonCResources= new ArrayList();
|
if (members == null || members.length == 0) {
|
||||||
for (int i= 0; i < members.length; i++) {
|
return NO_CHILDREN;
|
||||||
Object o= members[i];
|
}
|
||||||
// A folder can also be a source root in the following case
|
return filterNonCResources(members, cproject);
|
||||||
// Project
|
}
|
||||||
// + src <- source folder
|
|
||||||
// + excluded <- excluded from class path
|
private Object[] filterNonCResources(Object[] objects, ICProject cproject) {
|
||||||
// + included <- a new source folder.
|
ICElement[] binaries = cproject.getBinaryContainer().getChildren();
|
||||||
// Included is a member of excluded, but since it is rendered as a source
|
ICElement[] archives = cproject.getArchiveContainer().getChildren();
|
||||||
// folder we have to exclude it as a normal child.
|
ISourceRoot[] roots = null;
|
||||||
if (o instanceof IFolder) {
|
try {
|
||||||
ICElement element= CoreModel.getDefault().create((IFolder)o);
|
roots = cproject.getSourceRoots();
|
||||||
if (element instanceof ISourceRoot && element.exists()) {
|
} catch (CModelException e) {
|
||||||
|
roots = new ISourceRoot[0];
|
||||||
|
}
|
||||||
|
List nonCResources = new ArrayList(objects.length);
|
||||||
|
for (int i= 0; i < objects.length; i++) {
|
||||||
|
Object o= objects[i];
|
||||||
|
// A folder can also be a source root in the following case
|
||||||
|
// Project
|
||||||
|
// + src <- source folder
|
||||||
|
// + excluded <- excluded from class path
|
||||||
|
// + included <- a new source folder.
|
||||||
|
// Included is a member of excluded, but since it is rendered as a source
|
||||||
|
// folder we have to exclude it as a normal child.
|
||||||
|
if (o instanceof IFolder) {
|
||||||
|
IFolder folder = (IFolder)o;
|
||||||
|
for (int j = 0; j < roots.length; j++) {
|
||||||
|
if (roots[j].getPath().equals(folder.getFullPath())) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
} else if (o instanceof IFile){
|
}
|
||||||
boolean found = false;
|
} else if (o instanceof IFile){
|
||||||
for (int j = 0; j < binaries.length; j++) {
|
boolean found = false;
|
||||||
IResource res = binaries[j].getResource();
|
for (int j = 0; j < binaries.length; j++) {
|
||||||
|
IResource res = binaries[j].getResource();
|
||||||
|
if (o.equals(res)) {
|
||||||
|
o = binaries[j];
|
||||||
|
found = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!found) {
|
||||||
|
for (int j = 0; j < archives.length; j++) {
|
||||||
|
IResource res = archives[j].getResource();
|
||||||
if (o.equals(res)) {
|
if (o.equals(res)) {
|
||||||
o = binaries[j];
|
o = archives[j];
|
||||||
found = true;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!found) {
|
|
||||||
for (int j = 0; j < archives.length; j++) {
|
|
||||||
IResource res = archives[j].getResource();
|
|
||||||
if (o.equals(res)) {
|
|
||||||
o = archives[j];
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
nonCResources.add(o);
|
|
||||||
}
|
}
|
||||||
return nonCResources.toArray();
|
nonCResources.add(o);
|
||||||
} catch(CoreException e) {
|
|
||||||
}
|
}
|
||||||
return NO_CHILDREN;
|
return nonCResources.toArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Reference in a new issue