com.ca.directory.jxplorer.viewer
Class HTMLTemplateDisplay

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--javax.swing.JComponent
                    |
                    +--javax.swing.JPanel
                          |
                          +--com.ca.directory.jxplorer.viewer.HTMLTemplateDisplay
All Implemented Interfaces:
javax.accessibility.Accessible, DataSink, java.awt.image.ImageObserver, java.awt.MenuContainer, PluggableEditor, java.io.Serializable

public class HTMLTemplateDisplay
extends javax.swing.JPanel
implements DataSink, PluggableEditor

Display Template handles the insertion of attribute values into an HTML template, in order to display filtered information to the user in an attractive manner.

It also implements a simple web browser for viewing help links etc.

Form submission is done in the @MyHTMLEditorKit class.

See Also:
Serialized Form

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
static java.lang.String ATTRIBTAG
           
static java.lang.String AVIEXTENSION
           
protected  java.lang.String currentDN
           
static java.lang.String DEFAULTTEXT
           
static java.lang.String DOCEXTENSION
           
protected  MyHTMLEditorKit htmlEditorKit
           
protected  com.ca.directory.jxplorer.viewer.HTMLTemplateDisplay.MyHyperlinkListener hyperlinkListener
           
static java.lang.String ILLEGAL_VALUE
           
static java.lang.String JPEGEXTENSION
           
static int MAX_LEGAL_VALUE_LENGTH
           
static java.lang.String MIDEXTENSION
           
static java.lang.String NODATA
           
static java.lang.String NOVALUEFOUND
           
protected  boolean settingUpTemplates
           
 boolean showHTMLErrors
           
static java.lang.String startFile
           
static java.lang.String WAVEXTENSION
           
static java.lang.String XLSEXTENSION
           
 
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
HTMLTemplateDisplay(java.awt.Component owner, java.util.Properties props, CBResourceLoader resourceLoader)
          Default Constructor for HTMLTemplateDisplay
HTMLTemplateDisplay(java.awt.Component owner, java.lang.String templateURL, java.util.Properties props, CBResourceLoader resourceLoader)
          Constructor that attempts to open a new template
 
Method Summary
protected  void attemptToSetOCSpecificTemplate(DXAttributes entry, java.lang.String[] templates)
          This attempts to match a list of template names with the deepest possible object class.
 boolean canCreateEntry()
          Indicates whether the editor can create a new entry, given a unique name.
protected  void displayData(DXEntry entry)
          Checks if the HTML page has any custom tags such as...
 void displayEntry(DXEntry entry, DataSource formDataSource)
          Displays information about a given tree node, expressed as a DXEntry (an attribute set and associated distinguished name of a node).
 java.lang.String formattedAllAttributes(DXEntry attributes, java.lang.String modifier)
           
 java.lang.String formattedAttribute(javax.naming.directory.Attribute theAttribute, java.lang.String modifier)
          This takes a attribute type name and the complete attribute list, as well as an optional modifier, and returns the formatted html necessary to display the attribute in the html text.
 java.lang.String formattedAttribute(java.lang.String attType, javax.naming.directory.Attributes attributes, java.lang.String modifier)
          This takes a attribute type name and the complete attribute list, as well as an optional modifier, and returns the formatted html necessary to display the attribute in the html text.
 java.lang.String formattedListAttribute(javax.naming.NamingEnumeration attlist, java.lang.String modifier, java.lang.String syntaxOID, java.lang.String syntaxID)
          Takes a list of attribute values, and formats them as an html list, possibly of a type specified by the modifier.
protected  java.lang.String getAttValue(java.lang.String name, DXEntry entry)
          Get the value of an attribute corresponding to a particular name.
