Interface ICommandLauncher

  • All Known Implementing Classes:
    CommandLauncher

    public interface ICommandLauncher
    An interface for launchers of external commands.
    Since:
    5.1
    • Method Summary

      All Methods Instance Methods Abstract Methods Deprecated Methods 
      Modifier and Type Method Description
      java.lang.Process execute​(org.eclipse.core.runtime.IPath commandPath, java.lang.String[] args, java.lang.String[] env, org.eclipse.core.runtime.IPath workingDirectory, org.eclipse.core.runtime.IProgressMonitor monitor)
      Execute a command
      java.lang.String[] getCommandArgs()
      Returns an array of the command line arguments that were last used to execute a command.
      java.lang.String getCommandLine()
      Returns the constructed command line of the last command executed.
      java.util.Properties getEnvironment()
      Returns the set of environment variables in the context of which this launcher will execute commands.
      java.lang.String getErrorMessage()
      Returns a human readable error message corresponding to the last error encountered during command execution.
      org.eclipse.core.resources.IProject getProject()
      Gets the project this launcher is associated with.
      void setErrorMessage​(java.lang.String error)
      Sets the human readable error message corresponding to the last error encountered during command execution.
      void setProject​(org.eclipse.core.resources.IProject project)
      Sets the project that this launcher is associated with, or null if there is no such project.
      void showCommand​(boolean show)
      Sets if the command should be printed out first before executing.
      int waitAndRead​(java.io.OutputStream out, java.io.OutputStream err)
      int waitAndRead​(java.io.OutputStream output, java.io.OutputStream err, org.eclipse.core.runtime.IProgressMonitor monitor)
      Reads output form the process to the streams.
    • Method Detail

      • setProject

        void setProject​(org.eclipse.core.resources.IProject project)
        Sets the project that this launcher is associated with, or null if there is no such project.
        Parameters:
        project -
      • getProject

        org.eclipse.core.resources.IProject getProject()
        Gets the project this launcher is associated with.
        Returns:
        IProject, or null if there is no such project.
      • showCommand

        void showCommand​(boolean show)
        Sets if the command should be printed out first before executing.
      • getErrorMessage

        java.lang.String getErrorMessage()
        Returns a human readable error message corresponding to the last error encountered during command execution.
        Returns:
        A String corresponding to the error, or null if there has been no error. The message could be multi-line, however it is NOT guaranteed that it ends with end of line.
      • setErrorMessage

        void setErrorMessage​(java.lang.String error)
        Sets the human readable error message corresponding to the last error encountered during command execution. A subsequent call to getErrorMessage() will return this string.
        Parameters:
        error - A String corresponding to the error message, or null if the error state is intended to be cleared.
      • getCommandArgs

        java.lang.String[] getCommandArgs()
        Returns an array of the command line arguments that were last used to execute a command.
        Returns:
        an array of type String[] corresponding to the arguments. The array can be empty, but should not be null.
      • getEnvironment

        java.util.Properties getEnvironment()
        Returns the set of environment variables in the context of which this launcher will execute commands.
        Returns:
        Properties
      • getCommandLine

        java.lang.String getCommandLine()
        Returns the constructed command line of the last command executed.
        Returns:
        String
      • execute

        java.lang.Process execute​(org.eclipse.core.runtime.IPath commandPath,
                                  java.lang.String[] args,
                                  java.lang.String[] env,
                                  org.eclipse.core.runtime.IPath workingDirectory,
                                  org.eclipse.core.runtime.IProgressMonitor monitor)
                           throws org.eclipse.core.runtime.CoreException
        Execute a command
        Parameters:
        env - The list of environment variables in variable=value format.
        Throws:
        org.eclipse.core.runtime.CoreException - if there is an error executing the command.
      • waitAndRead

        int waitAndRead​(java.io.OutputStream output,
                        java.io.OutputStream err,
                        org.eclipse.core.runtime.IProgressMonitor monitor)
        Reads output form the process to the streams. A progress monitor is polled to test if the cancel button has been pressed. Destroys the process if the monitor becomes canceled override to implement a different way to read the process inputs