com.ca.directory.jxplorer.search
Class SearchGUI

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--java.awt.Window
                    |
                    +--java.awt.Dialog
                          |
                          +--javax.swing.JDialog
                                |
                                +--com.ca.commons.cbutil.CBDialog
                                      |
                                      +--com.ca.directory.jxplorer.search.SearchGUI
All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.image.ImageObserver, java.awt.MenuContainer, javax.swing.RootPaneContainer, java.io.Serializable, javax.swing.WindowConstants

public class SearchGUI
extends CBDialog

This class creates a dialog that has currently three tabs on it. The first one is for creating or building filters, the second on is for joining already created filters and the third one allows the user to enter or paste in a text filter. This class acts as a a controller between the view (build, join & text tabs) and the model (SearchModel) as well as being a part of the view itself.

This class, in brief, sets up a search dialog that can be used to build, load, view, edit, join or save filters aswell as search an LDAP directory with the filter that the user has created.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class javax.swing.JDialog
javax.swing.JDialog.AccessibleJDialog
 
Nested classes inherited from class java.awt.Dialog
java.awt.Dialog.AccessibleAWTDialog
 
Nested classes inherited from class java.awt.Window
java.awt.Window.AccessibleAWTWindow
 
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  javax.swing.JTabbedPane tabbedPane
           
 
Fields inherited from class com.ca.commons.cbutil.CBDialog
buttonPanel, Cancel, display, Help, OK, owner
 
Fields inherited from class javax.swing.JDialog
accessibleContext, rootPane, rootPaneCheckingEnabled
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface javax.swing.WindowConstants
DISPOSE_ON_CLOSE, DO_NOTHING_ON_CLOSE, EXIT_ON_CLOSE, HIDE_ON_CLOSE
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
SearchGUI(DN baseDN, JXplorer jxplorer)
          Contructor that sets up the display and initiates the main search objects: SearchModel, BuildFilterPanel, JoinFilterPanel and TextFilterPanel.
 
Method Summary
 void doOK()
          Sets the search Alias Behaviour in the property file, gets the filter and executes the search & display before closing the window.
protected  void edit(int row)
          Displays the filter(s) corresponding to the edit button that the user has selected.
 CBPanel getButtonPanel()
          Returns a panel with four buttons on it: More, Less, Save & View.
protected  javax.swing.JButton getEditButton()
          Returns an edit button, i.e. a button labelled "Edit", has a dimension of 55x21, has a tooltip "Edit this filter
protected  java.lang.String getLDAPFilter()
          Returns the LDAP filter of the currently displayed tabbed pane.
 CBPanel getMainPanel(DN baseDN)
          Sets up a panel with the components which display the name of the filter, the base DN, aliase prefs, search level prefs and the button panel.
protected  boolean isFilterValid()
          Does a check to see if the filter is valid i.e. it check if there is a value in each of the combo boxes.
protected  void load(java.lang.String name)
          Gets the values of the base dn, search level, return attributes and alias state from the property file that pertain to the filter being loaded and sets these values in the GUI.
protected  void loadBuild()
          Displays a JOptionPane message which has a combo box containing all the possible filters that can be loaded into the build display.
protected  void loadJoin()
          Displays a JOptionPane message which has a combo box containing all the possible filters that can be loaded into the join display.
protected  void loadText()
          Displays a JOptionPane message which has a combo box containing all the possible filters that can be loaded into the text display.
protected  boolean recursiveFilterCheck(java.lang.String filterName, java.lang.String filter)
          Checks if the user is trying to save a copy of the filter into itself, for example if a filter named t3 contains the filter t3 as part of a join.
protected  boolean recursiveFilterCheck(java.lang.String filterName, java.lang.String filter, java.lang.String type)
          Checks if the user is trying to save a copy of the filter into itself, for example if a filter named t3 contains the filter t3 as part of a join.
protected  void save()
          Save the filter to the property file 'search_filter.txt".
protected  void save(java.lang.String name)
          Saves the base DN, return attribute list name, the search level and the alias state to the property file so they can be loaded similar to the filter.
 void setAliasOptions()
          Determines which search alias behaviour the user has selected in the search GUI.
protected  void setButtons(boolean state)
          Enables or disables the More, Less and View buttons.