protected  java.lang.String getAttValue(java.lang.String name, DXEntry entry, int position)
          Get the value of an attribute corresponding to a particular name.
 DataSink getDataSink()
          Returns the data sink that will be used to slurp data.
 javax.swing.JComponent getDisplayComponent()
          This returns the swing component being used to display the data, so that another component can set its visibility.
 javax.swing.ImageIcon getIcon()
          Returns the icon of the editor.
 java.lang.String getMediaTags(java.lang.String listStart, java.lang.String listEnd, java.lang.String itemStart, java.lang.String itemEnd, java.lang.String type)
          Returns a string representation of all HTML code need to display all of the jpegPhoto or audio attributes in the template.
 java.lang.String getName()
          Returns the title of the editor.
protected  javax.swing.JEditorPane getNewEditor()
          As advised in the doco, it is apparently better to re-create an editor pane every time, rather than reuse the old one.
 java.lang.String[] getObjectClasses(DXAttributes atts)
           
 java.lang.String getObjectClassSignature(java.lang.String[] objectClasses)
          Concatenates a string array of alphabetically ordered object Classes into one long string, providing a unique String for this combination of classes.
 javax.swing.JPopupMenu getPopupMenu(java.lang.String rdn)
          Use the default popupmenu.
 java.awt.Component getPrintComponent()
          Return the thingumy that should be printed.
protected  java.lang.String getTagValue(java.lang.String tagName, java.lang.String tag)
           
 java.io.File getTemplateFile(java.lang.String fileNameAndPath)
          Returns a template file given the root path and name of the file.
 java.lang.String getToolTip()
          Returns the Tool Tip of the editor.
 javax.swing.ImageIcon getTreeIcon(java.lang.String rdn)
          Use the default tree icon system based on naming value or object class.
 boolean hideSubEntries(java.lang.String rdn)
          Don't hide sub entries.
 void initToolBar()
          Sets up the initial tool bar.
protected  java.lang.String insertFormAudioData(java.lang.String htmlString, DXEntry entry)
          Inserts audio hyperlinks into the html file/template.
protected  java.lang.String insertFormData(java.lang.String htmlString, DXEntry entry)
          This method looks for form elements, and fills in the initial form values based on the entry data received.
protected  java.lang.String insertFormImageData(java.lang.String htmlString, DXEntry entry)
          Inserts jpegPhoto values into the html file/template.
protected  java.lang.String insertFormInputData(java.lang.String htmlString, DXEntry entry)
          Goes through the html template, checking for any field tags of text type for example: <tr> <th align="right" width="200">Common Name:</th> <td width="230"><input type="text" name="cn" value=""/></td> </tr> If one is found, it checks the name and gets (in this example) the cn value from the entry and inserts it into the value part of the tag (for example value="Trudi").
protected  java.lang.String insertFormSelectData(java.lang.String htmlString, DXEntry entry)
           
protected  java.lang.String insertFormTextAreaData(java.lang.String htmlString, DXEntry entry)
          Goes through the html template, checking for any text area tags for example: <tr> <th align="right" valign="top" width="200">Address:</th> <td width="230"><textarea name="postalAddress" rows="4"></textarea></td> </tr> If one is found, it checks the name and gets (in this example) the postalAddress value from the entry and inserts it into the value part of the tag (for example value="21 Jump Street").
protected  java.lang.String insertFormValue(java.lang.String tag, DXEntry entry, java.lang.String name)
          Inserts the attribute value into the tag.
protected  java.lang.String insertFormValue(java.lang.String tag, DXEntry entry, java.lang.String name, int position)
          Inserts the attribute value into the tag.
 boolean isUnique()
          This sets whether the component expects to be the only editor used for its object class, or whether it will co-exist with any other applicable editors, and the default (html/table) editor.
 void launchMailClient(java.lang.String desc)
          Tricky method that launches the users default mail client.
