console
Class SystemShell

java.lang.Object
  extended by console.Shell
      extended by console.SystemShell
All Implemented Interfaces:
java.util.EventListener, org.gjt.sp.util.TaskListener

public class SystemShell
extends Shell
implements org.gjt.sp.util.TaskListener

A SystemShell is shared across all instances of Console. It has own environment (variables), and executes system statements in a shell which resembles in terms of user interface, something that is a cross between the Windows "cmd.exe" and the Linux bash shell, so it should be easy to use for both. It manages a mapping of Console to ConsoleState objects, where the ConsoleState manages the actual ConsoleProcess and the state of that shell. When SystemShell executes something, the process itself is started indirectly by ProcessRunner.exec().

Author:
1999, 2005 Slava Pestov, 2006, 2009 Alan Ezust

Nested Class Summary
 
Nested classes/interfaces inherited from class console.Shell
Shell.CompletionInfo, Shell.ShellAction, Shell.SwitchAction, Shell.ToggleAction
 
Field Summary
 
Fields inherited from class console.Shell
SERVICE
 
Constructor Summary
SystemShell()
           
 
Method Summary
 void beforeStopping()
           
 boolean chDir(Console console, java.lang.String path)
          A System Shell can override this method if it can respond to chDir messages
 void closeConsole(Console console)
          Called when a Console dockable is closed.
 void detach(Console console)
          Detaches the currently running process.
 void done(org.gjt.sp.util.Task task)
           
 void endOfFile(Console console)
          Sends an end of file.
 void execute(Console console, java.lang.String input, Output output, Output error, java.lang.String command)
          Executes a command.
 void executeBuiltIn(Console console, Output output, Output error, java.lang.String command, java.util.Vector<java.lang.String> args)
           
 java.util.Hashtable<java.lang.String,java.lang.String> getAliases()
           
 Shell.CompletionInfo getCompletions(Console console, java.lang.String command)
          Returns possible completions for the specified command.
 java.lang.String getVariableValue(org.gjt.sp.jedit.View view, java.lang.String varName)
           
 boolean handlesVFS(java.lang.String vfsPath)
          A System Shell can override this method and use any criteria at all to decide whether this is a path that is preferred by this shell.
 void maximumUpdated(org.gjt.sp.util.Task task)
           
 void openConsole(Console console)
          Called when a Console dockable first selects this shell.
 void printInfoMessage(Output output)
          Prints a 'info' message to the specified console.
 void printPrompt(Console console, Output output)
          Prints a prompt to the specified console.
 void running(org.gjt.sp.util.Task task)
           
 void statusUpdated(org.gjt.sp.util.Task task)
           
 void stop(Console console)
          Stops the currently executing command, if any.
 void valueUpdated(org.gjt.sp.util.Task task)
           
 boolean waitFor(Console console)
          Waits for currently running Console processes to finish execution.
 void waiting(org.gjt.sp.util.Task task)
           
 
Methods inherited from class console.Shell
execute, getName, getShell, getShellNames, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SystemShell

public SystemShell()
Method Detail

beforeStopping

public void beforeStopping()

openConsole

public void openConsole(Console console)
Called when a Console dockable first selects this shell.

Overrides:
openConsole in class Shell
Since:
Console 4.0.2

closeConsole

public void closeConsole(Console console)
Called when a Console dockable is closed.

Overrides:
closeConsole in class Shell
Since:
Console 4.0.2

printInfoMessage

public void printInfoMessage(Output output)
Description copied from class: Shell
Prints a 'info' message to the specified console.

Overrides:
printInfoMessage in class Shell
Parameters:
output - The output

printPrompt

public void printPrompt(Console console,
                        Output output)
Prints a prompt to the specified console.

Overrides:
printPrompt in class Shell
Parameters:
output - The output
console - The console instance

executeBuiltIn

public void executeBuiltIn(Console console,
                           Output output,
                           Output error,
                           java.lang.String command,
                           java.util.Vector<java.lang.String> args)

handlesVFS

public boolean handlesVFS(java.lang.String vfsPath)
Description copied from class: Shell
A System Shell can override this method and use any criteria at all to decide whether this is a path that is preferred by this shell.

Overrides:
handlesVFS in class Shell
Parameters:
vfsPath - the path to test if this shell handles
Returns:
true if this shell is preferred for handling a path that looks like vfsPath

chDir

public boolean chDir(Console console,
                     java.lang.String path)
Description copied from class: Shell
A System Shell can override this method if it can respond to chDir messages

Overrides:
chDir in class Shell
path - vfs path to change directory
Returns:
true if the function did something, false if not.

execute

public void execute(Console console,
                    java.lang.String input,
                    Output output,
                    Output error,
                    java.lang.String command)
Description copied from class: Shell
Executes a command. Override this abstract method in custom derived classes.

Specified by:
execute in class Shell
Parameters:
console - The Console instance, to distinguish it from others when there are multiple View or Console instances.
input - optional string to feed into the command's Standard input
output - Standard output - the destination to send output
error - Standard error - the destionation to send error messages
command - The command

stop

public void stop(Console console)
Description copied from class: Shell
Stops the currently executing command, if any. When the user clicks the "stop" button on the console, this method is called.

Overrides:
stop in class Shell
Parameters:
console - the same Console instance that was passed to execute()

waitFor

public boolean waitFor(Console console)
Waits for currently running Console processes to finish execution.

Overrides:
waitFor in class Shell
Parameters:
console - the same Console instance that was passed to execute()
Returns:
true if all was successful (i.e. the error status code was 0)

endOfFile

public void endOfFile(Console console)
Sends an end of file.

Overrides:
endOfFile in class Shell
Parameters:
console - The console

detach

public void detach(Console console)
Detaches the currently running process.

Overrides:
detach in class Shell
Parameters:
console - The console

getCompletions

public Shell.CompletionInfo getCompletions(Console console,
                                           java.lang.String command)
Returns possible completions for the specified command.

Overrides:
getCompletions in class Shell
Parameters:
console - The console instance
command - The command
Since:
Console 3.6

getVariableValue

public java.lang.String getVariableValue(org.gjt.sp.jedit.View view,
                                         java.lang.String varName)

getAliases

public java.util.Hashtable<java.lang.String,java.lang.String> getAliases()

waiting

public void waiting(org.gjt.sp.util.Task task)
Specified by:
waiting in interface org.gjt.sp.util.TaskListener

running

public void running(org.gjt.sp.util.Task task)
Specified by:
running in interface org.gjt.sp.util.TaskListener

done

public void done(org.gjt.sp.util.Task task)
Specified by:
done in interface org.gjt.sp.util.TaskListener

maximumUpdated

public void maximumUpdated(org.gjt.sp.util.Task task)
Specified by:
maximumUpdated in interface org.gjt.sp.util.TaskListener

valueUpdated

public void valueUpdated(org.gjt.sp.util.Task task)
Specified by:
valueUpdated in interface org.gjt.sp.util.TaskListener

statusUpdated

public void statusUpdated(org.gjt.sp.util.Task task)
Specified by:
statusUpdated in interface org.gjt.sp.util.TaskListener