com.sas.swing.visuals.dataselectors.dataitems
Class DataItemSelector

com.sas.swing.visuals.dataselectors.dataitems.DataItemSelector
All Implemented Interfaces:
DataSelectorInterface, PanelInterface, LayoutConstants, java.awt.event.ActionListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.util.EventListener, javax.swing.event.TreeModelListener, javax.swing.event.TreeSelectionListener

public class DataItemSelector
implements LayoutConstants, javax.swing.event.TreeModelListener, javax.swing.event.TreeSelectionListener, java.awt.event.ActionListener

The DataItemSelector provides a user interface for dynamically changing items assigned to query roles.

The selector includes a dual-tree selector for displaying the available and selected items, and a text area to display a description of an item (if available).

With OLAP queries, the selector includes a dropdown list for selecting the roles to assign items to, a dropdown list to set the available tree display to an alphabetical or by item type view, and a Move Item button that allows the user to quickly move items in the selected tree to the opposite role. Note: This implementation currently only supports the Row and Column roles.

With relational queries, the selector includes radio buttons that allow the user to set the query type to view either a detail (shows all rows in the dataset) or a grouped report.

Since:
3.1
See Also:
Serialized Form

Field Summary
protected  javax.swing.JRadioButton detailRadioButton
          The radio button for setting the query type to Detail
protected  DualTreeSelector dualSelector
          The dual tree selector component used to select items for the query
protected  javax.swing.JRadioButton groupByRadioButton
          The radio button for setting the query type to Group By
protected  javax.swing.JPanel lowerPanel
          A panel containing the viewItemsPanel and the positionPanel
protected  javax.swing.JPanel messagePanel
          The panel containing the message text area
protected  javax.swing.JTextArea messageTextArea
          The text area used to display descriptions of items in the dual selector
protected  DataItemSelectorInterface model
          The selector data model
protected  javax.swing.JButton moveItemButton
          The Move Item button used to move selected items between role nodes
protected  javax.swing.JPanel positionPanel
          The panel containing the Move Item button
protected  javax.swing.JPanel querySelectionPanel
          The main selector panel
protected  javax.swing.JLabel queryTypeLabel
          The Query Type label
protected  javax.swing.JPanel queryTypePanel
          The panel containing the Query Type radio buttons
protected  javax.swing.JComboBox roleComboBox
          The role selection combobox
protected  javax.swing.JLabel roleLabel
          The label for the role selection combobox
protected  javax.swing.JPanel sourceContainer
          The dualSelector container above the available tree containing the role selection combobox
protected  javax.swing.JComboBox viewItemsComboBox
          The View Items combobox used to set the available tree display type
protected  javax.swing.JLabel viewItemsLabel
          The label for the View Items combobox
protected  javax.swing.JPanel viewItemsPanel
          The container for the View Items combobox
 
Fields inherited from class com.sas.swing.visuals.dataselectors.BaseSwingSelectorPanel
command, contentsValid, selectorModel, wasCancelled
 
Fields inherited from interface com.sas.swing.visuals.util.LayoutConstants
DOTS_BUTTON_INSETS, EMPTY_INSETS, HGAP, HMARGIN, INDENTED_BORDER, TAB_BORDER, TEXTFIELD_INSETS, VGAP, VMARGIN
 
Fields inherited from interface com.sas.swing.visuals.PanelInterface
CONTENTS_VALID_PROPERTY
 
Constructor Summary
DataItemSelector()
          Default constructor
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent e)
          Responds to events fired by the role selection combobox, the view items by combobox, the Move Item button, and the query type radio buttons.
protected  void addListeners()
          Sets the appropriate components as listeners for events fired from the selector.
