Class PlatformUtils

java.lang.Object
dk.gtz.graphedit.util.PlatformUtils

public class PlatformUtils extends Object
General utilities relating to the operating system
  • Method Summary

    Modifier and Type
    Method
    Description
    static boolean
    Check if the current running platform is running a GTK-based desktop environment - think the GNOME desktop environment
    static boolean
    Check if the current running platform is Apple OSX
    static boolean
    isProgramInstalled(String executableName)
    Check if a command-line program is installed on the current running platform Note that this may not work on Microsoft Windows
    static boolean
    Check if the menu bar can be delegated to the OS to handle.
    static boolean
    Check if the current running platform is a UNIX-like OS - think GNU/Linux
    static boolean
    Check if the current running platform is Microsoft Windows
    static void
    launchProgram(String command, String... arguments)
    Launch a new subprocess and wait for it to complete whilst logging the stout to TRACE-level and stderr to ERROR-level logging.
    static void
    launchProgram(String command, String workingDir, List<String> arguments)
    Launch a new subprocess and wait for it to complete whilst logging the stout to TRACE-level and stderr to ERROR-level logging.
    static void
    launchProgram(String command, List<String> arguments)
    Launch a new subprocess and wait for it to complete whilst logging the stout to TRACE-level and stderr to ERROR-level logging.
    static String
    Remove the file-extension part of a filename string.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • isSystemMenuBarSupported

      public static boolean isSystemMenuBarSupported()
      Check if the menu bar can be delegated to the OS to handle.
      Returns:
      true if the OS supports system menu bars
    • isWindows

      public static boolean isWindows()
      Check if the current running platform is Microsoft Windows
      Returns:
      true if current running platform is Microsoft Windows
    • isMac

      public static boolean isMac()
      Check if the current running platform is Apple OSX
      Returns:
      true if current running platform is Apple OSX
    • isUnix

      public static boolean isUnix()
      Check if the current running platform is a UNIX-like OS - think GNU/Linux
      Returns:
      true if current running platform is a UNIX-like OS
    • isGtk

      public static boolean isGtk()
      Check if the current running platform is running a GTK-based desktop environment - think the GNOME desktop environment
      Returns:
      true if the desktop environment is GTK-based
    • isProgramInstalled

      public static boolean isProgramInstalled(String executableName)
      Check if a command-line program is installed on the current running platform Note that this may not work on Microsoft Windows
      Parameters:
      executableName - The executable to check for
      Returns:
      true if the program is discoverable through the PATH variable, false otherwise
    • removeFileExtension

      public static String removeFileExtension(String fname)
      Remove the file-extension part of a filename string. Example: "myfile.txt" -> "myfile" Note that this will only remove the last file-extension, so if you have multiple, you have to call the function multiple times. Example: "myfile.ignore.txt" -> "myfile.ignore"
      Parameters:
      fname - the filename to modify
      Returns:
      the same filename as provided, but with the file extension removed. If there was no extension, simply return the same filename
    • launchProgram

      public static void launchProgram(String command, List<String> arguments)
      Launch a new subprocess and wait for it to complete whilst logging the stout to TRACE-level and stderr to ERROR-level logging. cwd is the root directory of the currently open project Note that this will block the current thread of execution until the command is completed.
      Parameters:
      command - The command to launch the subprocess with
      arguments - The command-line arguments to provide the subprocess with
    • launchProgram

      public static void launchProgram(String command, String... arguments)
      Launch a new subprocess and wait for it to complete whilst logging the stout to TRACE-level and stderr to ERROR-level logging. cwd is the root directory of the currently open project Note that this will block the current thread of execution until the command is completed.
      Parameters:
      command - The command to launch the subprocess with
      arguments - The command-line arguments to provide the subprocess with
    • launchProgram

      public static void launchProgram(String command, String workingDir, List<String> arguments)
      Launch a new subprocess and wait for it to complete whilst logging the stout to TRACE-level and stderr to ERROR-level logging. Note that this will block the current thread of execution until the command is completed.
      Parameters:
      command - The command to launch the subprocess with
      workingDir - The working directory to launch the subprocess in
      arguments - The command-line arguments to provide the subprocess with