| /******************************************************************************* |
| * Copyright (c) 2000, 2017 IBM Corporation and others. |
| * This program and the accompanying materials are made available under the |
| * terms of the Eclipse Public License v. 2.0 which is available at |
| * http://www.eclipse.org/legal/epl-2.0. |
| * |
| * SPDX-License-Identifier: EPL-2.0 |
| * |
| *******************************************************************************/ |
| package org.eclipse.dltk.internal.ui.filters; |
| |
| import org.eclipse.core.resources.IProject; |
| import org.eclipse.core.resources.IResource; |
| import org.eclipse.dltk.core.IProjectFragment; |
| import org.eclipse.dltk.internal.ui.scriptview.BuildPathContainer; |
| import org.eclipse.jface.viewers.Viewer; |
| import org.eclipse.jface.viewers.ViewerFilter; |
| |
| /** |
| * The LibraryFilter is a filter used to determine whether |
| * a script library is shown |
| */ |
| public class LibraryFilter extends ViewerFilter { |
| |
| @Override |
| public boolean select(Viewer viewer, Object parentElement, Object element) { |
| if (element instanceof BuildPathContainer) |
| return false; |
| if (element instanceof IProjectFragment) { |
| IProjectFragment root= (IProjectFragment)element; |
| if (root.isArchive()) { |
| // don't filter out archives contained in the project itself |
| IResource resource= root.getResource(); |
| if (resource != null) { |
| IProject archiveProject= resource.getProject(); |
| IProject container= root.getScriptProject().getProject(); |
| return container.equals(archiveProject); |
| } |
| return false; |
| } |
| } |
| return true; |
| } |
| } |