From 7a30d756081c60a9066d6c001200a7a510f6ae8b Mon Sep 17 00:00:00 2001 From: Shuai Li Date: Thu, 19 Mar 2015 16:09:36 +0100 Subject: - Remove unnused imports - Use IAdaptable pattern, and IFile to test if selection is file or container Change-Id: I82f5de56d11497d77dc952e2e3403e14fda8eb55 Signed-off-by: Shuai Li Reviewed-on: https://git.eclipse.org/r/44258 Tested-by: Hudson CI Reviewed-by: florian noyrit Tested-by: florian noyrit --- .../papyrus/views/search/scope/ScopeCollector.java | 31 ++++++++++++---------- 1 file changed, 17 insertions(+), 14 deletions(-) (limited to 'plugins/views/org.eclipse.papyrus.views.search') diff --git a/plugins/views/org.eclipse.papyrus.views.search/src/org/eclipse/papyrus/views/search/scope/ScopeCollector.java b/plugins/views/org.eclipse.papyrus.views.search/src/org/eclipse/papyrus/views/search/scope/ScopeCollector.java index f683e4d8b93..c26d890b076 100644 --- a/plugins/views/org.eclipse.papyrus.views.search/src/org/eclipse/papyrus/views/search/scope/ScopeCollector.java +++ b/plugins/views/org.eclipse.papyrus.views.search/src/org/eclipse/papyrus/views/search/scope/ScopeCollector.java @@ -24,8 +24,8 @@ import java.util.List; import java.util.Set; import java.util.SortedSet; -import org.eclipse.core.internal.resources.Project; 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.IWorkspaceRoot; @@ -145,16 +145,16 @@ public class ScopeCollector implements IScopeCollector { while (it.hasNext()) { Object next = it.next(); - if (!(next instanceof IPapyrusFile) && !(next instanceof IPapyrusFile)) { - if (next instanceof Project) { - Project project = (Project) next; + if (!(next instanceof IPapyrusFile)) { + if (next instanceof IContainer) { // Folder, project, etc... + IContainer project = (IContainer) next; ArrayList diFiles = new ArrayList(); IPath path = project.getLocation(); IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot(); - + recursiveFindDiFiles(diFiles, path, workspaceRoot); results.addAll(diFiles); - } else { + } else { // Not a container, so it is some other kind of resource (e.g. file, graphical element) Object element = BusinessModelResolver.getInstance().getBusinessModel(next); if (element instanceof EObject) { // CDO resource *are* EObjects @@ -202,18 +202,21 @@ public class ScopeCollector implements IScopeCollector { } protected void recursiveFindDiFiles(ArrayList diFiles, IPath path, IWorkspaceRoot workspaceRoot) { - IContainer container = workspaceRoot.getContainerForLocation(path); + IContainer container = workspaceRoot.getContainerForLocation(path); try { IResource[] iResources; iResources = container.members(); - for (IResource iResource : iResources){ - // for c files - if ("di".equalsIgnoreCase(iResource.getFileExtension())) { - //diFiles.add(iResource.getLocationURI()); - URI theURI = URI.createPlatformResourceURI(iResource.getFullPath().toString(), true); - diFiles.add(theURI); - } else if (iResource.getType() == IResource.FOLDER) { + + for (IResource iResource : iResources) { + IFile iFile = (IFile) iResource.getAdapter(IFile.class); + + if (iFile != null) { + if ("di".equalsIgnoreCase(iResource.getFileExtension())) { + URI theURI = URI.createPlatformResourceURI(iResource.getFullPath().toString(), true); + diFiles.add(theURI); + } + } else { IPath tmpPath = iResource.getLocation(); recursiveFindDiFiles(diFiles, tmpPath, workspaceRoot); } -- cgit v1.2.3