KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ui > internal > dialogs > NewWizardActivityFilter


1 /*******************************************************************************
2  * Copyright (c) 2004 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.ui.internal.dialogs;
12
13 import org.eclipse.jface.viewers.AbstractTreeViewer;
14 import org.eclipse.jface.viewers.ITreeContentProvider;
15 import org.eclipse.jface.viewers.Viewer;
16 import org.eclipse.jface.viewers.ViewerFilter;
17 import org.eclipse.ui.activities.WorkbenchActivityHelper;
18 import org.eclipse.ui.model.AdaptableList;
19
20 /**
21  * Viewer filter designed to work with the new wizard page (and its input/content provider).
22  * This will filter all non-primary wizards that are not enabled by activity.
23  *
24  * @since 3.0
25  */

26 public class NewWizardActivityFilter extends ViewerFilter {
27
28     /* (non-Javadoc)
29      * @see org.eclipse.jface.viewers.ViewerFilter#select(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
30      */

31     public boolean select(Viewer viewer, Object JavaDoc parentElement, Object JavaDoc element) {
32         Object JavaDoc[] children = ((ITreeContentProvider) ((AbstractTreeViewer) viewer)
33                 .getContentProvider()).getChildren(element);
34         if (children.length > 0)
35             return filter(viewer, element, children).length > 0;
36
37         if (parentElement.getClass().equals(AdaptableList.class))
38             return true; //top-level ("primary") wizards should always be returned
39

40         if (WorkbenchActivityHelper.filterItem(element))
41             return false;
42
43         return true;
44     }
45 }
46
Popular Tags