edu.uky.rch.ept.data.ui
Class GeneralAddressSelector

java.lang.Object
  extended byorg.eclipse.swt.widgets.Widget
      extended byorg.eclipse.swt.widgets.Control
          extended byorg.eclipse.swt.widgets.Scrollable
              extended byorg.eclipse.swt.widgets.Composite
                  extended byedu.uky.rch.ept.data.ui.GeneralAddressSelector
All Implemented Interfaces:
org.eclipse.swt.graphics.Drawable, IAddressListener, IAddressSelector

public class GeneralAddressSelector
extends org.eclipse.swt.widgets.Composite
implements IAddressSelector, IAddressListener

General address selector providing access to all data source driver address selectors. Presents the user with a combo box for selecting the driver (disabled in relative mode), and a pane which toggles between the various address selectors, depending on the selected driver. Note that the makeControl(Composite) method should not be called, and will throw an exception.

Author:
Neil Moore
See Also:
IAddressSelector

Field Summary
 
Fields inherited from class org.eclipse.swt.widgets.Composite
embeddedHandle
 
Fields inherited from class org.eclipse.swt.widgets.Widget
handle
 
Fields inherited from interface edu.uky.rch.ept.data.ui.IAddressSelector
CREATE, OPEN, SAVE
 
Constructor Summary
GeneralAddressSelector(org.eclipse.swt.widgets.Composite parent)
          Create a new general address selector with the specified parent.
 
Method Summary
 void addAddressListener(IAddressListener listener)
          Add an address listener to this selector.
 void addressChanged(IAddressSelector source)
          Callback for notification of changes in an address selector's selected address.
 String getAddress()
          Get the address for this selector.
 org.eclipse.swt.widgets.Control getControl()
          Get the already-created GUI control.
 int getExistenceMode()
          Get the existence mode for this selector.
 String getRoot()
          Get the relative-mode root for this selector.
 boolean hasAddress()
          Determine whether the user has selected a valid address.
 boolean isDirectories()
          Determine whether this selector is configured to select files or directories.
 boolean isRelative()
          Determine whether this selector is in relative mode.
 org.eclipse.swt.widgets.Control makeControl(org.eclipse.swt.widgets.Composite parent)
          Unimplemented method.
 void removeAddressListener(IAddressListener listener)
          Remove the specified address listener to this selector.
 void setAbsolute()
          Set this address selector to absolute mode.
 void setDirectories(boolean dir)
          Configure this selector to allow selection of files or directories.
 void setEnabled(boolean enabled)
           
 void setExistenceMode(int mode)
          Set the existence mode for this selector.
 void setRelative(String root)
          Set this address selector to relative mode with the specified root.
 
Methods inherited from class org.eclipse.swt.widgets.Composite
checkSubclass, computeSize, getChildren, getLayout, getTabList, layout, layout, setFocus, setLayout, setTabList
 
Methods inherited from class org.eclipse.swt.widgets.Scrollable
computeTrim, getBorderWidth, getClientArea, getHorizontalBar, getVerticalBar
 
Methods inherited from class org.eclipse.swt.widgets.Control
addControlListener, addFocusListener, addHelpListener, addKeyListener, addMouseListener, addMouseMoveListener, addMouseTrackListener, addPaintListener, addTraverseListener, computeSize, forceFocus, getAccessible, getBackground, getBounds, getEnabled, getFont, getForeground, getLayoutData, getLocation, getMenu, getMonitor, getParent, getShell, getSize, getToolTipText, getVisible, internal_dispose_GC, internal_new_GC, isEnabled, isFocusControl, isReparentable, isVisible, moveAbove, moveBelow, pack, pack, redraw, redraw, removeControlListener, removeFocusListener, removeHelpListener, removeKeyListener, removeMouseListener, removeMouseMoveListener, removeMouseTrackListener, removePaintListener, removeTraverseListener, setBackground, setBounds, setBounds, setCapture, setCursor, setFont, setForeground, setLayoutData, setLocation, setLocation, setMenu, setParent, setRedraw, setSize, setSize, setToolTipText, setVisible, toControl, toControl, toDisplay, toDisplay, traverse, update
 
Methods inherited from class org.eclipse.swt.widgets.Widget
addDisposeListener, addListener, checkWidget, dispose, getData, getData, getDisplay, getStyle, isDisposed, isListening, notifyListeners, removeDisposeListener, removeListener, removeListener, setData, setData, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

GeneralAddressSelector

public GeneralAddressSelector(org.eclipse.swt.widgets.Composite parent)
Create a new general address selector with the specified parent. This constructor takes the place of the makeControl(Composite) method.

Parameters:
parent - a widget which will be the parent of the created instance. Must not be null.
Method Detail

addAddressListener

public void addAddressListener(IAddressListener listener)
Description copied from interface: IAddressSelector
Add an address listener to this selector. Every time the selected address changes (even to an invalid address), the listener's IAddressListener.addressChanged(IAddressSelector) method is called.

Specified by:
addAddressListener in interface IAddressSelector
Parameters:
listener - the listener to add to this selector.

removeAddressListener

public void removeAddressListener(IAddressListener listener)
Description copied from interface: IAddressSelector
Remove the specified address listener to this selector.

Specified by:
removeAddressListener in interface IAddressSelector
Parameters:
listener - the listener to remove from this selector.

getAddress

public String getAddress()
Description copied from interface: IAddressSelector
Get the address for this selector. Returns null if no valid address is selected (i.e., if IAddressSelector.hasAddress() would return false. If the selector is in relative mode, returns a relative address that may be appended to the result of IAddressSelector.getRoot() to obtain an absolute data layer address. If the selector is in absolute mode, returns an absolute data layer address.

Specified by:
getAddress in interface IAddressSelector
Returns:
the currently-selected address, or null if none is selected.

setRelative

public void setRelative(String root)
                 throws MalformedAddressException
Description copied from interface: IAddressSelector
Set this address selector to relative mode with the specified root. In relative mode, the user may only select files located beneath the root, and IAddressSelector.getAddress() returns relative paths. Changing between relative and absolute modes clears any address the user had previously selected.

Specified by:
setRelative in interface IAddressSelector
Parameters:
root - the data layer address relative to which the user selects addresses. If it does not end in IDataConstants.SEP_MAJOR, that string is appended.
Throws:
MalformedAddressException - if root is not an absolute data layer address with the correct protocol identifier.

setAbsolute

public void setAbsolute()
Description copied from interface: IAddressSelector
Set this address selector to absolute mode. In absolute mode, the user may select any file on the filesystem, and IAddressSelector.getAddress() returns absolute data layer addresses. Changing between relative and absolute modes clears any address the user had previously selected.

Specified by:
setAbsolute in interface IAddressSelector

isRelative

public boolean isRelative()
Description copied from interface: IAddressSelector
Determine whether this selector is in relative mode.

Specified by:
isRelative in interface IAddressSelector
Returns:
true if this selector is in relative mode, false if it is in absolute mode.

getRoot

public String getRoot()
Description copied from interface: IAddressSelector
Get the relative-mode root for this selector.

Specified by:
getRoot in interface IAddressSelector
Returns:
this selector's root as an absolute data layer address, if in relative mode. If in absolute mode, returns null.

setDirectories

public void setDirectories(boolean dir)
Description copied from interface: IAddressSelector
Configure this selector to allow selection of files or directories.

Specified by:
setDirectories in interface IAddressSelector
Parameters:
dir - if true, configure this selector to allow the selection of directories only. If false, allow the selection of non-directories only.

isDirectories

public boolean isDirectories()
Description copied from interface: IAddressSelector
Determine whether this selector is configured to select files or directories.

Specified by:
isDirectories in interface IAddressSelector
Returns:
true if this selector is configured to allow the selection of directories, otherwise false.
See Also:
IAddressSelector.setDirectories(boolean)

makeControl

public org.eclipse.swt.widgets.Control makeControl(org.eclipse.swt.widgets.Composite parent)
Unimplemented method. Use the GeneralAddressSelector(Composite) constructor instead.

Specified by:
makeControl in interface IAddressSelector
Parameters:
parent - the parent for the control.
Returns:
the control.
Throws:
IllegalStateException - always.
See Also:
IAddressSelector.makeControl(org.eclipse.swt.widgets.Composite)

getControl

public org.eclipse.swt.widgets.Control getControl()
Description copied from interface: IAddressSelector
Get the already-created GUI control.

Specified by:
getControl in interface IAddressSelector
Returns:
the control previously returned by IAddressSelector.makeControl(Composite), or null if makeControl has not yet been called.

hasAddress

public boolean hasAddress()
Description copied from interface: IAddressSelector
Determine whether the user has selected a valid address. An address is valid if its parent directory exits; and either the selector is in directory mode and no non-directory exists at the selected address, or the selector is not in directory mode and no directory exists at that address.

Specified by:
hasAddress in interface IAddressSelector
Returns:
true if a valid address has been selected, false otherwise.

addressChanged

public void addressChanged(IAddressSelector source)
Description copied from interface: IAddressListener
Callback for notification of changes in an address selector's selected address. This method is called whenever the selector's address changes, even if the new address is invalid. Implementations should call @link{IAddressSelector#hasAddress()} to determine whether the current address is invalid.

Specified by:
addressChanged in interface IAddressListener
Parameters:
source - the address selector whose change fired this event.

setExistenceMode

public void setExistenceMode(int mode)
Description copied from interface: IAddressSelector
Set the existence mode for this selector. The existence mode determines whether the user may select files that already exist (open mode), files that do not yet exist (create mode), or either (save mode). If this method is not called, the default is open mode.

Specified by:
setExistenceMode in interface IAddressSelector
Parameters:
mode - one of the constants IAddressSelector.OPEN, IAddressSelector.SAVE, or IAddressSelector.CREATE.

getExistenceMode

public int getExistenceMode()
Description copied from interface: IAddressSelector
Get the existence mode for this selector.

Specified by:
getExistenceMode in interface IAddressSelector
Returns:
one of the constants IAddressSelector.OPEN, IAddressSelector.SAVE, or IAddressSelector.CREATE.
See Also:
IAddressSelector.setExistenceMode(int)

setEnabled

public void setEnabled(boolean enabled)