sk.uniba.euromath.editor.wizards.document
Class NewDocumentWizardProvider

java.lang.Object
  extended by sk.uniba.euromath.editor.wizards.document.NewDocumentWizardProvider
All Implemented Interfaces:
IMultiWizardProvider

public class NewDocumentWizardProvider
extends Object
implements IMultiWizardProvider

A wizard that creates new XML document and returns it in a form of XMLAccess instance.

Author:
Martin Vysny

Field Summary
protected  MultiWizard parentWizard
          The instance of multiwizard object.
protected  Element root
          Root element; valid when user fills third page.
protected  String rootNamespace
          Root namespace of the document; valid when user fills second page.
protected  NewElementRule rootRule
          Root element rule; valid when user fills third page.
protected  List<IWizard> wizards
          List of pages that user visited.
protected  XMLAccess xmlAccess
          Document instance; non-null when user fills first page.
 
Constructor Summary
NewDocumentWizardProvider()
          The constructor.
 
Method Summary
 IWizard current()
          Fetches the current wizard.
 void dispose()
          Provider should dispose any objects it collected.
static XMLAccess execute(Shell shell)
          Helper method that executes the new document wizard.
 XMLAccess getDocument()
          Returns the document that was created using this wizard.
 String getName()
          Returns name of this wizard.
 boolean hasNext()
          Checks if there is next wizard.
 boolean hasPrevious()
          Checks if there is previous wizard.
protected  IWizard moveToFinishWizard()
          Creates the 'finish' page.
protected  IWizard moveToFourthWizard()
          Creates fourth page - starts to fill root element's contents, or finishes the document creation.
protected  OnePageWizard<NamespaceSelectorWizardPage> moveToSecondWizard()
          Creates second page - the root namespace selector page.
protected  OnePageWizard<NameListItemChooserWizardPage<NewElementRule>> moveToThirdWizard()
          Creates third page - the root element selector.
 IWizard next()
          Fetches the next wizard.
 void performCancel()
          Called when all opened wizards (from first wizard to current wizard) have already been cancelled.
 void performFinish()
          Called when all wizards (from first wizard to current wizard) have already been finished.
 IWizard previous()
          Fetches the previous wizard.
 void setWizard(MultiWizard wizard)
          Sets the multi-wizard object instance, that'll navigate user through other wizards using this provider.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

wizards

protected final List<IWizard> wizards
List of pages that user visited.


xmlAccess

protected XMLAccess xmlAccess
Document instance; non-null when user fills first page.


rootNamespace

protected String rootNamespace
Root namespace of the document; valid when user fills second page.


rootRule

protected NewElementRule rootRule
Root element rule; valid when user fills third page.


root

protected Element root
Root element; valid when user fills third page.


parentWizard

protected MultiWizard parentWizard
The instance of multiwizard object.

Constructor Detail

NewDocumentWizardProvider

public NewDocumentWizardProvider()
The constructor.

Method Detail

execute

public static XMLAccess execute(Shell shell)
Helper method that executes the new document wizard.

Parameters:
shell - parent of the wizard dialog. Can be null but this is not recommended.
Returns:
new document instance or null if user cancels the process.

current

public IWizard current()
Description copied from interface: IMultiWizardProvider
Fetches the current wizard.

Specified by:
current in interface IMultiWizardProvider
Returns:
current wizard. May return null only if the provider provides no wizards.

hasNext

public boolean hasNext()
Description copied from interface: IMultiWizardProvider
Checks if there is next wizard.

Specified by:
hasNext in interface IMultiWizardProvider
Returns:
true if there is next wizard or false if next() will fail.

hasPrevious

public boolean hasPrevious()
Description copied from interface: IMultiWizardProvider
Checks if there is previous wizard.

Specified by:
hasPrevious in interface IMultiWizardProvider
Returns:
true if there is previous wizard or false if previous() will fail.

next

public IWizard next()
             throws ProviderException
Description copied from interface: IMultiWizardProvider
Fetches the next wizard. Function may fail even when hasNext() returned true - it may throw ProviderException.

Specified by:
next in interface IMultiWizardProvider
Returns:
next wizard. The wizard does not have to be initialized - MultiWizard initializes it for you. Never null.
Throws:
ProviderException - if next wizard instance cannot be constructed thanks to some unexpected error. In such case, wizard stays at current page, exception is logged and an error dialog is shown.

performCancel

public void performCancel()
Description copied from interface: IMultiWizardProvider
Called when all opened wizards (from first wizard to current wizard) have already been cancelled.

Specified by:
performCancel in interface IMultiWizardProvider

performFinish

public void performFinish()
Description copied from interface: IMultiWizardProvider
Called when all wizards (from first wizard to current wizard) have already been finished.

Specified by:
performFinish in interface IMultiWizardProvider

previous

public IWizard previous()
Description copied from interface: IMultiWizardProvider
Fetches the previous wizard. Current wizard is automatically disposed.

Specified by:
previous in interface IMultiWizardProvider
Returns:
previous wizard.

setWizard

public void setWizard(MultiWizard wizard)
Description copied from interface: IMultiWizardProvider
Sets the multi-wizard object instance, that'll navigate user through other wizards using this provider.

Specified by:
setWizard in interface IMultiWizardProvider
Parameters:
wizard - the wizard that'll use this provider.

moveToSecondWizard

protected OnePageWizard<NamespaceSelectorWizardPage> moveToSecondWizard()
                                                                 throws ProviderException
Creates second page - the root namespace selector page.

Returns:
root namespace selector page, or null if error occured.
Throws:
ProviderException - if document fails to create.

moveToThirdWizard

protected OnePageWizard<NameListItemChooserWizardPage<NewElementRule>> moveToThirdWizard()
                                                                                  throws ProviderException
Creates third page - the root element selector.

Returns:
root element selector or null
Throws:
ProviderException - if schema fails to load.

moveToFourthWizard

protected IWizard moveToFourthWizard()
Creates fourth page - starts to fill root element's contents, or finishes the document creation.

Returns:
insertlist selector, or result of moveToFinishWizard() if no contents are required.

moveToFinishWizard

protected IWizard moveToFinishWizard()
Creates the 'finish' page.

Returns:
instance of the finish page.

dispose

public void dispose()
Description copied from interface: IMultiWizardProvider
Provider should dispose any objects it collected. Wizards are disposed automatically by the MultiWizard.

Specified by:
dispose in interface IMultiWizardProvider

getDocument

public XMLAccess getDocument()
Returns the document that was created using this wizard.

Returns:
document instance.

getName

public String getName()
Description copied from interface: IMultiWizardProvider
Returns name of this wizard. Describes this wizard. Shown in the dialog.

Specified by:
getName in interface IMultiWizardProvider
Returns:
displayable wizard name, like 'New element contents'. If null then the name is collected from child wizards.


Copyright © 2003-2006 null. All Rights Reserved.