Class PathManager


  • public class PathManager
    extends java.lang.Object
    Component that has a table to show pathnames; the panel includes buttons to control the order of the paths, and to add and remove paths. The add button brings up a file chooser. Call the setFileChooser() method to control how the file chooser should behave. If the table entries should not be edited, call setEditingEnabled(false).
    • Constructor Summary

      Constructors 
      Constructor Description
      PathManager​(boolean addToTop, boolean allowOrdering)  
      PathManager​(java.util.List<Path> paths, boolean addToTop, boolean allowOrdering)
      Construct a new PathnameTablePanel.
    • Constructor Detail

      • PathManager

        public PathManager​(java.util.List<Path> paths,
                           boolean addToTop,
                           boolean allowOrdering)
        Construct a new PathnameTablePanel.
        Parameters:
        paths - list of paths to show; may be null
        addToTop - true if new paths are to be added to the top of the table, false
        allowOrdering - if true the ability to move path items up/down will be provided if new paths are to be added to the end of the table
      • PathManager

        public PathManager​(boolean addToTop,
                           boolean allowOrdering)
    • Method Detail

      • setFileChooserProperties

        public void setFileChooserProperties​(java.lang.String title,
                                             java.lang.String preferenceForLastSelectedDir,
                                             GhidraFileChooserMode selectionMode,
                                             boolean allowMultiSelection,
                                             GhidraFileFilter filter)
        Set properties on the file chooser that is displayed when the "Add" button is pressed.
        Parameters:
        title - title of the file chooser
        preferenceForLastSelectedDir - Preference to use as the current directory in the file chooser
        selectionMode - mode defined in GhidraFileChooser, e.g., GhidraFileChooser.FILES_ONLY
        allowMultiSelection - true if multiple files can be selected
        filter - filter to use; may be null if no filtering is required
      • addPath

        public boolean addPath​(ResourceFile file,
                               boolean enabled)
        Add a new file path and set its enablement
        Parameters:
        file -
        enabled -
        Returns:
        true if the enabled path did not already exist
      • setPaths

        public void setPaths​(java.util.List<Path> paths)
        Set the paths.
      • clear

        public void clear()
        Clear the paths in the table.
      • getComponent

        public javax.swing.JComponent getComponent()
        Returns the GUI component for the path manager.
        Returns:
        the GUI component for the path manager
      • saveState

        public void saveState​(SaveState ss)
        Saves the paths to the specified SaveState object.
        Parameters:
        ss - the SaveState object
      • restoreFromPreferences

        public void restoreFromPreferences​(java.lang.String enablePathKey,
                                           Path[] defaultEnablePaths,
                                           java.lang.String disabledPathKey)
        Restore paths from user Preferences using the specified keys. If preferences have never been saved, the specified defaultEnablePaths will be used. Note: the encoded path list must have been stored using the same keys using the savePathsToPreferences(String, String, Path[]) or saveToPreferences(String, String) methods.
        Parameters:
        enablePathKey - preference key for storing enabled paths
        defaultEnablePaths - default paths
        disabledPathKey - preference key for storing disabled paths
      • getPathsFromPreferences

        public static Path[] getPathsFromPreferences​(java.lang.String enablePathKey,
                                                     Path[] defaultEnablePaths,
                                                     java.lang.String disabledPathKey)
        Restore paths from user Preferences using the specified keys. If preferences have never been saved, the specified defaultEnablePaths will be returned. Note: the encoded path list must have been stored using the same keys using the savePathsToPreferences(String, String, Path[]) or saveToPreferences(String, String) methods.
        Parameters:
        enablePathKey - preference key for storing enabled paths
        defaultEnablePaths - default paths
        disabledPathKey - preference key for storing disabled paths
        Returns:
        ordered paths from Preferences
      • saveToPreferences

        public boolean saveToPreferences​(java.lang.String enablePathKey,
                                         java.lang.String disabledPathKey)
      • savePathsToPreferences

        public static boolean savePathsToPreferences​(java.lang.String enablePathKey,
                                                     java.lang.String disabledPathKey,
                                                     Path[] paths)
        Save the specified paths to the user Preferences using the specified keys. Note: The encoded path Preferences are intended to be decoded by the restoreFromPreferences(String, Path[], String) and getPathsFromPreferences(String, Path[], String) methods.
        Parameters:
        enablePathKey - preference key for storing enabled paths
        disabledPathKey - preference key for storing disabled paths
        paths - paths to be saved
        Returns:
        true if Preference saved properly
      • restoreState

        public void restoreState​(SaveState ss)
        Restores the paths from the specified SaveState object.
        Parameters:
        ss - the SaveState object
      • dispose

        public void dispose()