Skip to main content



      Home
Home » Eclipse Projects » Rich Client Platform (RCP) » Disabling some new file wizard?
Disabling some new file wizard? [message #557646] Wed, 08 September 2010 07:57 Go to next message
Eclipse UserFriend
Hello,

is there a possibility to disable some new wizard (defined using
org.eclipse.ui.newWizards) contributed by another plug-in?

-Jan
Re: Disabling some new file wizard? [message #557675 is a reply to message #557646] Wed, 08 September 2010 09:47 Go to previous messageGo to next message
Eclipse UserFriend
Not sure if you can disable the wizard itself.

For your case would it be possible to simply remove the toolbar icon/menu item that launches the wizard?

Re: Disabling some new file wizard? [message #655349 is a reply to message #557646] Sat, 19 February 2011 13:00 Go to previous messageGo to next message
Eclipse UserFriend
AbstractExtensionWizardRegistry wizardRegistry = (AbstractExtensionWizardRegistry)WorkbenchPlugin.getDefault().getNewWizardRegistry();
IWizardCategory[] categories = WorkbenchPlugin.getDefault().getNewWizardRegistry().getRootCategory().getCategories();
for(IWizardDescriptor wizard : getAllWizards(categories)){
	WorkbenchWizardElement wizardElement = (WorkbenchWizardElement) wizard;
	if(!allowedWizard(wizardElement.getId())){
	wizardRegistry.removeExtension(wizardElement.getConfigurationElement().getDeclaringExtension(), new Object[]{wizardElement});
	}
}



getAllWizards() is a method where you want to collect all the wizards that may reside in any of the categories... categories are hierarhycal so must go down deep recursively after the wizards...

this did the job for me:
 
private IWizardDescriptor[] getAllWizards(IWizardCategory... categories) {
		List<IWizardDescriptor> results = new ArrayList<IWizardDescriptor>();
		for(IWizardCategory wizardCategory : categories){
			results.addAll(Arrays.asList(wizardCategory.getWizards()));
			results.addAll(Arrays.asList(getAllWizards(wizardCategory.getCategories())));
		}
		return results.toArray(new IWizardDescriptor[0]);
	}



includeWizard():
once you have ALL the wizards at hand, you can make the choice to remove or leave them there. Here i remove all the wizards (and their cathegories except the basic and Task wizards)
protected static final List<String> FILE_NEW__ALLOWED_WIZARDS = Collections.unmodifiableList(Arrays.asList(new String[]{
			"org.eclipse.mylyn.tasks.ui.wizards.new.category", // Tasks wizards
			"org.eclipse.mylyn.tasks.ui.wizards.new.repository.task",// Tasks wizards
			"org.eclipse.mylyn.tasks.ui.wizards.new.query",// Tasks wizards
			"org.eclipse.ui.editors.wizards.UntitledTextFileWizard", // Basic wizards
			"org.eclipse.ui.wizards.new.project",// Basic wizards
			"org.eclipse.ui.wizards.new.folder",// Basic wizards
			"org.eclipse.ui.wizards.new.file" // Basic wizards
	}));

protected boolean allowedWizard(String wizardId) {
		return FILE_NEW__ALLOWED_WIZARDS.contains(wizardId);
	}



Re: Disabling some new file wizard? [message #655497 is a reply to message #557646] Mon, 21 February 2011 08:14 Go to previous message
Eclipse UserFriend
You should also have a look at how to disable activities, it may be helful for your use-case:
http://help.eclipse.org/helios/index.jsp?topic=/org.eclipse. platform.doc.isv/reference/extension-points/org_eclipse_ui_a ctivities.html

HTH
--
Mickael Istria -- BonitaSoft S.A.
http://www.bonitasoft.com/products/BPM_download.php
Previous Topic:Special character in branding text
Next Topic:JDIC in RCP application
Goto Forum:
  


Current Time: Wed Jul 23 23:08:36 EDT 2025

Powered by FUDForum. Page generated in 0.26805 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top