/* * Copyright 2005 by Oracle USA * 500 Oracle Parkway, Redwood Shores, California, 94065, U.S.A. * All rights reserved. */ package javax.ide.wizard; import java.util.Collection; import java.util.HashMap; import java.util.Map; import javax.ide.Service; import javax.ide.command.Context; import javax.ide.extension.ExtensionRegistry; import javax.ide.spi.ProviderNotFoundException; import javax.ide.util.MetaClass; import javax.ide.wizard.spi.WizardHook; /** * The WizardManager provides the interface through which the IDE invokes * Wizards.
*/ public class WizardManager extends Service { private final Map _wizardInstancesById = new HashMap(); /** * Invokes a wizard with the specified execution context and * parameters.
*
* @param context The execution context for the invokable.
* @param id The id identifying the wizard.
*
* @return true
if the wizard completed successfully,
* otherwise false
.
*
*/
public boolean invokeWizard( Context context, String id )
{
Wizard theWizard = findOrCreateWizard( id );
return theWizard.invoke( context );
}
/**
* Initialize the wizard manager.
*/
protected final WizardHook getWizardHook()
{
return (WizardHook)ExtensionRegistry.getExtensionRegistry().getHook( WizardHook.ELEMENT );
}
private MetaClass getWizardClass( String id )
{
return getWizardHook().getWizardInfo( id ).getWizardClass();
}
/**
* Get the class names of all registered wizards.
*
* @return a collection of string class names of all registered wizards.
*/
protected final Collection /*