Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 168066

Summary: [Capabilities] cannot filter primary wizards
Product: [Eclipse Project] Platform Reporter: Paul E. Keyser <rolarenfan>
Component: UIAssignee: Kim Horne <eclipse>
Status: RESOLVED WONTFIX QA Contact:
Severity: normal    
Priority: P3 CC: acabler
Version: 3.2.1Keywords: helpwanted
Target Milestone: 3.4   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description Paul E. Keyser CLA 2006-12-14 10:44:12 EST
Build ID: M20060921-0945

Steps To Reproduce:
1. Create a new wizard (Java and markup) 
2. Add an activity and category, and bind the activity to the pattern of the id of the new wizard
3. follow the code execution from NewWizardNewPage, line 126 (checks activities regarding categories) and line 275 (createFilteredTree() and the content-provider: does *not* check activities)


More information:
Comment 1 Paul E. Keyser CLA 2006-12-14 13:01:22 EST
(under more info)

I think I wasn't clear enough: the activities work fine *IF* the new-wizard is in a category (that category is disabled); but what if I want (a) to disable wizards one by one rather than by category? or (b) want to place my new-wizards at the top-level (as one might, in an RCP app that had only a few new-wizards) and not in any category? 
Comment 2 Kim Horne CLA 2006-12-15 08:22:51 EST
Will investigate for M5
Comment 3 Adam Cabler CLA 2007-03-19 17:59:28 EDT
(In reply to comment #2)
> Will investigate for M5
> 

Is this still in the works for 3.3?
Comment 4 Kim Horne CLA 2007-03-19 18:19:37 EDT
I can't promise but I am more than willing to entertain a patch if you have one.  There are bigger issues we need to address first.
Comment 5 Kim Horne CLA 2007-05-08 11:15:07 EDT
I wont have time to look into this for 3.3.  Sorry.
Comment 6 Sebastian Staack CLA 2007-05-19 08:45:28 EDT
Proposal for solving this Bug
Replace the class WizardActivityFilter with this code (Changes are annotated):

/*******************************************************************************
 * Copyright (c) 2004, 2006 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/
package org.eclipse.ui.internal.dialogs;

import org.eclipse.jface.viewers.AbstractTreeViewer;
import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerFilter;
import org.eclipse.ui.activities.WorkbenchActivityHelper;
import org.eclipse.ui.model.AdaptableList;

/**
 * Viewer filter designed to work with the new wizard page (and its input/content provider).
 * This will filter all non-primary wizards that are not enabled by activity.
 * 
 * @since 3.0
 */
public class WizardActivityFilter extends ViewerFilter {

    /* (non-Javadoc)
     * @see org.eclipse.jface.viewers.ViewerFilter#select(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
     */
    public boolean select(Viewer viewer, Object parentElement, Object element) {
        Object[] children = ((ITreeContentProvider) ((AbstractTreeViewer) viewer)
                .getContentProvider()).getChildren(element);
        if (children.length > 0) {
			return filter(viewer, element, children).length > 0;
		}

        if (parentElement.getClass().equals(AdaptableList.class)) {
        	//SSoft
        	if (WorkbenchActivityHelper.filterItem(element)) {
    			return false;
    		}
        	//Original
			//return true; //top-level ("primary") wizards should always be returned
		}

        if (WorkbenchActivityHelper.filterItem(element)) {
			return false;
		}

        return true;
    }
}


Comment 7 Kim Horne CLA 2008-02-04 13:25:03 EST
Sorry for taking so long to look at this.

The problem with the patch is that it specifically works around "primary wizards."  Primary Wizards, by design, are intended to bypass activities entirely.  Specifying a wizard as primary is the only way to have a wizard show up at the top level and in this case having them always appear is consistent with our intentions.  

I'm inclined to close this as WONTFIX but would entertain a fix that satisfied our  "never filter" usage of primary wizards.  We have many downstream products that rely on this behaviour and we cannot change it.