Class GhidraFileChooserPanel

All Implemented Interfaces:
Droppable, ImageObserver, MenuContainer, Serializable, Accessible

public class GhidraFileChooserPanel extends JPanel implements Droppable
Panel for entering a file name that includes a title border, a text field for entering a filename, and a button for bringing up a file chooser dialog.
See Also:
  • Field Details

    • INPUT_MODE

      public static final int INPUT_MODE
      This mode denotes that only existing files will be chosen for the purpose of reading.
      See Also:
    • OUTPUT_MODE

      public static final int OUTPUT_MODE
      This mode denotes that existing files (or new files) will be chosen for the purpose of writing. If an existing file is selected the user will be prompted to confirm overwrite.
      See Also:
  • Constructor Details

    • GhidraFileChooserPanel

      public GhidraFileChooserPanel(String title, String propertyName, String defaultFileName, boolean createBorder, int mode)
      Constructs a new GhidraFileChooserPanel
      Parameters:
      title - the title for this panel
      propertyName - the property name to save state
      defaultFileName - the default file name.
      createBorder - flag to create the border or not.
      mode - whether INPUT_MODE or OUTPUT_MODE
  • Method Details

    • dispose

      public void dispose()
    • setListener

      public void setListener(GhidraFileChooserPanelListener listener)
      Sets the listener.
      Parameters:
      listener - the new listener
    • setFileFilter

      public void setFileFilter(GhidraFileFilter filter)
      Sets the file filter.
      Parameters:
      filter - the new file filter
    • addDocumentListener

      public void addDocumentListener(DocumentListener dl)
      Adds a document listener to the text field.
      Parameters:
      dl - the document listener to add.
    • getFileName

      public String getFileName()
      Returns the filename currently in the text field.
      Returns:
      the filename currently in the text field
    • getCurrentDirectory

      public String getCurrentDirectory()
    • setFileName

      public void setFileName(String path)
      Sets the textfield with the given filename.
      Parameters:
      path - the name of the file to put in the text field.
    • setEnabled

      public void setEnabled(boolean enabled)
      Overrides:
      setEnabled in class JComponent
      See Also:
    • setFileSelectionMode

      public void setFileSelectionMode(GhidraFileChooserMode mode)
      Sets the GhidraFileChooser to allow the user to just select files, just select directories, or select both files and directories. The default is GhidraFileChooserMode.FILES_ONLY.
      Parameters:
      mode - the type of files to be displayed
      Throws:
      IllegalArgumentException - if mode is an illegal Dialog mode
    • add

      public void add(Object obj, DropTargetDropEvent e, DataFlavor f)
      Description copied from interface: Droppable
      Add the object to the droppable component. The DropTargetAdapter calls this method from its drop() method.
      Specified by:
      add in interface Droppable
      Parameters:
      obj - Transferable object that is to be dropped.
      e - has current state of drop operation
      f - represents the opaque concept of a data format as would appear on a clipboard, during drag and drop.
      See Also:
    • isDropOk

      public boolean isDropOk(DropTargetDragEvent e)
      Description copied from interface: Droppable
      Return true if is OK to drop the transferable at the location specified the event
      Specified by:
      isDropOk in interface Droppable
      Parameters:
      e - event that has current state of drag and drop operation
      Returns:
      true if OK