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
|
2004-03-19 David Inglis
|
||||||
Update changing binary parser to use cdescriptor operation and remove call to deprecated call
|
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.
|
Added check before changes to prevent uneccessary changes of the .cdtproject file.
|
||||||
|
|
|
@ -303,7 +303,10 @@ public class BaseCElementContentProvider implements ITreeContentProvider {
|
||||||
|
|
||||||
private Object[] getResources(IFolder folder) {
|
private Object[] getResources(IFolder folder) {
|
||||||
try {
|
try {
|
||||||
Object[] members= folder.members();
|
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();
|
List nonCResources= new ArrayList();
|
||||||
for (int i= 0; i < members.length; i++) {
|
for (int i= 0; i < members.length; i++) {
|
||||||
Object o= members[i];
|
Object o= members[i];
|
||||||
|
@ -319,6 +322,25 @@ public class BaseCElementContentProvider implements ITreeContentProvider {
|
||||||
if (element instanceof ISourceRoot && element.exists()) {
|
if (element instanceof ISourceRoot && element.exists()) {
|
||||||
continue;
|
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);
|
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.IUsing;
|
||||||
import org.eclipse.cdt.core.model.IVariable;
|
import org.eclipse.cdt.core.model.IVariable;
|
||||||
import org.eclipse.cdt.core.model.IVariableDeclaration;
|
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.IResource;
|
||||||
|
import org.eclipse.core.resources.IStorage;
|
||||||
import org.eclipse.core.runtime.IAdaptable;
|
import org.eclipse.core.runtime.IAdaptable;
|
||||||
import org.eclipse.jface.viewers.ContentViewer;
|
import org.eclipse.jface.viewers.ContentViewer;
|
||||||
import org.eclipse.jface.viewers.IBaseLabelProvider;
|
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 CMODEL = 0;
|
||||||
private static final int PROJECT = 10;
|
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) {
|
public int category (Object element) {
|
||||||
if (element instanceof ICModel) {
|
if (element instanceof ICModel) {
|
||||||
|
@ -131,8 +139,16 @@ public class CElementSorter extends ViewerSorter {
|
||||||
return 174;
|
return 174;
|
||||||
}
|
}
|
||||||
return 180;
|
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)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.jface.viewers.ViewerSorter#compare(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
|
* @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
|
// 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);
|
return compareWithLabelProvider(viewer, e1, e2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue