Extension SDK 10.1.2

oracle.javatools.editor.plugins
Class BraceMatchingPlugin

java.lang.Object
  extended byoracle.javatools.editor.plugins.BraceMatchingPlugin
All Implemented Interfaces:
ActionHookInvoker, java.awt.event.ActionListener, javax.swing.event.CaretListener, javax.swing.event.DocumentListener, EditorPlugin, java.util.EventListener, java.beans.PropertyChangeListener

public final class BraceMatchingPlugin
extends java.lang.Object
implements ActionHookInvoker, java.awt.event.ActionListener, javax.swing.event.CaretListener, javax.swing.event.DocumentListener, EditorPlugin

The BraceMatchingPlugin provides support for brace matching in languages where the LanguageSupport provides an implementation of the BraceProvider interface for getting information about braces specific to a language. It will highlight a pair of matching braces when the caret is on either side of either brace. If the caret sits between two non-matching braces, the plugin will highlight both pairs in different styles. If a brace has no matching partner, it will be highlighted in a third (non-matching) style. To use this plugin, install it into the editor pane by calling installPlugin() on the BasicEditorPane. Make sure you have implementations of the BraceProvider interface for languages you want brace matching in.


Field Summary
static int DEFAULT_BRACE_PRIORITY
          The default priority level given to the highlight for brace matching results.
static java.lang.String HIGHLIGHT_BRACE_MATCH1
          The name of the highlight for the first matched brace pair.
static java.lang.String HIGHLIGHT_BRACE_MATCH2
          The name of the highlight for the second matched brace pair.
static java.lang.String HIGHLIGHT_BRACE_MISMATCH
          The name of the highlight for the brace mismatch.
 
Constructor Summary
BraceMatchingPlugin()
          Constructs a new BraceMatchingPlugin that is not currently associated with any editor or document.
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent event)
          This is invoked when an action is performed.
 void caretUpdate(javax.swing.event.CaretEvent event)
          Called when the caret position is updated.
 void changedUpdate(javax.swing.event.DocumentEvent event)
          Gives notification that an attribute or set of attributes changed.
 void deinstall(BasicEditorPane editor)
          Called when the plugin is being removed from the BasicEditorPane (for example when the editor is closed.) This is used to notify plugins that they should unregister any listeners that were attached.
 void insertUpdate(javax.swing.event.DocumentEvent event)
          Gives notification that there was an insert into the document.
 void install(BasicEditorPane editor)
          Called when this plugin is being installed into the BasicEditorPane.
 boolean invokeAction(java.lang.String actionKey)
          Invokes the Action corresponding to the given actionKey.
 void propertyChange(java.beans.PropertyChangeEvent event)
          This method gets called when a bound property is changed.
 void removeUpdate(javax.swing.event.DocumentEvent event)
          Gives notification that a portion of the document has been removed.
protected  void updateEnabled()
          Utility routine to check whether brace matching should be enabled or not.
protected  void updateTimerDelay()
          Private utility routine to update the delay used for the timer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_BRACE_PRIORITY

public static final int DEFAULT_BRACE_PRIORITY
The default priority level given to the highlight for brace matching results.

See Also:
Constant Field Values

HIGHLIGHT_BRACE_MATCH1

public static final java.lang.String HIGHLIGHT_BRACE_MATCH1
The name of the highlight for the first matched brace pair.

See Also:
Constant Field Values

HIGHLIGHT_BRACE_MATCH2

public static final java.lang.String HIGHLIGHT_BRACE_MATCH2
The name of the highlight for the second matched brace pair.

See Also:
Constant Field Values

HIGHLIGHT_BRACE_MISMATCH

public static final java.lang.String HIGHLIGHT_BRACE_MISMATCH
The name of the highlight for the brace mismatch.

See Also:
Constant Field Values
Constructor Detail

BraceMatchingPlugin

public BraceMatchingPlugin()
Constructs a new BraceMatchingPlugin that is not currently associated with any editor or document.

Method Detail

install

public void install(BasicEditorPane editor)
Called when this plugin is being installed into the BasicEditorPane.

Specified by:
install in interface EditorPlugin
Parameters:
editor - the editor pane

deinstall

public void deinstall(BasicEditorPane editor)
Called when the plugin is being removed from the BasicEditorPane (for example when the editor is closed.) This is used to notify plugins that they should unregister any listeners that were attached.

Specified by:
deinstall in interface EditorPlugin
Parameters:
editor - the editor pane

updateEnabled

protected void updateEnabled()
Utility routine to check whether brace matching should be enabled or not.


updateTimerDelay

protected void updateTimerDelay()
Private utility routine to update the delay used for the timer.


propertyChange

public void propertyChange(java.beans.PropertyChangeEvent event)
This method gets called when a bound property is changed.

Specified by:
propertyChange in interface java.beans.PropertyChangeListener
Parameters:
event - A PropertyChangeEvent object describing the event source and the property that has changed.

caretUpdate

public void caretUpdate(javax.swing.event.CaretEvent event)
Called when the caret position is updated.

Specified by:
caretUpdate in interface javax.swing.event.CaretListener
Parameters:
event - the caret event

insertUpdate

public void insertUpdate(javax.swing.event.DocumentEvent event)
Gives notification that there was an insert into the document. The range given by the DocumentEvent bounds the freshly inserted region.

Specified by:
insertUpdate in interface javax.swing.event.DocumentListener
Parameters:
event - the document event

removeUpdate

public void removeUpdate(javax.swing.event.DocumentEvent event)
Gives notification that a portion of the document has been removed. The range is given in terms of what the view last saw (that is, before updating sticky positions).

Specified by:
removeUpdate in interface javax.swing.event.DocumentListener
Parameters:
event - the document event

changedUpdate

public void changedUpdate(javax.swing.event.DocumentEvent event)
Gives notification that an attribute or set of attributes changed.

Specified by:
changedUpdate in interface javax.swing.event.DocumentListener
Parameters:
event - the document event

invokeAction

public boolean invokeAction(java.lang.String actionKey)
Invokes the Action corresponding to the given actionKey.

Specified by:
invokeAction in interface ActionHookInvoker
Parameters:
actionKey - the published key for the action
Returns:
true if the action is handled, false otherwise

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent event)
This is invoked when an action is performed. In this case, it should only be a Timer event.

Specified by:
actionPerformed in interface java.awt.event.ActionListener
Parameters:
event - the action event

Extension SDK

 

Copyright © 1997, 2004, Oracle. All rights reserved.