public interface CamelCaseInterceptor
KeyEvent
s that reach the default editor actions bound to
CTRL+DEL, CTRL+BACKSPACE, CTRL+RIGHT_ARROW, CTRL+LEFT_ARROW, CTRL+SHIFT+RIGHT_ARROW, CTRL+SHIFT+LEFT_ARROW events.
When you set nextWordOffset, the implementation deletes/jumps according to this value. If value is not set or set to -1, the default implementation of camel case action is performed.
Registration: CamelCaseInterceptor
s can be plugged in the editor infrastructure
by implementing the CamelCaseInterceptor.Factory
interface and registering it in MimeLookup
under the appropriate mimetype (ie. MimePath
).
The instances created from the Factory
will be reused for processing
the relevant key events received by all documents of the same mime type, which the interceptor
instances were registered for (including documents that contain embedded sections
of that mime type). As described in the general concepts of Typing Hooks SPI
the interceptors are guaranteed to be called in AWT thread only, which means that
they should not need any internal synchronization model.
Processing rules: If there are multiple instances of CamelCaseInterceptor
registered
for the same mime type the infrastructure will queue them up in their registration
order and when processing an event it will call them all until the processing is done
or terminated.
The interceptor has several methods that are called at different stages of the key typed event processing. When processing an event the infrastructure will call the methods in the order as they are listed below. Moreover if there are multiple interceptors queued up for processing an event each method is first called on all the queued interceptors before moving on to the next stage and calling next method.
Errors recovery: If an exception is thrown from any of the methods when calling an interceptor the infrastructure will catch it and log it, but it will not stop further processing. The infrastructure may blacklist the offending interceptor and exclude it from processing future events.
Modifier and Type | Interface and Description |
---|---|
static interface |
CamelCaseInterceptor.Factory
The factory interface for registering
CamelCaseInterceptor s
in MimeLookup . |
static class |
CamelCaseInterceptor.MutableContext
The context class providing information about the edited document, its
editor pane and the offset where the key event occurred.
|
Modifier and Type | Method and Description |
---|---|
void |
afterChange(CamelCaseInterceptor.MutableContext context)
This method is called after text is removed from a document and/or its editor's
caret is adjusted.
|
boolean |
beforeChange(CamelCaseInterceptor.MutableContext context)
This method is called before any text is removed from a document or before caret move.
|
void |
cancelled(CamelCaseInterceptor.MutableContext context)
This method is called when the normal processing is terminated by some
interceptor's
beforeChange method. |
void |
change(CamelCaseInterceptor.MutableContext context)
This method is called immediately after the text is removed from a document or caret is moved.
|
boolean beforeChange(CamelCaseInterceptor.MutableContext context) throws BadLocationException
This method can be used for stopping further processing of the current
key typed event. If this method returns true
the processing will
be terminated and CamelCaseInterceptor.cancelled(CamelCaseInterceptor.MutableContext)
will be called for all the interceptors
that have already had their beforeRemove
method called (including
the one that terminated the processing). The rest of the interceptors waiting
in the queue will not be called at all.
Locking: When this method is called the document is not locked by the infrastructure.
context
- The context object providing information necessary for processing
the event.true
the further processing will be stopped. Normally
the method should return false
.BadLocationException
- Since the document is not locked prior calling this
method the processing may fail when working with stale context data.void change(CamelCaseInterceptor.MutableContext context) throws BadLocationException
Context
object
passed in this method. The document is write-locked.
Locking: When this method is called the infrastructure has already write locked the document.
context
- The context object providing information necessary for processing
the event and allowing to modify the edited document.BadLocationException
- If the processing fails.void afterChange(CamelCaseInterceptor.MutableContext context) throws BadLocationException
Locking: When this method is called the document is not locked by the infrastructure.
context
- The context object providing information necessary for processing
the event. The Context.getText()
method will return text that was
removed from the document at the beginning of the text-removal stage.BadLocationException
- Since the document is not locked prior calling this
method the processing may fail when working with stale context data.void cancelled(CamelCaseInterceptor.MutableContext context)
beforeChange
method. Please note that this
method will not be called if the beforeChange
method was not
called.context
- The context object used for calling the beforeChange
method.