protected  void mediaCheck(DXEntry entry, java.lang.String type)
          Checks if there is any jpegPhoto, audio or odDocumentDOC attributes in the entry if so creates temporary files for them only if there isn't any already.
 boolean objectClassesChanged(java.lang.String classesSignature)
          Checks if the list of object classes has changed.
 boolean openDocumentURL(java.lang.String docURL)
          Convenience wrapper for openPage, that prefixes parameter URL with the document URL directory path.
 boolean openLocalURL(java.lang.String localURL)
          Convenience wrapper for openPage, that prefixes parameter URL with the local URL directory path.
 boolean openNewTemplate(java.lang.String subdir, java.lang.String templateURL)
          Try to open a new template.
 boolean openPage(java.lang.String urlString)
          identical in intent to openPage(URL) (see).
 boolean openPage(java.net.URL url)
          this opens a page for viewing.
 java.lang.StringBuffer parseNewTemplate(java.lang.StringBuffer templateText, java.net.URL url)
           
static java.lang.String parseXHTML(java.lang.String html)
          Changes XHTML into standard HTML for display.
 java.lang.String[] readTemplateNames(java.lang.String[] objectClassNames)
          Reads the template names by examining available template files on... disk...
 void registerComponents(javax.swing.JMenuBar menu, javax.swing.JToolBar buttons, javax.swing.JTree tree, javax.swing.JPopupMenu treeMenu, javax.swing.JFrame jx)
          Registers Swing components that the pluggable editor may manipulate.
protected  void setEditor(java.net.URL url)
          Sets the editor to display the particular (html only, no DNs...) url.
 void setEditorText(java.lang.String htmlText)
          Recreates the editor, and sets the text.
 void setNewTemplate(java.lang.String templateName)
           
protected  void setToDefault()
           
 java.lang.String syntaxParse(java.lang.String s, java.lang.String syntaxOID)
           
protected  boolean templateExists(java.lang.String candidate)
          Checks whether a particular candidate string corresponds to the name of a template in the viewTemplates combo box.
 java.lang.String toString()
           
 void unload()
          This method is called when the editor is being unloaded by the browser, and allows for any required clean up activity.
 
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, 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, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULTTEXT

public static final java.lang.String DEFAULTTEXT
See Also:
Constant Field Values

ATTRIBTAG

public static final java.lang.String ATTRIBTAG
See Also:
Constant Field Values

NOVALUEFOUND

public static java.lang.String NOVALUEFOUND

JPEGEXTENSION

public static final java.lang.String JPEGEXTENSION
See Also:
Constant Field Values

DOCEXTENSION

public static final java.lang.String DOCEXTENSION
See Also:
Constant Field Values

XLSEXTENSION

public static final java.lang.String XLSEXTENSION
See Also:
Constant Field Values

WAVEXTENSION

public static final java.lang.String WAVEXTENSION
See Also:
Constant Field Values

AVIEXTENSION

public static final java.lang.String AVIEXTENSION
See Also:
Constant Field Values

MIDEXTENSION

public static final java.lang.String MIDEXTENSION
See Also:
Constant Field Values

startFile

public static final java.lang.String startFile
See Also:
Constant Field Values

MAX_LEGAL_VALUE_LENGTH

public static final int MAX_LEGAL_VALUE_LENGTH
See Also:
Constant Field Values

ILLEGAL_VALUE

public static final java.lang.String ILLEGAL_VALUE
See Also:
Constant Field Values

NODATA

public static java.lang.String NODATA

showHTMLErrors

public boolean showHTMLErrors

hyperlinkListener

protected com.ca.directory.jxplorer.viewer.HTMLTemplateDisplay.MyHyperlinkListener hyperlinkListener

htmlEditorKit

protected MyHTMLEditorKit htmlEditorKit

settingUpTemplates

protected boolean settingUpTemplates

currentDN

protected java.lang.String currentDN
Constructor Detail

HTMLTemplateDisplay

public HTMLTemplateDisplay(java.awt.Component owner,
                           java.util.Properties props,
                           CBResourceLoader resourceLoader)
Default Constructor for HTMLTemplateDisplay


HTMLTemplateDisplay

public HTMLTemplateDisplay(java.awt.Component owner,
                           java.lang.String templateURL,
                           java.util.Properties props,
                           CBResourceLoader resourceLoader)
Constructor that attempts to open a new template

Parameters:
owner - the parent component.
templateURL - the URL of the html format template file
props - a properties object containing values for 'dir.templates', 'dir.local' and 'dir.htmldocs')
Method Detail

