Ontimize 5.2072EN

com.ontimize.util.swing
Class JCalculatedExpression

java.lang.Object
  extended byjava.awt.Component
      extended byjava.awt.Container
          extended byjavax.swing.JComponent
              extended byjavax.swing.JPanel
                  extended bycom.ontimize.util.swing.JCalculatedExpression
All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable
Direct Known Subclasses:
CalculatedExpressionDataField

public class JCalculatedExpression
extends javax.swing.JPanel

See Also:
Serialized Form

Nested Class Summary
static class JCalculatedExpression.ColumnPosition
           
protected static class JCalculatedExpression.CustomListModel
           
static class JCalculatedExpression.Expression
           
protected static class JCalculatedExpression.InsertSymbolListener
           
 
Nested classes inherited from class javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanel
 
Nested classes inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
protected  javax.swing.JButton addButton
          Add button.
protected  javax.swing.JList availableFieldsList
          JList component that contains a list with available fields to use into the editor of expressions.
protected  javax.swing.JPanel buttonPanel
          Panel that contains all operation buttons.
protected  javax.swing.JButton closeParenthesisButton
          Close Parenthesis button.
protected  java.util.List componentList
          List of all components that conform the JCalculatedExpression
protected  javax.swing.JButton divideButton
          Divide button.
protected  ComponentTextPane expressionPane
          The reference to the editor of the mathematical expression.
protected  javax.swing.JButton multiplyButton
          Multiply button.
protected  javax.swing.JButton openParenthesisButton
          Open Parenthesis button.
protected  javax.swing.JSplitPane splitPane
          SplitPane that contains the mathematical editor and the list of available fields.
protected  javax.swing.JButton substractButton
          Subtract button.
protected  javax.swing.undo.UndoManager undoManager
          The reference to the UndoManager.
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
JCalculatedExpression()
           
 
Method Summary
 void addAvailableFields(java.lang.Object field)
           
protected  void addColumnToExpression(int index)
          This method adds selected available field from the list to the editor of expressions.
protected  void checkExpression(java.lang.String expr)
          This method checks if the mathematical expression of the editor is well defined.
protected  javax.swing.JButton createButton(java.lang.String text, java.lang.String iconPath, boolean addToGroup)
          This method creates a new JButton
protected  ComponentTextPane createExpressionEditor(boolean addToGroup)
          This method creates and configures 'editor' component.
protected  javax.swing.JList createList(java.util.List values, boolean addToGroup)
          This method creates the JList component where are stored available field to use into the mathematical expression.
static MathExpressionParser createParser(java.lang.String expr, java.util.List columns)
          This method creates the parser that is used to check the mathematical expression of the editor.
 java.util.List getAvailableFields()
          Recovers the list of available fields to use into the mathematical expression.
 java.lang.Object getAvailableFields(int index)
          This method returns from stored available fields the one indicated by the specified index.
 java.lang.Object getExpression()
          This method returns the mathematical expression contained into the editor.
protected  int[] getExpressionIndexColName(java.lang.String colName, java.lang.String expression)
           
protected  java.lang.String getFieldTranslation(java.lang.String field)
           
protected  void init()
          Initializes all components and distribute into the component.
protected  void installHighlight(javax.swing.JButton button)
           
protected  void registerUndoableListener(javax.swing.text.JTextComponent component)
           
protected  void registerUndoRedoActions(javax.swing.text.JTextComponent component)
           
 void removeAllAvailableFields()
           
 void removeAvailableFields(int index)
           
 void removeAvailableFields(java.lang.Object element)
           
 void setAvailableFields(java.util.List values)
          Sets the list of fields that are going to be allowed to introduce into the mathematical expression of the editor.
 void setBorder(javax.swing.border.Border border)
           
 void setEnabled(boolean enabled)
           
 void setExpression(java.lang.Object value)
          This method sets the mathematical expression into the editor.
protected  void setExpressionText(java.lang.String expression)
          This method sets the expression into the editor replacing the name of the available fields by CustomLabel objects.
protected  void updateSelectedCalculatedColumnExpression()
          This method updates the color of the text of the expression depending on if the expression is well defined (black foreground color) or not (red foreground color).
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setFont, setForeground, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

componentList

protected java.util.List componentList
List of all components that conform the JCalculatedExpression


undoManager

protected javax.swing.undo.UndoManager undoManager
The reference to the UndoManager.


expressionPane

protected ComponentTextPane expressionPane
The reference to the editor of the mathematical expression.


buttonPanel

protected javax.swing.JPanel buttonPanel
Panel that contains all operation buttons.


addButton

protected javax.swing.JButton addButton
Add button. Adds 'add' Math symbol to the editor.


substractButton

protected javax.swing.JButton substractButton
Subtract button. Adds 'subtract' Math symbol to the editor.


multiplyButton

protected javax.swing.JButton multiplyButton
Multiply button. Adds 'multiply' Math symbol to the editor.


divideButton

protected javax.swing.JButton divideButton
Divide button. Adds 'divide' Math symbol to the editor.


openParenthesisButton

protected javax.swing.JButton openParenthesisButton
Open Parenthesis button. Adds 'open parenthesis' symbol to the editor.


closeParenthesisButton

protected javax.swing.JButton closeParenthesisButton
Close Parenthesis button. Adds 'close parenthesis' symbol to the editor.


availableFieldsList

protected javax.swing.JList availableFieldsList
JList component that contains a list with available fields to use into the editor of expressions. The components contained on it are SelectableItem that allows to visualize the name of the available field with a check to select if this field is required or not.


splitPane

protected javax.swing.JSplitPane splitPane
SplitPane that contains the mathematical editor and the list of available fields.

Constructor Detail

JCalculatedExpression

public JCalculatedExpression()
Method Detail

init

protected void init()
Initializes all components and distribute into the component. The panel has configured a GridBagLayout ant the distribution is the following: - First row: ButtonPanel with all operation buttons. - Second row: SplitPane that contains the editor(on left side) and the list of available fields(on the right side).


setBorder

public void setBorder(javax.swing.border.Border border)

setEnabled

public void setEnabled(boolean enabled)

getAvailableFields

public java.util.List getAvailableFields()
Recovers the list of available fields to use into the mathematical expression.

Returns:
a List of elements.

getAvailableFields

public java.lang.Object getAvailableFields(int index)
This method returns from stored available fields the one indicated by the specified index.

Parameters:
index - The index of the element to recover.
Returns:
an Object with the name of the available field.

removeAvailableFields

public void removeAvailableFields(int index)

removeAvailableFields

public void removeAvailableFields(java.lang.Object element)

removeAllAvailableFields

public void removeAllAvailableFields()

setAvailableFields

public void setAvailableFields(java.util.List values)
Sets the list of fields that are going to be allowed to introduce into the mathematical expression of the editor.

Parameters:
values - A list with the values.

addAvailableFields

public void addAvailableFields(java.lang.Object field)

getExpression

public java.lang.Object getExpression()
This method returns the mathematical expression contained into the editor.

Returns:
a String with the mathematical expression.

setExpression

public void setExpression(java.lang.Object value)
This method sets the mathematical expression into the editor.

Parameters:
value - The mathematical expression.

setExpressionText

protected void setExpressionText(java.lang.String expression)
This method sets the expression into the editor replacing the name of the available fields by CustomLabel objects. It allows to manage the name of the fields as a unique entity instead of a set of characters.

Parameters:
expression -

getExpressionIndexColName

protected int[] getExpressionIndexColName(java.lang.String colName,
                                          java.lang.String expression)

createExpressionEditor

protected ComponentTextPane createExpressionEditor(boolean addToGroup)
This method creates and configures 'editor' component.

Parameters:
addToGroup - Boolean that indicates if it is desired to add the current button to the list of all components of the JCalculatedExpression.
Returns:
a ComponentTextPane component.

updateSelectedCalculatedColumnExpression

protected void updateSelectedCalculatedColumnExpression()
This method updates the color of the text of the expression depending on if the expression is well defined (black foreground color) or not (red foreground color).


checkExpression

protected void checkExpression(java.lang.String expr)
                        throws java.lang.Exception
This method checks if the mathematical expression of the editor is well defined.

Parameters:
expr - The mathematical expression.
Throws:
java.lang.Exception - if the expression is not well defined.

createParser

public static MathExpressionParser createParser(java.lang.String expr,
                                                java.util.List columns)
This method creates the parser that is used to check the mathematical expression of the editor.

Parameters:
expr - The mathematical expression
columns - List of available fields that can be used into the expression.
Returns:

registerUndoableListener

protected void registerUndoableListener(javax.swing.text.JTextComponent component)

registerUndoRedoActions

protected void registerUndoRedoActions(javax.swing.text.JTextComponent component)

createButton

protected javax.swing.JButton createButton(java.lang.String text,
                                           java.lang.String iconPath,
                                           boolean addToGroup)
This method creates a new JButton

Parameters:
text - Text of the button.
iconPath - Path to the icon of the button.
addToGroup - Boolean that indicates if it is desired to add the current button to the list of all components of the JCalculatedExpression.
Returns:
a JButton component.

installHighlight

protected void installHighlight(javax.swing.JButton button)

createList

protected javax.swing.JList createList(java.util.List values,
                                       boolean addToGroup)
This method creates the JList component where are stored available field to use into the mathematical expression.

Parameters:
values - The list of elements to insert into the JList.
addToGroup - Boolean that indicates if it is desired to add the current button to the list of all components of the JCalculatedExpression.
Returns:
a JList component.

addColumnToExpression

protected void addColumnToExpression(int index)
This method adds selected available field from the list to the editor of expressions.

Parameters:
index -

getFieldTranslation

protected java.lang.String getFieldTranslation(java.lang.String field)

Ontimize