com.instantbank.lettertemplate.editor.applet
Class TemplateEditor

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--java.awt.Panel
                    |
                    +--java.applet.Applet
                          |
                          +--javax.swing.JApplet
                                |
                                +--com.instantbank.lettertemplate.editor.applet.TemplateEditor
All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.image.ImageObserver, java.awt.MenuContainer, javax.swing.RootPaneContainer, java.io.Serializable

public class TemplateEditor
extends javax.swing.JApplet

Applet for letters template edition. Some of the code has been adapted from the Swing book by Robinson and Vorobiev (Manning Ed).

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

Inner Class Summary
(package private)  class TemplateEditor.CategoryNameTemplateDialog
          Gui that allows to capture/display --fully or partially-- the main attributes of a template: its category, its name, the name of its components.
(package private)  class TemplateEditor.ComponentEditor
          Actual Editor for the template's components.
(package private)  class TemplateEditor.EditorStuff
          Contains the widgets that fire external actions on the editors of the template's components: header, body, closing.
(package private)  class TemplateEditor.MarginDialog
          User dialog that allows to define margins for a template.
(package private)  class TemplateEditor.SaveAsComponentDialog
          Auxiliary Gui class used to type/choose the name of a component.
(package private)  class TemplateEditor.TemplateCodes
          Auxiliary class to group basic attributes of a template or a letter component.
(package private)  class TemplateEditor.VariableFormatInsertion
          Auxiliary class that inserts a format for a variable in the text.
 
Inner classes inherited from class javax.swing.JApplet
javax.swing.JApplet.AccessibleJApplet
 
Inner classes inherited from class java.applet.Applet
java.applet.Applet.AccessibleApplet
 
Inner classes inherited from class java.awt.Panel
java.awt.Panel.AccessibleAWTPanel
 
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) static java.awt.Color backColor
          Background color for main widgets in the user interface.
protected  LabelText[] basicControls
          Array of LabelText containing the controls associated with Template, Header, Body, Closing, Category (in this order), grouped for fast access.
protected  CodeDescription[] categories
          The set of available template categories.
static java.lang.String DATEDELTA
          Name of the attribute that records the date offset of a variable.
 javax.swing.text.DefaultStyledDocument docClipboard
          Local document clipboard.
protected  TemplateEditor.EditorStuff edtStuff
          Editor user interface, excluding variables tree.
protected  java.lang.String fontName
          Font family name
protected  int fontSize
          Font size
static java.lang.String ICONBYTES
          Name of the attribute used to remember the points of insertion of images in the text.
static java.lang.String imgChar
          Character to be inserted with an image.
protected  javax.swing.JScrollPane jsTree
          JScrollPane for variables tree.
protected  javax.swing.JTree jtrVariables
          Variables tree.
protected  LabelComboCombo lbccFont
          Widget for font display (family name and size).
protected  LabelCombo lbcFormat
          Widget for format display.
protected  LabelText lbtBody
          Label and Text displaying the name of the body.
protected  LabelText lbtCategory
          Label and Text displaying the category of the template.
protected  LabelText lbtClosing
          Label and Text displaying the name of the closing.
protected  LabelText lbtHeader
          Label and Text displaying the name of the header.
protected  LabelText lbtPrintType
          Label and Text displaying the print type of the template.
protected  LabelText lbtTemplate
          Label and Text displaying the name of the template.
protected  javax.swing.JPanel pnlControl
          Upper panel containing controls displaying information related to template name, template type, font, header, body and closing.
protected  javax.swing.JPanel pnlRight
          Panel containing the right hand side of the user interface.
private  int printType
          The code of the current print type : LASER, TYPEWRITTER
protected  java.lang.String[] printTypes
          The known printType names.
protected  TemplateEditorProxy proxy
          Proxi for communicating with the servlet.
protected  java.lang.String[] remoteImages
          The list of available images for insertion
protected  TemplateEditor.ComponentEditor selectedTed
          Editor having the focus.
protected  boolean skipUpdate
          Indicates if update of the status controls --font, size, format-- must be done.
(package private) static java.awt.Color tabColor
          Color for components' tabs: header, body, closing
protected  Template template
          The Letter Template under edition.
protected  java.util.Hashtable templatesNames
          The set of template names for all categories with the current printType.
 java.lang.String urlbase
          Base url of the web server.
static java.lang.String varChar
          Character to be inserted with a variable.
static java.lang.String VARCODE
          Name of the attribute used to remember the code and points of insertion of loan variables in the text.
