01: /*******************************************************************************
02: * Copyright (c) 2007 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.pde.internal.ui.editor.toc.details;
11:
12: import org.eclipse.core.resources.IContainer;
13: import org.eclipse.core.resources.IFile;
14: import org.eclipse.core.resources.IProject;
15: import org.eclipse.core.resources.IResource;
16: import org.eclipse.core.runtime.CoreException;
17: import org.eclipse.core.runtime.IPath;
18: import org.eclipse.jface.viewers.Viewer;
19: import org.eclipse.jface.viewers.ViewerFilter;
20: import org.eclipse.pde.internal.ui.editor.toc.TocExtensionUtil;
21:
22: public class TocPageFilter extends ViewerFilter {
23: public boolean select(Viewer viewer, Object parent, Object element) {
24: if (element instanceof IFile) {
25: IPath path = ((IFile) element).getFullPath();
26:
27: return TocExtensionUtil.hasValidPageExtension(path);
28: }
29:
30: if (element instanceof IProject
31: && !((IProject) element).isOpen()) {
32: return false;
33: }
34:
35: if (element instanceof IContainer) {
36: try {
37: IResource[] resources = ((IContainer) element)
38: .members();
39: for (int i = 0; i < resources.length; i++) {
40: if (select(viewer, parent, resources[i])) {
41: return true;
42: }
43: }
44: } catch (CoreException e) {
45: }
46: }
47:
48: return false;
49: }
50: }
|