|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object
|
+--java.awt.Component
|
+--java.awt.Container
|
+--javax.swing.JComponent
|
+--javax.swing.JPanel
|
+--com.ca.commons.cbutil.CBSaveLoadTemplate
An object of this cunning class can be added as is to any container containing user-input components such as text fields, check boxes and so forth. When it is asked to 'save' a template, it scans through its parent container, identifies user-input components, and saves their data to a properties file with the name 'template name' + 'component number'.These can be automatically read back later.
At the moment it only handles the *swing* components:
JTextField, CBJComboBox, JCheckBox, but it could easily be modified
(would need to change JContainer checks to Container).
It will iterate through sub-components, but since there is no "JContainer" class, all sub-components must be explicitly listed in the code; at the moment it only handles JPanel.
The fact that it does not handle JPasswordField is considered a feature.
Warning This class is unlikely to correctly handle non-string data; i.e. combo boxes with icons etc.
| Nested Class Summary |
| 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 |
delete
|
protected CBJComboBox |
loadops
|
protected javax.swing.JButton |
makeDefault
|
protected javax.swing.JButton |
save
|
java.lang.String |
saveFileName
|
java.util.Properties |
templates
|
| 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 | |
CBSaveLoadTemplate(java.lang.String fileName)
Each CBSaveLoadTemplate object must have a file name to read and load data from... |
|
| Method Summary | |
void |
addIllegalComponent(java.awt.Component c)
|
void |
delete()
|
void |
deleteComponentInfo(java.awt.Container myContainer,
java.lang.String templateName)
|
void |
deleteComponentInfo(java.lang.String templateName)
Deletes a template that is saved in the property file. |
java.lang.String |
getComponentText(java.awt.Component c)
this ftn returns the text to save for a given component, and is the sister ftn to 'loadComponentText'. |
java.lang.String |
getCurrentTemplateName()
|
CBJComboBox |
getLoadComboBox()
Expose the root combo box for the use of adding listeners 'n stuff. |
void |
load()
Takes a template name, and attempts to read all the (string) values belonging to that template, and toss them in the appropriate numbered component. |
protected void |
loadComponent(java.awt.Component c,
int componentNo,
java.lang.String templateName)
This method handles the loading of a particular component. |
void |
loadComponentText(java.awt.Component c,
java.lang.String text)
|
void |
loadContainerInfo(java.awt.Container myContainer,
java.lang.String templateName)
|
void |
loadDefault()
Loads the dafault set up (if one has been saved) |
void |
loadTemplateName(java.lang.String templateName)
|
void |
makeDefault()
|
protected void |
parseFile(java.lang.String fileName)
|
void |
save()
saves a dialog windows state by working through all the components held by the parent container, and if they are (selected) User Input objects (TextFields etc.) saving their contents to a properties list. |
protected void |
saveComponent(java.awt.Component c,
int componentNo,
java.lang.String templateName)
This method handles the saving of a particular component. |
void |
saveContainerInfo(java.awt.Container myContainer,
java.lang.String templateName)
iterates through a container, saving user-entry components as it goes. |
void |
saveTemplateName(java.lang.String templateName)
|
int |
showMessage()
Opens an dialog that asks if the user wants to delete the template. |
| 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, setBorder, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, 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 |
protected javax.swing.JButton save
protected javax.swing.JButton delete
protected javax.swing.JButton makeDefault
protected CBJComboBox loadops
public java.lang.String saveFileName
public java.util.Properties templates
| Constructor Detail |
public CBSaveLoadTemplate(java.lang.String fileName)
| Method Detail |
public CBJComboBox getLoadComboBox()
public int showMessage()
public void loadDefault()
protected void parseFile(java.lang.String fileName)
public java.lang.String getCurrentTemplateName()
public void save()
public void saveTemplateName(java.lang.String templateName)
public void saveContainerInfo(java.awt.Container myContainer,
java.lang.String templateName)
myContainer - container to savetemplateName - unique name for this template and component
protected void saveComponent(java.awt.Component c,
int componentNo,
java.lang.String templateName)
c - the component to savecomponentNo - the index of the componenttemplateName - the name of the template being saved to.public java.lang.String getComponentText(java.awt.Component c)
c - the component to retrieve a text value for.
public void load()
public void loadTemplateName(java.lang.String templateName)
public void loadContainerInfo(java.awt.Container myContainer,
java.lang.String templateName)
protected void loadComponent(java.awt.Component c,
int componentNo,
java.lang.String templateName)
c - the component to loadcomponentNo - the index of the componenttemplateName - the name of the template being loaded from.
public void loadComponentText(java.awt.Component c,
java.lang.String text)
public void delete()
public void deleteComponentInfo(java.awt.Container myContainer,
java.lang.String templateName)
public void deleteComponentInfo(java.lang.String templateName)
templateName - the name of the template that is to be deleted from the property file.public void makeDefault()
public void addIllegalComponent(java.awt.Component c)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||