Class CliOrGui

java.lang.Object
eu.bandm.tools.util.files.CliOrGui

public class CliOrGui extends Object
Gets file names from command line or a very primitive interactive GUI input.
  • Method Details

    • wrap

      public static CliOrGui.FileChooser wrap(JFileChooser peer)
      Factory method to wrap a Java Swing file chooser.
      Parameters:
      peer - the Java Swing instance to wrap.
      Returns:
      a file chooser
    • selectOneInputFile

      @Opt public static @Opt File selectOneInputFile(String title, boolean lenient, String[] args)
      Define the path of one input file. When the command line parameters contain strings, then the first is tried as a file name. If not, an interactive swing gui is started. This method uses a default interactive file chooser, as defined by Java Swing.
      Parameters:
      title - of the GUI input dialog
      lenient - if multiple command line parameters are allowed
      args - the list of strings as found on the command line
      Returns:
      the selected file, or null if none is selected or there are unallowed multiple command line parameters
    • selectOneInputFile

      @Opt public static @Opt File selectOneInputFile(String title, CliOrGui.FileChooser fileChooser, boolean lenient, String[] args)
      Define the path of one input file. When the command line parameters contain strings, then the first is tried as a file name. If not, an interactive swing gui is started.
      Parameters:
      title - of the GUI input dialog
      fileChooser - the interactive file chooser to use, if the command line arguments are missing.
      lenient - if multiple command line parameters are allowed
      args - the list of strings as found on the command line
      Returns:
      the selected file, or null if none is selected or there are unallowed multiple command line parameters.