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

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

public class InsertElementWizardProvider
extends Object
implements IMultiWizardProvider

A wizard that queries contents of new element(s) that should be inserted at given location. When wizard finishes, these elements are returned as an array of insertpoints and elements. Wizard does not insert those elements itself, you may use ElementLoc.insert() method to do that.

Author:
Martin Vysny

Field Summary
protected  MultiWizard parent
          We are being executed in this multiwizard.
protected  List<Element> roots
          'Root' elements - elements that'll be inserted into given parent element.
protected  List<NewElementRule> rules
          Contains rules for elements.
protected  InsertList selected
          Selected insert list.
protected  NamespaceManager startNsManager
          This manager was given to the constructor.
protected  List<IWizard> wizards
          Wizards that has been activated.
protected  XMLAccess xmlAccess
          The document instance.
 
Constructor Summary
InsertElementWizardProvider(XMLAccess xmlAccess, List<InsertList> insertLists, Element parent, NamespaceManager nsManager)
          Constructor.
 
Method Summary
 IWizard current()
          Fetches the current wizard.
 void dispose()
          Provider should dispose any objects it collected.
static ElementLoc execute(Shell parent, XMLAccess xmlAccess, sk.baka.ikslibs.ptr.DomPointer place, NamespaceManager nsManager, QName preselected)
          Helper method that executes the insert element wizard.
protected  IWizard findNextWizard()
          Finds next wizard for querying contents of an element.
 List<Element> getElements()
          'Root' elements - elements that'll be inserted into given parent element.
 InsertList getInsertList()
          Selected insert list.
 String getName()
          Returns name of this wizard.
 NamespaceManager getPrevNsManager()
          Previous namespace manager.
 boolean hasNext()
          Checks if there is next wizard.
 boolean hasPrevious()
          Checks if there is previous wizard.
 NamespaceManager newNsManager()
          Current namespace manager.
 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

xmlAccess

protected final XMLAccess xmlAccess
The document instance.


wizards

protected final List<IWizard> wizards
Wizards that has been activated. Warning: may contain nulls in order to be consistent with rules and roots lists.


startNsManager

protected final NamespaceManager startNsManager
This manager was given to the constructor.


parent

protected MultiWizard parent
We are being executed in this multiwizard.


rules

protected final List<NewElementRule> rules
Contains rules for elements. Last rule is the rule being currently filled in. i-th rule fills contents of roots.get(i) using wizards.get(i+1) wizard. Note that this wizard may be null if element does not require any contents.


roots

protected List<Element> roots
'Root' elements - elements that'll be inserted into given parent element.


selected

protected InsertList selected
Selected insert list. null if this provider is showing first wizard.

Constructor Detail

InsertElementWizardProvider

public InsertElementWizardProvider(XMLAccess xmlAccess,
                                   List<InsertList> insertLists,
                                   Element parent,
                                   NamespaceManager nsManager)
Constructor.

Parameters:
xmlAccess - instance of the document.
insertLists - list of possible insertlists.
parent - the parent element - here all elements will be created.
nsManager - the namespace manager instance.
Method Detail

execute

public static ElementLoc execute(Shell parent,
                                 XMLAccess xmlAccess,
                                 sk.baka.ikslibs.ptr.DomPointer place,
                                 NamespaceManager nsManager,
                                 QName preselected)
Helper method that executes the insert element wizard.

Parameters:
parent - parent of the wizard dialog. Can be null but this is not recommended.
place - where to insert new elements.
xmlAccess - the document instance.
nsManager - the namespace manager instance.
preselected - this element was requested by user to appear as first element. May be null.
Returns:
new elements and their locations, or null if user cancelled the wizard or no elements are insertable.

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

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

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

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.

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.

getElements

public List<Element> getElements()
'Root' elements - elements that'll be inserted into given parent element. If wizard shows its first page then null is returned.

Returns:
list of root elements or null if wizard shows its first page.

getInsertList

public InsertList getInsertList()
Selected insert list.

Returns:
selected insert list. null if this provider is showing first wizard.

getPrevNsManager

public NamespaceManager getPrevNsManager()
Previous namespace manager. If this provider is showing first wizard, then construct-time namespace manager is returned.

Returns:
current namespace manager. Queried from the last shown wizard (i.e. wizard before the currently active wizard).

newNsManager

public NamespaceManager newNsManager()
Current namespace manager.

Returns:
current namespace manager. Queried from the currently active wizard.

next

public IWizard next()
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.

findNextWizard

protected IWizard findNextWizard()
Finds next wizard for querying contents of an element. Returns null if no wizard is needed. All used rules are placed into the rules array to mark progress done. The wizards array is filled with nulls if required, to remain consistent with the rules array.

Returns:
a wizard instance, or null if no wizard is needed.

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.

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.

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.