Class JDialogMemoryAllocation

All Implemented Interfaces:
DialogDefaultsInterface, ActionListener, FocusListener, ItemListener, WindowListener, ImageObserver, MenuContainer, Serializable, EventListener, Accessible, RootPaneContainer, WindowConstants

public class JDialogMemoryAllocation extends JDialogBase
Dialog to alter memory allocation of the runtime environment. The runtime memory allocation for the InstallAnywhere executable can be found in the LAX file: "mipav.lax" or "iaso.lax" within most environments or the file "Info.plist" in a Darwin/Mac OS 10 environment.

Reads the InstallAnywhere start up file then parses it, line-by-line, to come up with the memory options for the dialog. Waits for user input to declare what memory settings should be applied into the start-up file. InstallAnywhere will read those settings for the next time it restarts the application.

See Also:
  • Field Details

    • serialVersionUID

      private static final long serialVersionUID
      Use serialVersionUID for interoperability.
      See Also:
    • optionFlag

      private static final String optionFlag
      Flag to the java-runtime (as used in the XML-files) to indicate a memory-option. Literally, -X.
      See Also:
    • maxHeapOption

      private static final String maxHeapOption
      Flag to the java-runtime (as used in the XML-files) to indicate an maximum heap-size memory-option. Literally, mx.
      See Also:
    • maxHeapLAX

      private static final String maxHeapLAX
      Flag to the java-runtime (as used in the LAX-files) to indicate an maximum heap-size memory-option. Literally, lax.nl.java.option.java.heap.size.max=.
      See Also:
    • vmoptionsExt

      private static final String vmoptionsExt
      See Also:
    • laxExt

      private static final String laxExt
      See Also:
    • plistExt

      private static final String plistExt
      See Also:
    • debugLauncherStr

      private static final String debugLauncherStr
      See Also:
    • macAppVMOptions

      private static final String macAppVMOptions
      See Also:
    • MIN_HEAP_SIZE

      private static final int MIN_HEAP_SIZE
      See Also:
    • vmType

      private static JDialogMemoryAllocation.VMConfigType vmType
    • maxHeapText

      private JTextField maxHeapText
      DOCUMENT ME!
    • startupFile

      private File startupFile
      Contains all java properties of the MIPAV app (used at least when loading!)
    • usePreferencesButton

      private JButton usePreferencesButton
      DOCUMENT ME!
    • userInterface

      private final ViewUserInterface userInterface
      DOCUMENT ME!
  • Constructor Details

    • JDialogMemoryAllocation

      public JDialogMemoryAllocation()
      builds the dialog interface to get user to change the lax-file settings for the JVM to use on java start-up. calls to read the InstallAnywhere start up file then parses it, line-by-line to come up with the memory options for the dialog. Waits for user input to declare what memory settings should be applied into the start-up file. InstallAnywhere will read those settings for the next time it restarts the application.

      Failure to read the startup file will dispose the dialog before it is displayed.

    • JDialogMemoryAllocation

      public JDialogMemoryAllocation(ViewUserInterface ui, boolean checkOnPreferences)
      strictly reads the memory settings from the LAX-file.
      Parameters:
      ui - A reference to the VUI. Must be passed in since this dialog may be called while the VUI is still being constructed (can't use VUI.getReference()).
      checkOnPreferences - Whether this is a preferences-vs-lax file check.
  • Method Details

    • getStartupFile

      public static File getStartupFile() throws FileNotFoundException
      This method returns the startup file which contains the MIPAV start-up options. For most systems, the options are kept in a file called "mipav.lax". For Macintosh OS 10 (X), the application in the application menu is actually a directory "mipav.app" In this case, the start-up file is in "mipav.app/Contents/Info.plist". This method gets the application name ("mipav" or "iaso") and looks for a .lax file with that name; if it cannot find a .lax file, it then looks for a file "Info.plist" in the directory with the name of the application (.app)/Contents/.

      Ideally, the GetPath would look in application.app/Contents, but for now that location is found here.

      Parameters:
      ui - The main user-interface.
      Returns:
      DOCUMENT ME!
      Throws:
      FileNotFoundException - when the app title is not in the preferences file or the ViewUserInterface is null.
    • getAppName

      public static String getAppName() throws FileNotFoundException
      Throws:
      FileNotFoundException
    • getVMOptionsStartupFile

      public static File getVMOptionsStartupFile(String app, boolean debug) throws FileNotFoundException
      Throws:
      FileNotFoundException
    • getLaxStartupFile

      public static File getLaxStartupFile(String app) throws FileNotFoundException
      This method returns the startup file which contains the MIPAV start-up options. For most systems, the options are kept in a file called "mipav.lax". This method gets the application name ("mipav" or "iaso") and looks for a .lax file with that name.
      Parameters:
      app - The application name.
      Returns:
      DOCUMENT ME!
      Throws:
      FileNotFoundException - when the app title is not in the preferences file or the ViewUserInterface is null.
    • getPlistStartupFile

      public static File getPlistStartupFile(String app) throws FileNotFoundException
      This method returns the startup file which contains the MIPAV start-up options. For most systems, the options are kept in a file called "mipav.lax". For Macintosh OS 10 (X), the application in the application menu is actually a directory "mipav.app" In this case, the start-up file is in "mipav.app/Contents/Info.plist". This method gets the application name ("mipav" or "iaso") and looks for a .lax file with that name; if it cannot find a .lax file, it then looks for a file "Info.plist" in the directory with the name of the application (.app)/Contents/.

      Ideally, the GetPath would look in application.app/Contents, but for now that location is found here.

      Parameters:
      app - The application name.
      Returns:
      DOCUMENT ME!
      Throws:
      FileNotFoundException - when the app title is not in the preferences file or the ViewUserInterface is null.
    • setHeapMaxField

      protected boolean setHeapMaxField() throws IOException, FileNotFoundException
      Throws:
      IOException
      FileNotFoundException
    • readHeapMax

      public static String readHeapMax(File file) throws IOException, FileNotFoundException
      Throws:
      IOException
      FileNotFoundException
    • readVMOptionsFileHeapMax

      protected static String readVMOptionsFileHeapMax(File file) throws IOException, FileNotFoundException
      Throws:
      IOException
      FileNotFoundException
    • readLaxFileHeapMax

      public static String readLaxFileHeapMax(File lax) throws IOException, FileNotFoundException
      Reads the InstallAnywhere startup file and returns the start up heap memory string. Method can read LAX (Window,UNIX) finds the entry
      invalid reference
      JDialogMemoryAllocation#maxHeap
      . It returns the values of the associated entry in Megabytes.
      Parameters:
      lax - The File referring to the InstallAnywhere startup options LAX
      Returns:
      The maximum heap size-text
      Throws:
      IOException - when the LAX file cannot be read.
      FileNotFoundException - When the LAX file cannot be found.
    • readPlistFileHeapMax

      public static String readPlistFileHeapMax(File file) throws IOException, FileNotFoundException
      Reads the InstallAnywhere startup file and returns the start up heap memory string. Method can reads Info preferences list (Mac OS X) file, and finds
      invalid reference
      JDialogMemoryAllocation#maxHeap
      . It returns the values of the associated entry in Megabytes.
      Parameters:
      lax - The File referring to the InstallAnywhere startup options PLIST file
      Returns:
      The maximum heap size-text
      Throws:
      IOException - when the PLIST file cannot be read.
      FileNotFoundException - When the LAX PLIST cannot be found.
    • readFileContents

      protected static String readFileContents(File file) throws IOException, FileNotFoundException
      Throws:
      IOException
      FileNotFoundException
    • getVMOptionsMaxHeap

      protected static final String getVMOptionsMaxHeap(String line)
    • isVMOptionsFile

      protected static final boolean isVMOptionsFile(File file)
    • isLaxFile

      protected static final boolean isLaxFile(File file)
    • isPListFile

      protected static final boolean isPListFile(File file)
    • actionPerformed

      public void actionPerformed(ActionEvent ae)
      Reads event from one of the buttons to perform that buttons action. Buttons include OK, Cancel, Use Preferences and HELP
      Specified by:
      actionPerformed in interface ActionListener
      Overrides:
      actionPerformed in class JDialogBase
      Parameters:
      ae - The button's fired action event.
    • buildButtons

      public JPanel buildButtons(boolean includePrefs)
      creates the buttons, USE PREFERENCES, OKAY, CANCEL, and HELP. Over-rides
      invalid reference
      JDialog#buildButtons()
      if includesPrefs is false, otherwise, it returns what JDialog#buildButtons() returns.
      Parameters:
      includePrefs - If the preferences are available, the "Use Preferences" button is added to the panel when it is returned.
      Returns:
      A JPanel which holds the buttons for user input.
    • convertBytesToMBytes

      protected static String convertBytesToMBytes(String byteString) throws NumberFormatException
      convert the number given by the string (assuming it is a number indicating a quantity of bytes) to a number indicating a quantity of megabytes. If the input is improperly formatted it throws a NumberFormatException.
      Parameters:
      byteString - a number indicating a quantity of bytes
      Returns:
      String a number indicating the rounded value of the input as a megabyte
      Throws:
      NumberFormatException - if the byteString cannot be represented as a number.
    • convertBytesToGBytes

      protected static String convertBytesToGBytes(String byteString) throws NumberFormatException
      convert the number given by the string (assuming it is a number indicating a quantity of bytes) to a number indicating a quantity of gigabytes. If the input is improperly formatted it throws a NumberFormatException.
      Parameters:
      byteString - a number indicating a quantity of bytes
      Returns:
      String a number indicating the rounded value of the input as a gigabyte
      Throws:
      NumberFormatException - if the byteString cannot be represented as a number.
    • convertKBytesToMBytes

      protected static String convertKBytesToMBytes(String kilobyteString) throws NumberFormatException
      convert the number given by the string (assuming it is a number indicating a quantity of kilabytes) to a number indicating a quantity of megabytes. If the input is improperly formatted it throws a NumberFormatException.
      Parameters:
      kilobyteString - a number indicating a quantity of kilobytes
      Returns:
      String a number indicating the rounded value of the input as a byte
      Throws:
      NumberFormatException - DOCUMENT ME!
    • convertMBytesToGBytes

      protected static String convertMBytesToGBytes(String megabyteString) throws NumberFormatException
      convert the number given by the string (assuming it is a number indicating a quantity of megabytes) to a number indicating a quantity of gigabytes. If the input is improperly formatted it throws a NumberFormatException.
      Parameters:
      kilobyteString - a number indicating a quantity of megabytes
      Returns:
      String a number indicating the rounded value of the input in gigabytes
      Throws:
      NumberFormatException - DOCUMENT ME!
    • convertGBytesToMBytes

      protected static String convertGBytesToMBytes(String gigabyteString) throws NumberFormatException
      convert the number given by the string (assuming it is a number indicating a quantity of gigabytes) to a number indicating a quantity of megabytes. If the input is improperly formatted it throws a NumberFormatException.
      Parameters:
      kilobyteString - a number indicating a quantity of gigabytes
      Returns:
      String a number indicating the rounded value of the input in megabytes
      Throws:
      NumberFormatException - DOCUMENT ME!
    • convertKBytesToGBytes

      protected static String convertKBytesToGBytes(String kilobyteString) throws NumberFormatException
      convert the number given by the string (assuming it is a number indicating a quantity of kilabytes) to a number indicating a quantity of gigabytes. If the input is improperly formatted it throws a NumberFormatException.
      Parameters:
      kilobyteString - a number indicating a quantity of kilobytes
      Returns:
      String a number indicating the rounded value of the input as gigabytes
      Throws:
      NumberFormatException - DOCUMENT ME!
    • convertMBytesToBytes

      protected static String convertMBytesToBytes(String megabyteString) throws NumberFormatException
      convert the number given by the string (assuming it is a number indicating a quantity of megabytes) to a number indicating a quantity of bytes. If the input is improperly formatted it throws a NumberFormatException.
      Parameters:
      megabyteString - a number indicating a quantity of megabytes
      Returns:
      String a number indicating the rounded value of the input as a byte
      Throws:
      NumberFormatException - DOCUMENT ME!
    • convertGBytesToBytes

      protected static String convertGBytesToBytes(String gigabyteString) throws NumberFormatException
      convert the number given by the string (assuming it is a number indicating a quantity of gigabytes) to a number indicating a quantity of bytes. If the input is improperly formatted it throws a NumberFormatException.
      Parameters:
      megabyteString - a number indicating a quantity of gigabytes
      Returns:
      String a number indicating the rounded value of the input as a byte
      Throws:
      NumberFormatException - DOCUMENT ME!
    • interpretLAX

      protected static String[] interpretLAX(String line)
      reads the given line of a LAX file to search for the initial heap size and maximum heap size Strings.

      if the line starts with initial or max size strings given by initHeapLAX or maxHeapLAX, the value is converted into megabytes and loaded into the appropriate textBox.

      If the value found is not possible (ie., the conversion threw a NumberFormatException), the substitute "1" is given.

      Parameters:
      line - A line of a LAX file which is to be searched for the memory strings.
      Returns:
      the heap string, including LAX file variable name, the value in the text box as it would be found in the file.
    • interpretXML

      protected static String[] interpretXML(String line)
      reads the given line of a plist file to search for the initial heap size and maximum heap size Strings.

      If the file contains the "-X" java option the value is parsed out. the value is converted into megabytes, if needed and loaded into the appropriate textBox.

      If the value found is not possible (ie., the conversion threw a NumberFormatException), the substitute "1" is given.

      Parameters:
      line - A line of an XML file which is to be searched for the memory strings.
      Returns:
      the heap string, including XML formatting, the value in the text box as it would be found in the file.
    • createInputPanel

      protected JPanel createInputPanel(boolean usePrefs)
      creates the main panel with all the inputs.. argument true includes preferences if available. argument false does not include preferences ever.
      Parameters:
      usePrefs - Whether or not to include the preferences, if available.
      Returns:
      DOCUMENT ME!
    • writeStartOptionsFile

      protected void writeStartOptionsFile() throws IOException
      Throws:
      IOException
    • writeVMOptionsFile

      protected void writeVMOptionsFile(File vmoptionsFile) throws IOException
      Write out changes to the vmoptions file used to set the VM max heap size.
      Throws:
      IOException - DOCUMENT ME!
    • writePlistOptionsFile

      protected void writePlistOptionsFile() throws IOException
      write startup options file which is used during InstallAnywhere to run the executable. The starting options file it writes out is the one which would be native to the system (that is, on Windows or UNIX systems, the startup file is a LAX file; on the Macintosh OS 10 systems, it is the Info.plist file) as determined when by during dialog instantiation. This method writes initHeapText and maxHeapText to the appropriate start and max values.
      Throws:
      IOException - DOCUMENT ME!
    • writeLaxOptionsFile

      protected void writeLaxOptionsFile() throws IOException
      write startup options file which is used during InstallAnywhere to run the executable. The starting options file it writes out is the one which would be native to the system (that is, on Windows or UNIX systems, the startup file is a LAX file; on the Macintosh OS 10 systems, it is the Info.plist file) as determined when by during dialog instantiation. This method writes initHeapText and maxHeapText to the appropriate start and max values.
      Throws:
      IOException - DOCUMENT ME!
    • replacePatternMultiline

      protected static String replacePatternMultiline(String regex, String origStr, String replaceVal)