protected  void createComponents()
          Creates all of the components of the selector, sets the component properties, and creates the layout for the selector.
 java.lang.String getDialogTitle()
          Returns a title for this panel that should be displayed on a dialog's title bar.
 void onApply()
          This method is called when the OK button is clicked.
 void setRoleComboBoxModel()
          Creates and sets the combobox model for the role selection combobox.
 void setSelectorModel(java.lang.Object model)
          Sets the selector data model and selector component properties that depend on OLAP or relational models.
 void setTreeModels()
          Creates and sets the tree models for the available and selected trees of the dual tree selector, expands the folder nodes in the available model, expands the selected role node in the selected tree model, and turns off multiple selection for OLAP queries.
 void treeNodesChanged(javax.swing.event.TreeModelEvent e)
          Defined in javax.tree.event.TreeModelListener, but not implemented in this class
 void treeNodesInserted(javax.swing.event.TreeModelEvent e)
          Responds to events fired when nodes are inserted into the selected tree.
 void treeNodesRemoved(javax.swing.event.TreeModelEvent e)
          Responds to events fired when nodes are removed from the selected tree.
 void treeStructureChanged(javax.swing.event.TreeModelEvent e)
          Defined in javax.tree.event.TreeModelListener, but not implemented in this class
 void valueChanged(javax.swing.event.TreeSelectionEvent e)
          Receives and processes TreeSelectionEvents to enable or disable the Move Item button and set the item description in the text entry area.
 
Methods inherited from class com.sas.swing.visuals.dataselectors.BaseSwingSelectorPanel
getCommand, getHelpID, getPanel, getSelectorModel, getTabTitle, isContentsValid, isYesNo, onCancel, onClose, setCommand, setContentsValid
 
Methods inherited from interface com.sas.dataselectors.DataSelectorInterface
isVisible, setVisible
 

Field Detail

roleLabel

protected javax.swing.JLabel roleLabel
The label for the role selection combobox


roleComboBox

protected javax.swing.JComboBox roleComboBox
The role selection combobox


dualSelector

protected DualTreeSelector dualSelector
The dual tree selector component used to select items for the query


viewItemsLabel

protected javax.swing.JLabel viewItemsLabel
The label for the View Items combobox


viewItemsComboBox

protected javax.swing.JComboBox viewItemsComboBox
The View Items combobox used to set the available tree display type


moveItemButton

protected javax.swing.JButton moveItemButton
The Move Item button used to move selected items between role nodes


messageTextArea

protected javax.swing.JTextArea messageTextArea
The text area used to display descriptions of items in the dual selector


queryTypeLabel

protected javax.swing.JLabel queryTypeLabel
The Query Type label


groupByRadioButton

protected javax.swing.JRadioButton groupByRadioButton
The radio button for setting the query type to Group By


detailRadioButton

protected javax.swing.JRadioButton detailRadioButton
The radio button for setting the query type to Detail


model

protected DataItemSelectorInterface model
The selector data model


querySelectionPanel

protected javax.swing.JPanel querySelectionPanel
The main selector panel


lowerPanel

protected javax.swing.JPanel lowerPanel
A panel containing the viewItemsPanel and the positionPanel


sourceContainer

protected javax.swing.JPanel sourceContainer
The dualSelector container above the available tree containing the role selection combobox


viewItemsPanel

protected javax.swing.JPanel viewItemsPanel
The container for the View Items combobox


positionPanel

protected javax.swing.JPanel positionPanel
The panel containing the Move Item button


messagePanel

protected javax.swing.JPanel messagePanel
The panel containing the message text area


queryTypePanel

protected javax.swing.JPanel queryTypePanel
The panel containing the Query Type radio buttons

Constructor Detail

DataItemSelector

public DataItemSelector()
Default constructor

Method Detail

createComponents

protected void createComponents()
Creates all of the components of the selector, sets the component properties, and creates the layout for the selector.


onApply

public void onApply()
This method is called when the OK button is clicked. It performs a check on the adapter to see if the role assignments are valid, and sets the query type on the adapter for relational queries.

Specified by:
onApply in interface PanelInterface
Overrides:
onApply in class BaseSwingSelectorPanel

addListeners

protected void addListeners()
Sets the appropriate components as listeners for events fired from the selector.


setSelectorModel

public void setSelectorModel(java.lang.Object model)
Sets the selector data model and selector component properties that depend on OLAP or relational models. The model should be a DataItemSelectorInterface to work properly.

Specified by:
setSelectorModel in interface DataSelectorInterface
Overrides:
setSelectorModel in class BaseSwingSelectorPanel
Parameters:
model - - the selector data model
See Also:
DataItemSelectorInterface

setRoleComboBoxModel

public void setRoleComboBoxModel()
Creates and sets the combobox model for the role selection combobox.

See Also:
DefaultComboBoxModel

