mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-07 09:46:02 +02:00
bug 355601: Make Targets Not Found In Nested Folders
This commit is contained in:
parent
3b5d67f9e8
commit
e3358c10f7
1 changed files with 39 additions and 35 deletions
|
@ -23,7 +23,6 @@ import org.eclipse.core.resources.IProject;
|
||||||
import org.eclipse.core.resources.IResource;
|
import org.eclipse.core.resources.IResource;
|
||||||
import org.eclipse.core.resources.IResourceProxy;
|
import org.eclipse.core.resources.IResourceProxy;
|
||||||
import org.eclipse.core.resources.IResourceProxyVisitor;
|
import org.eclipse.core.resources.IResourceProxyVisitor;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
|
||||||
import org.eclipse.jface.action.Action;
|
import org.eclipse.jface.action.Action;
|
||||||
import org.eclipse.jface.action.IAction;
|
import org.eclipse.jface.action.IAction;
|
||||||
import org.eclipse.jface.dialogs.IDialogSettings;
|
import org.eclipse.jface.dialogs.IDialogSettings;
|
||||||
|
@ -57,54 +56,66 @@ public class FilterEmtpyFoldersAction extends Action {
|
||||||
setToolTipText(MakeUIPlugin.getResourceString("FilterEmptyFolderAction.tooltip")); //$NON-NLS-1$
|
setToolTipText(MakeUIPlugin.getResourceString("FilterEmptyFolderAction.tooltip")); //$NON-NLS-1$
|
||||||
setChecked(getSettings().getBoolean(FILTER_EMPTY_FOLDERS));
|
setChecked(getSettings().getBoolean(FILTER_EMPTY_FOLDERS));
|
||||||
MakeUIImages.setImageDescriptors(this, "tool16", MakeUIImages.IMG_TOOLS_MAKE_TARGET_FILTER); //$NON-NLS-1$
|
MakeUIImages.setImageDescriptors(this, "tool16", MakeUIImages.IMG_TOOLS_MAKE_TARGET_FILTER); //$NON-NLS-1$
|
||||||
fViewer.addFilter(new ViewerFilter() {
|
|
||||||
//Check the make targets of the specified container, and if they don't exist, run
|
|
||||||
//through the children looking for the first match that we can find that contains
|
|
||||||
//a make target.
|
|
||||||
private boolean hasMakeTargets(IContainer container) throws CoreException {
|
|
||||||
IMakeTarget [] targets = MakeCorePlugin.getDefault().getTargetManager().getTargets(container);
|
|
||||||
if(targets != null && targets.length > 0) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
fViewer.addFilter(new ViewerFilter() {
|
||||||
|
/**
|
||||||
|
* Run through the children looking for the first match that we can find that contains
|
||||||
|
* a make target.
|
||||||
|
*/
|
||||||
|
private boolean hasMakeTargets(final IContainer parentContainer) {
|
||||||
final boolean [] haveTargets = new boolean[1];
|
final boolean [] haveTargets = new boolean[1];
|
||||||
haveTargets[0] = false;
|
haveTargets[0] = false;
|
||||||
|
|
||||||
IResourceProxyVisitor visitor = new IResourceProxyVisitor() {
|
IResourceProxyVisitor visitor = new IResourceProxyVisitor() {
|
||||||
@Override
|
@Override
|
||||||
public boolean visit(IResourceProxy proxy) throws CoreException {
|
public boolean visit(IResourceProxy proxy) {
|
||||||
if(haveTargets[0]) {
|
if(haveTargets[0]) {
|
||||||
return false; // We found what we were looking for
|
return false; // We found what we were looking for
|
||||||
}
|
}
|
||||||
|
|
||||||
if(proxy.getType() != IResource.FOLDER) {
|
int rcType = proxy.getType();
|
||||||
return true; //We only look at folders for content
|
if(rcType != IResource.PROJECT && rcType != IResource.FOLDER) {
|
||||||
|
return false; // Ignore non-containers
|
||||||
}
|
}
|
||||||
|
|
||||||
IContainer folder = (IContainer) proxy.requestResource();
|
IContainer subFolder = (IContainer) proxy.requestResource();
|
||||||
IMakeTarget [] targets = MakeCorePlugin.getDefault().getTargetManager().getTargets(folder);
|
|
||||||
|
if (!(parentContainer instanceof IProject) && !subFolder.equals(parentContainer)
|
||||||
|
&& CCorePlugin.showSourceRootsAtTopOfProject() && MakeContentProvider.isSourceEntry(subFolder)) {
|
||||||
|
return false; // Skip source folders showing up second time as regular folders
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
IMakeTarget [] targets = MakeCorePlugin.getDefault().getTargetManager().getTargets(subFolder);
|
||||||
if(targets != null && targets.length > 0) {
|
if(targets != null && targets.length > 0) {
|
||||||
haveTargets[0] = true;
|
haveTargets[0] = true;
|
||||||
return false;
|
return false; // Found a target
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
// log any problem then ignore it
|
||||||
|
MakeUIPlugin.log(e);
|
||||||
}
|
}
|
||||||
return true; // Keep looking
|
return true; // Keep looking
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
container.accept(visitor, IResource.NONE);
|
|
||||||
|
try {
|
||||||
|
parentContainer.accept(visitor, IResource.NONE);
|
||||||
|
} catch (Exception e) {
|
||||||
|
// log any problem then ignore it
|
||||||
|
MakeUIPlugin.log(e);
|
||||||
|
}
|
||||||
|
|
||||||
return haveTargets[0];
|
return haveTargets[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.jface.viewers.ViewerFilter#select(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public boolean select(Viewer viewer, Object parentElement, Object element) {
|
public boolean select(Viewer viewer, Object parentElement, Object element) {
|
||||||
if (isChecked()) {
|
if (isChecked()) {
|
||||||
IContainer container = null;
|
IContainer container = null;
|
||||||
if (element instanceof IContainer) {
|
if (element instanceof IContainer) {
|
||||||
container = (IContainer) element;
|
container = (IContainer) element;
|
||||||
if (!(container instanceof IProject)) {
|
if (parentElement instanceof IProject && !(container instanceof IProject)) {
|
||||||
// under subfolders do not show source roots second time (when filtered)
|
// under subfolders do not show source roots second time (when filtered)
|
||||||
if (CCorePlugin.showSourceRootsAtTopOfProject() && MakeContentProvider.isSourceEntry(container))
|
if (CCorePlugin.showSourceRootsAtTopOfProject() && MakeContentProvider.isSourceEntry(container))
|
||||||
return false;
|
return false;
|
||||||
|
@ -114,11 +125,7 @@ public class FilterEmtpyFoldersAction extends Action {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (container != null) {
|
if (container != null) {
|
||||||
try {
|
|
||||||
return hasMakeTargets(container);
|
return hasMakeTargets(container);
|
||||||
} catch(Exception ex) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -126,9 +133,6 @@ public class FilterEmtpyFoldersAction extends Action {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.jface.action.Action#run()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
fViewer.refresh();
|
fViewer.refresh();
|
||||||
|
|
Loading…
Add table
Reference in a new issue