Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.gjt.sp.jedit
Class EditBus  view EditBus download EditBus.java

java.lang.Object
  extended byorg.gjt.sp.jedit.EditBus

public class EditBus
extends java.lang.Object

jEdit's global event notification mechanism.

Plugins register with the EditBus to receive messages reflecting changes in the application's state, including changes in buffers, views and edit panes, changes in the set of properties maintained by the application, and the closing of the application.

The EditBus maintains a list of objects that have requested to receive messages. When a message is sent using this class, all registered components receive it in turn. Classes for objects that subscribe to the EditBus must implement the EBComponent interface, which defines the single method EBComponent.handleMessage(EBMessage) 55 .

A plugin core class that extends the EBPlugin abstract class (and whose name ends with Plugin for identification purposes) will automatically be added to the EditBus during jEdit's startup routine. Any other class - for example, a dockable window that needs to receive notification of buffer changes - must perform its own registration by calling addToBus(EBComponent) 55 during its initialization. A convenient place to register in a class derived from JComponent would be in an implementation of the JComponent method addNotify().

Message types sent by jEdit can be found in the org.gjt.sp.jedit.msg package.

Plugins can also send their own messages - any object can send a message to the EditBus by calling the static method send(EBMessage) 55 . Most plugins, however, only concern themselves with receiving, not sending, messages.

Since:
jEdit 2.2pre6
Version:
$Id: EditBus.java,v 1.11 2003/05/01 02:21:26 spestov Exp $

Field Summary
private static java.util.ArrayList components
           
private static EBComponent[] copyComponents
           
 
Constructor Summary
private EditBus()
           
 
Method Summary
static void addToBus(EBComponent comp)
          Adds a component to the bus.
static EBComponent[] getComponents()
          Returns an array of all components connected to the bus.
static void removeFromBus(EBComponent comp)
          Removes a component from the bus.
static void send(EBMessage message)
          Sends a message to all components on the bus in turn.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

components

private static java.util.ArrayList components

copyComponents

private static EBComponent[] copyComponents
Constructor Detail

EditBus

private EditBus()
Method Detail

addToBus

public static void addToBus(EBComponent comp)
Adds a component to the bus. It will receive all messages sent on the bus.


removeFromBus

public static void removeFromBus(EBComponent comp)
Removes a component from the bus.


getComponents

public static EBComponent[] getComponents()
Returns an array of all components connected to the bus.


send

public static void send(EBMessage message)
Sends a message to all components on the bus in turn.