com.instantbank.lettertemplate.editor.applet
Class TemplateEditor.EditorStuff

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--javax.swing.JComponent
                    |
                    +--javax.swing.JPanel
                          |
                          +--com.instantbank.lettertemplate.editor.applet.TemplateEditor.EditorStuff
All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable
Enclosing class:
TemplateEditor

class TemplateEditor.EditorStuff
extends javax.swing.JPanel

Contains the widgets that fire external actions on the editors of the template's components: header, body, closing.

Author:
InstantBank (Rodrigo Lopez)
See Also:
Serialized Form

Inner Class Summary
(package private)  class TemplateEditor.EditorStuff.ExtraAction
          Extra Action for debugging purposes.
(package private)  class TemplateEditor.EditorStuff.GoHomeAction
          Exit from the editor.
(package private)  class TemplateEditor.EditorStuff.InsertImageAction
          Action bound to the btnImg button.
(package private)  class TemplateEditor.EditorStuff.MarginsAction
          MarginsAction.
(package private)  class TemplateEditor.EditorStuff.NewComponentAction
          Action bound to the btnNew button.
(package private)  class TemplateEditor.EditorStuff.NewTemplateAction
          Action bound to the btnNewTemplate button.
(package private)  class TemplateEditor.EditorStuff.OpenComponentAction
          Action bound to the btnOpen button.
(package private)  class TemplateEditor.EditorStuff.OpenTemplateAction
          Action bound to the btnOpenTemplate button.
(package private)  class TemplateEditor.EditorStuff.PreviewAction
          PreviewAction
(package private)  class TemplateEditor.EditorStuff.SaveAsComponentAction
          Action bound to the btnSaveAs button.
(package private)  class TemplateEditor.EditorStuff.SaveAsTemplateAction
          Action bound to the btnSaveAsTemplate button.
(package private)  class TemplateEditor.EditorStuff.SaveComponentAction
          Action bound to the btnSave button.
(package private)  class TemplateEditor.EditorStuff.SaveRawRtfAction
          Test class: sends rtf text to servlet and saves it in a fixed file.
(package private)  class TemplateEditor.EditorStuff.SaveTemplateAction
          Action bound to the btnSaveTemplate button.
(package private)  class TemplateEditor.EditorStuff.SetBoldAction
          Toggles selected text between Bold-nonBold.
(package private)  class TemplateEditor.EditorStuff.SetItalicAction
          Toggles selected text between Italic-nonItalic.
(package private)  class TemplateEditor.EditorStuff.SetUnderlineAction
          Toggles selected text between Underlined-non Underlined.
(package private)  class TemplateEditor.EditorStuff.TraceImgVarsAction
          Test class: Echoes the position of images and variables in the selected component.
 
Inner classes inherited from class javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanel
 
Inner classes inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent, javax.swing.JComponent.ActionStandin, javax.swing.JComponent.IntVector, javax.swing.JComponent.KeyboardState
 
Inner classes inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Inner classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.AWTTreeLock
 
Field Summary
(package private)  SmallToggleButton btnBold
          Bold button
(package private)  javax.swing.JButton btnExtra
          Extra button.
(package private)  javax.swing.JButton btnHome
          When pressed the editor is exited and control flows to the system's home page.
(package private)  javax.swing.JButton btnImg
          When pressed an image can be inserted in the current component at cursor's position.
(package private)  SmallToggleButton btnItalic
          Italic button
(package private)  javax.swing.JButton btnMargins
          When pressed, the margin dialogs is launched.
(package private)  javax.swing.JButton btnNew
          When pressed a new component is created as part of the current template.
(package private)  javax.swing.JButton btnNewTemplate
          When pressed, a new template is created to replace the current one.
(package private)  javax.swing.JButton btnOpen
          When pressed, an existing component can be opened to replace the current component of the current template.
(package private)  javax.swing.JButton btnOpenTemplate
          When pressed, an existing Template can be opened to replace the current one.
(package private)  javax.swing.JButton btnPreview
          When pressed, the current template is previewed in a new window.
