public class CommandEnv extends PropertySet
Modifier and Type | Field and Description |
---|---|
protected CommandRegistry |
commandRegistry |
protected Console |
console |
protected NavigationHistory |
navigationHistory |
protected Clipboard |
systemSelection |
protected Preferences |
userPreferences |
protected XMLClipboard |
xmlClipboard |
properties
Constructor and Description |
---|
CommandEnv()
Constructs an environment initialized using application-wide,
shared instances of user preferences, clipboard cache,
command registry, console, etc, but no navigation history.
|
CommandEnv(Preferences userPreferences,
XMLClipboard xmlClipboard,
Clipboard systemSelection,
CommandRegistry commandRegistry,
Console console,
NavigationHistory navigationHistory)
Constructs specified environment.
|
Modifier and Type | Method and Description |
---|---|
CommandRegistry |
getCommandRegistry()
Returns the command registry.
|
Console |
getConsole()
Returns the console.
|
Component |
getDialogParent(Component component)
Returns the parent of the dialog to be created by a command.
|
NavigationHistory |
getNavigationHistory()
Returns the navigation history.
|
static CommandEnv |
getSharedInstance()
Returns the shared instance of CommandEnv.
|
String |
getSystemProperty(String key)
Returns the value of specified system property.
|
Clipboard |
getSystemSelection()
Returns the system selection.
|
Preferences |
getUserPreferences()
Returns the user preferences.
|
XMLClipboard |
getXMLClipboard()
Returns the clipboard cache and thus, the underlying system clipboard.
|
void |
invokeLater(Runnable runnable)
Executes asynchronously specified task on the relevant thread.
|
void |
reportError(String msg)
Convenience method: prints specified error message on the console.
|
void |
reportInfo(String msg)
Same as
reportError(java.lang.String) but for info messages. |
void |
reportWarning(String msg)
Same as
reportError(java.lang.String) but for warning messages. |
static void |
setSharedInstance(CommandEnv env)
Installs the shared instance of CommandEnv.
|
String |
setSystemProperty(String key,
String value)
Sets or clears specified system property.
|
void |
showError(String msg,
Component component)
Convenience method: displays an error dialog box showing
specified error message when possible;
otherwise, prints message on the console.
|
void |
showInfo(String msg,
Component component)
Same as
showError(java.lang.String, java.awt.Component) but for info messages. |
void |
showStatus(Component component,
String message)
Equivalent to {#showStatus(Component, String, boolean)
showStatus(component, message, true)}.
|
void |
showStatus(Component component,
String message,
boolean autoErase)
Displays specified message in the status window corresponding
to specified panel.
|
void |
showWarning(String msg,
Component component)
Same as
showError(java.lang.String, java.awt.Component) but for warning messages. |
getProperties, getProperty, getPropertyCount, hasProperty, putProperties, putProperty, removeAllProperties, removeProperty
protected Preferences userPreferences
protected XMLClipboard xmlClipboard
protected Clipboard systemSelection
protected CommandRegistry commandRegistry
protected Console console
protected NavigationHistory navigationHistory
public CommandEnv()
public CommandEnv(Preferences userPreferences, XMLClipboard xmlClipboard, Clipboard systemSelection, CommandRegistry commandRegistry, Console console, NavigationHistory navigationHistory)
public String setSystemProperty(String key, String value)
key
- property namevalue
- property value; null
to clear the propertynull
otherwisepublic String getSystemProperty(String key)
key
- property namepublic Preferences getUserPreferences()
public XMLClipboard getXMLClipboard()
public Clipboard getSystemSelection()
public CommandRegistry getCommandRegistry()
public Console getConsole()
public void reportError(String msg)
getConsole()
public void reportWarning(String msg)
reportError(java.lang.String)
but for warning messages.public void reportInfo(String msg)
reportError(java.lang.String)
but for info messages.public NavigationHistory getNavigationHistory()
null
.public Component getDialogParent(Component component)
null
, in which case the command is expected to
be executed non-interactively.component
- any component which is a descendant of
current active Window; for example the panel hosting the gadget tree.
The default implementation uses this parameter but
some implementations may ignore it. In such case,
it is possible to pass null
.
public void showError(String msg, Component component)
msg
- the error messagecomponent
- any component which is a descendant of
current active Window; for example the panel hosting the gadget tree.
The default implementation uses this parameter but
some implementations may ignore it. In such case,
it is possible to pass null
.
getDialogParent(java.awt.Component)
,
reportError(java.lang.String)
public void showWarning(String msg, Component component)
showError(java.lang.String, java.awt.Component)
but for warning messages.public void showInfo(String msg, Component component)
showError(java.lang.String, java.awt.Component)
but for info messages.public void showStatus(Component component, String message)
public void showStatus(Component component, String message, boolean autoErase)
component
- any component which is a descendant of
current active Window; for example the panel hosting the gadget tree.
The default implementation uses this parameter but
some implementations may ignore it. In such case,
it is possible to pass null
.
message
- the message to be displayed; may be null
or
empty in which case the message area is immediately clearedautoErase
- if true
, instruct the application to
automatically erase the message after a few secondspublic void invokeLater(Runnable runnable)
The default implementation executes the task on the AWT event thread
by invoking EventQueue.invokeLater(java.lang.Runnable)
.
public static final void setSharedInstance(CommandEnv env)
getSharedInstance()
public static final CommandEnv getSharedInstance()
Creates and installs one if setSharedInstance(com.xmlmind.xmledit.edit.CommandEnv)
has never
been invoked or has been set to null
.