RSE
Release 3.3

org.eclipse.rse.files.ui.widgets
Class SystemSelectRemoteFileOrFolderForm

java.lang.Object
  extended by org.eclipse.rse.files.ui.widgets.SystemSelectRemoteFileOrFolderForm
All Implemented Interfaces:
ISelectionChangedListener
Direct Known Subclasses:
SaveAsForm

public class SystemSelectRemoteFileOrFolderForm
extends Object
implements ISelectionChangedListener

A reusable form for prompting for a remote file system folder or file.

This form may be used to populate a dialog or a wizard page.

To configure the functionality, call these methods:

To configure the text on the dialog, call these methods:

After running, call these methods to get the output:


Field Summary
protected  ISystemAddFileListener addButtonCallback
           
protected  boolean allowFolderSelection
           
protected  boolean allowForMultipleParents
           
protected  boolean alwaysEnableOK
           
protected  int autoExpandDepth
           
protected  Object caller
           
protected  boolean callerInstanceOfSystemPromptDialog
           
protected  boolean callerInstanceOfWizardPage
           
protected  boolean contentsCreated
           
protected  boolean fileMode
           
protected  boolean filesOnlyMode
           
protected  String fileTypes
           
protected  boolean initDone
           
protected  ISystemSelectRemoteObjectAPIProvider inputProvider
           
protected  Vector listeners
           
protected  String locationPrompt
           
protected  ISystemMessageLine msgLine
           
protected  boolean multipleSelectionMode
           
protected  Text nameEntryValue
           
protected  SystemRemoteObjectMatcher objectMatcher
           
protected  Composite outerParent
           
protected  IHost outputConnection
           
protected  Object[] outputObjects
           
protected  ISystemFilter preSelectFilter
           
protected  String preSelectFilterChild
           
protected  boolean preSelectRoot
           
protected  Object previousSelection
           
protected static int PROMPT_WIDTH
           
protected  Composite ps_composite
           
protected  IValidatorRemoteSelection selectionValidator
           
protected  boolean showLocationPrompt
           
protected  boolean showPropertySheet
           
protected  boolean showRootFilter
           
protected  Label spacer1
           
protected  Label spacer2
           
protected  ISystemRegistry sr
           
protected  String treeTip
           
protected  boolean valid
           
protected  String verbiage
           
protected  Label verbiageLabel
           
protected  List viewerFilters
           
 
Constructor Summary
SystemSelectRemoteFileOrFolderForm(ISystemMessageLine msgLine, Object caller, boolean fileMode)
          Constructor
 
Method Summary
 void addSelectionChangedListener(ISelectionChangedListener l)
          Add a listener to selection change events in the tree
 void addViewerFilter(ViewerFilter filter)
          Add viewer filter.
protected  void clearErrorMessage()
           
 Control createContents(Shell shell, Composite parent)
          In this method, we populate the given SWT container with widgets and return the container to the caller.
 void dispose()
           
 void enableAddMode(ISystemAddFileListener caller)
          Enable Add mode.
protected  Object getFirstSelection(ISelection selection)
          Return first item currently selected.
 Control getInitialFocusControl()
          Return control to recieve initial focus
protected  ISystemSelectRemoteObjectAPIProvider getInputProvider()
          Returns the input provider that drives the contents of the tree Subclasses can override to provide custom tree contents
 boolean getMultipleSelectionMode()
          Return the multiple selection mode current setting
protected  ISystemRemoteElementAdapter[] getRemoteAdapters(ISelection selection)
           
 IHost getSelectedConnection()
          Return selected connection
 Object getSelectedObject()
          Return first selected object
 Object[] getSelectedObjects()
          Return all selected objects.
 Object getSelectedParent()
           
protected  Object[] getSelections(ISelection selection)
          Return all items currently selected.
protected  Shell getShell()
          Return shell of parent dialog or wizard
 ISystemTree getSystemTree()
          Returns the system tree
protected  IHost internalGetConnection()
          Return the current connection
 boolean isPageComplete()
          This method can be called by the dialog or wizard page host, to decide whether to enable or disable the next, final or ok buttons.
 void removeSelectionChangedListener(ISelectionChangedListener l)
          Remove a listener for selection change events
 void selectionChanged(SelectionChangedEvent e)
          User selected something in the tree.
 void setAllowFolderSelection(boolean allow)
          Sets whether to allow folder selection.
 void setAllowForMultipleParents(boolean flag)
          Indicate whether the form should allow selection of objects from different parents
 void setAutoExpandDepth(int depth)
          Specify the zero-based auto-expand level for the tree.
 void setDefaultConnection(IHost conn)
          Set the connection to default the selection to
protected  void setErrorMessage(String msg)
           
protected  void setErrorMessage(SystemMessage msg)
           
 void setFileTypes(String fileTypes)
          For files mode, restrict the files list by a comman-delimited array of file types.
 void setFileTypes(String[] fileTypes)
          For files mode, restrict the files list by an array of file types This must be called BEFORE setRootFolder!
 void setLocationPrompt(String prompt)
           
 void setMessage(String message)
          Set the message shown as the text at the top of the form.
 void setMessageLine(ISystemMessageLine msgLine)
          Often the message line is null at the time of instantiation, so we have to call this after it is created.
 void setMultipleSelectionMode(boolean multiple)
          Set multiple selection mode.
protected  void setNameText(String text)
           
 void setPageComplete()
          Inform caller of page-complete status of this form
 void setPreSelection(IRemoteFile selection)
          Set a file or folder to preselect.
 void setRestrictFolders(boolean restrict)
          Specify whether setRootFolder should prevent the user from being able to see or select any other folder.
 void setRootFolder(IHost connection, String folderAbsolutePath)
          Set the root folder from which to start listing folders or files.
 void setRootFolder(IRemoteFile rootFolder)
          Set the root folder from which to start listing folders.
 void setSelectionTreeToolTipText(String tip)
          Set the tooltip text for the remote systems tree from which an item is selected.
 void setSelectionValidator(IValidatorRemoteSelection selectionValidator)
          Specify a validator to use when the user selects a remote file or folder.
 void setShowLocationPrompt(boolean show)
           
 void setShowNewConnectionPrompt(boolean show)
          Set to true if a "New Connection..." special connection is to be shown for creating new connections
 void setShowPropertySheet(boolean show)
          Show the property sheet on the right hand side, to show the properties of the selected object.
 void setSystemConnection(IHost conn)
          Set the connection to restrict the user to seeing
 void setSystemTypes(IRSESystemType[] systemTypes)
          Set the system types to restrict what connections the user sees, and what types of connections they can create.
 boolean toggleShowPropertySheet(Shell shell, Control contents)
          Show or hide the property sheet.
 boolean verify()
          Completes processing of the wizard page or dialog.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PROMPT_WIDTH

protected static final int PROMPT_WIDTH
See Also:
Constant Field Values

verbiageLabel

protected Label verbiageLabel

spacer1

protected Label spacer1

spacer2

protected Label spacer2

nameEntryValue

protected Text nameEntryValue

msgLine

protected ISystemMessageLine msgLine

outerParent

protected Composite outerParent

ps_composite

protected Composite ps_composite

sr

protected ISystemRegistry sr

verbiage

protected String verbiage

treeTip

protected String treeTip

locationPrompt

protected String locationPrompt

fileTypes

protected String fileTypes

fileMode

protected boolean fileMode

valid

protected boolean valid

filesOnlyMode

protected boolean filesOnlyMode

showRootFilter

protected boolean showRootFilter

alwaysEnableOK

protected boolean alwaysEnableOK

multipleSelectionMode

protected boolean multipleSelectionMode

allowForMultipleParents

protected boolean allowForMultipleParents

showPropertySheet

protected boolean showPropertySheet

showLocationPrompt

protected boolean showLocationPrompt

allowFolderSelection

protected boolean allowFolderSelection

objectMatcher

protected SystemRemoteObjectMatcher objectMatcher

addButtonCallback

protected ISystemAddFileListener addButtonCallback

listeners

protected Vector listeners

selectionValidator

protected IValidatorRemoteSelection selectionValidator

outputObjects

protected Object[] outputObjects

outputConnection

protected IHost outputConnection

inputProvider

protected ISystemSelectRemoteObjectAPIProvider inputProvider

preSelectFilter

protected ISystemFilter preSelectFilter

preSelectFilterChild

protected String preSelectFilterChild

preSelectRoot

protected boolean preSelectRoot

initDone

protected boolean initDone

contentsCreated

protected boolean contentsCreated

caller

protected Object caller

callerInstanceOfWizardPage

protected boolean callerInstanceOfWizardPage

callerInstanceOfSystemPromptDialog

protected boolean callerInstanceOfSystemPromptDialog

autoExpandDepth

protected int autoExpandDepth

previousSelection

protected Object previousSelection

viewerFilters

protected List viewerFilters
Constructor Detail

SystemSelectRemoteFileOrFolderForm

public SystemSelectRemoteFileOrFolderForm(ISystemMessageLine msgLine,
                                          Object caller,
                                          boolean fileMode)
Constructor

Parameters:
msgLine - A GUI widget capable of writing error messages to.
caller - The wizardpage or dialog hosting this form.
fileMode - true if in select-file mode, false if in select-folder mode
See Also:
setSystemConnection(IHost), setShowNewConnectionPrompt(boolean), setSystemTypes(IRSESystemType[]), setSelectionTreeToolTipText(String)
Method Detail

getInputProvider

protected ISystemSelectRemoteObjectAPIProvider getInputProvider()
Returns the input provider that drives the contents of the tree Subclasses can override to provide custom tree contents

Since:
3.0 replaced SystemSelectRemoteObjectAPIProvider by ISystemSelectRemoteObjectAPIProvider

setAllowForMultipleParents

public void setAllowForMultipleParents(boolean flag)
Indicate whether the form should allow selection of objects from different parents


setSystemConnection

public void setSystemConnection(IHost conn)
Set the connection to restrict the user to seeing


setDefaultConnection

public void setDefaultConnection(IHost conn)
Set the connection to default the selection to


setShowNewConnectionPrompt

public void setShowNewConnectionPrompt(boolean show)
Set to true if a "New Connection..." special connection is to be shown for creating new connections


setSystemTypes

public void setSystemTypes(IRSESystemType[] systemTypes)
Set the system types to restrict what connections the user sees, and what types of connections they can create.

Parameters:
systemTypes - An array of system types, or null to allow all registered valid system types. A system type is valid if at least one subsystem configuration is registered against it.

setMessage

public void setMessage(String message)
Set the message shown as the text at the top of the form. Eg, "Select a file"


setSelectionTreeToolTipText

public void setSelectionTreeToolTipText(String tip)
Set the tooltip text for the remote systems tree from which an item is selected.


setRootFolder

public void setRootFolder(IHost connection,
                          String folderAbsolutePath)
Set the root folder from which to start listing folders or files. This version identifies the folder via a connection object and absolute path. There is another overload that identifies the folder via a single IRemoteFile object.

Parameters:
connection - The connection to the remote system containing the root folder
folderAbsolutePath - The fully qualified folder to start listing from (eg: "\folder1\folder2")
See Also:
RemoteFileFilterString

setRootFolder

public void setRootFolder(IRemoteFile rootFolder)
Set the root folder from which to start listing folders. This version identifies the folder via an IRemoteFile object. There is another overload that identifies the folder via a connection and folder path.

Parameters:
rootFolder - The IRemoteFile object representing the remote folder to start the list from
See Also:
RemoteFileFilterString

setPreSelection

public void setPreSelection(IRemoteFile selection)
Set a file or folder to preselect. This will: If there is no parent, then we were given a root. In which case we will


setFileTypes

public void setFileTypes(String[] fileTypes)
For files mode, restrict the files list by an array of file types

This must be called BEFORE setRootFolder!


setFileTypes

public void setFileTypes(String fileTypes)
For files mode, restrict the files list by a comman-delimited array of file types. The last type must also end in a comma. Eg "java, class," or "class,".

This must be called BEFORE setRootFolder!


setAutoExpandDepth

public void setAutoExpandDepth(int depth)
Specify the zero-based auto-expand level for the tree. The default is zero, meaning only show the connections.


setRestrictFolders

public void setRestrictFolders(boolean restrict)
Specify whether setRootFolder should prevent the user from being able to see or select any other folder. This causes two effects:
  1. The special filter for root/drives is not shown
  2. No subfolders are listed in the target folder, if we are listing files. Of course, they are shown if we are listing folders, else it would be an empty list!


enableAddMode

public void enableAddMode(ISystemAddFileListener caller)
Enable Add mode. This means the OK button is replaced with an Add button, and the Cancel with a Close button. When Add is pressed, the caller is called back. The dialog is not exited until Close is pressed.

When a library is selected, the caller is called back to decide to enable the Add button or not.


setShowPropertySheet

public void setShowPropertySheet(boolean show)
Show the property sheet on the right hand side, to show the properties of the selected object.

