Class TextConsole
- All Implemented Interfaces:
IConsole
- Direct Known Subclasses:
IOConsole
Pattern match listeners can be registered with a console programmatically
or via the org.eclipse.ui.console.consolePatternMatchListeners
extension point.
Clients may subclass this class. Subclasses must provide a document partitioner.
- Since:
- 3.1
-
Constructor Summary
ConstructorDescriptionTextConsole
(String name, String consoleType, ImageDescriptor imageDescriptor, boolean autoLifecycle) Constructs a console with the given name, image descriptor, and lifecycle -
Method Summary
Modifier and TypeMethodDescriptionvoid
addHyperlink
(IHyperlink hyperlink, int offset, int length) Adds a hyperlink to this console.void
addPatternMatchListener
(IPatternMatchListener listener) Adds the given pattern match listener to this console.void
Clears the console.createPage
(IConsoleView view) Creates and returns a new page for this console.protected void
dispose()
Called when this console is removed from the console manager.getAttribute
(String key) Returns the attribute associated with the specified key.Returns the background color to use for this console ornull
for the default background color.int
Returns the current width of this console.Returns this console's document.getFont()
Returns the font used by this console.getHyperlink
(int offset) Returns the hyperlink at the given offset ornull
if none.Returns all hyperlinks in this console.protected abstract IConsoleDocumentPartitioner
Returns the console's document partitioner.getRegion
(IHyperlink link) Returns the region associated with the given hyperlink.Returns a scheduling rule which can be used to prevent jobs from running while this console's pattern matcher is active.int
Returns the tab width used in this console.protected void
init()
Called when this console is added to the console manager.boolean
Returns the user preference for enabling auto scroll lock feature.void
Called by this console's pattern matcher when matching is complete.void
This console's partitioner should call this method when it is not expecting any new data to be appended to the document.void
Removes the given pattern match listener from this console.void
setAttribute
(String key, Object value) Sets an attribute value.void
setBackgrond
(Color background) Deprecated.use setBackground(Color) insteadvoid
setBackground
(Color background) Sets the background color used by this console.void
setConsoleAutoScrollLock
(boolean autoScrollLockPref) Sets the auto scroll lock preference.void
setConsoleWidth
(int width) Sets the width of this console in characters.void
Sets the font used by this console.void
setTabWidth
(int newTabWidth) Sets the tab width used in this console.Methods inherited from class org.eclipse.ui.console.AbstractConsole
activate, addPropertyChangeListener, destroy, firePropertyChange, getHelpContextId, getImageDescriptor, getName, getType, initialize, removePropertyChangeListener, setImageDescriptor, setName, setType
-
Constructor Details
-
TextConsole
public TextConsole(String name, String consoleType, ImageDescriptor imageDescriptor, boolean autoLifecycle) Constructs a console with the given name, image descriptor, and lifecycle- Parameters:
name
- name to display for this consoleconsoleType
- console type identifier ornull
imageDescriptor
- image to display for this console ornull
autoLifecycle
- whether lifecycle methods should be called automatically when this console is added/removed from the console manager
-
-
Method Details
-
dispose
protected void dispose()Description copied from class:AbstractConsole
Called when this console is removed from the console manager. Default implementation does nothing. Subclasses may override.Since 3.1, this methods is only called automatically if this console was created with an automatic lifecycle.
- Overrides:
dispose
in classAbstractConsole
-
createPage
Description copied from interface:IConsole
Creates and returns a new page for this console. The page is displayed for this console in the console given view.- Parameters:
view
- the view in which the page is to be created- Returns:
- a page book view page representation of this console
-
getDocument
Returns this console's document.Note that a console may or may not support direct manipulation of its document. For example, an I/O console document and its partitions are produced from the streams connected to it, and clients are not intended to modify the document's contents.
- Returns:
- this console's document
-
getConsoleWidth
public int getConsoleWidth()Returns the current width of this console. A value of zero of less indicates this console has no fixed width.- Returns:
- the current width of this console
-
isConsoleAutoScrollLock
public boolean isConsoleAutoScrollLock()Returns the user preference for enabling auto scroll lock feature.- Returns:
- auto scroll lock
- Since:
- 3.8
-
setConsoleAutoScrollLock
public void setConsoleAutoScrollLock(boolean autoScrollLockPref) Sets the auto scroll lock preference.- Parameters:
autoScrollLockPref
- enable auto scroll lock preference.- Since:
- 3.8
-
init
protected void init()Description copied from class:AbstractConsole
Called when this console is added to the console manager. Default implementation does nothing. Subclasses may override.Since 3.1, this method is only called automatically if this console was created with an automatic lifecycle.
- Overrides:
init
in classAbstractConsole
-
setConsoleWidth
public void setConsoleWidth(int width) Sets the width of this console in characters. Any value greater than zero will cause this console to have a fixed width.- Parameters:
width
- the width to make this console. Values of 0 or less imply the console does not have any fixed width.
-
setTabWidth
public void setTabWidth(int newTabWidth) Sets the tab width used in this console.- Parameters:
newTabWidth
- the tab width
-
getTabWidth
public int getTabWidth()Returns the tab width used in this console.- Returns:
- tab width used in this console
-
getFont
Returns the font used by this console. Must be called in the UI thread.- Returns:
- font used by this console
-
setFont
Sets the font used by this console. Specifynull
to use the default text font.- Parameters:
newFont
- font, ornull
to indicate the default font
-
setBackgrond
Deprecated.use setBackground(Color) insteadSets the background color used by this console. Specifynull
to use the default background color.- Parameters:
background
- background color ornull
for default- Since:
- 3.3
-
setBackground
Sets the background color used by this console. Specifynull
to use the default background color.- Parameters:
background
- background color ornull
for default- Since:
- 3.3
-
getBackground
Returns the background color to use for this console ornull
for the default background color.- Returns:
- background color or
null
for default - Since:
- 3.3
-
clearConsole
public void clearConsole()Clears the console.Since a console may or may not support direct manipulation of its document's contents, this method should be called to clear a text console's document. The default implementation sets this console's document content to the empty string directly. Subclasses should override as required.
-
getPartitioner
Returns the console's document partitioner.- Returns:
- The console's document partitioner
-
getHyperlinks
Returns all hyperlinks in this console.- Returns:
- all hyperlinks in this console
-
getHyperlink
Returns the hyperlink at the given offset ornull
if none.- Parameters:
offset
- offset for which a hyperlink is requested- Returns:
- the hyperlink at the given offset or
null
if none
-
addPatternMatchListener
Adds the given pattern match listener to this console. The listener will be connected and receive match notifications. Has no effect if an identical listener has already been added.- Parameters:
listener
- the listener to add
-
removePatternMatchListener
Removes the given pattern match listener from this console. The listener will be disconnected and will no longer receive match notifications. Has no effect if the listener was not previously added.- Parameters:
listener
- the pattern match listener to remove
-
getSchedulingRule
Returns a scheduling rule which can be used to prevent jobs from running while this console's pattern matcher is active.Although this scheduling rule prevents jobs from running at the same time as pattern matching jobs for this console, it does not enforce any ordering of jobs. Since 3.2, pattern matching jobs belong to the job family identified by the console object that matching is occurring on. To ensure a job runs after all scheduled pattern matching is complete, clients must join on this console's job family.
- Returns:
- a scheduling rule which can be used to prevent jobs from running while this console's pattern matcher is active
-
partitionerFinished
public void partitionerFinished()This console's partitioner should call this method when it is not expecting any new data to be appended to the document. -
matcherFinished
public void matcherFinished()Called by this console's pattern matcher when matching is complete.Clients should not call this method.
-
addHyperlink
Adds a hyperlink to this console.- Parameters:
hyperlink
- the hyperlink to addoffset
- the offset in the console document at which the hyperlink should be addedlength
- the length of the text which should be hyperlinked- Throws:
BadLocationException
- if the specified location is not valid.
-
getRegion
Returns the region associated with the given hyperlink.- Parameters:
link
- hyperlink- Returns:
- the region associated with the hyperlink or null if the hyperlink is not found.
-
getAttribute
Returns the attribute associated with the specified key.- Parameters:
key
- attribute key- Returns:
- the attribute associated with the specified key
-
setAttribute
Sets an attribute value. Intended for client data.- Parameters:
key
- attribute keyvalue
- attribute value
-