console
Class Shell

java.lang.Object
  extended by console.Shell
Direct Known Subclasses:
ConsoleBeanShell, SystemShell

public abstract class Shell
extends java.lang.Object

Console has a single dockable window, which can contain multiple Shells. Each Shell is named, and executes commands in a different language, and can be selected via a JComboBox in the upper left corner of the Console.

By default, each Console has two shells: A SystemShell and a BeanShell. Each of these shells was defined in services.xml, which looks like this:

  <SERVICES>
        <SERVICE CLASS="console.Shell" NAME="System">
                new console.SystemShell();
        </SERVICE>
        <SERVICE CLASS="console.Shell" NAME="BeanShell">
                new console.ConsoleBeanShell();
        </SERVICE>
</SERVICES>

To define a new Shell for your own plugin extend from this class, and return an instance of it from the beanshell code in services.xml.

Because it is a service, it is a singleton instance, shared by all for all Views and Console instances, and created only once while the plugin is loaded.

Version:
$Id: Shell.java 11122 2007-11-22 17:54:24Z ezust $
Author:
Slava Pestov

Nested Class Summary
static class Shell.CompletionInfo
           
static class Shell.ShellAction
          All ShellActions select a named Shell.
static class Shell.SwitchAction
          A SwitchAction selects a shell and makes Console visible.
static class Shell.ToggleAction
          A ToggleAction is a ShellAction which also toggles the visibility of the Console.
 
Field Summary
static java.lang.String SERVICE
           
 
Constructor Summary
Shell(java.lang.String name)
           
 
Method Summary
 void closeConsole(Console console)
          Called when a Console dockable is closed.
 void detach(Console console)
          Detaches the currently running process.
 void endOfFile(Console console)
          Sends an end of file.
 void execute(Console console, java.lang.String command, Output output)
          A convenience function - you do not override this method.
abstract  void execute(Console console, java.lang.String input, Output output, Output error, java.lang.String command)
          Executes a command.
 Shell.CompletionInfo getCompletions(Console console, java.lang.String command)
          Returns possible completions for the specified command.
 java.lang.String getName()
          Returns the name of the shell.
static Shell getShell(java.lang.String name)
          Returns the shell with the specified name
static java.lang.String[] getShellNames()
          Returns an array of all registered shells.
 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.
static void registerShell(Shell shell)
          Deprecated. Write a services.xml file instead.
 void stop(Console console)
          Stops the currently executing command, if any.
 java.lang.String toString()
          Returns the name of the shell.
static void unregisterShell(Shell shell)
          Deprecated. Write a services.xml file instead.
 boolean waitFor(Console console)
          Waits until any currently executing commands finish.
 void waitUntilDone()
          Deprecated. - see waitFor(Console)
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

SERVICE

public static final java.lang.String SERVICE
See Also:
Constant Field Values
Constructor Detail

Shell

public Shell(java.lang.String name)
Method Detail

registerShell

public static void registerShell(Shell shell)
Deprecated. Write a services.xml file instead.


unregisterShell

public static void unregisterShell(Shell shell)
Deprecated. Write a services.xml file instead.


getShellNames

public static java.lang.String[] getShellNames()
Returns an array of all registered shells.


getShell

public static Shell getShell(java.lang.String name)
Returns the shell with the specified name

Parameters:
name - The shell name. Common values are: "System", "BeanShell", "Factor", "Ant", "Python", etc....

openConsole

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

Since:
Console 4.0.2

closeConsole

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

Since:
Console 4.0.2

printInfoMessage

public void printInfoMessage(Output output)
Prints a 'info' message to the specified console.

Parameters:
output - The output

printPrompt

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

Parameters:
console - The console instance
output - The output
Since:
Console 3.6

execute

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

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
Since:
Console 3.5

execute

public final void execute(Console console,
                          java.lang.String command,
                          Output output)
A convenience function - you do not override this method.


waitUntilDone

public void waitUntilDone()
Deprecated. - see waitFor(Console)

What is this for? It doesn't seem to be used *anywhere*.


stop

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

Parameters:
console - the same Console instance that was passed to execute()

waitFor

public boolean waitFor(Console console)
Waits until any currently executing commands finish.

Parameters:
console - the same Console instance that was passed to execute()
Returns:
True if the most recent command exited successfully, false otherwise

endOfFile

public void endOfFile(Console console)
Sends an end of file. Called when Ctrl-D is typed from Console.

Parameters:
console - the same Console instance that was passed to execute()

detach

public void detach(Console console)
Detaches the currently running process. Called when Ctrl-Z is typed from the console.

Parameters:
console - the same Console instance that was passed to execute()

getCompletions

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

Parameters:
console - The console instance
command - The command
Since:
Console 3.6

getName

public java.lang.String getName()
Returns the name of the shell.


toString

public java.lang.String toString()
Returns the name of the shell.

Overrides:
toString in class java.lang.Object