Package docking.widgets.filechooser
Class GhidraFileChooser
- java.lang.Object
- 
- docking.DialogComponentProvider
- 
- docking.widgets.filechooser.GhidraFileChooser
 
 
- 
- All Implemented Interfaces:
- ActionContextProvider,- GhidraFileChooserListener,- StatusListener,- TaskListener,- java.io.FileFilter
 
 public class GhidraFileChooser extends DialogComponentProvider implements GhidraFileChooserListener, java.io.FileFilter An implementation of a file chooser dialog. This class is designed to emulate the JFileChooser, but it removes the network locking issue. When a network drive is down, the JFileChooser can take several minutes to come up. Why use this file chooser over JFileChooser?? Let me enumerate the reasons...- JFileChooser cannot show hidden/system files, but we can!
- JFileChooser does not properly consume key strokes (global actions in docking windows)
- This class is threaded, so loading delays do not lock the GUI
- This class provides shortcut buttons similar to those of the Windows native chooser
 
- 
- 
Field SummaryFields Modifier and Type Field Description static intDIRECTORIES_ONLYInstruction to display only directories.static intFILES_AND_DIRECTORIESInstruction to display both files and directories.static intFILES_ONLYInstruction to display only files.- 
Fields inherited from class docking.DialogComponentProviderapplyButton, cancelButton, dismissButton, okButton, rootPanel
 
- 
 - 
Constructor SummaryConstructors Constructor Description GhidraFileChooser(java.awt.Component parent)Constructs a new ghidra file chooser.
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description booleanaccept(java.io.File file)voidaddFileFilter(GhidraFileFilter f)Adds the specified file filter.protected voidcancelCallback()The callback method for when the "Cancel" button is pressed.voidclose()voiddispose()java.io.FilegetCurrentDirectory()Returns the current directory.java.io.FilegetSelectedFile()Returns the selected file.java.io.FilegetSelectedFile(boolean show)Returns the selected file.java.util.List<java.io.File>getSelectedFiles()Returns the selected files.booleanisMultiSelectionEnabled()Returns true if multiple files can be selected.voidmodelChanged()Invoked when the contents of the file chooser model have changed.protected voidokCallback()The callback method for when the "OK" button is pressed.voidrescanCurrentDirectory()Causes the file chooser to refresh its contents with the content of the currently displayed directory.voidsetApproveButtonText(java.lang.String buttonText)Sets the text used in theOKbuttonvoidsetApproveButtonToolTipText(java.lang.String tooltipText)Sets the tooltip text used in theOKbuttonvoidsetCurrentDirectory(java.io.File directory)Sets the current directory.voidsetFileFilter(GhidraFileFilter filter)Sets the current file filter.voidsetFileSelectionMode(int mode)Deprecated.use insteadsetFileSelectionMode(GhidraFileChooserMode)voidsetFileSelectionMode(GhidraFileChooserMode mode)Sets this file chooser to allow the user to just select files, just select directories, or select both files and directories.voidsetMultiSelectionEnabled(boolean b)Sets the file chooser to allow multiple file selections.voidsetSelectedFile(java.io.File file)Sets the selected file.voidsetSelectedFileFilter(GhidraFileFilter filter)Set the selected filter to the given filtervoidsetShowDetails(boolean showDetails)When true is passed the chooser will use a detailed table view to show the files; false will show a simplified list of files.voidshow()booleanwasCancelled()Returns true if the user clicked the "cancel" button on the file chooser.- 
Methods inherited from class docking.DialogComponentProvideraddAction, addApplyButton, addButton, addCancelButton, addDismissButton, addOKButton, addWorkPanel, alertMessage, alertMessage, applyCallback, cancelCurrentTask, clearScheduledTask, clearStatusText, dialogClosed, dialogShown, dismissCallback, doInitialize, escapeCallback, executeProgressTask, getActionContext, getActions, getBackground, getBounds, getComponent, getDefaultButton, getDefaultSize, getDialogSize, getFocusComponent, getGlassPane, getHelpLocatdion, getIntialLocation, getLocationOnScreen, getPreferredSize, getRemberSize, getRememberLocation, getStatusLabel, getStatusText, getTaskMonitorComponent, getTaskScheduler, getTitle, getUseSharedLocation, hideTaskMonitorComponent, isApplyEnabled, isCancelEnabled, isModal, isOKEnabled, isResizeable, isRunningTask, isShowing, isTransient, isVisible, main, notifyContextChanged, removeAction, removeButton, removeWorkPanel, repack, setApplyEnabled, setApplyToolTip, setBackground, setCancelButtonText, setCancelEnabled, setCancelToolTip, setCursor, setDefaultButton, setDefaultSize, setDialogSize, setDismissToolTip, setFocusComponent, setGlassPane, setHelpLocation, setInitialLocation, setMinimumSize, setMinimumSize, setOkButtonText, setOkEnabled, setOkToolTip, setPreferredSize, setRememberLocation, setRememberSize, setResizable, setStatusJustification, setStatusText, setStatusText, setStatusText, setTitle, setTransient, setUseSharedLocation, showProgressBar, showTaskMonitorComponent, stopProgressTimer, taskCancelled, taskCompleted, toFront, toString, waitForCurrentTask
 
