com.sas.swing.models.remotefileselector
Class RemoteFileServerModel

com.sas.swing.models.remotefileselector.RemoteFileServerModel
All Implemented Interfaces:
RemoteFileServerModelInterface, java.beans.PropertyChangeListener, java.io.Serializable, java.util.EventListener, javax.swing.table.TableModel

public class RemoteFileServerModel
implements RemoteFileServerModelInterface, java.beans.PropertyChangeListener

RemoteFileServerModel defines the model that communicates between the service model and the user interface.

See Also:
RemoteFileComponentPanel,
, Serialized Form

Field Summary
static java.lang.String RB_KEY
          the resource location
 
Constructor Summary
RemoteFileServerModel(java.lang.String path, RemoteFileServiceModelInterface serviceModel)
          Constructs a RemoteFileServerModel with user supplied path, service model and directory/folder mode.
RemoteFileServerModel(java.lang.String path, RemoteFileServiceModelInterface serviceModel, boolean showDirectoriesOnly)
          Constructs a RemoteFileServerModel with user supplied path, service model and directory/folder mode.
RemoteFileServerModel(java.lang.String path, RemoteFileServiceModelInterface serviceModel, boolean showDirectoriesOnly, com.sas.util.transforms.TransformInterface[] transforms, java.lang.String[] columnNames)
          Constructs a RemoteFileServerModel with user supplied path, service model and directory/folder mode.
RemoteFileServerModel(java.lang.String path, RemoteFileServiceModelInterface serviceModel, com.sas.util.transforms.TransformInterface[] transforms, java.lang.String[] columnNames)
          Constructs a RemoteFileServerModel with user supplied path, service model and directory/folder mode.
 
Method Summary
 void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
          Adds the model as a PropertyChangeListener.
 void addToPasteBuffer(RemoteFileMetadataInterface node)
          Add the given metadata node to the paste buffer.
 void clearPasteBuffer()
          Clears the buffer of all metadata items.
 java.lang.String combineDirectoryPathAndFileName(java.lang.String path, java.lang.String name)
          Returns a concatenated file system path given an existing path and a folder/directory name.
 java.lang.String createPathFromArray(java.lang.Object[] namesArray)
          Given an array of folder names, this method returns a file system path.
 java.lang.String getBasePath()
          Returns the file system path used as the base for all navigation.
 CacheModel getCacheModel()
          Returns the cache model.
 int getColumnCount()
          Returns the number of columns in the model.
 java.lang.String getColumnName(int columnIndex)
          Returns the name of the column at columnIndex.
 java.lang.String[] getColumnNames()
          Returns the column names.
 RemoteFileServiceModelInterface getModel()
          Returns the model used to communicate with the file system.
 RemoteFileMetadataInterface getNodeAt(int rowIndex)
          Returns a RemoteFileMetadataInterface for specified index.
 java.util.List getPasteBuffer()
          Returns the contents of the paste buffer.
 int getPasteBufferCommandType()
          Returns the command type.
 java.lang.String getPath()
          Returns the file system path currently being viewed.
 int getRowCount()
          Returns the number of rows in the model.
 java.lang.String getServerName()
          Returns the name of the file system top level.
 com.sas.util.transforms.TransformInterface[] getTransforms()
          Returns the transforms being used to get the metadata information.
 java.lang.Object getValueAt(int rowIndex, int columnIndex)
          Returns the value for the cell at columnIndex and rowIndex.
 boolean isCacheEnabled()
          Returns the current status of cacheing.
 boolean isCellEditable(int rowIndex, int columnIndex)
          Returns true if the cell at rowIndex and columnIndex is editable and the table is editable.
 boolean isTableEditable()
          Determine if the table is editable.
 boolean isUpwardPathRestricted()
          Returns true if the model's current path is at the topmost path of the current server, false otherwise.
 java.util.List parseIntoPathElements(java.lang.String path)
          Takes a give file system path and breaks it into the component pieces.
 void propertyChange(java.beans.PropertyChangeEvent e)
          Listens for the PropertyChangeEvent serviceModel and triggers a refresh of the model.
 void refresh()
          Refreshes the currently viewed file system path.
 void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
          Removes the model as a PropertyChangeListener.
 void setBasePath(java.lang.String basePath)
          Allows setting of a file system path used as the base for all navigation.
 void setCacheEnabled(boolean enabled)
          Sets whether to allow cacheing of the file information.
 void setColumnName(java.lang.String columnName, int columnIndex)
          Sets the name of the column at columnIndex to columnName.
 void setColumnNames(java.lang.String[] columnNames)
          Sets the column names used in by the table.
 void setModel(RemoteFileServiceModelInterface newServiceModel)
          Allows setting of the model to be used to communicate with the file system.
 void setPasteBufferCommandType(int commandType)
          Sets the paste buffer command type so it know's if we are copying or cutting the items.
 void setPath(java.lang.String path)
          Sets the file system path to be viewed.
 void setPath(java.lang.String path, boolean search)
          Sets the file system path to be viewed.
 void setTableEditable(boolean editable)
          Set the table to state defined by editable.
 void setTransform(com.sas.util.transforms.TransformInterface transform, int columnIndex)
          Sets the transform class for a columnIndex.
 void setTransforms(com.sas.util.transforms.TransformInterface[] transforms)
          Sets the transforms used to retrieve the metadata information.
 void setValueAt(java.lang.Object aValue, int rowIndex, int columnIndex)
          Sets the value in the cell at columnIndex and rowIndex to aValue.
 java.lang.String[] splitDirectoryPathAndFileName(java.lang.String path)
          Given a path, this method returns a collection containing a parent path and the child directory/folder name.
 void updateFilteredValues(java.util.List newFilterValues)
          Method is run when the file type filter is changed.
 

Field Detail

RB_KEY

public static final java.lang.String RB_KEY
the resource location

See Also:
Constant Field Values
Constructor Detail

RemoteFileServerModel

public RemoteFileServerModel(java.lang.String path,
                             RemoteFileServiceModelInterface serviceModel)
Constructs a RemoteFileServerModel with user supplied path, service model and directory/folder mode.

Parameters:
path - the starting file system path
serviceModel - the service model
See Also:
RemoteFileServiceModelInterface

RemoteFileServerModel

public RemoteFileServerModel(java.lang.String path,
                             RemoteFileServiceModelInterface serviceModel,
                             boolean showDirectoriesOnly)
Constructs a RemoteFileServerModel with user supplied path, service model and directory/folder mode.

Parameters:
path - the starting file system path
serviceModel - the service model
See Also:
RemoteFileServiceModelInterface

RemoteFileServerModel

public RemoteFileServerModel(java.lang.String path,
                             RemoteFileServiceModelInterface serviceModel,
                             com.sas.util.transforms.TransformInterface[] transforms,
                             java.lang.String[] columnNames)
Constructs a RemoteFileServerModel with user supplied path, service model and directory/folder mode.

Parameters:
path - the starting file system path
serviceModel - the service model
See Also:
RemoteFileServiceModelInterface

RemoteFileServerModel

public RemoteFileServerModel(java.lang.String path,
                             RemoteFileServiceModelInterface serviceModel,
                             boolean showDirectoriesOnly,
                             com.sas.util.transforms.TransformInterface[] transforms,
                             java.lang.String[] columnNames)
Constructs a RemoteFileServerModel with user supplied path, service model and directory/folder mode.

Parameters:
path - the starting file system path
serviceModel - the service model
showDirectoriesOnly - set to true, if only directories/folders are to be displayed
See Also:
RemoteFileServiceModelInterface
Method Detail

addPropertyChangeListener

public void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
Adds the model as a PropertyChangeListener.

Parameters:
listener -

removePropertyChangeListener

public void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
Removes the model as a PropertyChangeListener.

Parameters:
listener -

isUpwardPathRestricted

public boolean isUpwardPathRestricted()
Returns true if the model's current path is at the topmost path of the current server, false otherwise. Those consuming this model should call this method before moving upwards in the file system.

Specified by:
isUpwardPathRestricted in interface RemoteFileServerModelInterface
Returns:
returns true if the current path is the topmost path of the current server

getBasePath

public java.lang.String getBasePath()
Returns the file system path used as the base for all navigation. Returns a blank string as the default behavior because all levels of a file system are available by default.

Specified by:
getBasePath in interface RemoteFileServerModelInterface
Returns:
the base file system path
See Also:
setBasePath(String)

setBasePath

public void setBasePath(java.lang.String basePath)
Allows setting of a file system path used as the base for all navigation.

Parameters:
basePath - the base file system path, default value is blank
See Also:
getBasePath()

setPath

public void setPath(java.lang.String path)
             throws java.lang.IllegalArgumentException
Sets the file system path to be viewed.

Specified by:
setPath in interface RemoteFileServerModelInterface
Parameters:
path - the file system path
Throws:
java.lang.IllegalArgumentException
See Also:
getPath()

setPath

public void setPath(java.lang.String path,
                    boolean search)
             throws java.lang.IllegalArgumentException
Sets the file system path to be viewed.

Specified by:
setPath in interface RemoteFileServerModelInterface
Parameters:
path - the file system path
search - specifies if this is a call from the search model
Throws:
java.lang.IllegalArgumentException
See Also:
getPath()

combineDirectoryPathAndFileName

public java.lang.String combineDirectoryPathAndFileName(java.lang.String path,
                                                        java.lang.String name)
Returns a concatenated file system path given an existing path and a folder/directory name.

Specified by:
combineDirectoryPathAndFileName in interface RemoteFileServerModelInterface
Parameters:
path - the existing file system path
name - the folder/directory name
Returns:
the concatenated path
See Also:
splitDirectoryPathAndFileName(String)

splitDirectoryPathAndFileName

public java.lang.String[] splitDirectoryPathAndFileName(java.lang.String path)
Given a path, this method returns a collection containing a parent path and the child directory/folder name.

Specified by:
splitDirectoryPathAndFileName in interface RemoteFileServerModelInterface
Parameters:
path - the existing path
Returns:
the collection containing the parent path and the child directory/folder name
See Also:
combineDirectoryPathAndFileName(String, String)

getServerName

public java.lang.String getServerName()
Returns the name of the file system top level.

Specified by:
getServerName in interface RemoteFileServerModelInterface
Returns:
the name of the top level

setModel

public void setModel(RemoteFileServiceModelInterface newServiceModel)
Allows setting of the model to be used to communicate with the file system. Also know as the "Service Model".

Specified by:
setModel in interface RemoteFileServerModelInterface
Parameters:
newServiceModel - the model that communicates with the file system.
See Also:
getModel()

getModel

public RemoteFileServiceModelInterface getModel()
Returns the model used to communicate with the file system. Also know as the "Service Model".

Specified by:
getModel in interface RemoteFileServerModelInterface
Returns:
the model that communicates with the file system.
See Also:
setModel(RemoteFileServiceModelInterface)

getPath

public java.lang.String getPath()
Returns the file system path currently being viewed.

Specified by:
getPath in interface RemoteFileServerModelInterface
Returns:
the file system path
See Also:
setPath(String)

parseIntoPathElements

public java.util.List parseIntoPathElements(java.lang.String path)
Takes a give file system path and breaks it into the component pieces.

Specified by:
parseIntoPathElements in interface RemoteFileServerModelInterface
Parameters:
path - the path
Returns:
the collection of pieces

createPathFromArray

public java.lang.String createPathFromArray(java.lang.Object[] namesArray)
Given an array of folder names, this method returns a file system path.

Specified by:
createPathFromArray in interface RemoteFileServerModelInterface
Parameters:
namesArray - the array of folder names
Returns:
the file system path

updateFilteredValues

public void updateFilteredValues(java.util.List newFilterValues)
Method is run when the file type filter is changed.

Specified by:
updateFilteredValues in interface RemoteFileServerModelInterface
Parameters:
newFilterValues - the list of new filter type values

refresh

public void refresh()
Refreshes the currently viewed file system path.

Specified by:
refresh in interface RemoteFileServerModelInterface

setCacheEnabled

public void setCacheEnabled(boolean enabled)
Sets whether to allow cacheing of the file information. Cacheing helps speed performance of queries of items where the user has already visited. It is not automatically refreshed.

Specified by:
setCacheEnabled in interface RemoteFileServerModelInterface
Parameters:
enabled - the status of cacheing, by default set to true = cache results, false = don't cache
See Also:
isCacheEnabled()

isCacheEnabled

public boolean isCacheEnabled()
Returns the current status of cacheing.

Specified by:
isCacheEnabled in interface RemoteFileServerModelInterface
Returns:
the current status
See Also:
setCacheEnabled(boolean)

getCacheModel

public CacheModel getCacheModel()
Returns the cache model.

Specified by:
getCacheModel in interface RemoteFileServerModelInterface
Returns:
the cache model

propertyChange

public void propertyChange(java.beans.PropertyChangeEvent e)
Listens for the PropertyChangeEvent serviceModel and triggers a refresh of the model. This method re-initializes the cache model

Specified by:
propertyChange in interface java.beans.PropertyChangeListener
Parameters:
e - the PropertyChangeEvent

getRowCount

public int getRowCount()
Returns the number of rows in the model.

Specified by:
getRowCount in interface javax.swing.table.TableModel
Returns:
the number of rows

getColumnCount

public int getColumnCount()
Returns the number of columns in the model. This will always return two columns, one being the keys and the other being the values.

Specified by:
getColumnCount in interface javax.swing.table.TableModel
Returns:
the number of columns

getValueAt

public java.lang.Object getValueAt(int rowIndex,
                                   int columnIndex)
Returns the value for the cell at columnIndex and rowIndex.

Specified by:
getValueAt in interface javax.swing.table.TableModel
Parameters:
rowIndex - the row whose value is to be queried
columnIndex - the column whose value is to be queried

getNodeAt

public RemoteFileMetadataInterface getNodeAt(int rowIndex)
Returns a RemoteFileMetadataInterface for specified index.

Specified by:
getNodeAt in interface RemoteFileServerModelInterface
Parameters:
rowIndex - the specified table row
Returns:
the RemoteFileMetadataInterface

setValueAt

public void setValueAt(java.lang.Object aValue,
                       int rowIndex,
                       int columnIndex)
Sets the value in the cell at columnIndex and rowIndex to aValue. Only the values in the map can be changed, the keys must remain the same.

Specified by:
setValueAt in interface javax.swing.table.TableModel
Overrides:
setValueAt in class javax.swing.table.AbstractTableModel
Parameters:
aValue - the new value
rowIndex - the row whose value is to be changed
columnIndex - the column whose value is to be changed

isCellEditable

public boolean isCellEditable(int rowIndex,
                              int columnIndex)
Returns true if the cell at rowIndex and columnIndex is editable and the table is editable. Otherwise, setValueAt on the cell will not change the value of that cell. Only the values in the map are editable, the keys must remain the same.

Specified by:
isCellEditable in interface javax.swing.table.TableModel
Overrides:
isCellEditable in class javax.swing.table.AbstractTableModel
Parameters:
rowIndex - the row whose value to be queried
columnIndex - the column whose value to be queried
Returns:
true if the cell is editable

setColumnNames

public void setColumnNames(java.lang.String[] columnNames)
Sets the column names used in by the table.

Specified by:
setColumnNames in interface RemoteFileServerModelInterface
Parameters:
columnNames - the column names
See Also:
getColumnNames()

getColumnNames

public java.lang.String[] getColumnNames()
Returns the column names.

Specified by:
getColumnNames in interface RemoteFileServerModelInterface
Returns:
the column names
See Also:
setColumnNames(String[])

setColumnName

public void setColumnName(java.lang.String columnName,
                          int columnIndex)
Sets the name of the column at columnIndex to columnName. Note: this name does not need to be unique; two columns in a table can have the same name. If null is set as the column name, then the default column name will be used.

Specified by:
setColumnName in interface RemoteFileServerModelInterface
Parameters:
columnName - the new name of the column
columnIndex - the index of the column

getColumnName

public java.lang.String getColumnName(int columnIndex)
Returns the name of the column at columnIndex. This is used to initialize the table's column header name. Note: this name does not need to be unique; two columns in a table can have the same name. If null is set as the column name, then the default column name will be used.

Specified by:
getColumnName in interface javax.swing.table.TableModel
Overrides:
getColumnName in class javax.swing.table.AbstractTableModel
Parameters:
columnIndex - the index of the column
Returns:
the name of the column

setTransforms

public void setTransforms(com.sas.util.transforms.TransformInterface[] transforms)
Sets the transforms used to retrieve the metadata information.

Specified by:
setTransforms in interface RemoteFileServerModelInterface
Parameters:
transforms - the transforms
See Also:
getTransforms()

getTransforms

public com.sas.util.transforms.TransformInterface[] getTransforms()
Returns the transforms being used to get the metadata information.

Specified by:
getTransforms in interface RemoteFileServerModelInterface
Returns:
the transforms
See Also:
setTransforms(TransformInterface[])

setTransform

public void setTransform(com.sas.util.transforms.TransformInterface transform,
                         int columnIndex)
Sets the transform class for a columnIndex.

Specified by:
setTransform in interface RemoteFileServerModelInterface
Parameters:
transform - the transform class
columnIndex - the column to associate the transform

isTableEditable

public boolean isTableEditable()
Determine if the table is editable. If the table is not editable, then none of the cells will be editable. This value is false by default.

Specified by:
isTableEditable in interface RemoteFileServerModelInterface
Returns:
the editable value
See Also:
setTableEditable(boolean)

setTableEditable

public void setTableEditable(boolean editable)
Set the table to state defined by editable. Even though the table may be editable, the cell may not be editable.

Specified by:
setTableEditable in interface RemoteFileServerModelInterface
Parameters:
editable - the editable value
See Also:
isTableEditable()

addToPasteBuffer

public void addToPasteBuffer(RemoteFileMetadataInterface node)
Add the given metadata node to the paste buffer.

Specified by:
addToPasteBuffer in interface RemoteFileServerModelInterface
Parameters:
node - the node to be added.

clearPasteBuffer

public void clearPasteBuffer()
Clears the buffer of all metadata items.

Specified by:
clearPasteBuffer in interface RemoteFileServerModelInterface

getPasteBuffer

public java.util.List getPasteBuffer()
Returns the contents of the paste buffer.

Specified by:
getPasteBuffer in interface RemoteFileServerModelInterface
Returns:
a list of RemoteFileMetadataInterface nodes

setPasteBufferCommandType

public void setPasteBufferCommandType(int commandType)
Sets the paste buffer command type so it know's if we are copying or cutting the items.

Specified by:
setPasteBufferCommandType in interface RemoteFileServerModelInterface
Parameters:
commandType - the command type, copy = 0 and cut = 1
See Also:
getPasteBufferCommandType()

getPasteBufferCommandType

public int getPasteBufferCommandType()
Returns the command type.

Specified by:
getPasteBufferCommandType in interface RemoteFileServerModelInterface
Returns:
the command type
See Also:
setPasteBufferCommandType(int)



Copyright © 2009 SAS Institute Inc. All Rights Reserved.