edu.uky.rch.ept.data.filesystem
Class FileSystemAddressSelector

java.lang.Object
  extended byedu.uky.rch.ept.data.filesystem.FileSystemAddressSelector
All Implemented Interfaces:
IAddressSelector

public class FileSystemAddressSelector
extends Object
implements IAddressSelector

Implementation of IAddressSelector for the filesystem driver.

Author:
Neil Moore, Kranthi Bathula

Field Summary
 
Fields inherited from interface edu.uky.rch.ept.data.ui.IAddressSelector
CREATE, OPEN, SAVE
 
Constructor Summary
FileSystemAddressSelector()
           
 
Method Summary
 void addAddressListener(IAddressListener listener)
          Add an address listener to this selector.
protected  void fireListeners()
           
 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 getPath()
           
 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)
          Create a GUI control for this selector.
 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 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 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileSystemAddressSelector

public FileSystemAddressSelector()
Method Detail

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

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.

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.

makeControl

public org.eclipse.swt.widgets.Control makeControl(org.eclipse.swt.widgets.Composite parent)
Description copied from interface: IAddressSelector
Create a GUI control for this selector. The precise realization of this control is up to the implementing data source driver.

Specified by:
makeControl in interface IAddressSelector
Parameters:
parent - the parent for the control.
Returns:
the control.

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.

getPath

public String getPath()

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.

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.

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.

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)

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.

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)

fireListeners

protected void fireListeners()