com.jstatcom.ts
Class DefaultTSListPopup

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JPopupMenu
                  extended by com.jstatcom.ts.DefaultTSListPopup
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, javax.accessibility.Accessible, javax.swing.MenuElement

public class DefaultTSListPopup
extends javax.swing.JPopupMenu

A PopupMenu especially designed to work with the TSList component. It is invoked, when the RIGHT mouse button is pressed over a time series list. The underlying TSList can be referenced by getTSList after the popup was triggered. The component also takes care, that the registered TSActionTypes and TSMenuTypes get a reference to the underlying TSList via the TSListAccessor interface.

The DefaultTSListPopup can be customized by adding/removing TSActionTypes or TSMenuTypes. New actions/menus can easily be created by subclassing TSActionTypes or TSMenuTypes. This is the preferred and easiest way of costumizing the DefaultTSListPopup, although subclassing or using other methods provided by JPopupMenu are also possible.

Author:
Markus Kraetzig
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JPopupMenu
javax.swing.JPopupMenu.Separator
 
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.BaselineResizeBehavior
 
Field Summary
 
Fields inherited from class javax.swing.JComponent
TOOL_TIP_TEXT_KEY, 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
DefaultTSListPopup(java.lang.String label)
          Creates a DefaultTSListPopup with a descriptive name.
 
Method Summary
 void addTSAction(TSActionTypes actionType)
          Adds an action to this popup menu.
 void addTSActionAt(TSActionTypes actionType, int pos)
          Adds an action to this popup menu at a given index.
 void addTSMenu(com.jstatcom.ts.TSMenuTypes tsMenu)
          Adds a menu to this popup menu.
 void addTSMenuAt(com.jstatcom.ts.TSMenuTypes tsMenu, int pos)
          Adds a menu to this popup menu at a given index.
static DefaultTSListPopup getSharedInstance()
          Returns an instance of the popup, that can be shared across all TSList instances.
 TSList getTSList()
          Gets the reference to the underlying TSList that this popup is invoked on.
 void processMouseEvent(java.awt.event.MouseEvent e, javax.swing.MenuElement[] path, javax.swing.MenuSelectionManager manager)
          Triggers the popup menu if the invoker was a TSList.
 void removeAction(TSActionTypes actionType)
          Removes actions from the popupmenu.
 void setTSList(TSList newTsList)
          Sets the reference to the TSList that this popup is invoked on.
 java.lang.String toString()
          Returns a string representation of DefaultTSListPopup.
 
Methods inherited from class javax.swing.JPopupMenu
add, add, add, addMenuKeyListener, addPopupMenuListener, addSeparator, getAccessibleContext, getComponent, getComponentAtIndex, getComponentIndex, getDefaultLightWeightPopupEnabled, getInvoker, getLabel, getMargin, getMenuKeyListeners, getPopupMenuListeners, getSelectionModel, getSubElements, getUI, getUIClassID, insert, insert, isBorderPainted, isLightWeightPopupEnabled, isPopupTrigger, isVisible, menuSelectionChanged, pack, processKeyEvent, remove, removeMenuKeyListener, removePopupMenuListener, setBorderPainted, setDefaultLightWeightPopupEnabled, setInvoker, setLabel, setLightWeightPopupEnabled, setLocation, setPopupSize, setPopupSize, setSelected, setSelectionModel, setUI, setVisible, show, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintImmediately, paintImmediately, print, printAll, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setVerifyInputWhenFocusTarget, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, transferFocusDownCycle, validate
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, contains, createImage, createImage, createVolatileImage, createVolatileImage, dispatchEvent, enable, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setName, setSize, setSize, show, show, size, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DefaultTSListPopup

public DefaultTSListPopup(java.lang.String label)
Creates a DefaultTSListPopup with a descriptive name. Use this constructor only, if you need a instance that should be different from getSharedInstance.

Parameters:
label - String
Method Detail

addTSAction

public final void addTSAction(TSActionTypes actionType)
Adds an action to this popup menu. Nothing is done, if the same action was already added.

Parameters:
actionType - the action to add

addTSActionAt

public final void addTSActionAt(TSActionTypes actionType,
                                int pos)
Adds an action to this popup menu at a given index. Nothing is done, if the same action was already added.

Parameters:
actionType - the action to add
pos - index of new position
Throws:
java.lang.IllegalArgumentException - if pos not valid

addTSMenu

public final void addTSMenu(com.jstatcom.ts.TSMenuTypes tsMenu)
Adds a menu to this popup menu. Nothing is done, if the same menu was already added.

Parameters:
tsMenu - the menu to add

addTSMenuAt

public final void addTSMenuAt(com.jstatcom.ts.TSMenuTypes tsMenu,
                              int pos)
Adds a menu to this popup menu at a given index. Nothing is done, if the same menu was already added.

Parameters:
tsMenu - the menu to add
pos - index of new position
Throws:
java.lang.IllegalArgumentException - if pos not valid

getSharedInstance

public static DefaultTSListPopup getSharedInstance()
Returns an instance of the popup, that can be shared across all TSList instances. It is also possible to create instances with the constructor that can be individually configured and set to a TSList that should have a different popup.

Returns:
an instance of this class that can be shared

getTSList

public final TSList getTSList()
Gets the reference to the underlying TSList that this popup is invoked on.

Returns:
the currently referenced TSList

processMouseEvent

public void processMouseEvent(java.awt.event.MouseEvent e,
                              javax.swing.MenuElement[] path,
                              javax.swing.MenuSelectionManager manager)
Triggers the popup menu if the invoker was a TSList.

Specified by:
processMouseEvent in interface javax.swing.MenuElement
Overrides:
processMouseEvent in class javax.swing.JPopupMenu
Parameters:
e - the mouse event
path - can be null in this context
manager - can be null in this context

removeAction

public final void removeAction(TSActionTypes actionType)
Removes actions from the popupmenu. Nothing is done, if the action does not exist.

Parameters:
actionType - the action to be removed

setTSList

public final void setTSList(TSList newTsList)
Sets the reference to the TSList that this popup is invoked on.

Parameters:
newTsList - the list to be referenced

toString

public java.lang.String toString()
Returns a string representation of DefaultTSListPopup.

Overrides:
toString in class java.awt.Component
Returns:
string representation