protected  void setNumberOfRows(int rows)
          Currently used by the loadJoin() and edit() methods to prompt the JoinFilterPanel class to either add or remove rows.
protected  void showDialog(java.lang.String title, java.lang.String filter)
          Displays a JOptionPane message with a text area containing the current filter.
protected  void showMessage(java.lang.String message, java.lang.String title)
          Displays a information message dialog with the text that is supplied and titles the dialog with the title supplied.
 
Methods inherited from class com.ca.commons.cbutil.CBDialog
add, addln, doCancel, escKeyCheck, getDisplayPanel, makeHeavy, makeLight, makeWide, quit, setHelpLink, wasCancelled
 
Methods inherited from class javax.swing.JDialog
addImpl, createRootPane, dialogInit, getAccessibleContext, getContentPane, getDefaultCloseOperation, getGlassPane, getJMenuBar, getLayeredPane, getRootPane, isDefaultLookAndFeelDecorated, isRootPaneCheckingEnabled, paramString, processWindowEvent, remove, setContentPane, setDefaultCloseOperation, setDefaultLookAndFeelDecorated, setGlassPane, setJMenuBar, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, update
 
Methods inherited from class java.awt.Dialog
addNotify, dispose, getTitle, hide, isModal, isResizable, isUndecorated, setModal, setResizable, setTitle, setUndecorated, show
 
Methods inherited from class java.awt.Window
addPropertyChangeListener, addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, finalize, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getGraphicsConfiguration, getInputContext, getListeners, getLocale, getMostRecentFocusOwner, getOwnedWindows, getOwner, getToolkit, getWarningString, getWindowFocusListeners, getWindowListeners, getWindowStateListeners, isActive, isFocusableWindow, isFocusCycleRoot, isFocused, isShowing, pack, postEvent, processEvent, processWindowFocusEvent, processWindowStateEvent, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, setCursor, setFocusableWindowState, setFocusCycleRoot, setLocationRelativeTo, toBack, toFront
 
Methods inherited from class java.awt.Container
add, add, add, add, addContainerListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalPolicy, getInsets, getLayout, getMaximumSize, getMinimumSize, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paint, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, removeAll, removeContainerListener, removeNotify, setFocusTraversalKeys, setFocusTraversalPolicy, setFont, 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, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isOpaque, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

tabbedPane

protected javax.swing.JTabbedPane tabbedPane
Constructor Detail

SearchGUI

public SearchGUI(DN baseDN,
                 JXplorer jxplorer)
Contructor that sets up the display and initiates the main search objects: SearchModel, BuildFilterPanel, JoinFilterPanel and TextFilterPanel.

Parameters:
baseDN - the DN of the currently selected entry (i.e. unless changed is where the search will be conducted from).
jxplorer - JXplorer.
Method Detail

getMainPanel

public CBPanel getMainPanel(DN baseDN)
Sets up a panel with the components which display the name of the filter, the base DN, aliase prefs, search level prefs and the button panel.

Parameters:
baseDN - the Distinguished Name where the searching is done from. This is added to a text field on this panel.
Returns:
the panel with the components added.

getButtonPanel

public CBPanel getButtonPanel()
Returns a panel with four buttons on it: More, Less, Save & View. The buttons are set up with listeners and are placed one above the other.

Returns:
the panel with the buttons on it.

setButtons

protected void setButtons(boolean state)
Enables or disables the More, Less and View buttons. We basically don't want these buttons enabled if the user has selected the Text Filter tab.


showDialog

protected void showDialog(java.lang.String title,
                          java.lang.String filter)
Displays a JOptionPane message with a text area containing the current filter. The text area is set to do line wrapping and only vertical scrolling.

Parameters:
title - the heading of the dialog that appears in the title bar.
filter - the current LDAP filter (or any string to be displayed).

getEditButton

protected javax.swing.JButton getEditButton()
Returns an edit button, i.e. a button labelled "Edit", has a dimension of 55x21, has a tooltip "Edit this filter.", and has an action listener that calls the edit method with it's position (or row number).

Returns:
the configured button.

edit

protected void edit(int row)
Displays the filter(s) corresponding to the edit button that the user has selected. The edit buttons live on the join panel. If a user wants to edit a raw filter the raw filter is displayed in the build panel otherwise if the user wants to edit a filter that is a combination of filters, the filter is displayed in the join panel.

