sk.uniba.euromath.editor.widgets.namelist
Class NameListItemChooser<R extends BaseRule>

java.lang.Object
  extended by sk.uniba.euromath.editor.widgets.AbstractUserInputWidget
      extended by sk.uniba.euromath.editor.widgets.namelist.NameListItemChooser<R>
Type Parameters:
R - accepts namelists containing this type of BaseRule.
All Implemented Interfaces:
IUserInputWidget

public class NameListItemChooser<R extends BaseRule>
extends AbstractUserInputWidget

Allows the user to pick one item from given namelist. Automatically handles schema loading when needed.

Author:
Martin Vysny

Nested Class Summary
static class NameListItemChooser.State<R extends BaseRule>
          The state of the widget.
 
Field Summary
protected  QName _selectedQName
          Valid after the component is disposed.
protected  R _selectedRule
          Valid after the component is disposed.
protected  String _selectedValue
          Valid after the component is disposed.
protected  Combo cmbAttrName
          Combo containing all names from the namelist.
protected  Composite composite
          All controls are placed here.
 DisplayableNameList<R> dnl
          Allow to select item from this namelist.
protected  ValidityMessages lastMessages
          Error messages.
protected  Label lNamespace
          Displays namespace of selected name.
protected  Label lNamespaceDescription
          Displays description of namespace of selected name.
protected  Label lValueType
          Displays string describing allowed textual value.
 NamespaceManager nsManager
          Namespace manager.
protected  Text prefix
          Textbox that allows modification of the XML namespace prefix.
protected  Text textValue
          Allows to change textual value if the name is name of attribute.
protected  XMLAccess xmlAccess
          Document instance.
 
Fields inherited from class sk.uniba.euromath.editor.widgets.AbstractUserInputWidget
listeners, msgListeners
 
Constructor Summary
NameListItemChooser(Composite parent, XMLAccess xmlAccess, DisplayableNameList<R> dnl, String text, NamespaceManager nsManager)
          Constructs instance of the object.
 
Method Summary
 void checkErrors()
          Checks wrong values on component.
static NameListItemChooser<AttributeRule> createAttributeCreator(Composite parent, INameList<AttributeRule> nameList, XMLAccess xmlAccess, NamespaceManager nsManager)
          Constructs an instance of the component, that will be used to create an attribute.
static NameListItemChooser<AttributeRule> createAttributeEditor(Composite parent, Attr attr, AttributeRule rule, XMLAccess xmlAccess, NamespaceManager nsManager)
          Constructs an instance of the component, that will be using for edit an attribute value.
 Composite getComposite()
          Returns composite that is encapsulated in this object.
 ValidityMessages getMessages()
          Checks if data contained in the widget are correct.
 QName getSelectedQName()
          Returns qname of selected namelist item.
protected  QName getSelectedQNameFromControl()
          Retrieves selected qname from the combobox.
 R getSelectedRule()
          Returns rule for selected item.
protected  R getSelectedRuleFromControl()
          Retrieves rule for selected item from the combobox.
 String getSelectedValue()
          Contains value of the attribute.
 NameListItemChooser.State<R> getState()
          Returns the state of this widget.
 Class<?> getStateClass()
          Returns the class of the state that the widget accepts.
protected  void refreshControls()
          Refreshes the controls that the form shows.
 void setState(Object model)
          Sets new state for the widget.
protected  void update()
          Recreates the namelists and updates combobox.
 
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
All controls are placed here.


xmlAccess

protected final XMLAccess xmlAccess
Document instance.


nsManager

public final NamespaceManager nsManager
Namespace manager.


dnl

public final DisplayableNameList<R extends BaseRule> dnl
Allow to select item from this namelist.


cmbAttrName

protected final Combo cmbAttrName
Combo containing all names from the namelist.


prefix

protected final Text prefix
Textbox that allows modification of the XML namespace prefix.


lNamespace

protected final Label lNamespace
Displays namespace of selected name.


lNamespaceDescription

protected final Label lNamespaceDescription
Displays description of namespace of selected name.


textValue

protected final Text textValue
Allows to change textual value if the name is name of attribute. null if namelist contain element names.


lValueType

protected final Label lValueType
Displays string describing allowed textual value. null if namelist contain element names.


_selectedQName

protected QName _selectedQName
Valid after the component is disposed.


_selectedValue

protected String _selectedValue
Valid after the component is disposed.


_selectedRule

protected R extends BaseRule _selectedRule
Valid after the component is disposed.


lastMessages

protected ValidityMessages lastMessages
Error messages.

Constructor Detail

NameListItemChooser

public NameListItemChooser(Composite parent,
                           XMLAccess xmlAccess,
                           DisplayableNameList<R> dnl,
                           String text,
                           NamespaceManager nsManager)
Constructs instance of the object.

Parameters:
parent - here a composite with components will be placed.
xmlAccess - the document instance.
dnl - Allow to select item from this namelist.
text - this text will be displayed above all controls.
nsManager - namespace manager. If null then the one from xmlAccess will be used.
Method Detail

createAttributeCreator

public static NameListItemChooser<AttributeRule> createAttributeCreator(Composite parent,
                                                                        INameList<AttributeRule> nameList,
                                                                        XMLAccess xmlAccess,
                                                                        NamespaceManager nsManager)
Constructs an instance of the component, that will be used to create an attribute. Component will not create the attribute itself.

Parameters:
parent - here a composite with components will be placed.
nameList - list of attributes that can be created.
xmlAccess - the XMLAccess instance.
nsManager - the namespace manager. If null then the one from xmlAccess will be used.
Returns:
namelist item chooser, intented for creating an attribute

createAttributeEditor

public static NameListItemChooser<AttributeRule> createAttributeEditor(Composite parent,
                                                                       Attr attr,
                                                                       AttributeRule rule,
                                                                       XMLAccess xmlAccess,
                                                                       NamespaceManager nsManager)
Constructs an instance of the component, that will be using for edit an attribute value.

Parameters:
parent - here a composite with components will be placed.
attr - the attribute. The window will not change the attribute value itself.
rule - the rule for the attribute.
xmlAccess - the XMLAccess instance.
nsManager - namespace manager. If null then the one from xmlAccess will be used.
Returns:
namelist item chooser, intented for modifying attribute value only

getComposite

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

Returns:
composite where all controls are placed.

refreshControls

protected void refreshControls()
Refreshes the controls that the form shows.


update

protected void update()
Recreates the namelists and updates combobox.


getSelectedQName

public QName getSelectedQName()
Returns qname of selected namelist item.

Returns:
qname of selected namelist item or null if no item is selected.

getSelectedQNameFromControl

protected QName getSelectedQNameFromControl()
Retrieves selected qname from the combobox. Combobox must not be disposed.

Returns:
qname of selected namelist item or null if no item is selected.

getSelectedValue

public final String getSelectedValue()
Contains value of the attribute.

Returns:
the value or null if namelist contains element names.

getSelectedRule

public R getSelectedRule()
Returns rule for selected item.

Returns:
rule for selected item.

getSelectedRuleFromControl

protected R getSelectedRuleFromControl()
Retrieves rule for selected item from the combobox. Combobox must not be disposed.

Returns:
rule for selected or null if no item is selected.

checkErrors

public void checkErrors()
Checks wrong values on component.


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.

getState

public NameListItemChooser.State<R> 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 model)
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:
model - 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.