setTreeModels

public void setTreeModels()
Creates and sets the tree models for the available and selected trees of the dual tree selector, expands the folder nodes in the available model, expands the selected role node in the selected tree model, and turns off multiple selection for OLAP queries.


getDialogTitle

public java.lang.String getDialogTitle()
Returns a title for this panel that should be displayed on a dialog's title bar.

Specified by:
getDialogTitle in interface PanelInterface
Overrides:
getDialogTitle in class BaseSwingSelectorPanel
Returns:
the title to display if used in a dialog

valueChanged

public void valueChanged(javax.swing.event.TreeSelectionEvent e)
Receives and processes TreeSelectionEvents to enable or disable the Move Item button and set the item description in the text entry area. This method runs twice on each selection in the dual tree selector, once to select the item and another time to unselect an item in the other tree.

Specified by:
valueChanged in interface javax.swing.event.TreeSelectionListener
Parameters:
e - the tree selection event

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent e)
Responds to events fired by the role selection combobox, the view items by combobox, the Move Item button, and the query type radio buttons.

For the role selection combobox (OLAP only), the node in the selected tree corresponding to the previous role value is collapsed and the node for the new role value is expanded, a new tree model is created for the available tree, and the available and selected trees are repainted.

For View Items By combobox events (OLAP only), a new tree model is created for the available tree to represent the type of view selected by the user. If By Item Type is selected, the category nodes (Hierarchies, Levels, Measures) are expanded. The available tree is then repainted to display the values in the new model.

When an event is received from the Move Item button (OLAP only), the selected node is deleted from its current role node and added to the opposite role node, and new tree models are created for the available and selected trees to display the current items that are available and selected.

Events received for the Query Type radio buttons (relational only) result in a new tree model generated for the available tree. If detail is selected, items in the available tree that do not support detail usage are disabled. If group by is selected, all items in the available tree should be enabled.

Specified by:
actionPerformed in interface java.awt.event.ActionListener
Parameters:
e - - the event fired by one of the selector components
See Also:
DataItemActionType

treeNodesChanged

public void treeNodesChanged(javax.swing.event.TreeModelEvent e)
Defined in javax.tree.event.TreeModelListener, but not implemented in this class

Specified by:
treeNodesChanged in interface javax.swing.event.TreeModelListener

treeNodesInserted

public void treeNodesInserted(javax.swing.event.TreeModelEvent e)
Responds to events fired when nodes are inserted into the selected tree. For OLAP queries a new available tree model is generated since adding an item may result in other items being no longer available. For example, adding an item that is a member of a hierarchy would make that hierarchy no longer available. For relational queries, the query type radio buttons may be disabled as a result of an item being added. For example, if Group By is selected, and an item is added to the selected tree that does not support detail usage, the query type radio buttons would be disabled since all items in the selected tree no longer support detail. The selector data model is also updated to add the item to the appropriate role.

Specified by:
treeNodesInserted in interface javax.swing.event.TreeModelListener
Parameters:
e - - the event fired by the selected tree
See Also:
DataItemActionType, DataItemSelectorInterface

treeNodesRemoved

public void treeNodesRemoved(javax.swing.event.TreeModelEvent e)
Responds to events fired when nodes are removed from the selected tree. For OLAP queries a new available tree model is generated since removing an item may result in other items becoming available. For example, removing an item that is a hierarchy would make the members of the hierarchy available for selection. For relational queries, the query type radio buttons may be enabled as a result of an item being removed. For example, if the query type radio buttons are disabled because an item in the selected tree does not support detail usage, and that item is removed from the selected tree , the query type radio buttons would then be enabled since all items in the selected tree no then support detail. The selector data model is also updated to remove the item from the appropriate role.

Specified by:
treeNodesRemoved in interface javax.swing.event.TreeModelListener
Parameters:
e - - the event fired by the selected tree
See Also:
DataItemActionType, DataItemSelectorInterface

treeStructureChanged

public void treeStructureChanged(javax.swing.event.TreeModelEvent e)
Defined in javax.tree.event.TreeModelListener, but not implemented in this class

Specified by:
treeStructureChanged in interface javax.swing.event.TreeModelListener



Copyright © 2009 SAS Institute Inc. All Rights Reserved.