issrg.utils.gui.repository
Class LDAP_DIT

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JPanel
                  extended by issrg.utils.gui.repository.LDAP_DIT
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, javax.accessibility.Accessible
Direct Known Subclasses:
LDAPMultiBrowser

public class LDAP_DIT
extends javax.swing.JPanel

This is a component that displays the LDAP DIT

This is a Panel that contains a display of the LDAP DIT. The location of the DIT is passed when constructing it. Then you can browse the DIT, and programs can send commands to update certain nodes (DIT structure update: created a node, created a child, deleted).

Version:
1.0
Author:
A.Otenko
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanel
 
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
protected  java.lang.String[] binaryAttrs
           
static java.lang.String DEFAULT_ROOT_NAME
           
static java.lang.String NO_TIMEOUT
           
 
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
LDAP_DIT()
          This constructor builds an empty tree and no DirContext connected to it.
LDAP_DIT(javax.naming.directory.DirContext dc)
          This constructor builds a tree starting with the given context.
LDAP_DIT(java.lang.String url)
          This constructor builds a tree, given the URL of the LDAP server to use as the root.
 
Method Summary
static javax.naming.directory.DirContext connectTo(java.lang.String url)
          This method creates a DirContext using the default LDAP provider (SUN), version (3).
static javax.naming.directory.DirContext connectTo(java.lang.String url, java.lang.String[] binaryAttrs)
          This method creates a DirContext using the default LDAP provider (SUN), version (3) and the binary attributes that are provided.
static java.lang.String dnWithoutBaseDN(javax.naming.directory.DirContext root, java.lang.String dn)
          This utility method strips off the base dn (the DN of the root context) from the given DN.
 java.lang.String[] getBinaryAttributes()
          This method returns an array of attributes treated as binary by the DirContext.
static java.lang.String getConnectionTimeoutValue()
           
 javax.naming.directory.DirContext getSelectedNode()
          This method returns a DirContext corresponding to the selected node.
 void new_Tree()
          Resets GUI part of the DIT Panel to display a new tree: just a root node, nothing more.
 void setBinaryAttributes(java.lang.String[] bin)
          This methos sets which attributes should be treated as binary.
static void setConnectionTimeoutValue(java.lang.String time)
           
 void setEnabled(boolean enable)
          Overriding the method so that the whole cascade of components is disabled or enabled.
 java.lang.String setRoot(javax.naming.directory.DirContext rootC)
          This method sets a new Root Context for this Panel to display.
 java.lang.String setRoot(javax.naming.directory.DirContext rootC, java.lang.String defaultRootName)
          This method sets a new Root Context for this Panel to display.
 java.lang.String setRoot(java.lang.String url)
          This method sets a new Root Context for this Panel to display using the LDAP URL as the reference to the root.
 void setSelectionListener(DITSelectionListener d)
          This method sets a listener for two events: an item gets selected, or a user misses the tree (so it gets unselected, if anything).
 int showSelectionDialog(java.awt.Frame owner, java.lang.String title)
          Shows this LDAP_DIT object as a dialog modal to the owner Frame.
static javax.naming.directory.DirContext showSelectionDialog(java.awt.Frame owner, java.lang.String title, javax.naming.directory.DirContext root)
          This is a utility method that shows a dialog, where you can pick a LDAP entry and press OK or Cancel.
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, 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, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, 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, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, 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, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, 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

binaryAttrs

protected java.lang.String[] binaryAttrs

DEFAULT_ROOT_NAME

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

NO_TIMEOUT

public static final java.lang.String NO_TIMEOUT
See Also:
Constant Field Values
Constructor Detail

LDAP_DIT

public LDAP_DIT()
This constructor builds an empty tree and no DirContext connected to it. Use setRoot to attach a new DirContext.


LDAP_DIT

public LDAP_DIT(javax.naming.directory.DirContext dc)
         throws javax.naming.NamingException
This constructor builds a tree starting with the given context. If null, it will build an empty tree.

Parameters:
dc - - the DirContext of the root of the tree to be displayed
Throws:
javax.naming.NamingException

LDAP_DIT

public LDAP_DIT(java.lang.String url)
         throws javax.naming.NamingException
This constructor builds a tree, given the URL of the LDAP server to use as the root. It uses the Sun LDAP provider. To use alternative LDAP providers, build a DirContext and pass it to another constructor.

Parameters:
url - - the String URL of the LDAP server to browse
Throws:
javax.naming.NamingException
Method Detail

setRoot

public java.lang.String setRoot(javax.naming.directory.DirContext rootC)
                         throws javax.naming.NamingException
This method sets a new Root Context for this Panel to display. The name of the root node will be DEFAULT_ROOT_NAME, if the name within the NameSpace is empty.

Parameters:
rootC - DirContext to set as the root context for this view
Returns:
String name of the root context
Throws:
javax.naming.NamingException

setRoot

public java.lang.String setRoot(java.lang.String url)
                         throws javax.naming.NamingException
This method sets a new Root Context for this Panel to display using the LDAP URL as the reference to the root.

