Class ModelPanel
- java.lang.Object
-
- java.awt.Component
-
- java.awt.Container
-
- javax.swing.JComponent
-
- javax.swing.JPanel
-
- com.jstatcom.model.ModelPanel
-
- All Implemented Interfaces:
- Card, SymbolScope, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, javax.accessibility.Accessible
- Direct Known Subclasses:
- TSCalculator, TSSel
public class ModelPanel extends javax.swing.JPanel implements SymbolScope, Card
Panel to be used by components that need access to the symbol table hierarchy. The global and local symbol tables can be accessed viaglobalandlocal.The global symbol table is typically held by a
ModelFrameand stores data that must be shared by all panels belonging to a model frame.The global symbol table is found by traversing the component hierarchy on
addNotify. The nextSymbolScopeinstance is queried forglobal. If no parent component is aSymbolScope, thenlocalis used forglobal.The local symbol table is used to store data that is only visible to this component, but that should be displayed in the
SymbolTreeto make it transparent for viewing, saving and debugging.If this component is used in a
CardDisplayPanel, subclasses can overwriteshownto define the behaviour when this panel is displayed or hidden. This is often a good time to collect user specification and prepare data that is required by another panel.All
ModelPanelinstances are registered withJHelpContextMgrfor context sensitive help. The respective help IDs can be set in an XML file.- See Also:
CardDisplayPanel,ModelFrame, Serialized Form
-
-
Nested Class Summary
-
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
-
-
Constructor Summary
Constructors Constructor and Description ModelPanel()Creates aModelPanel.ModelPanel(java.awt.LayoutManager layout)Creates aModelPanelwith a layout manager.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method and Description voidaddNotify()Calls supermethod and finds parent instance ofSymbolScope.static SymbolScopefindParentScope(java.awt.Component comp)Finds the next parent that is aSymbolScope.SymbolTableglobal()Gets the global symbol table from the closest parent component that implementsSymbolScope.SymbolTablelocal()Gets the local symbol table that is only visible to this panel.voidshown(boolean isShown)Empty default imlementation forCardinterface.SymbolTableupper()Gets the local symbol table from the closest parent component that implementsSymbolScope.-
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, setUI, updateUI
-
Methods inherited from class javax.swing.JComponent
addAncestorListener, 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, hide, 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, setVisible, 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, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, 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, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, 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, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
-
-
-
-
Constructor Detail
-
ModelPanel
public ModelPanel()
Creates aModelPanel.
-
ModelPanel
public ModelPanel(java.awt.LayoutManager layout)
Creates aModelPanelwith a layout manager.- Parameters:
layout-
-
-
Method Detail
-
addNotify
public void addNotify()
Calls supermethod and finds parent instance ofSymbolScope. If no parent scope can be found, global and local will return the sameSymbolTable, meaning that this component will hold the global table.- Overrides:
addNotifyin classjavax.swing.JComponent
-
upper
public SymbolTable upper()
Gets the local symbol table from the closest parent component that implementsSymbolScope. If there is no parent implementingSymbolScope, the global, upper and local symbol table are the same.It might happen that this method is called before this component is added to the component hierarchy. In this case an initialized symbol table is returned. If the upper table changed after adding this to the hierarchy, all symbols from that table are copied to the new upper table and the reference changes. The remaining table is cleared and will not be displayed in the
SymbolTreeanymore.- Specified by:
upperin interfaceSymbolScope- Returns:
- the upper symbol table
- Throws:
java.lang.RuntimeException- ifglobalof a parentSymbolScopereturnsnull
-
global
public SymbolTable global()
Gets the global symbol table from the closest parent component that implementsSymbolScope. If there is no parent implementingSymbolScope, the global, upper and local symbol table are the same.It might happen that this method is called before this component is added to the component hierarchy. In this case an initialized symbol table is returned. If the global table changed after adding this to the hierarchy, all symbols from that table are copied to the new global table and the reference changes. The remaining table is cleared and will not be displayed in the
SymbolTreeanymore.- Specified by:
globalin interfaceSymbolScope- Returns:
- the global symbol table
- Throws:
java.lang.RuntimeException- ifglobalof a parentSymbolScopereturnsnull
-
local
public SymbolTable local()
Gets the local symbol table that is only visible to this panel. The name of this symbol table is equal togetName. If the name is empty, the classname is used instead. The parent is the upper symbol table.- Specified by:
localin interfaceSymbolScope- Returns:
- the local symbol table
-
shown
public void shown(boolean isShown)
Empty default imlementation forCardinterface. This method is only invoked if this component is shown or hidden by aCardDisplayPanel.
-
findParentScope
public static SymbolScope findParentScope(java.awt.Component comp)
Finds the next parent that is aSymbolScope. The result might benull, if this method is called on components that are not added to a component hierarchy yet. In that case the method must be run again onaddNotify.The result can be queried for
localorglobalto access the symbol table.If the calling component does not find a
SymbolScopeinstance in the hierarchy even afteraddNotifywas called, is has to deal with the situation by either firing an exception or by creating a new symbol table.- Parameters:
comp- the component to start traversing the component hierarchy from- Returns:
- the component that is instance of
SymbolScope - Throws:
java.lang.IllegalArgumentException-if (comp == null)
-
-
DMelt 3.0 © DataMelt by jWork.ORG