Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apply activity filter for primary wizards to be shown in the New Wizard #2810

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,15 @@
*******************************************************************************/
package org.eclipse.ui.internal.dialogs;

import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.StringTokenizer;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.wizard.IWizard;
import org.eclipse.jface.wizard.Wizard;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.activities.WorkbenchActivityHelper;
import org.eclipse.ui.internal.IWorkbenchGraphicConstants;
import org.eclipse.ui.internal.WorkbenchImages;
import org.eclipse.ui.internal.WorkbenchMessages;
Expand All @@ -33,11 +37,11 @@
public class NewWizard extends Wizard {
private static final String CATEGORY_SEPARATOR = "/"; //$NON-NLS-1$

private String categoryId = null;
private String categoryId;

private NewWizardSelectionPage mainPage;

private boolean projectsOnly = false;
private boolean projectsOnly;

private IStructuredSelection selection;

Expand All @@ -51,6 +55,10 @@ public void addPages() {
IWizardCategory root = WorkbenchPlugin.getDefault().getNewWizardRegistry().getRootCategory();
IWizardDescriptor[] primary = WorkbenchPlugin.getDefault().getNewWizardRegistry().getPrimaryWizards();

// Filter the wizards that are disabled by activity support. Issue 2809
Collection<IWizardDescriptor> filteredWizards = WorkbenchActivityHelper.filterCollection(List.of(primary),
new HashSet<>());

if (categoryId != null) {
IWizardCategory categories = root;
StringTokenizer familyTokenizer = new StringTokenizer(categoryId, CATEGORY_SEPARATOR);
Expand All @@ -65,7 +73,8 @@ public void addPages() {
}
}

mainPage = new NewWizardSelectionPage(workbench, selection, root, primary, projectsOnly);
mainPage = new NewWizardSelectionPage(workbench, selection, root,
filteredWizards.toArray(IWizardDescriptor[]::new), projectsOnly);
addPage(mainPage);
}

Expand Down
Loading