Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShuai Li2015-03-19 11:09:36 -0400
committerflorian noyrit2015-04-22 04:17:45 -0400
commit7a30d756081c60a9066d6c001200a7a510f6ae8b (patch)
treee26894555bfbd67beca4b9fccddd8bc4034dcdae /plugins/views/org.eclipse.papyrus.views.search
parent2d4af9118f39ca8069ab1af5e237407909baa169 (diff)
downloadorg.eclipse.papyrus-7a30d756081c60a9066d6c001200a7a510f6ae8b.tar.gz
org.eclipse.papyrus-7a30d756081c60a9066d6c001200a7a510f6ae8b.tar.xz
org.eclipse.papyrus-7a30d756081c60a9066d6c001200a7a510f6ae8b.zip
- Remove unnused imports
- Use IAdaptable pattern, and IFile to test if selection is file or container Change-Id: I82f5de56d11497d77dc952e2e3403e14fda8eb55 Signed-off-by: Shuai Li <shuai.li@cea.fr> Reviewed-on: https://git.eclipse.org/r/44258 Tested-by: Hudson CI Reviewed-by: florian noyrit <florian.noyrit@cea.fr> Tested-by: florian noyrit <florian.noyrit@cea.fr>
Diffstat (limited to 'plugins/views/org.eclipse.papyrus.views.search')
-rw-r--r--plugins/views/org.eclipse.papyrus.views.search/src/org/eclipse/papyrus/views/search/scope/ScopeCollector.java31
1 files changed, 17 insertions, 14 deletions
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<URI> diFiles = new ArrayList<URI>();
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<URI> 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);
}

Back to the top