|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
totalcross.lang.Objecttotalcross.ui.gfx.GfxSurface
totalcross.ui.Control
totalcross.ui.Container
totalcross.ui.Window
totalcross.ui.dialog.FileChooserBox
public class FileChooserBox
A class that shows all folders from a startup one to allow the user select a file or a folder. Here's a sample of how to use it:
try
{
FileChooserBox w = new FileChooserBox("Select the folder",new totalcross.lang.String[]{" This one "," Cancel "},
new FileChooserBox.Filter()
{
public boolean accept(File f) throws IOException
{
return f.isDir(); // will only list folders. you may filter by other file types too
}
});
w.mountTree(Settings.appPath,1);
w.popup();
return w.getPressedButtonIndex() == 0 ? w.getAnswer() : null;
}
catch (IOException e)
{
return null;
}
The tree is mounted on demand to speedup the process.
| Nested Class Summary | |
|---|---|
static interface |
FileChooserBox.Filter
Interface used if you want to filter the files that will be added to the tree. |
| Field Summary | |
|---|---|
protected String[] |
buttonCaptions
|
protected FileChooserBox.Filter |
ff
|
protected Node |
lastSelected
|
boolean |
multipleSelection
Set to true to allow multiple selections using a Check drawn before the nodes. |
protected PushButtonGroup |
pbg
|
protected int |
selectedIndex
|
protected Vector |
selectedNodes
|
protected TreeModel |
tmodel
|
protected totalcross.ui.dialog.FileChooserBox.LoadOnDemandTree |
tree
|
| Fields inherited from class totalcross.ui.Container |
|---|
alwaysEraseBackground, BORDER_LOWERED, BORDER_NONE, BORDER_RAISED, BORDER_SIMPLE, children, controlFound, finishedStart, ignoreOnAddAgain, ignoreOnRemove, insets, lastH, lastScreenWidth, lastW, nextTransitionEffect, started, tabOrder, tail, TRANSITION_CLOSE, TRANSITION_NONE, TRANSITION_OPEN, transitionEffect |
| Fields inherited from class totalcross.ui.Control |
|---|
AFTER, appId, appObj, asContainer, asWindow, backColor, BEFORE, BOTTOM, BOTTOM_OF, CENTER, CENTER_OF, clearValueInt, clearValueStr, enabled, enableUpdateScreen, FILL, FIT, fm, fmH, focusHandler, focusLess, focusOnPenDown, focusTraversable, font, foreColor, height, isHighlighting, KEEP, LEFT, onEventFirst, parent, PREFERRED, RANGE, repositionAllowed, RIGHT, RIGHT_OF, SAME, setFont, setH, setRel, setW, setX, setY, TOP, transparentBackground, uiCE, uiFlat, uiPalm, uiVista, visible, width, WILL_RESIZE, x, y |
| Constructor Summary | |
|---|---|
FileChooserBox(FileChooserBox.Filter ff)
Constructs a file chooser with "Select a file" as the window title, and "Select" and "Cancel" buttons. |
|
FileChooserBox(String caption,
String[] buttonCaptions,
FileChooserBox.Filter ff)
Constructs a file chooser with the given parameters. |
|
| Method Summary | |
|---|---|
String |
getAnswer()
Returns the path choosen by the user. |
int |
getPressedButtonIndex()
Returns the button index used to close this window. |
Tree |
getTree()
Returns the tree. |
protected void |
mountTree(Node root,
File f)
|
void |
mountTree(String filePath,
int volume)
Call this method to mount the tree, starting from the given path and volume. |
void |
onEvent(Event e)
Called to process key, pen, control and other posted events. |
protected void |
onPopup()
Placeholder called imediatly before the popup began. |
| Methods inherited from class totalcross.ui.Container |
|---|
add, add, add, add, add, broadcastEvent, clear, findChild, findNearestChild, findNextFocusControl, getChildren, getFocusableControls, getInsets, incLastX, incLastY, initUI, onAddAgain, onColorsChanged, onPaint, onRemove, paintChildren, remove, removeAll, setEnabled, setHighlighting, setInsets, swapToTopmostWindow |
| Methods inherited from class totalcross.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected PushButtonGroup pbg
protected totalcross.ui.dialog.FileChooserBox.LoadOnDemandTree tree
protected Node lastSelected
protected FileChooserBox.Filter ff
protected String[] buttonCaptions
protected TreeModel tmodel
protected int selectedIndex
protected Vector selectedNodes
public boolean multipleSelection
| Constructor Detail |
|---|
public FileChooserBox(String caption,
String[] buttonCaptions,
FileChooserBox.Filter ff)
caption - The caption to be displayed in the titlebuttonCaptions - The button captions that will be used in the PushButtonGroupff - The Filter. Pass null to accept all files.public FileChooserBox(FileChooserBox.Filter ff)
ff - The Filter. Pass null to accept all files.| Method Detail |
|---|
protected void onPopup()
Window
onPopup in class Window
public void mountTree(String filePath,
int volume)
throws IOException
filePath - The root from where the tree will be mounted.volume - The volume used in Palm OS only. Usually 1 is the NVFS volume, and 2 is the card slot.
IOException
protected void mountTree(Node root,
File f)
throws IOException
IOExceptionpublic void onEvent(Event e)
Control
onEvent in class Controle - the event to processEvent,
KeyEvent,
PenEventpublic int getPressedButtonIndex()
public String getAnswer()
public Tree getTree()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||