mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Fix for 205013: Project Explorer: filtering non-C project also filters out the C projects
This commit is contained in:
parent
35a31af9c6
commit
3930fa6ccf
3 changed files with 29 additions and 11 deletions
|
@ -242,7 +242,7 @@ HideArchiveFiles.description= Hides Archive files
|
|||
HideObjectFiles.label= Object files
|
||||
HideObjectFiles.description= Hides Object files
|
||||
|
||||
HideNonCElements.label= Non-C resource
|
||||
HideNonCElements.label= Non-C elements
|
||||
HideNonCElements.description= Show only C elements
|
||||
|
||||
HideNonCProjects.label = Non-C projects
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2000, 2006 IBM Corporation and others.
|
||||
* Copyright (c) 2000, 2007 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -7,9 +7,11 @@
|
|||
*
|
||||
* Contributors:
|
||||
* IBM Corporation - initial API and implementation
|
||||
* Anton Leherbauer (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.ui.filters;
|
||||
|
||||
import org.eclipse.cdt.core.model.CoreModel;
|
||||
import org.eclipse.cdt.core.model.ICElement;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
|
@ -21,7 +23,7 @@ import org.eclipse.jface.viewers.ViewerFilter;
|
|||
|
||||
|
||||
/**
|
||||
* Filters out all non-Java elements.
|
||||
* Filters out all non-C elements.
|
||||
*/
|
||||
public class NonCElementFilter extends ViewerFilter {
|
||||
|
||||
|
@ -34,13 +36,19 @@ public class NonCElementFilter extends ViewerFilter {
|
|||
public boolean select(Viewer viewer, Object parent, Object element) {
|
||||
if (element instanceof ICElement)
|
||||
return true;
|
||||
|
||||
if (element instanceof IResource) {
|
||||
IProject project= ((IResource)element).getProject();
|
||||
|
||||
if (element instanceof IProject) {
|
||||
IProject project = (IProject)element;
|
||||
if (!project.isOpen() || CoreModel.hasCNature(project)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
} else if (element instanceof IResource) {
|
||||
IProject project= ((IResource)element).getProject();
|
||||
return project == null || !project.isOpen();
|
||||
}
|
||||
|
||||
// Exclude all IStorage elements which are neither Java elements nor resources
|
||||
// Exclude all IStorage elements which are neither C elements nor resources
|
||||
if (element instanceof IStorage)
|
||||
return false;
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2000, 2006 IBM Corporation and others.
|
||||
* Copyright (c) 2000, 2007 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -7,18 +7,21 @@
|
|||
*
|
||||
* Contributors:
|
||||
* IBM Corporation - initial API and implementation
|
||||
* Anton Leherbauer (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.ui.filters;
|
||||
|
||||
|
||||
import org.eclipse.cdt.core.model.ICProject;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.jface.viewers.Viewer;
|
||||
import org.eclipse.jface.viewers.ViewerFilter;
|
||||
|
||||
import org.eclipse.cdt.core.model.CoreModel;
|
||||
import org.eclipse.cdt.core.model.ICProject;
|
||||
|
||||
|
||||
/**
|
||||
* Filters closed projects
|
||||
* Filters (open) non-C projects.
|
||||
*/
|
||||
public class NonCProjectsFilter extends ViewerFilter {
|
||||
|
||||
|
@ -29,7 +32,14 @@ public class NonCProjectsFilter extends ViewerFilter {
|
|||
if (element instanceof ICProject) {
|
||||
return true;
|
||||
} else if (element instanceof IProject) {
|
||||
return !((IProject)element).isOpen();
|
||||
IProject project = (IProject)element;
|
||||
if (!project.isOpen()) {
|
||||
return true;
|
||||
}
|
||||
if (CoreModel.hasCNature(project)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue