com.ca.directory.jxplorer.viewer
Class AttributeDisplay

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--javax.swing.JComponent
                    |
                    +--javax.swing.JTabbedPane
                          |
                          +--com.ca.directory.jxplorer.viewer.AttributeDisplay
All Implemented Interfaces:
javax.accessibility.Accessible, DataSink, java.awt.image.ImageObserver, java.awt.MenuContainer, java.awt.print.Printable, java.io.Serializable, javax.swing.SwingConstants

public class AttributeDisplay
extends javax.swing.JTabbedPane
implements DataSink, java.awt.print.Printable

AttributeDisplay holds a variety of display and editing classes, as well as a simple toolbar to allow switching between these. The main one is an HTML template displaying class, but there are (will be) also attribute editing and template editing classes...

Note that this class is *not* thread safe.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class javax.swing.JTabbedPane
javax.swing.JTabbedPane.AccessibleJTabbedPane, javax.swing.JTabbedPane.ModelListener
 
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  java.util.Vector activeEditors
          a list containing the currently displayed editors
protected  PluggableEditor currentEditor
          The editor currently being displayed to the user.
protected  DataSource dataSource
          the source of directory data for all editors
static int EDITOR
          The Table editor is always in position 2 (if present)
protected  java.util.Hashtable editors
          A hashtable of all the editors that have ever been used to display an entry in the current JX session.
protected  DXEntry entry
          the currently viewed entry (may be null)
static int HTMLRENDERER
          The HTML editor is always in position 1 (if present)
protected  boolean ignoreChangeEvents
          Every time a tab is added or deleted, or a new tab is selected, a change event is triggered.
protected  java.lang.ClassLoader myLoader
          A local copy of the special class loader used to load the plugable editors.
protected  java.util.Properties myProperties
          A convenience link to the global JX properties list.
protected static java.lang.String NONE
          A utility constant - this is used in the editor hashtable to indicate that no pluggable editor has been found, and that there is no need to use the resource loader to look again.
protected  java.lang.String oldOCSig
           
protected  javax.swing.JFrame owner
          the parent frame displaying this object
static java.lang.String PACKAGEPREFIX
          All Plugins must have this package prefix.
protected  CBResourceLoader resourceLoader
          A local copy of the special resource loader used to load the plugable editors and their associated resource files.
protected  TableAttributeEditor tableDisplay
          The default table editor, that is usually available, and displays entry data as a grid of strings.
protected  HTMLTemplateDisplay templateDisplay
          The default html editor, that is usually available, and which displays html template files
protected  javax.swing.JPanel view
          The main view panel.
protected  javax.swing.JScrollPane viewHolder
          The scroll pane that holds the main view object
 
Fields inherited from class javax.swing.JTabbedPane
changeEvent, changeListener, model, SCROLL_TAB_LAYOUT, tabPlacement, WRAP_TAB_LAYOUT
 
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.print.Printable
NO_SUCH_PAGE, PAGE_EXISTS
 
Fields inherited from interface javax.swing.SwingConstants
BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
AttributeDisplay(java.util.Properties props, javax.swing.JFrame owner, CBResourceLoader resourceLoader)
          The constructor for AttributeDisplay requires information about default file directories and urls.
 
Method Summary
 void add(PluggableEditor ed)
           
 void add(PluggableEditor ed, int index)
           
 boolean canCreateEntry()
          Indicates whether the editor can create a new entry, given a unique name.
 void displayEntry(DXEntry dxentry, DataSource ds)
          Displays data that can be modified by the user.
 void displaySpecialEntry(DXEntry entry, DataSource ds, java.lang.String editorName)
          This is a 'get out of jail free' method that allows an external class to force the display of a particular editor.
protected  PluggableEditor getCurrentEditor()
          Returns the current editor.
static java.lang.String getPackagePrefix()
           
 java.awt.Component getPrintComponent()
          Return the thingumy that should be printed.
 PluggableEditor getUniqueEditor(javax.naming.directory.Attribute oc)
          This looks through a list of object classes in an attribute until it finds a unique editor corresponding to a particular value.
protected  void initHTMLEditor()
          delay initialising the html editor until we need it, or it is loaded by a background thread.
protected  void initTableEditor()
          delay initialising the table editor until we need it, or it is loaded by a background thread.
 void openDocumentURL(java.lang.String docURL)
          Used to force Attribute Display to show a particular web page, rather than an attribute display.
 void print()
          Starts the print operation.
 int print(java.awt.Graphics g, java.awt.print.PageFormat pf, int pageIndex)
          The method @print@ must be implemented for @Printable@ interface.
 void refreshEditors()
          Refreshes the currently visible editor with new info.
 void refreshEditors(DXEntry entry, DataSource ds)
          Refreshes the currently visible editor with new info.
 void registerClassLoader(java.lang.ClassLoader loader)
          This specifies the class loader used to load plugin editors.
 void registerComponents(javax.swing.JMenuBar menu, javax.swing.JToolBar buttons, javax.swing.JTree tree, javax.swing.JPopupMenu treeMenu, javax.swing.JFrame jxplorer)
          This can be used to register Swing components that may be used by sub editors to affect the outside environment.
 void remove(int index)
           
 void removeAll()
           
