sk.uniba.euromath.editor.widgets
Class GraphSelectorWidget

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

public class GraphSelectorWidget
extends AbstractUserInputWidget

Allows user to select choices in an export graph. Able to convert list of graph nodes to a list of TransformNode instances.

Author:
Martin Vysny

Nested Class Summary
 class GraphSelectorWidget.State
          The state of the widget.
 
Field Summary
protected  Composite composite
          Here all controls will be placed.
protected  ExportGraph graph
          Graph provided to the constructor.
protected  IdentityHashMap<GraphNode,Map<String,sk.uniba.euromath.editor.widgets.GraphSelectorWidget.ComboAndValue>> graphChoices
          Contains choices in graphs.
protected  Map<String,sk.uniba.euromath.editor.widgets.GraphSelectorWidget.CheckboxAndValue> wildcardCheckboxes
          Contains all wildcard checkboxes.
 
Fields inherited from class sk.uniba.euromath.editor.widgets.AbstractUserInputWidget
listeners, msgListeners
 
Constructor Summary
GraphSelectorWidget(Composite parent, Map<GraphNode,Set<String>> editableChoices, ExportGraph graph)
          Constructor.
 
Method Summary
 Composite getComposite()
          Returns composite that is encapsulated in this object.
static Map<GraphNode,Set<String>> getEditableChoices(ExportGraph graph)
          Computes and returns all choice nodes that the user can edit using this widget.
 ValidityMessages getMessages()
          Checks if data contained in the widget are correct.
 Object getState()
          Returns the state of this widget.
 Class<?> getStateClass()
          Returns the class of the state that the widget accepts.
 TransformGraph getTransformationInfo(CoordinatorInfo info)
           Processes actual selection and returns exact transformation tree.
protected static void scanGraph(GraphNode graph, Map<GraphNode,Set<String>> editableChoices)
          Scans the graph for a choice node.
 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
Here all controls will be placed.


graph

protected final ExportGraph graph
Graph provided to the constructor.


graphChoices

protected final IdentityHashMap<GraphNode,Map<String,sk.uniba.euromath.editor.widgets.GraphSelectorWidget.ComboAndValue>> graphChoices
Contains choices in graphs. Maps graph node instance and a namespace string to a combobox instance. Combo allows to select one of the graph node children.


wildcardCheckboxes

protected final Map<String,sk.uniba.euromath.editor.widgets.GraphSelectorWidget.CheckboxAndValue> wildcardCheckboxes
Contains all wildcard checkboxes. If this checkbox is checked then the namespace is transmitted to receiver as a tree representation, it is not exported normally.

Constructor Detail

GraphSelectorWidget

public GraphSelectorWidget(Composite parent,
                           Map<GraphNode,Set<String>> editableChoices,
                           ExportGraph graph)
Constructor.

Parameters:
parent - the parent widget
editableChoices - all choice nodes. May be empty or null.
graph - offer this graph to user. Must not be empty.
Throws:
IllegalArgumentException - if graphList or editableChoices is empty, or editableChoices refers to non-choosable nodes.
Method Detail

getEditableChoices

public static Map<GraphNode,Set<String>> getEditableChoices(ExportGraph graph)
Computes and returns all choice nodes that the user can edit using this widget.

Parameters:
graph - the export graph. Should be able to transform whole document.
Returns:
never null. A map of choice nodes. If empty then there are no choice points.

scanGraph

protected static void scanGraph(GraphNode graph,
                                Map<GraphNode,Set<String>> editableChoices)
Scans the graph for a choice node. If such node is found then it is registered into the graphChoices map and the scan continues. Descendants of the choice node are not searched for the choice nodes.

Parameters:
graph - graph to analyze.
editableChoices - put all choice nodes here.

getTransformationInfo

public TransformGraph getTransformationInfo(CoordinatorInfo info)
                                     throws ExportException,
                                            IOException

Processes actual selection and returns exact transformation tree. Each transformation info is produced from appropriate graph node: i-th info is produced from i-th graphlist item.

Not all choice nodes are made selectable; if a choice node is not selectable then simply the first exporter is selected.

Parameters:
info - the coordinator info object.
Returns:
list of transformation infos.
Throws:
ExportException - if exporter fails to initialize.
IOException - if i/o error occurs.

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.

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.