Package dk.gtz.graphedit.util
Class PlatformUtils
java.lang.Object
dk.gtz.graphedit.util.PlatformUtils
General utilities relating to the operating system
-
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
isGtk()
Check if the current running platform is running a GTK-based desktop environment - think the GNOME desktop environmentstatic boolean
isMac()
Check if the current running platform is Apple OSXstatic 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 Windowsstatic boolean
Check if the menu bar can be delegated to the OS to handle.static boolean
isUnix()
Check if the current running platform is a UNIX-like OS - think GNU/Linuxstatic boolean
Check if the current running platform is Microsoft Windowsstatic 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
removeFileExtension
(String fname) Remove the file-extension part of a filename string.
-
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
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
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
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 witharguments
- The command-line arguments to provide the subprocess with
-
launchProgram
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 witharguments
- The command-line arguments to provide the subprocess with
-
launchProgram
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 withworkingDir
- The working directory to launch the subprocess inarguments
- The command-line arguments to provide the subprocess with
-