View | Details | Raw Unified | Return to bug 401104 | Differences between
and this patch

Collapse All | Expand All

(-)a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/views/imagebrowser/repositories/AbstractRepository.java (-3 / +3 lines)
Lines 70-83 Link Here
70
70
71
	protected boolean isImage(final File resource) {
71
	protected boolean isImage(final File resource) {
72
		if (resource.isFile())
72
		if (resource.isFile())
73
			return isImageName(resource.getName().toLowerCase());
73
			return isImageName(resource.getName());
74
74
75
		return false;
75
		return false;
76
	}
76
	}
77
77
78
	protected boolean isImageName(final String fileName) {
78
	protected boolean isImageName(final String fileName) {
79
		for (String extension : KNOWN_EXTENSIONS) {
79
		for (String extension : KNOWN_EXTENSIONS) {
80
			if (fileName.endsWith(extension))
80
			if (fileName.regionMatches(true, fileName.length() - extension.length(), extension, 0, extension.length()))
81
				return true;
81
				return true;
82
		}
82
		}
83
83
Lines 95-101 Link Here
95
			Enumeration<? extends ZipEntry> entries = zipFile.entries();
95
			Enumeration<? extends ZipEntry> entries = zipFile.entries();
96
			while ((entries.hasMoreElements()) && (!monitor.isCanceled())) {
96
			while ((entries.hasMoreElements()) && (!monitor.isCanceled())) {
97
				ZipEntry entry = entries.nextElement();
97
				ZipEntry entry = entries.nextElement();
98
				if (isImageName(entry.getName().toLowerCase())) {
98
				if (isImageName(entry.getName())) {
99
					InputStream inputStream = null;
99
					InputStream inputStream = null;
100
					try {
100
					try {
101
						inputStream = zipFile.getInputStream(entry);
101
						inputStream = zipFile.getInputStream(entry);
(-)a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/views/imagebrowser/repositories/WorkspaceRepository.java (-22 / +34 lines)
Lines 29-72 Link Here
29
	}
29
	}
30
30
31
	@Override
31
	@Override
32
	protected boolean populateCache(IProgressMonitor monitor) {
32
	protected boolean populateCache(final IProgressMonitor monitor) {
33
		if (fProjects == null)
33
		if (fProjects == null)
34
			initialize(monitor);
34
			initialize(monitor);
35
35
36
		if (!fProjects.isEmpty()) {
36
		if (!fProjects.isEmpty()) {
37
			IProject project = fProjects.get(fProjects.size() - 1);
37
38
			final IProject project = fProjects.remove(0);
38
39
39
			// look for a manifest
40
			// look for a manifest
40
			IFile manifest = project.getFile("META-INF/MANIFEST.MF"); //$NON-NLS-1$
41
			IFile manifest = project.getFile("META-INF/MANIFEST.MF"); //$NON-NLS-1$
42
41
			if (manifest.exists()) {
43
			if (manifest.exists()) {
42
				try {
44
				try {
43
					// extract plugin name
45
					// extract plugin name
44
					String pluginName = getPluginName(manifest.getContents());
46
					final String pluginName = getPluginName(manifest.getContents());
45
47
46
					// parse all folders
48
					// parse all folders
47
					Collection<IContainer> locations = new HashSet<IContainer>();
49
					project.accept(new IResourceProxyVisitor() {
48
					locations.add(project);
49
					do {
50
						IContainer next = locations.iterator().next();
51
						locations.remove(next);
52
50
53
						for (IResource resource : next.members()) {
51
						private boolean fIsCanceled = false;
54
							if (monitor.isCanceled())
55
								return true;
56
52
57
							if (resource instanceof IFile) {
53
						public boolean visit(IResourceProxy proxy) throws CoreException {
58
								try {
54
							if (fIsCanceled)
59
									if (isImageName(resource.getName().toLowerCase()))
55
								return false;
60
										addImageElement(new ImageElement(createImageData((IFile) resource), pluginName, resource.getProjectRelativePath().toPortableString()));
61
56
62
								} catch (Exception e) {
57
							switch (proxy.getType()) {
63
									// could not create image for location
58
								case IResource.PROJECT :
64
								}
59
									// fall through
65
							} else if (resource instanceof IContainer)
60
								case IResource.FOLDER :
66
								locations.add((IContainer) resource);
61
									// parse subfolders
62
									return true;
63
64
								case IResource.FILE :
65
									// look for image files
66
									try {
67
										if (isImageName(proxy.getName())) {
68
											addImageElement(new ImageElement(createImageData((IFile) proxy.requestResource()), pluginName, project.getProjectRelativePath().toPortableString()));
69
											if (monitor.isCanceled())
70
												fIsCanceled = true;
71
										}
72
73
									} catch (Exception e) {
74
										// could not create image for location
75
									}
76
									break;
77
							}
78
79
							return false;
67
						}
80
						}
68
81
					}, IResource.DEPTH_INFINITE, IContainer.INCLUDE_TEAM_PRIVATE_MEMBERS | IContainer.INCLUDE_HIDDEN);
69
					} while ((!locations.isEmpty()) && (!monitor.isCanceled()));
70
				} catch (CoreException e) {
82
				} catch (CoreException e) {
71
					PDEPlugin.log(e);
83
					PDEPlugin.log(e);
72
				} catch (IOException e) {
84
				} catch (IOException e) {

Return to bug 401104