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

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

public class CreateAttributeListWizard
extends Object
implements IWizard

Manages the process of creating new attributes into newly created element. Attributes themselves are not created, their names and values are returned instead. Prefixes for new namespaces are queried.

Author:
Martin Vysny

Field Summary
 CreateAttributeListWizardPage calPage
          First wizard page.
protected  NamespaceManager currentManager
          Current namespace manager.
 XMLAccess xmlAccess
          The document instance.
 
Constructor Summary
CreateAttributeListWizard(List<AttributeListRule> listRules, String parentName, XMLAccess xmlAccess, NamespaceManager currentManager)
          Constructor.
 
Method Summary
 boolean canFinish()
          Returns whether this wizard could be finished without further user interaction.
 void createAttributes(Element e, DocumentModifier modifier)
          Creates all selected attributes with their values.
 BaseWizardPage current()
          Fetches the current page.
 void dispose()
          Disposes of this wizard.
static void execute(Shell parent, List<AttributeListRule> listRules, Element element, XMLAccess xmlAccess, Node context)
          Executes the wizard.
 String getName()
          Returns name of this wizard.
 List<QName> getNames()
          Returns qnames of new attributes, with appropriate prefixes when needed.
 NewPrefixesQueryWizardPage getNpqPage()
          Returns second wizard page.
 RGB getTitleBarColor()
          Returns the title bar color for this wizard.
 boolean hasNext()
          Checks if there is next page.
 boolean hasPrevious()
          Checks if there is previous page.
 NamespaceManager newNsManager()
          Creates new namespace manager, with new namespace-prefix mappings.
 BaseWizardPage next()
          Fetches the next page.
 boolean performCancel()
          Performs any actions appropriate in response to the user having pressed the Cancel button, or refuse if canceling now is not permitted.
 boolean performFinish()
          Performs any actions appropriate in response to the user having pressed the Finish button, or refuse if finishing now is not permitted.
 BaseWizardPage previous()
          Fetches the previous page.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

calPage

public final CreateAttributeListWizardPage calPage
First wizard page. Never null.


xmlAccess

public final XMLAccess xmlAccess
The document instance.


currentManager

protected final NamespaceManager currentManager
Current namespace manager.

Constructor Detail

CreateAttributeListWizard

public CreateAttributeListWizard(List<AttributeListRule> listRules,
                                 String parentName,
                                 XMLAccess xmlAccess,
                                 NamespaceManager currentManager)
Constructor.

Parameters:
listRules - the list of lists of attribute. Exactly one list will be chosen.
parentName - the name of the parent element. Used only to display the name on the shell.
xmlAccess - the xml document instance.
currentManager - the current manager. It won't get modified. If new prefixes needs to be registered, they are registered in a separate namespace manager, built on demand by the newNsManager().
Method Detail

getNpqPage

public NewPrefixesQueryWizardPage getNpqPage()
Returns second wizard page. null when wizard is on the first page.

Returns:
second wizard page. null when wizard is on the first page.

newNsManager

public NamespaceManager newNsManager()
Creates new namespace manager, with new namespace-prefix mappings. If no new mappings are defined, function simply returns old namespace manager.

Returns:
new namespace manager, or instance given to the object constructor if no new namespaces are introduced.
Throws:
IllegalArgumentException - if the page contains errors thus some prefixes cannot be registered.
IllegalStateException - if the page contains errors thus some prefixes cannot be registered.

canFinish

public boolean canFinish()
Description copied from interface: IWizard
Returns whether this wizard could be finished without further user interaction.

The result of this method is typically used by the wizard container to enable or disable the Finish button.

Specified by:
canFinish in interface IWizard
Returns:
true if the wizard could be finished, and false otherwise

hasNext

public boolean hasNext()
Description copied from interface: IWizard
Checks if there is next page. This method must return false if current page contains errors.

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

hasPrevious

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

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

next

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

Specified by:
next in interface IWizard
Returns:
next page. The page does not have to be initialized - MultiWizard initializes it for you. Never null.

current

public BaseWizardPage current()
Description copied from interface: IWizard
Fetches the current page.

Specified by:
current in interface IWizard
Returns:
current page. May return null only if the provider provides no pages.

dispose

public void dispose()
Description copied from interface: IWizard
Disposes of this wizard. All SWT resources are freed automatically when this method finishes.

Specified by:
dispose in interface IWizard

getName

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

Specified by:
getName in interface IWizard
Returns:
displayable wizard name, like 'New element contents'.

getTitleBarColor

public RGB getTitleBarColor()
Description copied from interface: IWizard
Returns the title bar color for this wizard.

Specified by:
getTitleBarColor in interface IWizard
Returns:
the title bar color, or null if default should be used.

previous

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

Specified by:
previous in interface IWizard
Returns:
previous page.

performCancel

public boolean performCancel()
Description copied from interface: IWizard
Performs any actions appropriate in response to the user having pressed the Cancel button, or refuse if canceling now is not permitted.

Specified by:
performCancel in interface IWizard
Returns:
true to indicate the cancel request was accepted, and false to indicate that the cancel request was refused

performFinish

public boolean performFinish()
Description copied from interface: IWizard
Performs any actions appropriate in response to the user having pressed the Finish button, or refuse if finishing now is not permitted. Normally this method is only called on the container's current wizard. However if the current wizard is a nested wizard this method will also be called on all wizards in its parent chain. Such parents may use this notification to save state etc. However, the value the parents return from this method is ignored.

Specified by:
performFinish in interface IWizard
Returns:
true to indicate the finish request was accepted, and false to indicate that the finish request was refused

getNames

public List<QName> getNames()
Returns qnames of new attributes, with appropriate prefixes when needed.

Returns:
qnames of new attributes. null if error occurs.

createAttributes

public void createAttributes(Element e,
                             DocumentModifier modifier)
Creates all selected attributes with their values. Function fails if there are errors on the page.

Parameters:
e - create attributes here.
modifier - if not null then changes are written using document modifier. Otherwise, they are written directly to the element.
Throws:
IllegalStateException - if there are still errors on the page.

execute

public static void execute(Shell parent,
                           List<AttributeListRule> listRules,
                           Element element,
                           XMLAccess xmlAccess,
                           Node context)
                    throws ExportException
Executes the wizard. When the wizard finishes the attributes are created succesfully, or nothing is done if the operation is cancelled by the user.

Parameters:
parent - the parent window. Should not be null.
listRules - the rules describing creatable attributes.
element - where to create the attributes.
xmlAccess - the document instance.
context - where the attribute will be created.
Throws:
ExportException - if modification finalizer fails.


Copyright © 2003-2006 null. All Rights Reserved.