- 
 
- 
- 
- 
Field Detail- 
FILES_ONLYpublic static final int FILES_ONLY Instruction to display only files.- See Also:
- Constant Field Values
 
 - 
DIRECTORIES_ONLYpublic static final int DIRECTORIES_ONLY Instruction to display only directories.- See Also:
- Constant Field Values
 
 - 
FILES_AND_DIRECTORIESpublic static final int FILES_AND_DIRECTORIES Instruction to display both files and directories.- See Also:
- Constant Field Values
 
 
- 
 - 
Method Detail- 
setShowDetailspublic void setShowDetails(boolean showDetails) When true is passed the chooser will use a detailed table view to show the files; false will show a simplified list of files.- Parameters:
- showDetails- true to show details
 
 - 
modelChangedpublic void modelChanged() Description copied from interface:GhidraFileChooserListenerInvoked when the contents of the file chooser model have changed.- Specified by:
- modelChangedin interface- GhidraFileChooserListener
 
 - 
acceptpublic boolean accept(java.io.File file) - Specified by:
- acceptin interface- java.io.FileFilter
 
 - 
setFileSelectionMode@Deprecated public void setFileSelectionMode(int mode) Deprecated.use insteadsetFileSelectionMode(GhidraFileChooserMode)Sets theGhidraFileChooserto allow the user to just select files, just select directories, or select both files and directories. The default isJFilesChooser.FILES_ONLY.- Parameters:
- mode- the type of files to be displayed:- GhidraFileChooser.FILES_ONLY
- GhidraFileChooser.DIRECTORIES_ONLY
- GhidraFileChooser.FILES_AND_DIRECTORIES
 
- Throws:
- java.lang.IllegalArgumentException- if- modeis an illegal Dialog mode
 
 - 
setFileSelectionModepublic void setFileSelectionMode(GhidraFileChooserMode mode) Sets this file chooser to allow the user to just select files, just select directories, or select both files and directories. The default isGhidraFileChooserMode.FILES_ONLY.- Parameters:
- mode- the type of files to be displayed
 
 - 
isMultiSelectionEnabledpublic boolean isMultiSelectionEnabled() Returns true if multiple files can be selected.- Returns:
- true if multiple files can be selected
- See Also:
- setMultiSelectionEnabled(boolean)
 
 - 
setMultiSelectionEnabledpublic void setMultiSelectionEnabled(boolean b) Sets the file chooser to allow multiple file selections.- Parameters:
- b- true if multiple files may be selected
- See Also:
- isMultiSelectionEnabled()
 
 - 
setApproveButtonTextpublic void setApproveButtonText(java.lang.String buttonText) Sets the text used in theOKbutton- Parameters:
- buttonText- the text
 
 - 
setApproveButtonToolTipTextpublic void setApproveButtonToolTipText(java.lang.String tooltipText) Sets the tooltip text used in theOKbutton- Parameters:
- tooltipText- the tooltip text
 
 - 