(package private)  javax.swing.JButton btnSave
          When pressed, the current component of the current template is saved.
(package private)  javax.swing.JButton btnSaveAs
          When pressed, the current component of the current template can be saved with a different name.
(package private)  javax.swing.JButton btnSaveAsTemplate
          When pressed, the current template can be saved with a new name or changing any of its components.
(package private)  javax.swing.JButton btnSaveTemplate
          When pressed, the current template is saved.
(package private)  SmallToggleButton btnUnderline
          Underline button
(package private)  TemplateEditor.ComponentEditor[] editors
          Array of ComponentEditors referencing --in its order-- the header, the body and the closing editors.
(package private)  javax.swing.JLabel lblStatus
          Label for status messages.
(package private)  javax.swing.JPanel pnlStatus
          Thin lower panel for status messages.
(package private)  javax.swing.Timer statusTimer
          Timer for vanishing the status messages.
(package private)  javax.swing.JTabbedPane tabpane
          Tabbed pane share by theeditors of the components.
(package private)  TemplateEditor.ComponentEditor tedb
          ComponentEditor for the template's body.
(package private)  TemplateEditor.ComponentEditor tedc
          ComponentEditor for the template's closing.
(package private)  TemplateEditor.ComponentEditor tedh
          ComponentEditor for the template's header.
(package private)  javax.swing.JToolBar toolBar
          Toolbar for action buttons
 
Fields inherited from class javax.swing.JPanel
defaultLayout, uiClassID
 
Fields inherited from class javax.swing.JComponent
_bounds, accessibleContext, actionMap, ACTIONMAP_CREATED, alignmentX, alignmentY, ANCESTOR_INPUTMAP_CREATED, ANCESTOR_USING_BUFFER, ancestorInputMap, ancestorNotifier, autoscroller, border, changeSupport, clientProperties, CREATED_DOUBLE_BUFFER, flags, FOCUS_INPUTMAP_CREATED, focusInputMap, HAS_FOCUS, htmlKey, htmlView, inputVerifier, IS_DOUBLE_BUFFERED, IS_OPAQUE, IS_PAINTING_TILE, IS_PRINTING, IS_PRINTING_ALL, KEY_EVENTS_ENABLED, KEYBOARD_BINDINGS_KEY, listenerList, maximumSize, minimumSize, NEXT_FOCUS, paintImmediatelyClip, paintingChild, preferredSize, readObjectCallbacks, REQUEST_FOCUS_DISABLED, tmpRect, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, verifyInputWhenFocusTarget, vetoableChangeSupport, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW, WHEN_IN_FOCUSED_WINDOW_BINDINGS, WIF_INPUTMAP_CREATED, windowInputMap
 
Fields inherited from class java.awt.Container
component, containerListener, containerSerializedDataVersion, dbg, dispatcher, layoutMgr, listeningBoundsChildren, listeningChildren, maxSize, ncomponents, printing, printingThreads, serialVersionUID
 
Fields inherited from class java.awt.Component
actionListenerK, adjustmentListenerK, appContext, background, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, componentListener, componentListenerK, componentOrientation, componentSerializedDataVersion, containerListenerK, cursor, dropTarget, enabled, eventMask, focusListener, focusListenerK, font, foreground, graphicsConfig, hasFocus, height, hierarchyBoundsListener, hierarchyBoundsListenerK, hierarchyListener, hierarchyListenerK, incRate, inputMethodListener, inputMethodListenerK, isInc, isPacked, itemListenerK, keyListener, keyListenerK, LEFT_ALIGNMENT, locale, LOCK, metrics, minSize, mouseListener, mouseListenerK, mouseMotionListener, mouseMotionListenerK, name, nameExplicitlySet, newEventsOnly, ownedWindowK, parent, peer, peerFont, popups, prefSize, privateKey, RIGHT_ALIGNMENT, textListenerK, TOP_ALIGNMENT, valid, visible, width, windowClosingException, windowListenerK, x, y
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
TemplateEditor.EditorStuff()
          Constructor for the EditorStuff object
 
Method Summary
private  java.lang.String brokenVarsMessage(java.lang.String brokenVars)
           
private  void displayTemplate(Template templ)
          Displays a template in the user interface.
 void fillTemplateCodes(Template templ, CodeDescription[] codes)
          Fill the code and stamp attributes of a template and its components.
 void fillTemplateFromGui(Template templ)
          Fill a Template with the content managed by the three ComponentEditors: header, body and closing.
 void fillTemplateFromGuiResult(Template templ, CodeDescription[] result)
          Fill a Template with the content managed by the three ComponentEditors: header, body and closing.
 TemplateEditor.TemplateCodes[] getTemplateCodes(Template template)
          Calculates an array of < code,name,stamp> values corresponding to a Template and its LetterComponents.
 void initEditorStuffGui()
          Inits the Gui for the component editors: cleans the text, and puts the cursor at the 0 position.
 CodeDescription[] initSaveAsResult()
          Calculates a "void" value for the response that is calculated by the TemplateEditor.CategoryNameTemplateDialog Gui.
 void restoreTemplateCodes(Template templ, TemplateEditor.TemplateCodes[] oldTemplate)
          Fills < code, name, stamp> attributes of a template, from an array of TemplateCodes.
private  boolean saveComponent(LetterComponent component)
          Saves a letter component in the data base.
private  boolean saveComponentAs(LetterComponent component)
          Requests to save a component.
private  void saveTemplate()
          The current template is stored in the data base.
private  void saveTemplateAs(int mode)
          Requests to save the current template.
 void setEnableComponentsButtons(boolean mode)
          Allows to enable/disable the toolbar buttons related to basic operations over the letter component under edition.
 void showLocals(CodeDescription[] locals)
          Debug method that shows the content of a < code, description> array in a window dialog.
 void showStatus(java.lang.String s)
          Shows a message in the status area.
 
Methods inherited from class javax.swing.JPanel
, getAccessibleContext, getUIClassID, paramString, updateUI, writeObject
 
Methods inherited from class javax.swing.JComponent
_paintImmediately, addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, adjustPaintFlags, alwaysOnTop, checkIfChildObscuredBySibling, clearFocusOwners, componentInputMapChanged, computeVisibleRect, computeVisibleRect, compWriteObjectNotify, contains, createToolTip, disable, enable, enableSerialization, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getActionMap, getAlignmentX, getAlignmentY, getAutoscrolls, getBorder, getBounds, getClientProperties, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getCreatedDoubleBuffer, getDebugGraphicsOptions, getFlag, getGraphics, getHeight, getInputMap, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getVerifyInputWhenFocusTarget, getVisibleRect, getWidth, getX, getY, grabFocus, hasFocus, hide, isDoubleBuffered, isFocusCycleRoot, isFocusTraversable, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, paintWithBuffer, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processFocusEvent, processKeyBinding, processKeyBindings, processKeyBindingsForAllComponents, processKeyEvent, processMouseMotionEvent, putClientProperty, readObject, rectangleIsObscured, rectangleIsObscuredBySibling, registerKeyboardAction, registerKeyboardAction, registerWithKeyboardManager, registerWithKeyboardManager, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setCreatedDoubleBuffer, setDebugGraphicsOptions, setDoubleBuffered, setEnabled, setFlag, setFont, setForeground, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPaintingChild, setPreferredSize, setRequestFocusEnabled, setToolTipText, setUI, setVerifyInputWhenFocusTarget, setVisible, shouldDebugGraphics, superProcessMouseMotionEvent, unregisterKeyboardAction, unregisterWithKeyboardManager, unregisterWithKeyboardManager, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, adjustListeningChildren, applyOrientation, checkGD, countComponents, createChildHierarchyEvents, createHierarchyEvents, deliverEvent, dispatchEventImpl, dispatchEventToSelf, doLayout, eventEnabled, findComponentAt, findComponentAt, findComponentAt, getAccessibleAt, getAccessibleChild, getAccessibleChildrenCount, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents_NoClientCode, getComponents, getLayout, getMouseEventTarget, getWindow, initIDs, insets, invalidate, invalidateTree, isAncestorOf, layout, lightweightPaint, lightweightPrint, list, list, locate, minimumSize, nextFocus, numListening, paintComponents, paintHeavyweightComponents, postProcessKeyEvent, postsOldMouseEvents, preferredSize, preProcessKeyEvent, printComponents, printHeavyweightComponents, processContainerEvent, processEvent, proxyEnableEvents, proxyRequestFocus, remove, remove, removeAll, removeContainerListener, setFocusOwner, setLayout, transferFocus, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, areInputMethodsEnabled, bounds, checkImage, checkImage, checkWindowClosingException, coalesceEvents, constructComponentName, contains, createImage, createImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, getAccessibleIndexInParent, getAccessibleStateSet, getBackground, getBounds, getColorModel, getComponentOrientation, getCursor, getDropTarget, getFont_NoClientCode, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getInputContext, getInputMethodRequests, getLocale, getLocation, getLocationOnScreen_NoTreeLock, getLocationOnScreen, getName, getNativeContainer, getParent_NoClientCode, getParent, getPeer, getSize, getToolkit, getToolkitImpl, getTreeLock, getWindowForObject, gotFocus, handleEvent, imageUpdate, inside, isDisplayable, isEnabled, isEnabledImpl, isLightweight, isRecursivelyVisible, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, repaint, repaint, repaint, resetGC, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, wait, wait, wait
 