Default is false


setMultipleSelectionMode

public void setMultipleSelectionMode(boolean multiple)
Set multiple selection mode. Default is single selection mode

If you turn on multiple selection mode, you must use the getSelectedObjects() method to retrieve the list of selected objects.

Further, if you turn this on, it has the side effect of allowing the user to select any remote object. The assumption being if you are prompting for files, you also want to allow the user to select a folder, with the meaning being that all files within the folder are implicitly selected.

See Also:
getSelectedObjects()

addSelectionChangedListener

public void addSelectionChangedListener(ISelectionChangedListener l)
Add a listener to selection change events in the tree


removeSelectionChangedListener

public void removeSelectionChangedListener(ISelectionChangedListener l)
Remove a listener for selection change events


setSelectionValidator

public void setSelectionValidator(IValidatorRemoteSelection selectionValidator)
Specify a validator to use when the user selects a remote file or folder. This allows you to decide if OK should be enabled or not for that remote file or folder.


getSelectedObject

public Object getSelectedObject()
Return first selected object


getSelectedObjects

public Object[] getSelectedObjects()
Return all selected objects.

See Also:
setMultipleSelectionMode(boolean)

getSelectedConnection

public IHost getSelectedConnection()
Return selected connection


getMultipleSelectionMode

public boolean getMultipleSelectionMode()
Return the multiple selection mode current setting


setMessageLine

public void setMessageLine(ISystemMessageLine msgLine)
Often the message line is null at the time of instantiation, so we have to call this after it is created.


getInitialFocusControl

public Control getInitialFocusControl()
Return control to recieve initial focus


toggleShowPropertySheet

public boolean toggleShowPropertySheet(Shell shell,
                                       Control contents)
Show or hide the property sheet. This is called after the contents are created when the user toggles the Details button.

Parameters:
shell - Use getShell() in your dialog or wizard page
contents - Use getContents() in your dialog or wizard page
Returns:
new state -> true if showing, false if hiding

dispose

public void dispose()

createContents

public Control createContents(Shell shell,
                              Composite parent)
In this method, we populate the given SWT container with widgets and return the container to the caller.

Parameters:
parent - The parent composite

verify

public boolean verify()
Completes processing of the wizard page or dialog. If this method returns true, the wizard/dialog will close; otherwise, it will stay active.

Returns:
true if no errors

internalGetConnection

protected IHost internalGetConnection()
Return the current connection


setNameText

protected void setNameText(String text)

selectionChanged

public void selectionChanged(SelectionChangedEvent e)
User selected something in the tree.

Specified by:
selectionChanged in interface ISelectionChangedListener

getRemoteAdapters

protected ISystemRemoteElementAdapter[] getRemoteAdapters(ISelection selection)

getFirstSelection

protected Object getFirstSelection(ISelection selection)
Return first item currently selected.


getSelections

protected Object[] getSelections(ISelection selection)
Return all items currently selected.


isPageComplete

public boolean isPageComplete()
This method can be called by the dialog or wizard page host, to decide whether to enable or disable the next, final or ok buttons. It returns true if the minimal information is available and is correct.


setPageComplete

public void setPageComplete()
Inform caller of page-complete status of this form


clearErrorMessage

protected void clearErrorMessage()

setErrorMessage

protected void setErrorMessage(String msg)

setErrorMessage

protected void setErrorMessage(SystemMessage msg)

getShell

protected Shell getShell()
Return shell of parent dialog or wizard


setShowLocationPrompt

public void setShowLocationPrompt(boolean show)

setLocationPrompt

public void setLocationPrompt(String prompt)

addViewerFilter

public void addViewerFilter(ViewerFilter filter)
Add viewer filter.

Parameters:
filter - a viewer filter.

setAllowFolderSelection

public void setAllowFolderSelection(boolean allow)
Sets whether to allow folder selection. The default selection validator will use this to determine whether the OK button will be enabled when a folder is selected. The default is true. This call only makes sense if the form is in file selection mode.

Parameters:
allow - true to allow folder selection, false otherwise.

getSystemTree

public ISystemTree getSystemTree()
Returns the system tree

Returns:
the system tree
Since:
3.0 replacing the previous getSystemViewForm method

getSelectedParent

public Object getSelectedParent()
Since:
3.0

RSE
Release 3.3

Copyright (c) IBM Corporation and others 2000, 2011. All Rights Reserved.