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(); }
new FvFileChooser()static public onFileChooserEVENT:EventTypestatic public APPROUVE_OPTION:Numberstatic public CANCEL_OPTION:Numberstatic public ERROR_OPTION:Numberstatic public BASE_PATH:Stringstatic public function getChooser():FvFileChooserReturns singleton instance of FvFileChooser class.
public function addListener(listener:FvFileChooserListener):Void
Adds passed-in listener listener for receiving all events.
public function removeListener(listener:FvFileChooserListener):Void
Removes passed-in listener listener for receiving all events.
listener | Listener object. |
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) );
type | Name of the Event. |
listener | Listener object. |
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);
type | Name of the Event. |
listener | Listener object. |
public function connect(accessor:IAccessor):VoidConnects 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();
accessor | IAccessor instance ( take a look at Pixlib bourre.core package ) |
public function setFileSelectionHandler(scope, callback:Function):VoidHandler is call when user click on approuve button.
public function releaseFileSelectionHandler():VoidReleases file selection handler.
public function showOpenDialog():VoidShow 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
public function showSaveDialog():VoidShow 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
public function showFolderBrowser():VoidShow 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
public function showDialog(buttonCaption:String):VoidShow 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
buttonCaption | Caption of the 'ok' button |
public function setMultiSelectionEnabled(enabled:Boolean):VoidSets whether multiple files can be selected at once.
By default, a user can choose only one file.
public function isMultiSelectionEnabled():BooleanReturns whether multiple files can be selected at once.
public function setUploadEnabled(enabled:Boolean):Void
Sets whether upload feature is enabled true or not
false
Default is false
public function isUploadEnabled():Boolean
Returns true if upload feature is enabled in current
FvFileChooser component.
public function setPreviewEnabled(enabled:Boolean):Void
Sets whether preview feature is enabled true or not
false
Default is false
public function isPreviewEnabled():Boolean
Returns true if preview feature is enabled in current
FvFileChooser component.
public function addPreviewCommand(type:String, previewCommand:Command):VoidAdd new type to preview loader.
public function addPreviewType(type:String, scopeMethod, parsingMethod:Function):VoidAdd new type to preview loader.
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.
public function isAcceptAllFileFilterUsed():BooleanReturns whether the' AcceptAll' file filter is used as an allowable choice in the choosable filter list.
public function setFileFilter(filter:FileFilter):VoidSets the file chooser's primary file filter.
public function getFileFilter():FileFilterReturns the file chooser's primary file filter.
public function getChoosableFileFilters():IndexedArrayReturns file chooser filter list.
public function addChoosableFileFilter(filter:FileFilter):VoidAdds a new custom file filter.
public function removeChoosableFileFilter(filter:FileFilter):BooleanRemoves passed-in FileFilter from file chooser filter list.
true is filter is removed, otherwise false
public function resetChoosableFileFilters():VoidResets file chooser filter list to primary filter list.
public function getAcceptAllFileFilter():FileFilterReturns the default 'AcceptAll' filter instance.
public function fireResult(type:Number, files:Array, path:String):VoidBroadcasts an ON_FILE_CHOOSER_RESULT event type.
type | Possible values are |
files | Array structure with all selected files |
path | Base path of selected files |