protected  void setCurrentEditor(PluggableEditor makeCurrent)
          Sets the current editor to the specified editor, loads the current entry, and makes sure that it is visible to the user.
protected  void setEditors(DXEntry entry, DataSource ds, java.util.Vector ocs)
          Clear out all the old editors, and get new editors corresponding to the new object classes.
static void setPackagePrefix(java.lang.String prefix)
           
 boolean suggestHTMLEditor()
           
 boolean suggestPluggableEditor()
          If a purpose written pluggable editor is available, switch to that,
 boolean suggestTableEditor()
           
 
Methods inherited from class javax.swing.JTabbedPane
add, add, add, add, add, addChangeListener, addTab, addTab, addTab, createChangeListener, fireStateChanged, getAccessibleContext, getBackgroundAt, getBoundsAt, getChangeListeners, getComponentAt, getDisabledIconAt, getDisplayedMnemonicIndexAt, getForegroundAt, getIconAt, getMnemonicAt, getModel, getSelectedComponent, getSelectedIndex, getTabCount, getTabLayoutPolicy, getTabPlacement, getTabRunCount, getTitleAt, getToolTipText, getToolTipTextAt, getUI, getUIClassID, indexAtLocation, indexOfComponent, indexOfTab, indexOfTab, insertTab, isEnabledAt, paramString, remove, removeChangeListener, removeTabAt, setBackgroundAt, setComponentAt, setDisabledIconAt, setDisplayedMnemonicIndexAt, setEnabledAt, setForegroundAt, setIconAt, setMnemonicAt, setModel, setSelectedComponent, setSelectedIndex, setTabLayoutPolicy, setTabPlacement, setTitleAt, setToolTipTextAt, 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, 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
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, 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

HTMLRENDERER

public static final int HTMLRENDERER
The HTML editor is always in position 1 (if present)

See Also:
Constant Field Values

EDITOR

public static final int EDITOR
The Table editor is always in position 2 (if present)

See Also:
Constant Field Values

viewHolder

protected javax.swing.JScrollPane viewHolder
The scroll pane that holds the main view object


view

protected javax.swing.JPanel view
The main view panel. This is what holds the various editors.


dataSource

protected DataSource dataSource
the source of directory data for all editors


entry

protected DXEntry entry
the currently viewed entry (may be null)


currentEditor

protected PluggableEditor currentEditor
The editor currently being displayed to the user. This is updated every time the user tabs to a new editor, or a different editor is loaded.


templateDisplay

protected HTMLTemplateDisplay templateDisplay
The default html editor, that is usually available, and which displays html template files


tableDisplay

protected TableAttributeEditor tableDisplay
The default table editor, that is usually available, and displays entry data as a grid of strings. Binary data may be edited using special 'attribute editors'.


myProperties

protected java.util.Properties myProperties
A convenience link to the global JX properties list.


editors

protected java.util.Hashtable editors
A hashtable of all the editors that have ever been used to display an entry in the current JX session. When an entry is loaded, these are checked first to determine whether an editor already exists, and if it does, it is re-used.


activeEditors

protected java.util.Vector activeEditors
a list containing the currently displayed editors


owner

protected javax.swing.JFrame owner
the parent frame displaying this object


oldOCSig

protected java.lang.String oldOCSig

myLoader

protected java.lang.ClassLoader myLoader
A local copy of the special class loader used to load the plugable editors.


resourceLoader

protected CBResourceLoader resourceLoader
A local copy of the special resource loader used to load the plugable editors and their associated resource files.


PACKAGEPREFIX

public static java.lang.String PACKAGEPREFIX
All Plugins must have this package prefix. Usually it is com.ca.directory.jxplorer.viewer, but it can be reset in the configuration.


NONE

protected static final java.lang.String NONE
A utility constant - this is used in the editor hashtable to indicate that no pluggable editor has been found, and that there is no need to use the resource loader to look again.

See Also:
Constant Field Values

ignoreChangeEvents

protected boolean ignoreChangeEvents
Every time a tab is added or deleted, or a new tab is selected, a change event is triggered. Sometimes we'd like to ignore these while we're getting our tabs sorted out (i.e. when we're adding and deleting large numbers of tabs) and this flags that such changes should be ignored.

Constructor Detail

AttributeDisplay

public AttributeDisplay(java.util.Properties props,
                        javax.swing.JFrame owner,
                        CBResourceLoader resourceLoader)
The constructor for AttributeDisplay requires information about default file directories and urls. These are passed in via a Properties object, that should contain values for 'dir.templates', 'dir.htmldocs', and 'dir.local'.

Parameters:
props - list of defaults for file and url locations.
owner - the parent frame, used for gui sanity and L&F propogation
resourceLoader - the resource loader used to load HTML templates from zip/jar files
Method Detail

setPackagePrefix

public static void setPackagePrefix(java.lang.String prefix)

getPackagePrefix

public static java.lang.String getPackagePrefix()

registerClassLoader

public void registerClassLoader(java.lang.ClassLoader loader)
This specifies the class loader used to load plugin editors. (This may not be known when an AttributeDisplay object is first created, at which time only the default system class loader is used).


initHTMLEditor

protected void initHTMLEditor()
delay initialising the html editor until we need it, or it is loaded by a background thread.


initTableEditor

protected void initTableEditor()
delay initialising the table editor until we need it, or it is loaded by a background thread.


print

public int print(java.awt.Graphics g,
                 java.awt.print.PageFormat pf,
                 int pageIndex)
          throws java.awt.print.PrinterException
The method @print@ must be implemented for @Printable@ interface. Parameters are supplied by system.

Specified by:
print in interface java.awt.print.Printable
java.awt.print.PrinterException

print

public void print()
Starts the print operation. This is quite expensive, and is kicked off in a separate thread.


openDocumentURL

public void openDocumentURL(java.lang.String docURL)
Used to force Attribute Display to show a particular web page, rather than an attribute display. This forces it to change view to an HTMLTemplateDisplay editor, and then show the desired URL thrugh this display.


displaySpecialEntry

public void displaySpecialEntry(DXEntry entry,
                                DataSource ds,
                                java.lang.String editorName)
This is a 'get out of jail free' method that allows an external class to force the display of a particular editor. (e.g. for a pluggable editor system that wants to be started on an empty directory).

Parameters:
entry - the entry to display (may be null)
ds - the data source to use for directory info.
editorName - the name to display in the editor tab.

displayEntry

public void displayEntry(DXEntry dxentry,
                         DataSource ds)

Displays data that can be modified by the user.

This method also organises which editors are used to display the current entry, searching for pluggable editors and so on.

Specified by:
displayEntry in interface DataSink
Parameters:
ds - the datasource the editors may use for more info
dxentry - the directory entry to display. If null, indicates that a blank or 'empty' entry should be displayed.

suggestPluggableEditor

public boolean suggestPluggableEditor()
If a purpose written pluggable editor is available, switch to that,


suggestTableEditor

public boolean suggestTableEditor()

suggestHTMLEditor

public boolean suggestHTMLEditor()

setCurrentEditor

protected void setCurrentEditor(PluggableEditor makeCurrent)
Sets the current editor to the specified editor, loads the current entry, and makes sure that it is visible to the user.

Parameters:
makeCurrent - the editor to select.

getCurrentEditor

protected PluggableEditor getCurrentEditor()
Returns the current editor.


setEditors

protected void setEditors(DXEntry entry,
                          DataSource ds,
                          java.util.Vector ocs)
Clear out all the old editors, and get new editors corresponding to the new object classes.

Parameters:
entry - the entry to be displayed by all the editors
ds - the datasource the editors may use for more info
ocs - the object classes (in order) to find editors for.

getUniqueEditor

public PluggableEditor getUniqueEditor(javax.naming.directory.Attribute oc)
This looks through a list of object classes in an attribute until it finds a unique editor corresponding to a particular value. If no editor is found 'null' is returned. Note that If multiple unique editors exist, which one is returned is undefined.

Parameters:
oc - the objectClass attribute; a list of object classes
Returns:
the unique pluggable editor corresponding to one particular object class value, or null if none is found.

registerComponents

public void registerComponents(javax.swing.JMenuBar menu,
                               javax.swing.JToolBar buttons,
                               javax.swing.JTree tree,
                               javax.swing.JPopupMenu treeMenu,
                               javax.swing.JFrame jxplorer)
This can be used to register Swing components that may be used by sub editors to affect the outside environment.


refreshEditors

public void refreshEditors()
Refreshes the currently visible editor with new info.


refreshEditors

public void refreshEditors(DXEntry entry,
                           DataSource ds)
Refreshes the currently visible editor with new info.


getPrintComponent

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


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

add

public void add(PluggableEditor ed)

add

public void add(PluggableEditor ed,
                int index)

remove

public void remove(int index)
Overrides:
remove in class javax.swing.JTabbedPane

removeAll

public void removeAll()
Overrides:
removeAll in class javax.swing.JTabbedPane