Field Detail

btnNewTemplate

javax.swing.JButton btnNewTemplate
When pressed, a new template is created to replace the current one.

See NewTemplateAction.


btnOpenTemplate

javax.swing.JButton btnOpenTemplate
When pressed, an existing Template can be opened to replace the current one.

See OpenTemplateAction.


btnSaveTemplate

javax.swing.JButton btnSaveTemplate
When pressed, the current template is saved.

See SaveTemplateAction.


btnSaveAsTemplate

javax.swing.JButton btnSaveAsTemplate
When pressed, the current template can be saved with a new name or changing any of its components.

See SaveAsTemplateAction.


btnNew

javax.swing.JButton btnNew
When pressed a new component is created as part of the current template.

See NewComponentAction.


btnOpen

javax.swing.JButton btnOpen
When pressed, an existing component can be opened to replace the current component of the current template.

See OpenComponentAction.


btnSave

javax.swing.JButton btnSave
When pressed, the current component of the current template is saved.

See SaveComponentAction.


btnSaveAs

javax.swing.JButton btnSaveAs
When pressed, the current component of the current template can be saved with a different name.

See SaveAsComponentAction.


btnImg

javax.swing.JButton btnImg
When pressed an image can be inserted in the current component at cursor's position.

See InsertImageAction.


btnHome

javax.swing.JButton btnHome
When pressed the editor is exited and control flows to the system's home page.

btnPreview

javax.swing.JButton btnPreview
When pressed, the current template is previewed in a new window.

btnMargins

javax.swing.JButton btnMargins
When pressed, the margin dialogs is launched.

btnExtra

javax.swing.JButton btnExtra
Extra button. Used for debugging purposes.

btnBold

SmallToggleButton btnBold
Bold button

btnItalic

SmallToggleButton btnItalic
Italic button

btnUnderline

SmallToggleButton btnUnderline
Underline button

tedh

TemplateEditor.ComponentEditor tedh
ComponentEditor for the template's header.

tedb

TemplateEditor.ComponentEditor tedb
ComponentEditor for the template's body.

tedc

TemplateEditor.ComponentEditor tedc
ComponentEditor for the template's closing.

editors

TemplateEditor.ComponentEditor[] editors
Array of ComponentEditors referencing --in its order-- the header, the body and the closing editors.

toolBar

javax.swing.JToolBar toolBar
Toolbar for action buttons

tabpane

javax.swing.JTabbedPane tabpane
Tabbed pane share by theeditors of the components.

pnlStatus

javax.swing.JPanel pnlStatus
Thin lower panel for status messages.

lblStatus

javax.swing.JLabel lblStatus
Label for status messages.