Parameters:
url - - the LDAP URL of the root to set.
Returns:
String name of the root context
Throws:
javax.naming.NamingException

getBinaryAttributes

public java.lang.String[] getBinaryAttributes()
This method returns an array of attributes treated as binary by the DirContext.


setBinaryAttributes

public void setBinaryAttributes(java.lang.String[] bin)
This methos sets which attributes should be treated as binary. This will affect only the future connections open using connectTo method.

Parameters:
bin - - the array of attributes to be treated as binary
See Also:
connectTo(java.lang.String)

setRoot

public java.lang.String setRoot(javax.naming.directory.DirContext rootC,
                                java.lang.String defaultRootName)
                         throws javax.naming.NamingException
This method sets a new Root Context for this Panel to display. The name of the root node will be defaultRootName. This name will be displayed only in case the full name of the rootC is empty; the latter will be displayed otherwise. Returns the actual name of the Root in the namespace.

Parameters:
rootC - DirContext to set as the root context for this view
Returns:
String name of the root context
Throws:
javax.naming.NamingException

getSelectedNode

public javax.naming.directory.DirContext getSelectedNode()
                                                  throws javax.naming.NamingException
This method returns a DirContext corresponding to the selected node. Returns null, if nothing is selected.

Returns:
a valid DirContext, or null, if nothing is selected
Throws:
javax.naming.NamingException

new_Tree

public void new_Tree()
Resets GUI part of the DIT Panel to display a new tree: just a root node, nothing more.


setSelectionListener

public void setSelectionListener(DITSelectionListener d)
This method sets a listener for two events: an item gets selected, or a user misses the tree (so it gets unselected, if anything). It should also handle communication errors.

Parameters:
d - - the DITSelectionListener that handles all the events

showSelectionDialog

public static javax.naming.directory.DirContext showSelectionDialog(java.awt.Frame owner,
                                                                    java.lang.String title,
                                                                    javax.naming.directory.DirContext root)
This is a utility method that shows a dialog, where you can pick a LDAP entry and press OK or Cancel. If pressed OK, the corresponding DirContext is returned. Otherwise, returns null. See also another method, that displays the given LDAP_DIT in the dialog.

Parameters:
owner - is the Frame, to which the dialog is displayed modally
title - is the title of the dialog displayed
root - is the root Directory Context
Returns:
a valid DirContext, corresponding to the selected node; null if nothing was selected or the dialog was canceled, or an exception occured during communication to LDAP
Throws:
actually, - it does not throw anything, so if you want to process the NamingExceptions that might otherwise be ignored, do the following:

ldit=new LDAP_DIT(root); ldit.showSelectionDialog(owner, title); ldit.getSelectedNode();

which is exactly what this routine does.


showSelectionDialog

public int showSelectionDialog(java.awt.Frame owner,
                               java.lang.String title)
Shows this LDAP_DIT object as a dialog modal to the owner Frame. Call this method to display a dialog with the LDAP DIT in it, so the user can select the node and press OK or Cancel. If OK is pressed, your code can infer what was the selected node and its DirContext using getSelectedNode method.

Parameters:
owner - is the Frame, to which the dialog is displayed modally
title - is the title of the dialog displayed
Returns:
either CLOSE_OPTION or OK_OPTION, depending on what the user did; getSelectedNode will return meaningful result only if OK_OPTION is returned by this method

connectTo

public static javax.naming.directory.DirContext connectTo(java.lang.String url)
                                                   throws javax.naming.NamingException
This method creates a DirContext using the default LDAP provider (SUN), version (3).

Parameters:
url - - the LDAP URL of the repository
Throws:
javax.naming.NamingException

connectTo

public static javax.naming.directory.DirContext connectTo(java.lang.String url,
                                                          java.lang.String[] binaryAttrs)
                                                   throws javax.naming.NamingException
This method creates a DirContext using the default LDAP provider (SUN), version (3) and the binary attributes that are provided.

Parameters:
url - - the LDAP URL of the repository; should not be null
binaryAttrs - - the array of attributes to be used as binary; if null, no attributes will be assumed binary
Returns:
DirContext or null, if the url is null
Throws:
javax.naming.NamingException

getConnectionTimeoutValue

public static java.lang.String getConnectionTimeoutValue()

setConnectionTimeoutValue

public static void setConnectionTimeoutValue(java.lang.String time)

setEnabled

public void setEnabled(boolean enable)
Overriding the method so that the whole cascade of components is disabled or enabled.

Overrides:
setEnabled in class javax.swing.JComponent

dnWithoutBaseDN

public static java.lang.String dnWithoutBaseDN(javax.naming.directory.DirContext root,
                                               java.lang.String dn)
                                        throws javax.naming.NamingException
This utility method strips off the base dn (the DN of the root context) from the given DN.

Parameters:
root - - the DirContext of the root
dn - - the LDAP DN with or without the base DN
Returns:
the given DN without base DN, if there was any
Throws:
javax.naming.NamingException