setToDefault

protected void setToDefault()

setEditorText

public void setEditorText(java.lang.String htmlText)
Recreates the editor, and sets the text.

Parameters:
htmlText - the Text (possibly html) to display

getNewEditor

protected javax.swing.JEditorPane getNewEditor()
As advised in the doco, it is apparently better to re-create an editor pane every time, rather than reuse the old one. Phenomenal.


templateExists

protected boolean templateExists(java.lang.String candidate)
Checks whether a particular candidate string corresponds to the name of a template in the viewTemplates combo box.

Returns:
whether it exists.

initToolBar

public void initToolBar()
Sets up the initial tool bar. The toolbar should have different numbers of components visible, depending on the users privileges and whether or not they're actively editing the page...


setNewTemplate

public void setNewTemplate(java.lang.String templateName)

readTemplateNames

public java.lang.String[] readTemplateNames(java.lang.String[] objectClassNames)
Reads the template names by examining available template files on... disk... Mmmm... not good - should extend to read urls...


openNewTemplate

public boolean openNewTemplate(java.lang.String subdir,
                               java.lang.String templateURL)
Try to open a new template. Try both ".html" and ".htm" extensions if necessary. Start in subdirectory (for object class specific templates) and then try the default template directory for general templates.


parseNewTemplate

public java.lang.StringBuffer parseNewTemplate(java.lang.StringBuffer templateText,
                                               java.net.URL url)

getTemplateFile

public java.io.File getTemplateFile(java.lang.String fileNameAndPath)
Returns a template file given the root path and name of the file.

Parameters:
fileNameAndPath - the name and path, but not the extension, of the template file
Returns:
the File object found. This may be null, or may not exist; these conditions must be checked for.

getObjectClasses

public java.lang.String[] getObjectClasses(DXAttributes atts)

getObjectClassSignature

public java.lang.String getObjectClassSignature(java.lang.String[] objectClasses)
Concatenates a string array of alphabetically ordered object Classes into one long string, providing a unique String for this combination of classes.


objectClassesChanged

public boolean objectClassesChanged(java.lang.String classesSignature)
Checks if the list of object classes has changed. If it has, reset the 'oldClassSignature' and return true, otherwise return false.


displayEntry

public void displayEntry(DXEntry entry,
                         DataSource formDataSource)
Description copied from interface: DataSink
Displays information about a given tree node, expressed as a DXEntry (an attribute set and associated distinguished name of a node). The method also provides a data Source which may be used to update the node. This data Source may be null for non-editable data.

Specified by:
displayEntry in interface DataSink
Parameters:
entry - the directory entry to display. If null, indicates that a blank or 'empty' entry should be displayed.
formDataSource - the datasource used for data modification/schema access etc. May be null, in which case no schema checking/prompting will be done, and no editing will be possible.

attemptToSetOCSpecificTemplate

protected void attemptToSetOCSpecificTemplate(DXAttributes entry,
                                              java.lang.String[] templates)
This attempts to match a list of template names with the deepest possible object class.


displayData

protected void displayData(DXEntry entry)
Checks if the HTML page has any custom tags such as...

if so it enters the data. If the tag is 'get-all-attributes', all the attributes are included in the page. If the tag is 'get-attribute', the specific attribute is displayed. This method also kicks off the handling of inserting form data.

Parameters:
entry - the entry that we are trying to display.

mediaCheck

protected void mediaCheck(DXEntry entry,
                          java.lang.String type)
Checks if there is any jpegPhoto, audio or odDocumentDOC attributes in the entry if so creates temporary files for them only if there isn't any already. Gets the byte[] of the jpegPhoto, audio or odDocumentDOC attributes of the entry being displayed. Makes a temp directory called 'temp'. Lists all files in the directory, if there are any temp files for the jpegPhoto, audio or odDocumentDOC attributes in question it does not recreate them. Otherwise, if there isn't any temp files for the entry, it goes ahead and makes them. The temp files are named as followed: dn+unique number+.jpg. The temp files and directory are removed when the JX exists.

Parameters:
entry - the entry that is to be displayed.
type - the type of media being checked for (jpegPhoto, audio or odDocumentDOC).

parseXHTML

public static java.lang.String parseXHTML(java.lang.String html)
Changes XHTML into standard HTML for display. (Currently all this involves is changing any string '/>' into '>').


insertFormData

protected java.lang.String insertFormData(java.lang.String htmlString,
                                          DXEntry entry)
This method looks for form elements, and fills in the initial form values based on the entry data received. It is fairly picky about white space - it prefers there to be minimal whitespace in the form html. Also, there is minimal form validation; an incorrect form will cause all sorts of mess.

Note that if anything is wrong with the form, this will simply fail with an exception (probably a substring exception).


getTagValue

protected java.lang.String getTagValue(java.lang.String tagName,
                                       java.lang.String tag)

insertFormInputData

protected java.lang.String insertFormInputData(java.lang.String htmlString,
                                               DXEntry entry)
Goes through the html template, checking for any field tags of text type for example:

<tr> <th align="right" width="200">Common Name:</th> <td width="230"><input type="text" name="cn" value=""/></td> </tr>

If one is found, it checks the name and gets (in this example) the cn value from the entry and inserts it into the value part of the tag (for example value="Trudi"). If the attribute is multivalued, the input tag (<input type="text" name="cn" value=""/>) is copied and reused until all of the attribute values are inserted. For layout, a </br> is added to the end of multivalued attribute tags. The tag is then inserted back into the html template and returned.

Parameters:
htmlString - the actual html file that is to be displayed.
entry - the current entry that the html file is trying to display.
Returns:
the updated html file (updated with the values of the text fields that are to be displayed).

insertFormSelectData

protected java.lang.String insertFormSelectData(java.lang.String htmlString,
                                                DXEntry entry)

insertFormTextAreaData

protected java.lang.String insertFormTextAreaData(java.lang.String htmlString,
                                                  DXEntry entry)
Goes through the html template, checking for any text area tags for example:

<tr> <th align="right" valign="top" width="200">Address:</th> <td width="230"><textarea name="postalAddress" rows="4"></textarea></td> </tr>

If one is found, it checks the name and gets (in this example) the postalAddress value from the entry and inserts it into the value part of the tag (for example value="21 Jump Street"). If the attribute is multivalued, the input tag (<textarea name="postalAddress" rows="4"></textarea>) is copied and reused until all of the attribute values are inserted. For layout, a </br> is added to the end of multivalued attribute tags. The tag is then inserted back into the html template and returned.

Parameters:
htmlString - the actual html file that is to be displayed.
entry - the current entry that the html file is trying to display.
Returns:
the updated html file (updated with the values of the text fields that are to be displayed).

insertFormImageData

protected java.lang.String insertFormImageData(java.lang.String htmlString,
                                               DXEntry entry)
Inserts jpegPhoto values into the html file/template. It searches the html file (which is the parameter: "htmlString") for the jpegPhoto tag (or flag): "Image N/A". If there is one or more audio values in the entry it removes the whole tag (or flag) "Image N/A", and makes a string buffer containing the new tags of all of the jpegPhoto attributes that pertain to the current entry.

For example: <br/><img src="..\..\temp\cn=Allison MOODY,o=DEMOCORP,c=AU0.jpg" border="1" /> <br/><img src="..\..\temp\cn=Allison MOODY,o=DEMOCORP,c=AU1.jpg" border="1" /> <br/><img src="..\..\temp\cn=Allison MOODY,o=DEMOCORP,c=AU2.jpg" border="1" />

It gets the names of the files from searching the temp directory for names that begin with the DN of the current entry and end in '.jpg'. The string buffer is inserted in the place of the removed image tag (the last ">" is removed), and then returned.

The html files/templates reside in jxplorer>templates>inetOrgPerson (inetOrgPerson being the only object class that contains the jpegPhoto attribute that we provide templates for) whereas the temp directory resides in the jxplorer directory. This is why the image tag needs "..\..\temp\".

Parameters:
htmlString - the actual html file that is to be displayed & that the jpegPhoto image is to be set.
entry - the current entry that the html file is trying to display.
Returns:
the updated html file (updated with the names and locations of the images that are to be displayed).

insertFormAudioData

protected java.lang.String insertFormAudioData(java.lang.String htmlString,
                                               DXEntry entry)
Inserts audio hyperlinks into the html file/template. It searches the html file (which is the parameter: "htmlString") for the audio tag (or flag): "Audio N/A". If there is one or more audio values in the entry it removes the whole tag (or flag) "Audio N/A", and makes a string buffer containing the new tags of all of the audio attributes that pertain to the current entry.

For example: <a href="..\..\temp\cn=Allison MOODY,o=DEMOCORP,c=AU0.wav">Sound File<a/><br/> <a href="..\..\temp\cn=Allison MOODY,o=DEMOCORP,c=AU1.wav">Sound File<a/><br/> <a href="..\..\temp\cn=Allison MOODY,o=DEMOCORP,c=AU2.wav">Sound File<a/><br/>

It gets the names of the files from searching the temp directory for names that begin with the DN of the current entry & that don't end in '.jpg'. The string buffer is inserted in the place of the removed audio tag , and then returned.

The html files/templates reside in jxplorer>templates>inetOrgPerson (inetOrgPerson being the only object class that contains the audio attribute that we provide templates for) whereas the temp directory resides in the jxplorer directory. This is why the image tag needs "..\..\temp\".

Parameters:
htmlString - the actual html file that the audio hyperlinks need to be inserted into.
entry - the current entry that the html file is trying to display.
Returns:
the updated html file (updated with the names and locations of the audio files that are to be hyperlinked to).

insertFormValue

protected java.lang.String insertFormValue(java.lang.String tag,
                                           DXEntry entry,
                                           java.lang.String name)
Inserts the attribute value into the tag.

Parameters:
tag - the html tag that the value needs to be inserted into e.g. <input type="text" name="cn" value=""/>.
entry - the current entry (or the entry that needs to be displayed).
name - the name of the attribute (e.g. 'cn').
Returns:
the tag with the value inserted.

insertFormValue

protected java.lang.String insertFormValue(java.lang.String tag,
                                           DXEntry entry,
                                           java.lang.String name,
                                           int position)
Inserts the attribute value into the tag.

Parameters:
tag - the html tag that the value needs to be inserted into e.g. <input type="text" name="cn" value=""/>.
entry - the current entry (or the entry that needs to be displayed).
name - the name of the attribute (e.g. 'cn').
position - the position of the value to be inserted (an attribute may be multivalued).
Returns:
the tag with the value inserted.

getAttValue

protected java.lang.String getAttValue(java.lang.String name,
                                       DXEntry entry)
Get the value of an attribute corresponding to a particular name.

Parameters:
name - the name of the attribute(e.g. 'cn').
entry - the current entry (or the entry that needs to be displayed).
Returns:
the attribute value (e.g. 'frank').

getAttValue

protected java.lang.String getAttValue(java.lang.String name,
                                       DXEntry entry,
                                       int position)

Get the value of an attribute corresponding to a particular name.

For simplicity elsewhere in the code (!) we make sure that for naming attributes the first value (in position 0) is *always* the naming value.

Parameters:
name - the actual attribute name (e.g. 'cn').
entry - the current entry (or the entry that needs to be displayed).
position - the position of the value to be inserted (an attribute may be multivalued).
Returns:
the attribute value (e.g. 'frank').

formattedAttribute

public java.lang.String formattedAttribute(java.lang.String attType,
                                           javax.naming.directory.Attributes attributes,
                                           java.lang.String modifier)
This takes a attribute type name and the complete attribute list, as well as an optional modifier, and returns the formatted html necessary to display the attribute in the html text.

Parameters:
attType - the type of the attribute being formatted
attributes - a list of all available attributes
modifier - one of list|table|plain, or a null value (which is equivalent to list) that sets the html list display type
Returns:
formatted html text displaying the attribute

formattedAttribute

public java.lang.String formattedAttribute(javax.naming.directory.Attribute theAttribute,
                                           java.lang.String modifier)
This takes a attribute type name and the complete attribute list, as well as an optional modifier, and returns the formatted html necessary to display the attribute in the html text.

Parameters:
modifier - one of list|table|plain, or a null value (which is equivalent to list) that sets the html list display type
Returns:
formatted html text displaying the attribute

syntaxParse

public java.lang.String syntaxParse(java.lang.String s,
                                    java.lang.String syntaxOID)

formattedListAttribute

public java.lang.String formattedListAttribute(javax.naming.NamingEnumeration attlist,
                                               java.lang.String modifier,
                                               java.lang.String syntaxOID,
                                               java.lang.String syntaxID)
Takes a list of attribute values, and formats them as an html list, possibly of a type specified by the modifier.

Parameters:
attlist - a list of objects to display.
modifier - one of list|table|plain, or a null value (which is equivalent to list) that sets the html list display type.
syntaxOID - eg 1.3.6.1.4.1.1466.155.121.1.41 for postalAddress.
syntaxID - eg postalAddress.
Returns:
the html text necessary to display th elist of values.

getMediaTags

public java.lang.String getMediaTags(java.lang.String listStart,
                                     java.lang.String listEnd,
                                     java.lang.String itemStart,
                                     java.lang.String itemEnd,
                                     java.lang.String type)
