sk.uniba.euromath.editor.widgets
Class NewPrefixesQuery

java.lang.Object
  extended by sk.uniba.euromath.editor.widgets.AbstractUserInputWidget
      extended by sk.uniba.euromath.editor.widgets.NewPrefixesQuery
All Implemented Interfaces:
IUserInputWidget

public class NewPrefixesQuery
extends AbstractUserInputWidget

Queries for new prefixes.

Author:
Martin Vysny

Nested Class Summary
protected  class NewPrefixesQuery.TextDisposeListener
          Dispose listener for text boxes.
 
Field Summary
protected  Composite composite
          Composite where all controls are placed.
protected  ValidityMessages lastMessages
          Error messages.
protected  Set<String> namespaces
          Get prefixes for these namespaces.
protected  NamespaceManager nsManager
          Current namespace manager.
protected  Map<String,String> prefixes
          Maps namespace URI to prefix.
protected  Map<String,Text> prefixTexts
          Here all prefix textboxes are kept.
 
Fields inherited from class sk.uniba.euromath.editor.widgets.AbstractUserInputWidget
listeners, msgListeners
 
Constructor Summary
NewPrefixesQuery(Composite parent, Set<String> namespaces, NamespaceManager nsManager)
          Constructs the component.
 
Method Summary
protected  void checkErrors(Map<String,String> map)
          Checks data for errors.
 Composite getComposite()
          Returns composite that is encapsulated in this object.
 ValidityMessages getMessages()
          Checks if data contained in the widget are correct.
static Set<String> getNamespaces(List<? extends QName> qnames)
          Returns all namespaces that occurs in given list.
 Map<String,String> getPrefixes()
          Returns currently selected prefixes.
 Map<String,String> getPrefixesInternal()
          Returns currently selected prefixes.
 Map<String,String> getState()
          Returns the state of this widget.
 Class<?> getStateClass()
          Returns the class of the state that the widget accepts.
 NamespaceManager newUpdatedManager()
          Produces a namespace manager where these new prefixes are registered.
 List<QName> setPrefixes(List<QName> qnames)
          Modifies the prefixes of all qnames to currently selected prefixes.
 void setState(Object state)
          Sets new state for the widget.
 
Methods inherited from class sk.uniba.euromath.editor.widgets.AbstractUserInputWidget
addMessageListener, addModifyListener, allowModifyEvent, fireDataModified, removeMessageListener, removeModifyListener, suppressModifyEvent
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

composite

protected final Composite composite
Composite where all controls are placed.


namespaces

protected final Set<String> namespaces
Get prefixes for these namespaces.


nsManager

protected final NamespaceManager nsManager
Current namespace manager.


prefixTexts

protected final Map<String,Text> prefixTexts
Here all prefix textboxes are kept.


prefixes

protected final Map<String,String> prefixes
Maps namespace URI to prefix.


lastMessages

protected ValidityMessages lastMessages
Error messages.

Constructor Detail

NewPrefixesQuery

public NewPrefixesQuery(Composite parent,
                        Set<String> namespaces,
                        NamespaceManager nsManager)
Constructs the component.

Parameters:
parent - the parent composite.
namespaces - get prefixes for these namespaces.
nsManager - current namespace manager. New prefixes are not registered here, new manager is created instead.
Method Detail

getComposite

public Composite getComposite()
Description copied from interface: IUserInputWidget
Returns composite that is encapsulated in this object.

Returns:
composite where all controls are placed.

getPrefixes

public Map<String,String> getPrefixes()
Returns currently selected prefixes.

Returns:
map that maps namespace URI to prefix, never null.

getPrefixesInternal

public Map<String,String> getPrefixesInternal()
Returns currently selected prefixes. Does not check for errors.

Returns:
map that maps namespace URI to prefix, never null.

getNamespaces

public static Set<String> getNamespaces(List<? extends QName> qnames)
Returns all namespaces that occurs in given list. Empty namespace is not in the result set - this is because empty namespace does not have prefix in EuroMath2.

Parameters:
qnames - set of qnames. nulls are permitted - they are simply ignored.
Returns:
all namespaces in given list.

newUpdatedManager

public NamespaceManager newUpdatedManager()
Produces a namespace manager where these new prefixes are registered.

Returns:
namespace manager containing new prefix mappings.
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.

getMessages

public ValidityMessages getMessages()
Description copied from interface: IUserInputWidget
Checks if data contained in the widget are correct. Contains error/info/warning messages that occured during last data change.

Returns:
null if data is correct, or instance of ValidityMessages if there is error, warning or info message.

checkErrors

protected void checkErrors(Map<String,String> map)
Checks data for errors.

Parameters:
map - map that maps namespace URI to prefix, must not be null.

setPrefixes

public List<QName> setPrefixes(List<QName> qnames)
Modifies the prefixes of all qnames to currently selected prefixes.

Parameters:
qnames - list of qnames to modify
Returns:
modified qnames

getState

public Map<String,String> getState()
Description copied from interface: IUserInputWidget
Returns the state of this widget. The state must be in sync with the controls placed on the widget.

Returns:
the model.

getStateClass

public Class<?> getStateClass()
Description copied from interface: IUserInputWidget
Returns the class of the state that the widget accepts.

Returns:
model class, never null.

setState

public void setState(Object state)
Description copied from interface: IUserInputWidget
Sets new state for the widget. The widget must re-read all relevant properties from the state and set its controls with new values.

Parameters:
state - the model to set. You may use the construct setModel(getModel()) to reflect changes made in the model. Please note that nearly all widgets rejects null value.


Copyright © 2003-2006 null. All Rights Reserved.