statusTimer

javax.swing.Timer statusTimer
Timer for vanishing the status messages.
Constructor Detail

TemplateEditor.EditorStuff

public TemplateEditor.EditorStuff()
Constructor for the EditorStuff object
Method Detail

fillTemplateFromGuiResult

public void fillTemplateFromGuiResult(Template templ,
                                      CodeDescription[] result)
Fill a Template with the content managed by the three ComponentEditors: header, body and closing. Moreover, fills the names of the components and template from the a CodeDescription array that follows the THBC order.
Parameters:
templ - The template to be filled.
result - The array where names are stored.

fillTemplateFromGui

public void fillTemplateFromGui(Template templ)
Fill a Template with the content managed by the three ComponentEditors: header, body and closing.
Parameters:
templ - The template to be filled.

fillTemplateCodes

public void fillTemplateCodes(Template templ,
                              CodeDescription[] codes)
Fill the code and stamp attributes of a template and its components.
Parameters:
templ - The template to be filled.
codes - Array containing the attributes in the THBC order.

restoreTemplateCodes

public void restoreTemplateCodes(Template templ,
                                 TemplateEditor.TemplateCodes[] oldTemplate)
Fills < code, name, stamp> attributes of a template, from an array of TemplateCodes. Moreover it also fills the template's category attribute.
Parameters:
templ - The template to be filled.
oldTemplate - The array containing the attribute values. It follows the THBCCR order.

displayTemplate

private void displayTemplate(Template templ)
Displays a template in the user interface. See TemplateEditor.ComponentEditor.displayLetterComponent(LetterComponent).
Parameters:
templ - The template to be displayed.

saveTemplate

private void saveTemplate()
The current template is stored in the data base.

saveTemplateAs

private void saveTemplateAs(int mode)
Requests to save the current template.
Parameters:
mode - The saving mode.
  • LetterOp.SAVEAS =>
    • The template is new (it is the first time it is going to be saved), or
    • It is an old template and the user wants to change its name and/or the component's names.
  • LetterOp.SAVEWITHNEW => It is an old template and the user wants to change one of its components.
The provided Gui is based on the TemplateEditor.CategoryNameTemplateDialog widget.

saveComponent

private boolean saveComponent(LetterComponent component)
Saves a letter component in the data base.
Parameters:
component - The component to be saved.
Returns:
True if the store action was succesful, False otherwise.

saveComponentAs

private boolean saveComponentAs(LetterComponent component)
Requests to save a component.
Parameters:
component - The component to be saved.

The provided Gui is based on TemplateEditor.SaveAsComponentDialog

Returns:
True if the component could be saved, False otherwise.

setEnableComponentsButtons

public void setEnableComponentsButtons(boolean mode)
Allows to enable/disable the toolbar buttons related to basic operations over the letter component under edition.
Parameters:
mode -
  • True => Buttons are enabled.
  • False => Buttons are disabled.

initSaveAsResult

public CodeDescription[] initSaveAsResult()
Calculates a "void" value for the response that is calculated by the TemplateEditor.CategoryNameTemplateDialog Gui. It is used by the caller of that Gui.
Returns:
An array of < code,description> in the THBCCR order with all attributes "undefined".

initEditorStuffGui

public void initEditorStuffGui()
Inits the Gui for the component editors: cleans the text, and puts the cursor at the 0 position.

showLocals

public void showLocals(CodeDescription[] locals)
Debug method that shows the content of a < code, description> array in a window dialog. The array is in the THBCCR order
Parameters:
locals - The array to be shown.

getTemplateCodes

public TemplateEditor.TemplateCodes[] getTemplateCodes(Template template)
Calculates an array of < code,name,stamp> values corresponding to a Template and its LetterComponents.
Parameters:
template - The template.
Returns:
The array of codes in the THBC order .

showStatus

public void showStatus(java.lang.String s)
Shows a message in the status area. The message will disappear after 2 seconds.
Parameters:
s - The message to be shown.

brokenVarsMessage

private java.lang.String brokenVarsMessage(java.lang.String brokenVars)