Returns a string representation of all HTML code need to display all of the jpegPhoto or audio attributes in the template. Lists all the files in the temp directory. Checks if any pertain to the entry that is to be displayed (checks that it starts with the dn of the entry and ends with '.jpg', or for audio checks that it doesn't end in ',jpg'). If so, appends the html code to a string buffer which is returned as a string.

Parameters:
listStart - the start tag for the display type (bullet or table).
listEnd - the end tag for the display type.
itemStart - the start tag for the display inserts.
itemEnd - the end tag for the display inserts.
Returns:
the whole html code for displaying the jpeg photos within the display.

formattedAllAttributes

public java.lang.String formattedAllAttributes(DXEntry attributes,
                                               java.lang.String modifier)

openLocalURL

public boolean openLocalURL(java.lang.String localURL)
Convenience wrapper for openPage, that prefixes parameter URL with the local URL directory path.

Parameters:
localURL - the URL to convert to a fully defined path

openDocumentURL

public boolean openDocumentURL(java.lang.String docURL)
Convenience wrapper for openPage, that prefixes parameter URL with the document URL directory path.

Parameters:
docURL - the URL to convert to a fully defined path

launchMailClient

public void launchMailClient(java.lang.String desc)
Tricky method that launches the users default mail client. Does this by creating a bat file (which is deleted on JX exit) called 'temp.bat'. It then writes something like 'start mailto:whoever@whereever.com' to this file It then uses the runtime class to run this bat file which should launch the default mail client (on windows only).


openPage

public boolean openPage(java.lang.String urlString)
identical in intent to openPage(URL) (see). This version takes a string form of the URL instead.

Parameters:
urlString - the string form of the url to be opened.
Returns:
whether the new page loading was successfull.

openPage

public boolean openPage(java.net.URL url)
this opens a page for viewing. It handles all errors internally. If it is unable to open a page, it will attempt to restore the current page.

Parameters:
url - the location of the page (help file, template etc.) to be opened
Returns:
whether the new page loading was successfull.

setEditor

protected void setEditor(java.net.URL url)
                  throws java.io.IOException
Sets the editor to display the particular (html only, no DNs...) url.

Parameters:
url - the url of the local file/web page to display
java.io.IOException

getDisplayComponent

public javax.swing.JComponent getDisplayComponent()
Description copied from interface: PluggableEditor
This returns the swing component being used to display the data, so that another component can set its visibility.

In many cases this may be the editor itself.

Specified by:
getDisplayComponent in interface PluggableEditor
Returns:
the java.swing component being used to display the node data.

toString

public java.lang.String toString()
Overrides:
toString in class java.awt.Component

getName

public java.lang.String getName()
Description copied from interface: PluggableEditor
Returns the title of the editor. (This might be displayed on a tab or similar). If null, the object class name will be used instead.

Specified by:
getName in interface PluggableEditor
Overrides:
getName in class java.awt.Component

getIcon

public javax.swing.ImageIcon getIcon()
Description copied from interface: PluggableEditor
Returns the icon of the editor. (This might be displayed on a tab or similar).

Specified by:
getIcon in interface PluggableEditor

getToolTip

public java.lang.String getToolTip()
Description copied from interface: PluggableEditor
Returns the Tool Tip of the editor. (This might be displayed on a tab or similar).

Specified by:
getToolTip in interface PluggableEditor

getPrintComponent

public java.awt.Component getPrintComponent()
Return the thingumy that should be printed.

Specified by:
getPrintComponent in interface PluggableEditor
Returns:
the component being used to print the node data.

isUnique

public boolean isUnique()
Description copied from interface: PluggableEditor
This sets whether the component expects to be the only editor used for its object class, or whether it will co-exist with any other applicable editors, and the default (html/table) editor.

Specified by:
isUnique in interface PluggableEditor

getDataSink

public DataSink getDataSink()
Description copied from interface: PluggableEditor
Returns the data sink that will be used to slurp data.

In many cases this may be the editor itself.

Specified by:
getDataSink in interface PluggableEditor
Returns:
a data sink to display or process data.

canCreateEntry

public boolean canCreateEntry()
Description copied from interface: DataSink
Indicates whether the editor can create a new entry, given a unique name.

Specified by:
canCreateEntry in interface DataSink

registerComponents

public void registerComponents(javax.swing.JMenuBar menu,
                               javax.swing.JToolBar buttons,
                               javax.swing.JTree tree,
                               javax.swing.JPopupMenu treeMenu,
                               javax.swing.JFrame jx)
Description copied from interface: PluggableEditor
Registers Swing components that the pluggable editor may manipulate. Any or all of these may be null if the editor is not permitted to manipulate the objects.

Any changes made by the editor should be removed when the editor is unloaded.

Specified by:
registerComponents in interface PluggableEditor
Parameters:
menu - the main menu that appears on the top of JXplorer
buttons - the JXplorer button bar
tree - the JXplorer tree
treeMenu - the popup menu that JXplorer uses for tree items
jx - the root JXplorer object, from which the entire GUI tree descends. (You need this for look & feel updates, and possibly for paintology)

unload

public void unload()
Description copied from interface: PluggableEditor
This method is called when the editor is being unloaded by the browser, and allows for any required clean up activity. Note that this is not necessarily called when JXplorer shuts down.

Specified by:
unload in interface PluggableEditor

getTreeIcon

public javax.swing.ImageIcon getTreeIcon(java.lang.String rdn)
Use the default tree icon system based on naming value or object class.

Specified by:
getTreeIcon in interface PluggableEditor
Parameters:
rdn - the name of the tree node being displayed (i.e. the rdn of the entry)
Returns:
an image icon to display - usually 'null' to revert to default behaviour.

getPopupMenu

public javax.swing.JPopupMenu getPopupMenu(java.lang.String rdn)
Use the default popupmenu.

Specified by:
getPopupMenu in interface PluggableEditor
Parameters:
rdn - the name of the tree node being displayed (i.e. the rdn of the entry)
Returns:
a popup menu to use for this type of entry - usually 'null' to revert to default behaviour.

hideSubEntries

public boolean hideSubEntries(java.lang.String rdn)
Don't hide sub entries.

Specified by:
hideSubEntries in interface PluggableEditor
Parameters:
rdn - the name of the tree node being displayed (i.e. the rdn of the entry)
Returns:
whether to truncate the subtree (normally 'false').