getSelectedFilepublic java.io.File getSelectedFile() Returns the selected file. This can be set either by the programmer viasetSelectedFile(File)or by a user action, such as either typing the filename into the UI or selecting the file from a list in the UI.- Returns:
- the selected file; null if cancelled or no file was selected
 
 - 
getSelectedFilespublic java.util.List<java.io.File> getSelectedFiles() Returns the selected files. This will show the file chooser- Returns:
- the selected files; an empty array if cancelled or no file was selected
 
 - 
getSelectedFilepublic java.io.File getSelectedFile(boolean show) Returns the selected file. This can be set either by the programmer viasetSelectedFile(File)or by a user action, such as either typing the filename into the UI or selecting the file from a list in the UI.Note: this method can be called after the chooser has been shown, in which case the value returned has been validated by the chooser. Also, the method may be called while the chooser is showing (like from a test thread). In this case, the selected file will not have been validated by the chooser. - Parameters:
- show- if true then the dialog is displayed
- Returns:
- the selected file; null if cancelled or no file was selected
 
 - 
setSelectedFilepublic void setSelectedFile(java.io.File file) Sets the selected file. If the file's parent directory is not the current directory, changes the current directory to be the file's parent directory.If the given file is a directory, then it's parent directory will be made the current directory and the directory represented by the file will be selected within the parent directory. If the given file does not exist, then the following will happen: - If the parent directory of the file exists, then the parent directory will be made the current directory and the name of the file will be put into the filename textfield; otherwise,
- If the parent file does not exist, then the selection is cleared.
 If the given file is null, then the selected file state is cleared. - Parameters:
- file- the selected file
- See Also:
- getSelectedFile()
 
 - 
showpublic void show() 
 - 
closepublic void close() - Overrides:
- closein class- DialogComponentProvider
 
 - 
getCurrentDirectorypublic java.io.File getCurrentDirectory() Returns the current directory.- Returns:
- the current directory
- See Also:
- setCurrentDirectory(java.io.File)
 
 - 
setCurrentDirectorypublic void setCurrentDirectory(java.io.File directory) Sets the current directory. Passing innullsets the file chooser to point to the user's default directory. This default depends on the operating system. It is typically the "My Documents" folder on Windows, and the user's home directory on Unix.
 If the file passed in ascurrentDirectoryis not a directory, the parent of the file will be used as the currentDirectory. If the parent is not traversable, then it will walk up the parent tree until it finds a traversable directory, or hits the root of the file system.- Parameters:
- directory- the current directory to point to
- See Also:
- getCurrentDirectory()
 
 - 
rescanCurrentDirectorypublic void rescanCurrentDirectory() Causes the file chooser to refresh its contents with the content of the currently displayed directory.
 - 
disposepublic void dispose() 
 - 
addFileFilterpublic void addFileFilter(GhidraFileFilter f) Adds the specified file filter.- Parameters:
- f- the new file filter
 
 - 
setSelectedFileFilterpublic void setSelectedFileFilter(GhidraFileFilter filter) Set the selected filter to the given filter- Parameters:
- filter- the filter to initially set
 
 - 
setFileFilterpublic void setFileFilter(GhidraFileFilter filter) Sets the current file filter.- Parameters:
- filter- the file filter to make current
 
 - 
wasCancelledpublic boolean wasCancelled() Returns true if the user clicked the "cancel" button on the file chooser.- Returns:
- true if the user clicked the "cancel" button on the file chooser
 
 - 
cancelCallbackprotected void cancelCallback() Description copied from class:DialogComponentProviderThe callback method for when the "Cancel" button is pressed. The default behavior is to call setVisible(false) and dispose() on the dialog.- Overrides:
- cancelCallbackin class- DialogComponentProvider
 
 - 
okCallbackprotected void okCallback() Description copied from class:DialogComponentProviderThe callback method for when the "OK" button is pressed.- Overrides:
- okCallbackin class- DialogComponentProvider
 
 
- 
 
-