mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Fix the CView sorting.
This commit is contained in:
parent
7de97b8a11
commit
90ef8946ae
3 changed files with 51 additions and 4 deletions
|
@ -1,3 +1,12 @@
|
|||
2004-03-21 Alain Magloire
|
||||
|
||||
Show the binaries in the CView even if the parent
|
||||
is a resource, this happen for IBinary/IArchive on
|
||||
the IOutputEntry path.
|
||||
|
||||
* src/org/eclipse/cdt/internal/ui/BaseCElementContentProvider.java
|
||||
* src/org/eclipse/cdt/ui/CElementSorter.java
|
||||
|
||||
2004-03-19 David Inglis
|
||||
Update changing binary parser to use cdescriptor operation and remove call to deprecated call
|
||||
Added check before changes to prevent uneccessary changes of the .cdtproject file.
|
||||
|
|
|
@ -303,6 +303,9 @@ public class BaseCElementContentProvider implements ITreeContentProvider {
|
|||
|
||||
private Object[] getResources(IFolder folder) {
|
||||
try {
|
||||
ICProject cproject = CoreModel.getDefault().create(folder.getProject());
|
||||
ICElement[] binaries = cproject.getBinaryContainer().getChildren();
|
||||
ICElement[] archives = cproject.getArchiveContainer().getChildren();
|
||||
Object[] members = folder.members();
|
||||
List nonCResources= new ArrayList();
|
||||
for (int i= 0; i < members.length; i++) {
|
||||
|
@ -319,6 +322,25 @@ public class BaseCElementContentProvider implements ITreeContentProvider {
|
|||
if (element instanceof ISourceRoot && element.exists()) {
|
||||
continue;
|
||||
}
|
||||
} else if (o instanceof IFile){
|
||||
boolean found = false;
|
||||
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)) {
|
||||
o = archives[j];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
nonCResources.add(o);
|
||||
}
|
||||
|
|
|
@ -26,7 +26,11 @@ import org.eclipse.cdt.core.model.ITranslationUnit;
|
|||
import org.eclipse.cdt.core.model.IUsing;
|
||||
import org.eclipse.cdt.core.model.IVariable;
|
||||
import org.eclipse.cdt.core.model.IVariableDeclaration;
|
||||
import org.eclipse.core.resources.IContainer;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.core.resources.IStorage;
|
||||
import org.eclipse.core.runtime.IAdaptable;
|
||||
import org.eclipse.jface.viewers.ContentViewer;
|
||||
import org.eclipse.jface.viewers.IBaseLabelProvider;
|
||||
|
@ -48,7 +52,11 @@ public class CElementSorter extends ViewerSorter {
|
|||
|
||||
private static final int CMODEL = 0;
|
||||
private static final int PROJECT = 10;
|
||||
private static final int RESOURCE = 200;
|
||||
|
||||
private static final int RESOURCES= 300;
|
||||
private static final int RESOURCEFOLDERS= 210;
|
||||
private static final int STORAGE= 400;
|
||||
private static final int OTHERS= 500;
|
||||
|
||||
public int category (Object element) {
|
||||
if (element instanceof ICModel) {
|
||||
|
@ -131,8 +139,16 @@ public class CElementSorter extends ViewerSorter {
|
|||
return 174;
|
||||
}
|
||||
return 180;
|
||||
} else if (element instanceof IFile) {
|
||||
return RESOURCES;
|
||||
} else if (element instanceof IProject) {
|
||||
return PROJECT;
|
||||
} else if (element instanceof IContainer) {
|
||||
return RESOURCEFOLDERS;
|
||||
} else if (element instanceof IStorage) {
|
||||
return STORAGE;
|
||||
}
|
||||
return RESOURCE;
|
||||
return OTHERS;
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.viewers.ViewerSorter#compare(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
|
||||
|
@ -153,7 +169,7 @@ public class CElementSorter extends ViewerSorter {
|
|||
}
|
||||
|
||||
// non - c resources are sorted using the label from the viewers label provider
|
||||
if (cat1 == RESOURCE) {
|
||||
if (cat1 == RESOURCES || cat1 == RESOURCEFOLDERS || cat1 == STORAGE || cat1 == OTHERS) {
|
||||
return compareWithLabelProvider(viewer, e1, e2);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue