Class fvaswing.components.FvFileChooser

Description

FvFileChooser provides a simple mechanism for the user to choose a file for save or open process.

Remoting process used Pixlib remoting implementation which can be found on : http://www.tweenpix.net/tmp/alpha_remoting.rar
Pixlib remoting still in alpha version but it's already robust.
Thanks to author Francis Bourre.

By default, the remoting service start his search from the root web folder.
If you want to constraint user to a specific folder ( as his root folder ), modify the $start_path property in the DirectoryService file.

Example

 public function run() : Void
 {
	var chooser = new FvFileChooser();
	chooser.addEventListener( FvFileChooser.ON_FILE_CHOOSER_RESULT, this, _onResult );
	
	chooser.showOpenDialog();
 }
 

Field Index

APPROUVE_OPTION, BASE_PATH, CANCEL_OPTION, ERROR_OPTION, onFileChooserEVENT

Method Index

new FvFileChooser()
addChoosableFileFilter(), addEventListener(), addListener(), addPreviewCommand(), addPreviewType(), connect(), disconnect(), fireResult(), getAcceptAllFileFilter(), getChoosableFileFilters(), getChooser(), getFileFilter(), isAcceptAllFileFilterUsed(), isMultiSelectionEnabled(), isPreviewEnabled(), isUploadEnabled(), releaseEvent(), releaseFileSelectionHandler(), removeChoosableFileFilter(), removeEventListener(), removeListener(), resetChoosableFileFilters(), setAcceptAllFileFilterUsed(), setFileFilter(), setFileSelectionHandler(), setMultiSelectionEnabled(), setPreviewEnabled(), setUploadEnabled(), showDialog(), showFolderBrowser(), showOpenDialog(), showSaveDialog(), toString()

Constructor Detail

FvFileChooser

public function FvFileChooser()

Constructor.

Field Detail

onFileChooserEVENT

static public onFileChooserEVENT:EventType
Dispatches when user close the chooser dialog.

APPROUVE_OPTION

static public APPROUVE_OPTION:Number
ID used when user select a file

CANCEL_OPTION

static public CANCEL_OPTION:Number
ID used when user cancel operation.

ERROR_OPTION

static public ERROR_OPTION:Number
ID used when error occured in chooser.

BASE_PATH

static public BASE_PATH:String
Base path to map AMFPHP start folder definition.

Method Detail

getChooser

static public function getChooser():FvFileChooser

Returns singleton instance of FvFileChooser class.

addListener

public function addListener(listener:FvFileChooserListener):Void

Adds passed-in listener listener for receiving all events.

Parameters

removeListener

public function removeListener(listener:FvFileChooserListener):Void

Removes passed-in listener listener for receiving all events.

Parameters

listenerListener object.

addEventListener

public function addEventListener(type:EventType, listener):Void

Adds passed-in listener for receiving passed-in type event.

Example

   var oEB : EventBroadcaster = new EventBroadcaster(this);
   oEB.addEventListener( myClass.onSometingEVENT, myFirstObject);
   oEB.addEventListener( myClass.onSometingElseEVENT, this, _onSomethingElse);
   oEB.addEventListener( myClass.onSometingElseEVENT, this, Delegate.create(this, _onSomething) );
 

Parameters

typeName of the Event.
listenerListener object.

removeEventListener

public function removeEventListener(type:EventType, listener):Void

Removes passed-in listener that suscribed for passed-in type event.

Example

   var oEB : EventBroadcaster = new EventBroadcaster(this);
   oEB.removeEventListener( myClass.onSometingEVENT, myFirstObject);
   oEB.removeEventListener( myClass.onSometingElseEVENT, this);
 

Parameters

typeName of the Event.
listenerListener object.

releaseEvent

public function releaseEvent():Void

Unsuscribes all listeners.

connect

public function connect(accessor:IAccessor):Void

Connects Pixlib Accessor to chooser.

When chooser is closed, result is automatically sent to accessor instance.

Example

   var input : JTextField = new JTextField( "", 15 );
   chooser.connect( AccessorFactory.getInstance( input, input.setText, input.getText ) );
   chooser.showOpenDialog();
 

Parameters

accessorIAccessor instance ( take a look at Pixlib bourre.core package )

