public class GralFileSelector extends GralWidgetBase
FileRemote
. This type inherits from File
and is supported for a local file system on PC. It is possible to work with any remote file system.
setActionOnFileSelected(GralUserAction)
allows any action while the user
select any file. For example a user's program can show the content of the file.
Modifier and Type | Class and Description |
---|---|
protected class |
GralFileSelector.Callbacks |
static class |
GralFileSelector.Constants |
private static class |
GralFileSelector.ERefresh
Name of the current file.
|
static class |
GralFileSelector.FavorPath
Entry in the favorite list.
|
protected class |
GralFileSelector.FileSelectList
Implementation of the base widget.
|
static class |
GralFileSelector.Gui
Inner data of Graphical User Interface.
|
protected static class |
GralFileSelector.InternalData |
static class |
GralFileSelector.MenuTexts
This class is instantiated static and contains English menu texts.
|
class |
GralFileSelector.WindowConfirmSearch
A window for search-in-file dialogue.
|
GralWidgetBase.GralWidgComposite, GralWidgetBase.TimeOrderCreateImplWidget
Modifier and Type | Field and Description |
---|---|
(package private) GralFileSelector.Callbacks |
action |
static GralFileSelector.MenuTexts |
contextMenuTexts |
private EventSource |
evSrc |
protected <any> |
fillinEv
Event as back event for fillin.
|
protected GralFileSelector.Gui |
gui |
protected GralFileSelector.InternalData |
idata |
static java.lang.String |
sVersion
Version, history and copyright/copyleft.
|
protected GralFileSelector.WindowConfirmSearch |
windSearch |
_cdata, _wdgPos, bVisibleState, gralMng, name, pixSize
Constructor and Description |
---|
GralFileSelector(GralPos refPosParent,
java.lang.String posName,
GralWindow windFileSelector,
int rows,
int[] columns,
boolean bWithFavor,
java.lang.String sExecBtn,
GralViewFileContent fileViewer,
GralFileProperties wdgFileProperties)
Creates a new instance of this comprehensive widget for file selection, search and viewing
|
Modifier and Type | Method and Description |
---|---|
boolean |
actionUserKey(int keyCode,
java.lang.Object userDataOfLine,
GralTableLine_ifc<FileRemote> line)
This method is called on any user key or mouse event while operating in the file table.
|
GralTableLine_ifc<GralFileSelector.FavorPath> |
add(java.lang.String name,
java.lang.String path) |
GralTableLine_ifc<GralFileSelector.FavorPath> |
addFavor(GralFileSelector.FavorPath favorPathInfo)
Adds a line to this table.
|
void |
addFavor(java.util.List<GralFileSelector.FavorPath> list) |
protected java.lang.String |
buildKey(FileRemote file,
boolean bAllCompleteWithFileInfoP,
java.lang.String[] retSortName) |
void |
checkRefresh(long since)
Refreshes cyclically
|
void |
clear() |
void |
closeDialog() |
private void |
completeLine(GralTableLine_ifc<FileRemote> tline,
FileRemote file,
long timeNow) |
static GralFileSelector |
createGralFileSelectorWindow(GralMng mng,
boolean visible,
java.lang.String posName,
java.lang.String sExec,
java.util.List<GralFileSelector.FavorPath> favors) |
FileRemote |
currentDir()
Gets the directory which is currently shown.
|
FileRemote |
currentFile()
Gets the current selected file.
|
protected void |
doActionExec(int key,
GralWidget_ifc widgd,
java.lang.Object... params) |
protected void |
doActionGetFileName(int key,
GralWidget_ifc widgd,
java.lang.Object... params)
Copies the name of the current selected file as file name into the #widgPathDir
as presetting for save, rename etc.
|
void |
doActionSelectFileTableFromFavor()
Called from click on line in favor table to select this favor
and show the adequate file table.
|
void |
doActivateFavor()
Activates the favor card.
|
(package private) void |
doFileLineSelect(GralTable.TableLineData line) |
void |
fillFavorPaths(java.util.List<GralFileSelector.FavorPath> listfavorPaths)
Add all favor paths from the SelectTab newly
|
void |
fillIn(FileRemote fileIn,
boolean bDonotRefrehs)
Fills the content with given directory.
|
protected void |
fillIn(java.util.List<java.io.File> files) |
void |
fillInCurrentDir()
It is the refresh operation.
|
void |
fillInOriginDir()
Fills the content with the first directory or the directory which was set with
#setOriginDir(File) . |
(package private) void |
finishShowFileTable()
Finishes a newly showed file table.
|
void |
forcefillIn(FileRemote fileIn,
boolean bDonotRefrehs) |
FileRemote |
getCurrentDir()
same as
currentDir() . |
java.lang.String |
getCurrentDirPath()
Creates the window to confirm search in files.
|
GralWidgetBase_ifc |
getFocusedWidget()
Returns the widget which is in focus of a panel or comprehensive widget.
|
java.lang.String |
getLabelCurrFavor() |
java.util.List<FileRemote> |
getSelectedFiles(boolean bAlsoDirs,
int mask)
Gets the selected file from this panel.
|
boolean |
isInFocus()
Returns true if this widget is the focused one.
|
boolean |
isVisible()
Returns whether the widget is visible or not.
|
void |
openDialog(FileRemote startFile,
java.lang.String sTitle,
java.lang.String sBtnText,
GralUserAction actionEnter,
GralUserAction actionButton)
Prepares the action and appearance and shows the window or the widget (get visible).
|
void |
refresh()
Refreshes the content especially after change as copy, delete etc.
|
boolean |
remove()
Removes the widget from the lists in its panel and from the graphical representation.
|
boolean |
selectFile(java.lang.String name)
Selects the file with the given name in the table
|
void |
selectFileTable(java.lang.String sFavor,
FileRemote startFile) |
protected void |
selectFileTableFromFavor(GralFileSelector.FavorPath favor,
FileRemote fileStart)
Called either from tab selection or from a line in the favor table (
doActionSelectFileTableFromFavor() . |
GralUserAction |
setActionOnEnterDirectory(GralUserAction newAction)
This action will be called on pressing enter or mouse-click on a directory.
|
GralUserAction |
setActionOnEnterFile(GralUserAction newAction)
Sets the action which is called if any file is entered.
|
GralUserAction |
setActionOnEnterPathNewFile(GralUserAction newAction)
This action will be called on pressing enter or mouse-click on the path text field
if it contains any text which can't assigned to an existing file.
|
void |
setActionOnFileSelected(GralUserAction actionOnLineSelected)
Sets an action which is called any time when another line in a file table is selected.
|
void |
setActionOnFocusedFileTable(GralUserAction newAction)
Sets the action which is called if any file is entered.
|
GralUserAction |
setActionOnSaveButton(GralUserAction newAction,
java.lang.String textButton)
Sets the action which is called if any file is entered.
|
GralUserAction |
setActionSaveFavors(GralUserAction newAction)
This action will be called on context menu for the Favor tab to save its content.
|
GralUserAction |
setActionSetFileLineAttrib(GralUserAction newAction)
Sets the action which is called if any file is set to the table.
|
void |
setDateFormat(java.lang.String sFormat)
Maybe called after construction, should be called before
#setToPanel(GralMngBuild_ifc) |
void |
setFocus()
Sets the focus of the associated table widget.
|
void |
setFocus(int delay,
int latest) |
void |
setFocusedWidget(GralWidgetBase_ifc widg)
If this widget is a comprehensive widget or a panel, it sets one of the content as focused.
|
(package private) void |
setNewDirFile(java.lang.String sPathP) |
void |
setOriginDir(FileRemote dir) |
void |
setSortOrder(char sortOrder)
Sets the sort order of entries.
|
boolean |
setVisible(boolean visible)
Sets this widget visible on graphic or invisible.
|
(package private) void |
showFile(FileRemote file1)
This routine is invoked in callback of
#callbackChildren1 for fillIn(FileRemote, boolean) in the refresh thread. |
protected void |
showFileInfo(GralTable.TableLineData line)
If given in ctor, opens the file property window and show file properties.
|
(package private) void |
stop() |
protected void |
updateFavorWithCurrentDir()
Updates the current favor with the current file table's directory path.
|
java.io.File |
XXXgetSelectedFile()
Gets the selected file from this panel.
|
checkImplWidgetCreation, createImplWidget_Gthread, createImplWidget, getImplAccess, getName, gralMng, hasFocus, pos, removeImplWidget_Gthread, resizePostPreparation, setFocused, toString, toString
public static final java.lang.String sVersion
#widgFavorTabs
as on left side
the tab "+sel" to select the favor table. A more intuitive approach.
#openDialog(FileRemote, String, String, GralUserAction)
now from the GralFileSelectWindow,
which should be get deprecated or removed, because this class contains the #windFileSelector
.
GralFileProperties
is able to aggregate.
GralHorizontalSelector
as before in Fcmd only
GralPos.setAsFrame()
.
A test class org.vishia.gral.test.basics.Test_GralFileSelector
is created for test.
fillIn(FileRemote, boolean)
, if the file is a file not directory
then this file is highlighted. Firstly used on InspcCurveViewApp to get cfg and data from the same directory,
re-read the same file is before by saving the gotten file before.
#widgFavorTable
is unused yet, create only if position is given.
#GralFileSelector(String, int, int[], int[])
: The rows argument is used yet for table zLinesMax.
The old last argument size was never used. replaced by the column designation for the #widgFavorTable
.
If it is null, do not create a #widgFavorTable
.
setVisible(boolean)
for this large widget.
fillInCurrentDir()
does not refresh if it was refreshed in the last seconds.
fillIn(FileRemote, boolean)
now with new meaning of boolean: show newly without refresh with the file system.
This is used in callback routines which does a refresh but does not invoke showFile(FileRemote)
especially called from Fcmd.refreshFilePanel(FileRemote)
.
#actionSetPath
because the property whether it is a directory or not should be known. Prevents a timeout waiting in graphic thread!!!
fillIn(FileRemote, boolean)
using the new FileRemote#getChildren(org.vishia.fileRemote.FileRemote.ChildrenEvent).
getSelectedFiles(boolean, int)
now has that 2 arguments for directory and mark mask.
Now it is possible and necessary for the application to choice whether directories are gotten too.
The usage is improved. If some files are marked but not visible, it was able that the user does not know about
this situation and an unexpected behavior for the user is done. Now only marked files are returned
if the current file is marked too. The method is correct named 'selected' because the selection is returned,
either the current file or all marked.
fillIn(FileRemote, boolean)
modi of refresh.
#fillInRefreshed(FileRemote, boolean)
now does not clear
the table but writes only lines if the data are changed. This method can be called
in a higher frequency without disturbing the appearance of the table. Used for cyclically refresh.
checkRefresh(long)
, chg: Don't change the content in the table
if the content is identical with the current presentation in table, for refreshing.
fillIn(FileRemote, boolean)
now uses the FileRemote#timeRefresh
#actionOnMarkLine
changes the select status of FileRemote#setMarked(int)
CallbackCmd#successCode
etc.
#setToPanel(GralMngBuild_ifc, String, int, int[], char)
preserves the panel
before calling.
#fillInRefreshed(File, boolean)
: If all files are complete with file info,
nevertheless the RefreshTimed#delayedFillin(int) was called because the whole routine was called with false
as bCompleteWithFileInfo-argument. Now that is prevented if all files were tested already.
protected GralFileSelector.WindowConfirmSearch windSearch
public static GralFileSelector.MenuTexts contextMenuTexts
protected final GralFileSelector.InternalData idata
protected final GralFileSelector.Gui gui
private final EventSource evSrc
protected final <any> fillinEv
final GralFileSelector.Callbacks action
public GralFileSelector(GralPos refPosParent, java.lang.String posName, GralWindow windFileSelector, int rows, int[] columns, boolean bWithFavor, java.lang.String sExecBtn, GralViewFileContent fileViewer, GralFileProperties wdgFileProperties)
refPosParent
- Reference position for the whole spread for this comprehensive widget in a panel.posName
- "@position=name"
or "name"
, see GralWidget#GralWidget(String, char)
rows
- Number of rows intended to use for the file list (max length)columns
- should have the form new int[]{2,0,-6,-12}
, the width of field for size, datd can be justified.
last is date (timestamp), before last is file size, first is mark. The 0 is the rest length of the file name.
to do proportional determination?bWithFavor
- true then a favor table is created, select favor. False: prevent this capabilitysExecBtn
- if given then this widget contains a [exec] button for file-save action etc. with this text.
The text can be changed also with #openDialog(FileRemote, String, String, GralUserAction)
fileViewer
- Instance of a file viewer (for content). It is possible to share one fileViewer to more instances of this.wdgFileProperties
- maybe null, then this fuction is not available.
Should be instantiated recommended by GralFileProperties.createWindow(GralPos, String, String)
but maybe concurrently used for more as one GralFileSelector. The Key public void setDateFormat(java.lang.String sFormat)
#setToPanel(GralMngBuild_ifc)
name
- public static GralFileSelector createGralFileSelectorWindow(GralMng mng, boolean visible, java.lang.String posName, java.lang.String sExec, java.util.List<GralFileSelector.FavorPath> favors)
mng
- The GralMng is necessary because only the String given pos is used.posName
- sExec
- If given, it is the initial text for the [Exec] button, if null Ecec button is not present.favors
- If given initial favors, at least an empty list. If null no favors possible.public java.lang.String getCurrentDirPath()
public void setOriginDir(FileRemote dir)
public void setSortOrder(char sortOrder)
sortOrder
- public void setActionOnFileSelected(GralUserAction actionOnLineSelected)
actionOnLineSelected
- The action, null to switch off this functionality.public GralUserAction setActionOnEnterFile(GralUserAction newAction)
newAction
- The action to use. The action is invoked with to dopublic GralUserAction setActionOnSaveButton(GralUserAction newAction, java.lang.String textButton)
newAction
- The action to use. The action is invoked with to dopublic void setActionOnFocusedFileTable(GralUserAction newAction)
newAction
- The action to use. The action is invoked with to dopublic GralUserAction setActionOnEnterDirectory(GralUserAction newAction)
public GralUserAction setActionSaveFavors(GralUserAction newAction)
addFavor(FavorPath)
to fill the favor table.public GralUserAction setActionOnEnterPathNewFile(GralUserAction newAction)
public GralUserAction setActionSetFileLineAttrib(GralUserAction newAction)
newAction
- The action to use. The action is invoked with to dopublic void clear()
public GralTableLine_ifc<GralFileSelector.FavorPath> addFavor(GralFileSelector.FavorPath favorPathInfo)
ix
- Show which index is used for a local table, 0..2 for left, mid, right,
than show the label in the left cell (column)favorPathInfo
- The favorite infopublic void addFavor(java.util.List<GralFileSelector.FavorPath> list)
public GralTableLine_ifc<GralFileSelector.FavorPath> add(java.lang.String name, java.lang.String path)
public void openDialog(FileRemote startFile, java.lang.String sTitle, java.lang.String sBtnText, GralUserAction actionEnter, GralUserAction actionButton)
#widgBtnExec
.
The button is marked with
"select" or "write" depending on the param bForWrite. For actionSelect the method
GralUserAction.exec(int, GralWidget_ifc, Object...)
is called with null for the widget (a widget should not
necessary for the user) but with the selected File(s) as Object parameter.
If one file is selected the first Object is instanceof File. If more as one files are selected
a ListstartDir
- sTitle
- shown in title bar of the windowbForWrite
- true then the name field is editable and "Save" is shown on button. False then the name Field
is readonly and "select" is shown on buttonactionSelect
- Action which is called on Button ok. The first Object of exec(...,object) is the selected File
or a File[] or Listpublic void closeDialog()
public void fillFavorPaths(java.util.List<GralFileSelector.FavorPath> listfavorPaths)
favorTabInfo
- public void fillInOriginDir()
#setOriginDir(File)
.public void fillInCurrentDir()
#fillinPending
is set yet this operation does nothing. It means it is possible to call in a short cycle
more as one time after another, for example for all files of a directory without calculation effort.protected void fillIn(java.util.List<java.io.File> files)
public void forcefillIn(FileRemote fileIn, boolean bDonotRefrehs)
public void fillIn(FileRemote fileIn, boolean bDonotRefrehs)
fileIn
- The directory which's files are shown or a file in this directory.
If it is a file this line is marked.
Elsewhere that line is marked which's file is found in #idxSelectFileInDir due to the fileIn directory.bDonotRefrehs
- false then invoke an extra thread to walk through the file system,
see @FileRemote#refreshPropertiesAndChildren(FileRemoteWalkerCallback)
and #callbackChildren1
.
On any file showFile(FileRemote)
is called in the file thread which fills the table lines.
On done event finishShowFileTable()
is called in the file thread.
If true then it is presumed that the FileRemote children are refreshed in the last time already.
The fill the table newly with given content in this thread.void showFile(FileRemote file1)
#callbackChildren1
for fillIn(FileRemote, boolean)
in the refresh thread.file1
- void finishShowFileTable()
#colorBackPending
yet, they are not refreshed because that files don't exist furthermore.
Gets the currentFile()
of this table from the #idxSelectFileInDir
if the currentFile()
is null,
sets the current line and repaint the table.private void completeLine(GralTableLine_ifc<FileRemote> tline, FileRemote file, long timeNow)
protected java.lang.String buildKey(FileRemote file, boolean bAllCompleteWithFileInfoP, java.lang.String[] retSortName)
public void refresh()
public void checkRefresh(long since)
since
- public java.lang.String getLabelCurrFavor()
public java.io.File XXXgetSelectedFile()
public java.util.List<FileRemote> getSelectedFiles(boolean bAlsoDirs, int mask)
bAlsoDirs
- false then returns never a directory. If the current selected file is a directory
then return null.public boolean selectFile(java.lang.String name)
name
- name of file like it is shown in the table (given as key).public FileRemote currentFile()
File.isDirectory()
.public FileRemote currentDir()
currentFile()
is the parent. Elsewhere this method returns the parent of
currentFile()
.public FileRemote getCurrentDir()
currentDir()
.public void setFocus()
public void setFocus(int delay, int latest)
public boolean isInFocus()
GralWidgetBase_ifc
public boolean isVisible()
GralWidgetBase_ifc
isVisible
in interface GralWidgetBase_ifc
isVisible
in class GralWidgetBase
public boolean setVisible(boolean visible)
GralWidgetBase_ifc
GralWindow
, its the visibility of the whole window.
Note that a window which is invisible is not shown in the task bar of the operation system.
Note that an application can have more as one window.
Note that a dialog window can be set to invisible if it is not need yet instead destroy and build newly.setVisible
in interface GralWidgetBase_ifc
setVisible
in class GralWidgetBase
void stop()
public boolean remove()
GralWidgetBase
GralWidgImplAccess_ifc.removeWidgetImplementation()
is called which is overridden in the graphic implementation sources in a specific kind
(SWT: for example SwtTextFieldWrapper.removeWidgetImplementation()
)
It calls the protected GralWidgetBase.GralWidgComposite.removeWidget(GralWidgetBase)
and also GralMng.deregisterWidgetName(GralWidgetBase)
.remove
in class GralWidgetBase
public void setFocusedWidget(GralWidgetBase_ifc widg)
GralWidgetBase_ifc
widg
- The sub widget which should be focused.
It influences for example the current tab of a tabbed panel,
or influences which widget of a comprehensive widget is first focused.
On a panel it determines which widget should get the focus if the panel gets the focus.public GralWidgetBase_ifc getFocusedWidget()
GralWidgetBase_ifc
public void selectFileTable(java.lang.String sFavor, FileRemote startFile)
void doFileLineSelect(GralTable.TableLineData line)
protected void doActionGetFileName(int key, GralWidget_ifc widgd, java.lang.Object... params)
key
- unusedwidgd
- The widget where the command was invoked fromparams
- unusedprotected void doActionExec(int key, GralWidget_ifc widgd, java.lang.Object... params)
public void doActionSelectFileTableFromFavor()
protected void selectFileTableFromFavor(GralFileSelector.FavorPath favor, FileRemote fileStart)
doActionSelectFileTableFromFavor()
.favor
- The favor of the tab or line.public void doActivateFavor()
updateFavorWithCurrentDir()
void setNewDirFile(java.lang.String sPathP)
protected void updateFavorWithCurrentDir()
#widgFavorTabs
.protected void showFileInfo(GralTable.TableLineData line)
line
- The line in fileTablepublic boolean actionUserKey(int keyCode, java.lang.Object userDataOfLine, GralTableLine_ifc<FileRemote> line)
key
- code or mouse code, one of constants from KeyCode
.userDataOfLine
- The user data stored in the line of table.line
- The table line.