static java.awt.Color varColor
          Color for visual repesentation of variables
protected  long varFormat
          Current format of variable.
static java.lang.String VARFORMAT
          Name of the attribute that records the format of a variable.
protected  CodeDescription[] varFormats
          The set of available variable formats.
 VariablesManager varManager
          The manager of loan variables information.
 
Fields inherited from class javax.swing.JApplet
accessibleContext, rootPane, rootPaneCheckingEnabled
 
Fields inherited from class java.applet.Applet
serialVersionUID, stub
 
Fields inherited from class java.awt.Panel
base, nameCounter
 
Fields inherited from class java.awt.Container
component, containerListener, containerSerializedDataVersion, dbg, dispatcher, layoutMgr, listeningBoundsChildren, listeningChildren, maxSize, ncomponents, printing, printingThreads
 
Fields inherited from class java.awt.Component
actionListenerK, adjustmentListenerK, appContext, background, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, changeSupport, 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()
           
 
Method Summary
private  javax.swing.JTree buildTree()
          Constructs the Variables tree.
 void goHome()
          Exit to home page
 void init()
          Initializes the user interface
private  boolean isValidName(java.lang.String name)
          Verifies if its argument has the right syntax for template and letter components names.
private  void refreshStatusGui(Template templ)
          Shows the basic status of a Template in the upper controls of the GUI (except for the Category).
private  java.lang.String shortenUrl(java.lang.String url, int ncomp)
          Deletes a number of components at the end of the url
 
Methods inherited from class javax.swing.JApplet
addImpl, createRootPane, createRootPaneException, getAccessibleContext, getContentPane, getGlassPane, getJMenuBar, getLayeredPane, getRootPane, isRootPaneCheckingEnabled, paramString, processKeyEvent, remove, setContentPane, setGlassPane, setJMenuBar, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, update
 
Methods inherited from class java.applet.Applet
destroy, getAppletContext, getAppletInfo, getAudioClip, getAudioClip, getCodeBase, getDocumentBase, getImage, getImage, getLocale, getParameter, getParameterInfo, isActive, newAudioClip, play, play, resize, resize, setStub, showStatus, start, stop
 
Methods inherited from class java.awt.Panel
, addNotify, constructComponentName
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, adjustListeningChildren, applyOrientation, checkGD, countComponents, createChildHierarchyEvents, createHierarchyEvents, deliverEvent, dispatchEventImpl, dispatchEventToSelf, doLayout, eventEnabled, findComponentAt, findComponentAt, findComponentAt, getAccessibleAt, getAccessibleChild, getAccessibleChildrenCount, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents_NoClientCode, getComponents, getInsets, getLayout, getListeners, getMaximumSize, getMinimumSize, getMouseEventTarget, getPreferredSize, getWindow, initIDs, insets, invalidate, invalidateTree, isAncestorOf, layout, lightweightPaint, lightweightPrint, list, list, locate, minimumSize, nextFocus, numListening, paint, paintComponents, paintHeavyweightComponents, postProcessKeyEvent, postsOldMouseEvents, preferredSize, preProcessKeyEvent, print, printComponents, printHeavyweightComponents, processContainerEvent, processEvent, proxyEnableEvents, proxyRequestFocus, readObject, remove, removeAll, removeContainerListener, removeNotify, setFocusOwner, setFont, transferFocus, validate, validateTree, writeObject
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addPropertyChangeListener, addPropertyChangeListener, areInputMethodsEnabled, bounds, checkImage, checkImage, checkWindowClosingException, coalesceEvents, contains, contains, createImage, createImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, getAccessibleIndexInParent, getAccessibleStateSet, getBackground, getBounds, getBounds, getColorModel, getComponentOrientation, getCursor, getDropTarget, getFont_NoClientCode, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getInputContext, getInputMethodRequests, getLocation, getLocation, getLocationOnScreen_NoTreeLock, getLocationOnScreen, getName, getNativeContainer, getParent_NoClientCode, getParent, getPeer, getSize, getSize, getToolkit, getToolkitImpl, getTreeLock, getWidth, getWindowForObject, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isDisplayable, isDoubleBuffered, isEnabled, isEnabledImpl, isFocusTraversable, isLightweight, isOpaque, isRecursivelyVisible, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseEvent, processMouseMotionEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, resetGC, reshape, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setForeground, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, 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

backColor

static final java.awt.Color backColor
Background color for main widgets in the user interface.

tabColor

