Class SaveChooser

java.lang.Object
org.aavso.tools.vstar.ui.dialog.SaveChooser

public class SaveChooser extends Object
  • Constructor Details

    • SaveChooser

      public SaveChooser(FileNameExtensionFilter[] extensionFilterSave, String defaultExt, String titleSave)
      Constructor: save file dialogs
      Parameters:
      extensionFilterSave - file filters for 'Save' dialog
      defaultExt - default file extension for 'Save' dialog
      titleSave -
  • Method Details

    • showDialog

      public boolean showDialog(Component parent)
      Show the file save dialog.
      Parameters:
      parent - The parent component to which the dialog should be positioned relative.
      Returns:
      Whether the dialog was "approved".
    • getSaveDialogSelectedFile

      public File getSaveDialogSelectedFile()
      Returns the selected file and ensures it has a @defaultExt suffix (specified in the constructor)
      Returns:
      The selected file.
    • writeStringToFile

      public boolean writeStringToFile(Component parent, String content, Charset charset) throws IOException
      Invoke Save Dialog (chooser) and write @content to the selected file.
      Parameters:
      parent - The parent component to which the dialog should be positioned relative.
      content - String to be written
      charset - Charset, if null, the default charset is used.
      Returns:
      true if dialog was approved, false otherwise.
      Throws:
      IOException
    • writeStringToFile

      public void writeStringToFile(String path, String content, Charset charset) throws IOException
      Write a String to file
      Parameters:
      path - Path to a file
      content - String to be written
      charset - Charset, if null, the default charset is used.
      Throws:
      IOException