//////////////////////////////////////////////////////////////////////////////// // // Licensed to the Apache Software Foundation (ASF) under one or more // contributor license agreements. See the NOTICE file distributed with // this work for additional information regarding copyright ownership. // The ASF licenses this file to You under the Apache License, Version 2.0 // (the "License"); you may not use this file except in compliance with // the License. You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // //////////////////////////////////////////////////////////////////////////////// package mx.controls { import flash.events.KeyboardEvent; import flash.filesystem.File; import mx.controls.fileSystemClasses.FileSystemControlHelper; import mx.controls.List; import mx.core.mx_internal; import mx.core.ScrollPolicy; import mx.events.ListEvent; import mx.styles.CSSStyleDeclaration; import mx.styles.StyleManager; use namespace mx_internal; //-------------------------------------- // Events //-------------------------------------- /** * Dispatched when the directory displayed by this control * has changed for any reason. * * @eventType mx.events.FileEvent.DIRECTORY_CHANGE * * @langversion 3.0 * @playerversion AIR 1.1 * @productversion Flex 3 */ [Event(name="directoryChange", type="mx.events.FileEvent")] /** * Dispatched when the user tries to change * the directory displayed by this control. * *
The user can try to change the directory * by double-clicking a subdirectory, * by pressing Enter or Ctrl-Down when a subdirectory is selected, * by pressing Ctrl-Up when the control isn't displaying * the COMPUTER directory, * by pressing Ctrl-Left when there is a previous directory * in the history list to navigate back to, * or by pressing Ctrl-Right when there is a next directory * in the history list to navigate forward to.
* *This event is cancelable.
* If you call event.preventDefault()
,
* the directory is not changed.
After the directory
property has changed
* and the dataProvider
contains File instances
* for the items in the new directory,
* the directoryChange
event is dispatched.
directoryIcon="@Embed(source='directoryIcon.jpg');"
*
* @default TreeNodeIcon
*
* @langversion 3.0
* @playerversion AIR 1.1
* @productversion Flex 3
*/
[Style(name="directoryIcon", type="Class", format="EmbeddedFile", inherit="no")]
/**
* Specifies the icon that indicates a file.
* The default icon is located in the Assets.swf file.
* In MXML, you can use the following syntax to set this property:
* fileIcon="@Embed(source='fileIcon.jpg');"
*
* @default TreeNodeIcon
*
* @langversion 3.0
* @playerversion AIR 1.1
* @productversion Flex 3
*/
[Style(name="fileIcon", type="Class", format="EmbeddedFile", inherit="no")]
//--------------------------------------
// Other metadata
//--------------------------------------
[IconFile("FileSystemList.png")]
[ResourceBundle("aircontrols")]
/**
* The FileSystemList control lets you display the contents of a
* single file system directory, in a list format.
*
* To change the displayed data, rather than using the dataProvider
property,
* you set the directory
property.
* The control then automatically populates the dataProvider
* property by enumerating the contents of that directory.
* You should not set the dataProvider
yourself.
You set the directory
property to a File instance,
* as the following example shows:
* <mx:FileSystemList directory="{File.desktopDirectory}"/>* *
You can set the enumerationMode
property to specify
* whether to show files, subdirectories, or both.
* There are three ways to show both: directories first,
* files first, or intermixed.
You can set the extensions
property
* to filter the displayed items so that only files
* with the specified extensions appear.
* The showHidden
determines whether the control
* displays files and subdirectories that the operating system
* normally hides.
* You can specify an additional filterFunction
* to perform custom filtering, and a nameCompareFunction
* to perform custom sorting.
Because AIR does not support file system notifications,
* this control does not automatically refresh if a file or
* subdirectory is created, deleted, moved, or renamed;
* in other words, it can display an out-of-date view of the file system.
* However, you can call refresh()
to re-enumerate
* the current directory
.
* You could, for example, choose to do this when you have
* performed a file operation that you know causes the control's
* view to become out-of-date, or when the user deactivates
* and reactivates your application.
You can use the showIcons
property
* to show or hide icons, and the showExtensions
* property to show or hide file extensions.
The control provides two methods, findItem()
* and findIndex()
, which you can use to search the
* displayed files and subdirectories to find the one
* with a specified nativePath
.
Two properties, selectedPath
* and selectedPaths
, work similarly
* to selectedItem
and selectedItems
* or selectedIndex
and selectedIndices
,
* but let you specify the selection via nativePath
* strings.
* These are very useful if you need to display a directory
* with particular items preselected, since in this case
* you don't yet have the File items that the control will create
* when it enumerates the directory, and you don't know what
* their indices will be.
The control allows the user to navigate to other directories
* using the mouse or keyboard.
* The user can try to change the directory
* by double-clicking a subdirectory,
* by pressing Enter or Ctrl-Down when a subdirectory is selected,
* by pressing Ctrl-Up when the control isn't displaying
* the COMPUTER directory, by pressing Ctrl-Left when there is
* a "previous" directory to navigate back to, or by pressing Ctrl-Right
* when there is a "next" directory to navigate forward to.
* If the user attempts to change the directory being displayed,
* the control dispatches a cancelable directoryChanging
event.
* If you don't cancel this event by calling
* event.preventDefault()
, the control displays the
* contents of the new directory and the directory
* property changes.
* Whenever the directory
property changes, for any reason,
* the controls dispatches a directoryChange
event
* to let you know.
In order to support "Up" and "Down" controls, the FileSystemList
* has canNavigateUp
and canNavigateDown
* properties and navigateUp()
and navigateDown()
* methods. There is also a navigateTo()
for navigating
* to an arbitrary directory.
The control keeps track of the directories to which the user
* has navigated, in order to make it easy for you to support
* "Back" and "Forward" controls.
* For more information, see the backHistory
,
* forwardHistory
, canNavigateBack
,
* and canNavigateForward
properties, and the
* navigateBack()
and navigateForward()
methods.
Note: The icons displayed for each item are generic file and directory
* icons which you can set using the fileIcon
* and directoryIcon
styles.
* Flex's list-based controls currently support displaying
* only embedded icons, not icons read at runtime.
* Therefore the actual file system icons displayed in the operating system
* are not displayed in a FileSystemList, even though they are
* accessible in AIR via the icon
property of a File.
The <mx:FileSystemList>
tag inherits all of the tag
* attributes of its superclass and adds the following tag attributes:
* <mx:FileSystemList * Properties * directory="null" * enumerationMode="directoriesFirst" * extensions="null" * filterFunction="null" * nameCompareFunction="null" * selectedPath="null" * selectedPaths="null" * showExtensions="true" * showHidden="false" * showIcons="true" * * Styles * directoryIcon="TreeNodeIcon" * fileIcon="TreeNodeIcon" * * Events * directoryChange="No default" * directoryChanging="No default" * fileChoose="No default" * /> ** * @see flash.filesystem.File * * * @langversion 3.0 * @playerversion AIR 1.1 * @productversion Flex 3 */ public class FileSystemList extends List { include "../core/Version.as"; //-------------------------------------------------------------------------- // // Class constants // //-------------------------------------------------------------------------- /** * A constant that can be used as a value for the
directory
property,
* representing a pseudo-top level directory named "Computer". This pseudo-directory
* contains the root directories
* (such as C:\ and D:\ on Windows or / on Macintosh).
*
* @langversion 3.0
* @playerversion AIR 1.1
* @productversion Flex 3
*/
public static const COMPUTER:File = FileSystemControlHelper.COMPUTER;
//--------------------------------------------------------------------------
//
// Constructor
//
//--------------------------------------------------------------------------
/**
* Constructor.
*
* @langversion 3.0
* @playerversion AIR 1.1
* @productversion Flex 3
*/
public function FileSystemList()
{
super();
helper = new FileSystemControlHelper(this, false);
doubleClickEnabled = true;
horizontalScrollPolicy = ScrollPolicy.AUTO;
iconFunction = helper.fileIconFunction;
labelFunction = helper.fileLabelFunction;
showDataTips = true;
addEventListener(ListEvent.ITEM_DOUBLE_CLICK, itemDoubleClickHandler);
// Set the initial dataProvider by enumerating the root directories.
directory = COMPUTER;
}
//--------------------------------------------------------------------------
//
// Variables
//
//--------------------------------------------------------------------------
/**
* @private
* An undocumented class that implements functionality
* shared by various file system components.
*/
mx_internal var helper:FileSystemControlHelper;
//--------------------------------------------------------------------------
//
// Properties
//
//--------------------------------------------------------------------------
//----------------------------------
// backHistory
//----------------------------------
[Bindable("historyChanged")]
/**
* An Array of File objects representing directories
* to which the user can navigate backward.
*
* The first item in this Array is the next directory backward * in the history list. * The last item is the directory furthest backward * in the history list.
* *This Array may contain a null
item, which represents
* the non-existent directory whose contents are root directories
* such as C:\ and D:\ on Microsoft Windows.
The following example shows how to use this property * along with the FileSystemHistoryButton control * to implement a back button:
* ** <mx:FileSystemList id="fileSystemViewer" directory="{File.desktopDirectory}"/> * <mx:FileSystemHistoryButton label="Back" * enabled="{fileSystemViewer.canNavigateBack}" * dataProvider="{fileSystemViewer.backHistory}" * click="fileSystemViewer.navigateBack();" * itemClick="fileSystemViewer.navigateBack(event.index);"/>* * @default [] * * @see #canNavigateBack * @see #navigateBack() * @see mx.controls.FileSystemHistoryButton * * @langversion 3.0 * @playerversion AIR 1.1 * @productversion Flex 3 */ public function get backHistory():Array { return helper.backHistory; } //---------------------------------- // canNavigateBack //---------------------------------- [Bindable("historyChanged")] /** * A flag which is
true
if there is at least one directory
* in the history list to which the user can navigate backward.
*
* The following example shows how to use this property * along with the FileSystemHistoryButton control * to implement a back button:
* ** <mx:FileSystemList id="fileSystemViewer" directory="{File.desktopDirectory}"/> * <mx:FileSystemHistoryButton label="Back" * enabled="{fileSystemViewer.canNavigateBack}" * dataProvider="{fileSystemViewer.backHistory}" * click="fileSystemViewer.navigateBack();" * itemClick="fileSystemViewer.navigateBack(event.index);"/>* * @default false * * @see #backHistory * @see #navigateBack() * * @langversion 3.0 * @playerversion AIR 1.1 * @productversion Flex 3 */ public function get canNavigateBack():Boolean { return helper.canNavigateBack; } //---------------------------------- // canNavigateDown //---------------------------------- [Bindable("change")] [Bindable("directoryChanged")] /** * A flag which is
true
if the user can navigate down
* into a selected directory.
* This flag is false
when there is no selected item
* or when the selected item is a file rather than a directory.
*
* The following example shows how to use this property * along with the Button control:
* ** <mx:FileSystemList id="fileSystemViewer" directory="{File.desktopDirectory}"/> * <mx:Button label="Open" * enabled="{fileSystemViewer.canNavigateDown}" * click="fileSystemViewer.navigateDown();"/>* * @default false * * @see #navigateDown() * * @langversion 3.0 * @playerversion AIR 1.1 * @productversion Flex 3 */ public function get canNavigateDown():Boolean { return helper.canNavigateDown; } //---------------------------------- // canNavigateForward //---------------------------------- [Bindable("historyChanged")] /** * A flag which is
true
if there is at least one directory
* in the history list to which the user can navigate forward.
*
* The following example shows how to use this property * along with the FileSystemHistoryButton control * to implement a forward button:
* ** <mx:FileSystemList id="fileSystemViewer" directory="{File.desktopDirectory}"/> * <mx:FileSystemHistoryButton label="Forward" * enabled="{fileSystemViewer.canNavigateForward}" * dataProvider="{fileSystemViewer.forwardHistory}" * click="fileSystemViewer.navigateForward();" * itemClick="fileSystemViewer.navigateForward(event.index);"/>* * @default false * * @see #forwardHistory * @see #navigateForward() * * @langversion 3.0 * @playerversion AIR 1.1 * @productversion Flex 3 */ public function get canNavigateForward():Boolean { return helper.canNavigateForward; } //---------------------------------- // canNavigateUp //---------------------------------- [Bindable("directoryChanged")] /** * A flag which is
true
if the user can navigate up
* to a parent directory.
* This flag is only false
when this control is
* displaying the root directories
* such as C:\ and D:\ on Microsoft Windows.
* (This is the case in which the directory
* property is COMPUTER
.)
*
* The following example shows how to use this property * along with the Button control:
* ** <mx:FileSystemList id="fileSystemViewer" directory="{File.desktopDirectory}"/> * <mx:Button label="Up" * enabled="{fileSystemViewer.canNavigateUp}" * click="fileSystemViewer.navigateUp();"/>* * @default false * * @see #navigateUp() * * @langversion 3.0 * @playerversion AIR 1.1 * @productversion Flex 3 */ public function get canNavigateUp():Boolean { return helper.canNavigateUp; } //---------------------------------- // directory //---------------------------------- [Bindable("directoryChanged")] /** * The directory whose contents this control displays. * *
If you set this property to a File object representing
* an existing directory, the dataProvider
* immediately becomes null
.
* Later, when this control is revalidated by the LayoutManager,
* it enumerates that directory's contents
* and populates the dataProvider
property
* with an ArrayCollection of the resulting File objects
* for the directory's files and subdirectories.
Setting this to a File which does not represent
* an existing directory is an error.
* Setting this to COMPUTER
synchronously displays
* the root directories, such as C: and D: on Windows.
Setting this property deselects any previously selected items * and causes the control to reset its scroll position * to the upper-left corner.
* * @default COMPUTER * * @langversion 3.0 * @playerversion AIR 1.1 * @productversion Flex 3 */ public function get directory():File { return helper.directory; } /** * @private */ public function set directory(value:File):void { helper.directory = value; } //---------------------------------- // enumerationMode //---------------------------------- /** * A String specifying whether this control displays * only files, only subdirectories, or both. * In the case that both are displayed, * it also specifies whether the subdirectories are displayed * before, after, or mixed in with the files. * The possible values are specified * by the FileSystemEnumerationMode class. * *This property affects which subdirectories
* and files are displayed in the control,
* and the order in which they appear.
* However, it does not affect which File instances
* are in the dataProvider
property; it works
* by changing the behavior of the filter function
* that is applied to the dataProvider
.
* Setting it does not cause the current directory
* to be re-enumerated.
Setting this property deselects any selected items * and causes the control to reset its scroll position * to the upper-left corner.
* * @default FileSystemEnumerationMode.DIRECTORIES_FIRST * * @see mx.controls.FileSystemEnumerationMode * * @langversion 3.0 * @playerversion AIR 1.1 * @productversion Flex 3 */ public function get enumerationMode():String { return helper.enumerationMode; } /** * @private */ public function set enumerationMode(value:String):void { helper.enumerationMode = value; } //---------------------------------- // extensions //---------------------------------- /** * An Array of extensions specifying which files * can be displayed in this control. * If this property is set, for example, * to[ ".htm", ".html" ]
,
* then only files with these extensions can be displayed.
*
* Extensions are considered case-insensitive
* and the preceding dot is optional.
* For example, specifying ".HTML"
* is equivalent to specifying "html"
.
Directories are not subject to extension filtering, * even if they have names containing dots.
* *The enumerationMode
and filterFunction
* properties are also involved in determining which files
* appear in the control.
* For example, if this property is [ ".htm", ".html" ]
,
* an .html file is not displayed if the
* enumerationMode
property is
* FileSystemEnumerationMode.DIRECTORIES_ONLY
,
* or if the filterFunction
returns false
* for the file.
If this property is null
, no extension filtering
* occurs, and all files are displayed.
* If this property is an empty Array, all extensions are filtered out
* and no files with extensions are displayed.
This property affects which files are displayed in the control.
* However, it does not affect which File instances
* are in the dataProvider
property; it works
* by changing the behavior of the filter function
* that is applied to the dataProvider
.
* Setting it does not cause the current directory
* to be re-enumerated.
Setting this property deselects any selected items * and causes the control to reset its scroll position * to the upper-left corner.
* * @default null * * @langversion 3.0 * @playerversion AIR 1.1 * @productversion Flex 3 */ public function get extensions():Array /* of String */ { return helper.extensions; } /** * @private */ public function set extensions(value:Array /* of String */):void { helper.extensions = value; } //---------------------------------- // filterFunction //---------------------------------- /** * A callback Function that you can use to perform additional filtering, * after theenumerationMode
and extensions
* properties have been applied, to determine which files
* and subdirectories are displayed and which are hidden.
*
* This function must have the following signature:
* *function myFilterFunction(file:File):Boolean* * This function should return
true
to show the specified
* file or subdirectory and false
to hide it.
*
* To ensure that every enumerated file and subdirectory is passed
* to this function, the enumerationMode
property must
* not be FileSystemEnumerationMode.FILES_ONLY
or
* FileSystemEnumerationMode.DIRECTORIES_ONLY
,
* and the extensions
property must be null
.
* Otherwise, these properties cause pre-filtering to occur
* before this filter function is called.
This property affects which subdirectories
* and files are displayed in the control.
* However, it does not affect which File instances
* are in the dataProvider
property; it works
* by changing the behavior of the filter function
* that is applied to the dataProvider
.
* Setting it does not cause the current directory
* to be re-enumerated.
Setting this property deselects any selected items * and causes the control to reset its scroll position * to the upper-left corner.
* * @default null * * @langversion 3.0 * @playerversion AIR 1.1 * @productversion Flex 3 */ public function get filterFunction():Function { return helper.filterFunction; } /** * @private */ public function set filterFunction(value:Function):void { helper.filterFunction = value; } //---------------------------------- // forwardHistory //---------------------------------- [Bindable("historyChanged")] /** * An Array of File objects representing directories * to which the user can navigate forward. * *The first item in this Array is the next directory forward * in the history list. * The last item is the directory furthest forward * in the history list.
* *This Array may contain the special COMPUTER
File object,
* which represents the non-existent directory whose contents
* are root directories such as C:\ and D:\ on Windows.
The following example shows how to use this property * along with the FileSystemHistoryButton control * to implement a forward button:
* ** <mx:FileSystemList id="fileSystemViewer" directory="{File.desktopDirectory}"/> * <mx:FileSystemHistoryButton label="Forward" * enabled="{fileSystemViewer.canNavigateForward}" * dataProvider="{fileSystemViewer.forwardHistory}" * click="fileSystemViewer.navigateForward();" * itemClick="fileSystemViewer.navigateForward(event.index);"/>* * @default [] * * @see #canNavigateForward * @see #navigateForward() * @see mx.controls.FileSystemHistoryButton * * @langversion 3.0 * @playerversion AIR 1.1 * @productversion Flex 3 */ public function get forwardHistory():Array { return helper.forwardHistory; } //---------------------------------- // nameCompareFunction //---------------------------------- /** * A callback Function that you can use to change how file and subdirectory * names are compared in order to produce the sort order. * *
This function must have the following signature:
* *function myNameCompareFunction(name1:String, name2:String):int* *
It returns -1
if name1
should sort before
* name2
, 1
if name1
should
* sort after name2
, and 0
if the names
* are the same.
If you do not set this property, the control performs
* a case-insensitive, locale-dependent comparison of the two names,
* by first calling the String method toLocaleLowerCase()
* on each name and then comparing them with the <
* and >
operators.
If you have set enumerationMode
to either
* FileSystemEnumerationMode.FILES_FIRST
or
* FileSystemEnumerationMode.DIRECTORIES_FIRST
,
* then this method is used to compare names only within
* the separate groups of files and directories.
This property affects the order in which
* subdirectories and files are displayed in the control.
* However, it does not affect which File instances
* are in the dataProvider
property; it works
* by changing the behavior of the sort
* that is applied to the dataProvider
.
* Setting it does not cause the current directory
* to be re-enumerated.
Setting this property deselects any selected items * and causes the control to reset its scroll position * to the upper-left corner.
* * @default null * * @langversion 3.0 * @playerversion AIR 1.1 * @productversion Flex 3 */ public function get nameCompareFunction():Function { return helper.nameCompareFunction; } /** * @private */ public function set nameCompareFunction(value:Function):void { helper.nameCompareFunction = value; } //---------------------------------- // selectedPath //---------------------------------- [Bindable("change")] [Bindable("directoryChanged")] /** * ThenativePath
of the File item
* representing the selected subdirectory or file,
* or null
if no item is selected.
*
* If multiple items are selected, getting this property
* gives the first path in the selectedPaths
array.
Setting this property affects the selectedPaths
,
* selectedItem
, selectedItems
,
* selectedIndex
, and selectedIndices
* properties.
nativePath
Strings for the File items
* representing the selected subdirectories and files.
* This Array is empty if no items are selected.
*
* Setting this property affects the selectedPaths
,
* selectedItem
, selectedItems
,
* selectedIndex
, and selectedIndices
* properties.
true
to show file extensions
* and to false
to hide them.
* Extensions in directory names are always shown.
*
* Setting this property does not affect which items * are displayed, or the order in which they appear. * It also does not affect which items are selected, * or the scroll position.
* * @default true * * @langversion 3.0 * @playerversion AIR 1.1 * @productversion Flex 3 */ public function get showExtensions():Boolean { return helper.showExtensions; } /** * @private */ public function set showExtensions(value:Boolean):void { helper.showExtensions = value; } //---------------------------------- // showHidden //---------------------------------- /** * A flag that specifies whether files and directories * that the operating system considers hidden are displayed. * Set this property totrue
to show hidden files
* and directories and to false
to hide them.
*
* Setting this property deselects any selected items * and causes the control to reset its scroll position * to the upper-left corner.
* * @default false * * @langversion 3.0 * @playerversion AIR 1.1 * @productversion Flex 3 */ public function get showHidden():Boolean { return helper.showHidden; } /** * @private */ public function set showHidden(value:Boolean):void { helper.showHidden = value; } //---------------------------------- // showIcons //---------------------------------- /** * A flag that specifies that icons are displayed * before the file name. * Set this property totrue
to show icons
* and to false
to hide them.
*
* You can set the directoryIcon
* and fileIcon
styles to change the default icons.
* This control cannot display the actual icon that the operating system
* displays for a file, because AIR does not support that feature.
Setting this property does not affect which items * are displayed, or the order in which they appear. * It also does not affect which items are selected, * or the scroll position.
* * @default true * * @langversion 3.0 * @playerversion AIR 1.1 * @productversion Flex 3 */ public function get showIcons():Boolean { return helper.showIcons; } /** * @private */ public function set showIcons(value:Boolean):void { helper.showIcons = value; } //-------------------------------------------------------------------------- // // Overridden methods // //-------------------------------------------------------------------------- /** * @private */ override protected function commitProperties():void { // Call this before the supermethod // because it sets the dataProvider superproperty. helper.commitProperties(); super.commitProperties(); } /** * @private */ override protected function measure():void { super.measure(); var text:String = resourceManager.getString( "aircontrols", "fileSystemList_measuredText"); measuredWidth = measureText(text).width; } /** * @private */ override public function styleChanged(styleProp:String):void { super.styleChanged(styleProp); helper.styleChanged(styleProp); } /** * @private */ override protected function itemToUID(data:Object):String { return helper.itemToUID(data); } /** * @private */ override public function itemToDataTip(data:Object):String { return helper.fileLabelFunction(File(data)); } //-------------------------------------------------------------------------- // // Methods // //-------------------------------------------------------------------------- /** * Returns the index of the File item with the specified * native file system path. * *Items which are present in the control's collection * but not displayed because of filtering are not searched.
* * @param file A String specifying thenativePath
* of a File item.
*
* @return A zero-based index, or -1
* if no File was found with the specified path.
*
* @see flash.filesystem.File#nativePath
*
* @langversion 3.0
* @playerversion AIR 1.1
* @productversion Flex 3
*/
public function findIndex(nativePath:String):int
{
return helper.findIndex(nativePath);
}
/**
* Searches the File instances currently displayed in this control
* and returns the one with the specified nativePath
property.
*
* File instances which are present in the control's collection * but not displayed because of filtering are not searched.
* * @param file A String specifying thenativePath
* of a File item.
*
* @return A File instance if one was found with the specified
* nativePath
, or null
if none was found.
*
* @langversion 3.0
* @playerversion AIR 1.1
* @productversion Flex 3
*/
public function findItem(nativePath:String):File
{
return helper.findItem(nativePath);
}
/**
* Changes this control to display the contents
* of the selected subdirectory.
*
* If a subdirectory is not selected, this method does nothing.
* *When this method returns, the directory
property
* contains the File instance for the new directory.
* The dataProvider
property is temporarily
* null
until the new directory has been enumerated.
* After the enumeration, the dataProvider
property
* contains an ArrayCollection of File instances
* for the new directory's contents.
The following example shows how to use this method * along with the Button control to create an open button:
* ** <mx:FileSystemList id="fileSystemViewer" directory="{File.desktopDirectory}"/> * <mx:Button label="Open" * enabled="{fileSystemViewer.canNavigateDown}" * click="fileSystemViewer.navigateDown();"/>* * @see #canNavigateDown * * @langversion 3.0 * @playerversion AIR 1.1 * @productversion Flex 3 */ public function navigateDown():void { helper.navigateDown(); } /** * Changes this control to display the contents of the next directory * up in the hierarchy. * *
If this control is currently displaying root directories * (such as C: and D: on Microsoft Windows), this method does nothing.
* *When this method returns, the directory
property
* contains the File instance for the new directory.
* The dataProvider
property is temporarily
* null
until the new directory has been enumerated.
* After the enumeration, the dataProvider
property
* contains an ArrayCollection of File instances
* for the new directory's contents.
The following example shows how to use this method * along with the Button control to create an up button:
* ** <mx:FileSystemList id="fileSystemViewer" directory="{File.desktopDirectory}"/> * <mx:Button label="Up" * enabled="{fileSystemViewer.canNavigateUp}" * click="fileSystemViewer.navigateUp();"/>* * @see #canNavigateUp * * @langversion 3.0 * @playerversion AIR 1.1 * @productversion Flex 3 */ public function navigateUp():void { helper.navigateUp(); } /** * Changes this control to display the contents of a previously-visited * directory in the
backHistory
array.
*
* If the backHistory
array is empty, or if you specify
* an index that is not in that array, then this method does nothing.
When this method returns, the directory
property
* contains the File instance for the new directory.
* The dataProvider
property is temporarily
* null
until the new directory has been enumerated.
* After the enumeration, the dataProvider
property
* contains an ArrayCollection of File instances
* for the new directory's contents.
The history list is left unchanged. However, the current index
* into it changes, which affects the backHistory
* and forwardHistory
properties.
* They have new values as soon as this method returns.
The following example shows how to use this method * along with the FileSystemHistoryButton control to create a back button:
* ** <mx:FileSystemList id="fileSystemViewer" directory="{File.desktopDirectory}"/> * <mx:FileSystemHistoryButton label="Back" * enabled="{fileSystemViewer.canNavigateBack}" * dataProvider="{fileSystemViewer.backHistory}" * click="fileSystemViewer.navigateBack();" * itemClick="fileSystemViewer.navigateBack(event.index);"/>* * @param index The index in the
backHistory
array
* to navigate to.
* The default is 0, indicating the directory that is "closest back".
*
* @see #backHistory
* @see #canNavigateBack
*
* @langversion 3.0
* @playerversion AIR 1.1
* @productversion Flex 3
*/
public function navigateBack(index:int = 0):void
{
helper.navigateBack(index);
}
/**
* Changes this control to display the contents of a previously-visited
* directory in the forwardHistory
array.
*
* If the forwardHistory
array is empty, or if you specify
* an index that is not in that array, then this method does nothing.
When this method returns, the directory
property
* contains the File instance for the new directory.
* The dataProvider
property is temporarily
* null
until the new directory has been enumerated.
* After the enumeration, the dataProvider
property
* contains an ArrayCollection of File instances
* for the new directory's contents.
The history list is left unchanged. However, the current index
* into it changes, which affects the backHistory
* and forwardHistory
properties.
* They have new values as soon as this method returns.
The following example shows how to use this method * along with the FileSystemHistoryButton control to create a forward button:
* ** <mx:FileSystemList id="fileSystemViewer" directory="{File.desktopDirectory}"/> * <mx:FileSystemHistoryButton label="Forward" * enabled="{fileSystemViewer.canNavigateForward}" * dataProvider="{fileSystemViewer.forwardHistory}" * click="fileSystemViewer.navigateForward();" * itemClick="fileSystemViewer.navigateForward(event.index);"/>* * @param index The index in the
forwardHistory
array
* to navigate to.
* The default is 0, indicating the directory that is "closest forward".
*
* @see #canNavigateForward
* @see #forwardHistory
*
* @langversion 3.0
* @playerversion AIR 1.1
* @productversion Flex 3
*/
public function navigateForward(index:int = 0):void
{
helper.navigateForward(index);
}
/**
* Changes this control to display the contents of the specified
* directory.
*
* @param file A file object representing a file or directory.
*
* @langversion 3.0
* @playerversion AIR 1.1
* @productversion Flex 3
*/
public function navigateTo(directory:File):void
{
helper.navigateTo(directory);
}
/**
* Re-enumerates the current directory being displayed by this control.
*
* Because AIR does not support file system notifications,
* this control does not automatically refresh if a file or
* subdirectory is created, deleted, moved, or renamed;
* in other words, it can display an out-of-date view of the file system.
* However, you can call refresh()
to re-enumerate
* the current directory
so that it is up-to-date.
* You could, for example, choose to do this when you have
* performed a file operation that you know causes the control's
* view to become stale, or when the user deactivates
* and reactivates your application.
This method preserves any selected items (if they still exist) * and the scroll position (if the first visible item still exists).
* * @langversion 3.0 * @playerversion AIR 1.1 * @productversion Flex 3 */ public function refresh():void { helper.refresh(); } /** * Clears this control so that it displays no items. * *This method sets the dataProvider
to null
* but leaves the directory
property unchanged.
* You can call refresh
to populate this control again.