Parameters:
row - the row number that the filter name is to be taken from.

setNumberOfRows

protected void setNumberOfRows(int rows)
Currently used by the loadJoin() and edit() methods to prompt the JoinFilterPanel class to either add or remove rows. If adding rows is required, the extra number of edit buttons are created before the hand-balling goes off to the JoinFilterPanel class.

Parameters:
rows - the number of rows that need to be added.

save

protected void save()
Save the filter to the property file 'search_filter.txt". Checks first to see if the filter exists. If it does a JOptionPane message asks the user if they want to replace it. If the filter is saved successfully a confirmation message is displayed again using JOptionPane. This also updates the filter combo of the join tab so that a user can see changes straight away.


save

protected void save(java.lang.String name)
Saves the base DN, return attribute list name, the search level and the alias state to the property file so they can be loaded similar to the filter.

Parameters:
name - the name of the filter, will be used in the key (e.g. name.baseDN=whatever).

loadBuild

protected void loadBuild()
Displays a JOptionPane message which has a combo box containing all the possible filters that can be loaded into the build display. Gets the user selection and hand-balls the loading off to the BuildFilterPanel class.


loadJoin

protected void loadJoin()
Displays a JOptionPane message which has a combo box containing all the possible filters that can be loaded into the join display. Gets the user selection and creates the edit buttons before hand-balling the loading off to the JoinFilterPanel class.


loadText

protected void loadText()
Displays a JOptionPane message which has a combo box containing all the possible filters that can be loaded into the text display. Gets the user selection and hand-balls the loading off to the JoinFilterPanel class.


load

protected void load(java.lang.String name)
Gets the values of the base dn, search level, return attributes and alias state from the property file that pertain to the filter being loaded and sets these values in the GUI.

Parameters:
name - the name of the filter that is being loaded.

isFilterValid

protected boolean isFilterValid()
Does a check to see if the filter is valid i.e. it check if there is a value in each of the combo boxes.

Returns:
false if one or more of the combo boxes does not contain a value, true otherwise.

getLDAPFilter

protected java.lang.String getLDAPFilter()
Returns the LDAP filter of the currently displayed tabbed pane. This assumes that the build tab is at position 0, the join tab is at position 1 and the text tab is at position 2.

Returns:
the LDAP filter for example (cn=f*)

showMessage

protected void showMessage(java.lang.String message,
                           java.lang.String title)
Displays a information message dialog with the text that is supplied and titles the dialog with the title supplied.

Parameters:
message - the text to be displayed.
title - the title of this information message dialog.

doOK

public void doOK()
Sets the search Alias Behaviour in the property file, gets the filter and executes the search & display before closing the window.

Overrides:
doOK in class CBDialog

setAliasOptions

public void setAliasOptions()
Determines which search alias behaviour the user has selected in the search GUI. The combinations are:

always - both alias check boxes are checked.
never - neither alias check boxes are checked.
finding - only the 'Resolve aliases when finding base object' check box is checked.
searching - only the 'Resolve aliases while searching' check box is checked.

The search alias option is set in JXplorer's property file under 'option.ldap.searchAliasBehaviour'.


recursiveFilterCheck

protected boolean recursiveFilterCheck(java.lang.String filterName,
                                       java.lang.String filter,
                                       java.lang.String type)
Checks if the user is trying to save a copy of the filter into itself, for example if a filter named t3 contains the filter t3 as part of a join. This check applies only for the join tab. Constructs an info dialog if the filter is recursive.

Parameters:
filterName - the user specified name for the filter that is currently being saved.
filter - the value of the filter for example 'JXFilter.t1JXFilter.t1'.
type - the source of the filter being constructed for example: view, save or search (used in the info dialog).
Returns:
true if the filter contains itself, false otherwise.

recursiveFilterCheck

protected boolean recursiveFilterCheck(java.lang.String filterName,
                                       java.lang.String filter)
Checks if the user is trying to save a copy of the filter into itself, for example if a filter named t3 contains the filter t3 as part of a join. This check applies only for the join tab.

Parameters:
filterName - the user specified name for the filter that is currently being saved.
filter - the value of the filter for example 'JXFilter.t1JXFilter.t1'.
Returns:
true if the filter contains itself, false otherwise.