Class Program

java.lang.Object
org.eclipse.swt.program.Program

public final class Program extends Object
Instances of this class represent programs and their associated file extensions in the operating system.
See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    equals(Object other)
    Compares the argument to the receiver, and returns true if they represent the same object using a class specific comparison.
    boolean
    execute(String fileName)
    Executes the program with the file as the single argument in the operating system.
    static Program
    findProgram(String extension)
    Finds the program that is associated with an extension.
    static String[]
    Answer all program extensions in the operating system.
    Returns the receiver's image data at 100% zoom level.
    getImageData(int zoom)
    Returns the receiver's image data based on the given zoom level.
    Returns the receiver's name.
    static Program[]
    Answers all available programs in the operating system.
    int
    Returns an integer hash code for the receiver.
    static boolean
    launch(String fileName)
    Launches the operating system executable associated with the file or URL (http:// or https://).
    static boolean
    launch(String fileName, String workingDir)
    Launches the operating system executable associated with the file or URL (http:// or https://).
    Returns a string containing a concise, human-readable description of the receiver.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Method Details

    • findProgram

      public static Program findProgram(String extension)
      Finds the program that is associated with an extension. The extension may or may not begin with a '.'. Note that a Display must already exist to guarantee that this method returns an appropriate result.
      Parameters:
      extension - the program extension
      Returns:
      the program or null
      Throws:
      IllegalArgumentException -
      • ERROR_NULL_ARGUMENT when extension is null
    • getExtensions

      public static String[] getExtensions()
      Answer all program extensions in the operating system. Note that a Display must already exist to guarantee that this method returns an appropriate result.
      Returns:
      an array of extensions
    • getPrograms

      public static Program[] getPrograms()
      Answers all available programs in the operating system. Note that a Display must already exist to guarantee that this method returns an appropriate result.
      Returns:
      an array of programs
    • launch

      public static boolean launch(String fileName)
      Launches the operating system executable associated with the file or URL (http:// or https://). If the file is an executable then the executable is launched. Note that a Display must already exist to guarantee that this method returns an appropriate result.
      Parameters:
      fileName - the file or program name or URL (http:// or https://)
      Returns:
      true if the file is launched, otherwise false
      Throws:
      IllegalArgumentException -
      • ERROR_NULL_ARGUMENT when fileName is null
    • launch

      public static boolean launch(String fileName, String workingDir)
      Launches the operating system executable associated with the file or URL (http:// or https://). If the file is an executable then the executable is launched. The program is launched with the specified working directory only when the workingDir exists and fileName is an executable. Note that a Display must already exist to guarantee that this method returns an appropriate result.
      Parameters:
      fileName - the file name or program name or URL (http:// or https://)
      workingDir - the name of the working directory or null
      Returns:
      true if the file is launched, otherwise false
      Throws:
      IllegalArgumentException -
      • ERROR_NULL_ARGUMENT when fileName is null
      Since:
      3.6
    • execute

      public boolean execute(String fileName)
      Executes the program with the file as the single argument in the operating system. It is the responsibility of the programmer to ensure that the file contains valid data for this program.
      Parameters:
      fileName - the file or program name
      Returns:
      true if the file is launched, otherwise false
      Throws:
      IllegalArgumentException -
      • ERROR_NULL_ARGUMENT when fileName is null
    • getImageData

      public ImageData getImageData()
      Returns the receiver's image data at 100% zoom level. This is the icon that is associated with the receiver in the operating system.
      Returns:
      the image data for the program, may be null
    • getImageData

      public ImageData getImageData(int zoom)
      Returns the receiver's image data based on the given zoom level. This is the icon that is associated with the receiver in the operating system.
      Parameters:
      zoom - The zoom level in % of the standard resolution
      Returns:
      the image data for the program, may be null
      Since:
      3.125
    • getName

      public String getName()
      Returns the receiver's name. This is as short and descriptive a name as possible for the program. If the program has no descriptive name, this string may be the executable name, path or empty.
      Returns:
      the name of the program
    • equals

      public boolean equals(Object other)
      Compares the argument to the receiver, and returns true if they represent the same object using a class specific comparison.
      Overrides:
      equals in class Object
      Parameters:
      other - the object to compare with this object
      Returns:
      true if the object is the same as this object and false otherwise
      See Also:
    • hashCode

      public int hashCode()
      Returns an integer hash code for the receiver. Any two objects that return true when passed to equals must return the same value for this method.
      Overrides:
      hashCode in class Object
      Returns:
      the receiver's hash
      See Also:
    • toString

      public String toString()
      Returns a string containing a concise, human-readable description of the receiver.
      Overrides:
      toString in class Object
      Returns:
      a string representation of the program