sk.uniba.euromath.editor.widgets
Class InsertListChooser

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

public class InsertListChooser
extends AbstractUserInputWidget

Allows the user to choose between multiple insertlists, and to choose the name of each element. These user settings are returned. Alternatively, user may choose to enter some text if it is permitted by the rule.

Author:
Martin Vysny

Nested Class Summary
protected  class InsertListChooser.ComboSelected
          Event handler for each combobox.
protected  class InsertListChooser.IlItemData
          Contains information on insertlist's comboboxes.
 class InsertListChooser.State
          The state of the chooser.
 
Field Summary
protected  int _selected
          Stores the index of the insertlist radio button, that is checked (selected).
protected  String _text
          Stores the text value that new element may contain.
protected  Composite composite
          Here all controls will be placed.
protected  List<List<InsertListChooser.IlItemData>> ilControls
          Controls (comboboxes) containing chosen qnames for each insertlist.
protected  List<InsertList> insertLists
          Insertlists.
protected  ValidityMessages lastMessages
          Last messages.
protected  NamespaceManager nsManager
          Current namespace manager.
protected  List<Button> radioButtons
          List of radio buttons.
protected  Button radioText
          This controls is valid (non- null) when the user can enter some text as an alternative to the insertlists.
protected  IValueRule textRule
          User may choose to enter text contents of an element instead.
protected  Text textText
          This control is valid (non- null) when the user can enter some text as an alternative to the insertlists.
protected  XMLAccess xmlAccess
          The XML Access instance.
 
Fields inherited from class sk.uniba.euromath.editor.widgets.AbstractUserInputWidget
listeners, msgListeners
 
Constructor Summary
InsertListChooser(Composite parent, XMLAccess xmlAccess, List<InsertList> insertLists, NamespaceManager nsManager, String parentName, IValueRule textRule)
          Creates an instance of the window.
 
Method Summary
 Set<String> getAllNamespaces()
          Retrieves all namespaces of currently selected attributes.
 Composite getComposite()
          Returns composite that is encapsulated in this object.
 InsertList getInsertList()
          Returns selected insertlist as a list of qnames.
 List<QName> getInsertListNames()
          Returns selected insertlist as a list of qnames.
 ValidityMessages getMessages()
          Checks if data contained in the widget are correct.
 int getSelected()
          Returns the index of the insert list, that is checked (selected).
protected  int getSelectedFromControl()
          Returns the index of the radio button, that is checked (selected).
protected  int getSelectedInternal()
          Returns the index of the radio button, that is checked (selected).
 Object getState()
          Returns the state of this widget.
 Class<?> getStateClass()
          Returns the class of the state that the widget accepts.
 String getText()
          Returns new textual value of element.
 void setState(Object state)
          Sets new state for the widget.
protected  void updateMessages()
          Updates error messages.
 
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
Here all controls will be placed.


xmlAccess

protected final XMLAccess xmlAccess
The XML Access instance.


insertLists

protected final List<InsertList> insertLists
Insertlists.


textRule

protected final IValueRule textRule
User may choose to enter text contents of an element instead.


nsManager

protected final NamespaceManager nsManager
Current namespace manager.


ilControls

protected final List<List<InsertListChooser.IlItemData>> ilControls
Controls (comboboxes) containing chosen qnames for each insertlist. Each list is a list of IlItemData instances, one instance depicts one ElementLoc.


radioButtons

protected final List<Button> radioButtons
List of radio buttons. These radio buttons serves for choosing the insertlist.


textText

protected final Text textText
This control is valid (non- null) when the user can enter some text as an alternative to the insertlists.


radioText

protected final Button radioText
This controls is valid (non- null) when the user can enter some text as an alternative to the insertlists.


_selected

protected int _selected
Stores the index of the insertlist radio button, that is checked (selected). -1 if none is selected and -2 if the text is selected. Valid after all radio buttons are disposed.


_text

protected String _text
Stores the text value that new element may contain. Valid after textText is disposed.


lastMessages

protected ValidityMessages lastMessages
Last messages.

Constructor Detail

InsertListChooser

public InsertListChooser(Composite parent,
                         XMLAccess xmlAccess,
                         List<InsertList> insertLists,
                         NamespaceManager nsManager,
                         String parentName,
                         IValueRule textRule)
Creates an instance of the window.

Parameters:
parent - where to place controls.
xmlAccess - the XML Access instance.
insertLists - the list of choosable insertlists.
nsManager - the map of namespace>prefix mapping. It will not get modified. If null then manager from xmlAccess will be used.
parentName - the displayable qname of the parent. It is only displayed in a window as a text - it is not used in other way.
textRule - if not null then it is possible to choose a text value also. This value must comply this rule.
Method Detail

getSelectedFromControl

protected int getSelectedFromControl()
Returns the index of the radio button, that is checked (selected). Radio buttons must not be disposed.

Returns:
the index of selected radio button, -1 if none is selected and -2 if the text is selected.

getSelectedInternal

protected int getSelectedInternal()
Returns the index of the radio button, that is checked (selected). Does not check for errors.

Returns:
the index of selected radio button, -1 if none is selected and -2 if the text is selected.

getSelected

public int getSelected()
Returns the index of the insert list, that is checked (selected). Sets error if -1 is returned.

Returns:
the index of selected radio button, -1 if none is selected and -2 if the text is selected.

getText

public String getText()
Returns new textual value of element. Sets error if text value is invalid.

Returns:
new text value, never null.

getInsertListNames

public List<QName> getInsertListNames()
Returns selected insertlist as a list of qnames. Calls getInsertList().

Returns:
list of qnames, never null. May contain nulls if appropriate qnames were not selected.
Throws:
IllegalStateException - if insertlist is not selected.

getInsertList

public InsertList getInsertList()
Returns selected insertlist as a list of qnames.

Returns:
list of qnames, never null.
Throws:
IllegalStateException - if insertlist is not selected.

getComposite

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

Returns:
composite where all controls are placed.

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.

updateMessages

protected void updateMessages()
Updates error messages.


getAllNamespaces

public Set<String> getAllNamespaces()
Retrieves all namespaces of currently selected attributes. Function must not be used when no insertlist is selected.

Returns:
all namespaces of the attributes. If there are errors on the page, the function may return incomplete set.

getState

public Object 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.