static final java.awt.Color tabColor
Color for components' tabs: header, body, closing

ICONBYTES

public static final java.lang.String ICONBYTES
Name of the attribute used to remember the points of insertion of images in the text.

varManager

public VariablesManager varManager
The manager of loan variables information.

VARCODE

public static final java.lang.String VARCODE
Name of the attribute used to remember the code and points of insertion of loan variables in the text.

VARFORMAT

public static final java.lang.String VARFORMAT
Name of the attribute that records the format of a variable.

DATEDELTA

public static final java.lang.String DATEDELTA
Name of the attribute that records the date offset of a variable.

varColor

public static final java.awt.Color varColor
Color for visual repesentation of variables

imgChar

public static final java.lang.String imgChar
Character to be inserted with an image.

varChar

public static final java.lang.String varChar
Character to be inserted with a variable.

lbtPrintType

protected LabelText lbtPrintType
Label and Text displaying the print type of the template.

lbtTemplate

protected LabelText lbtTemplate
Label and Text displaying the name of the template.

lbtCategory

protected LabelText lbtCategory
Label and Text displaying the category of the template.

lbtHeader

protected LabelText lbtHeader
Label and Text displaying the name of the header.

lbtBody

protected LabelText lbtBody
Label and Text displaying the name of the body.

lbtClosing

protected LabelText lbtClosing
Label and Text displaying the name of the closing.

basicControls

protected LabelText[] basicControls
Array of LabelText containing the controls associated with Template, Header, Body, Closing, Category (in this order), grouped for fast access.

lbccFont

protected LabelComboCombo lbccFont
Widget for font display (family name and size).

lbcFormat

protected LabelCombo lbcFormat
Widget for format display.

pnlControl

protected javax.swing.JPanel pnlControl
Upper panel containing controls displaying information related to template name, template type, font, header, body and closing.

pnlRight

protected javax.swing.JPanel pnlRight
Panel containing the right hand side of the user interface.

edtStuff

protected TemplateEditor.EditorStuff edtStuff
Editor user interface, excluding variables tree.

selectedTed

protected TemplateEditor.ComponentEditor selectedTed
Editor having the focus.

jsTree

protected javax.swing.JScrollPane jsTree
JScrollPane for variables tree.

jtrVariables

protected javax.swing.JTree jtrVariables
Variables tree.

printTypes

protected java.lang.String[] printTypes
The known printType names.

printType

private int printType
The code of the current print type : LASER, TYPEWRITTER

docClipboard

public javax.swing.text.DefaultStyledDocument docClipboard
Local document clipboard. Replaces the system clipboard in order to do copy/cut/paste including images and other attributes.

urlbase

public java.lang.String urlbase
Base url of the web server.

fontName

protected java.lang.String fontName
Font family name

fontSize

protected int fontSize
Font size

skipUpdate

protected boolean skipUpdate
Indicates if update of the status controls --font, size, format-- must be done.

varFormat

protected long varFormat
Current format of variable.

proxy

protected TemplateEditorProxy proxy
Proxi for communicating with the servlet.

remoteImages

protected java.lang.String[] remoteImages
The list of available images for insertion

categories

protected CodeDescription[] categories
The set of available template categories.

varFormats

protected CodeDescription[] varFormats
The set of available variable formats.

template

protected Template template
The Letter Template under edition.

templatesNames

protected java.util.Hashtable templatesNames
The set of template names for all categories with the current printType. Content is: < categoryName, CodeDescription[] of (templateCode, templDescr)>
Constructor Detail

TemplateEditor

public TemplateEditor()
Method Detail

init

public void init()
Initializes the user interface
Overrides:
init in class java.applet.Applet

shortenUrl

private java.lang.String shortenUrl(java.lang.String url,
                                    int ncomp)
Deletes a number of components at the end of the url
Parameters:
url - An url path
ncomp - Number of components to delete
Returns:
The url without its last ncomp components.

goHome

public void goHome()
Exit to home page

buildTree

private javax.swing.JTree buildTree()
Constructs the Variables tree.
Returns:
The variables tree

refreshStatusGui

private void refreshStatusGui(Template templ)
Shows the basic status of a Template in the upper controls of the GUI (except for the Category).
Parameters:
templ - The template whose status is showed.

isValidName

private boolean isValidName(java.lang.String name)
Verifies if its argument has the right syntax for template and letter components names. Java identifiers syntax is currently used.
Parameters:
name - The string to be verified.
Returns:
true if valid, false otherwise.