disconnect

public function disconnect():Void

Releases accessor connection.

setFileSelectionHandler

public function setFileSelectionHandler(scope, callback:Function):Void

Handler is call when user click on approuve button.

releaseFileSelectionHandler

public function releaseFileSelectionHandler():Void

Releases file selection handler.

showOpenDialog

public function showOpenDialog():Void

Show an 'Open' modal dialog containing the file chooser.

When receive the FvFileChooserEvent you can check the fvaswing.components.filechooser.events.FvFileChooserEvent.getResult properties to know operation success.
These propertie can be

showSaveDialog

public function showSaveDialog():Void

Show a 'Save' modal dialog containing the file chooser.

When receive the FvFileChooserEvent you can check the fvaswing.components.filechooser.events.FvFileChooserEvent.getResult properties to know operation success.
These propertie can be

setMultiSelectionEnabled is reset to false

showFolderBrowser

public function showFolderBrowser():Void

Show a 'Browse folder' modal dialog containing the file chooser.

When receive the FvFileChooserEvent you can check the fvaswing.components.filechooser.events.FvFileChooserEvent.getResult properties to know operation success.
These propertie can be

setMultiSelectionEnabled is reset to false

showDialog

public function showDialog(buttonCaption:String):Void

Show a 'custom' modal dialog containing the file chooser.

When receive the FvFileChooserEvent you can check the fvaswing.components.filechooser.events.FvFileChooserEvent.getResult properties to know operation success.
These propertie can be

Parameters

buttonCaptionCaption of the 'ok' button

setMultiSelectionEnabled

public function setMultiSelectionEnabled(enabled:Boolean):Void

Sets whether multiple files can be selected at once.

By default, a user can choose only one file.

isMultiSelectionEnabled

public function isMultiSelectionEnabled():Boolean

Returns whether multiple files can be selected at once.

setUploadEnabled

public function setUploadEnabled(enabled:Boolean):Void

Sets whether upload feature is enabled true or not false

Default is false

isUploadEnabled

public function isUploadEnabled():Boolean

Returns true if upload feature is enabled in current FvFileChooser component.

setPreviewEnabled

public function setPreviewEnabled(enabled:Boolean):Void

Sets whether preview feature is enabled true or not false

Default is false

isPreviewEnabled

public function isPreviewEnabled():Boolean

Returns true if preview feature is enabled in current FvFileChooser component.

addPreviewCommand

public function addPreviewCommand(type:String, previewCommand:Command):Void

Add new type to preview loader.

addPreviewType

public function addPreviewType(type:String, scopeMethod, parsingMethod:Function):Void

Add new type to preview loader.

setAcceptAllFileFilterUsed

public function setAcceptAllFileFilterUsed(enabled:Boolean):Void

Sets whether the 'AcceptAll' file filter is used as an allowable choice in the choosable filter list; the default value is true.

isAcceptAllFileFilterUsed

public function isAcceptAllFileFilterUsed():Boolean

Returns whether the' AcceptAll' file filter is used as an allowable choice in the choosable filter list.

setFileFilter

public function setFileFilter(filter:FileFilter):Void

Sets the file chooser's primary file filter.

getFileFilter

public function getFileFilter():FileFilter

Returns the file chooser's primary file filter.

getChoosableFileFilters

public function getChoosableFileFilters():IndexedArray

Returns file chooser filter list.

addChoosableFileFilter

public function addChoosableFileFilter(filter:FileFilter):Void

Adds a new custom file filter.

removeChoosableFileFilter

public function removeChoosableFileFilter(filter:FileFilter):Boolean

Removes passed-in FileFilter from file chooser filter list.

Return

true is filter is removed, otherwise false

resetChoosableFileFilters

public function resetChoosableFileFilters():Void

Resets file chooser filter list to primary filter list.

getAcceptAllFileFilter

public function getAcceptAllFileFilter():FileFilter

Returns the default 'AcceptAll' filter instance.

fireResult

public function fireResult(type:Number, files:Array, path:String):Void

Broadcasts an ON_FILE_CHOOSER_RESULT event type.

Parameters

typePossible values are
filesArray structure with all selected files
pathBase path of selected files

toString

public function toString():String

Returns string representation.