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.
Modifier and Type | Class and Description |
---|---|
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.
|
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
SERVICE |
Constructor and Description |
---|
Shell(java.lang.String name) |
Modifier and Type | Method and Description |
---|---|
boolean |
chDir(Console console,
java.lang.String pathStr)
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 |
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 service singleton with the specified name
|
static java.lang.String[] |
getShellNames()
Returns an array of all registered shells.
|
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 |
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 |
stop(Console console)
Stops the currently executing command, if any.
|
java.lang.String |
toString()
Returns the name of the shell.
|
boolean |
waitFor(Console console)
Waits until any currently executing commands finish.
|
public static final java.lang.String SERVICE
public static java.lang.String[] getShellNames()
public boolean handlesVFS(java.lang.String vfsPath)
vfsPath
- the path to test if this shell handlespublic boolean chDir(Console console, java.lang.String pathStr)
pathStr
- vfs path to change directorypublic static Shell getShell(java.lang.String name)
name
- The shell name. Common values are:
"System", "BeanShell", "Factor", "Ant", "Python", etc....public void openConsole(Console console)
public void closeConsole(Console console)
public void printInfoMessage(Output output)
output
- The outputpublic void printPrompt(Console console, Output output)
console
- The console instanceoutput
- The outputpublic abstract void execute(Console console, java.lang.String input, Output output, Output error, java.lang.String command)
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 inputoutput
- Standard output - the destination to send outputerror
- Standard error - the destionation to send error messagescommand
- The commandpublic final void execute(Console console, java.lang.String command, Output output)
public void stop(Console console)
console
- the same Console instance that was passed to execute()public boolean waitFor(Console console)
console
- the same Console instance that was passed to execute()public void endOfFile(Console console)
console
- the same Console instance that was passed to execute()public void detach(Console console)
console
- the same Console instance that was passed to execute()public Shell.CompletionInfo getCompletions(Console console, java.lang.String command)
console
- The console instancecommand
- The commandpublic java.lang.String getName()
public java.lang.String toString()
toString
in class java.lang.Object