com.ephox.editlive.plugins
Class SafeLoadingPlugin

java.lang.Object
  extended by com.ephox.editlive.plugins.SafeLoadingPlugin

public abstract class SafeLoadingPlugin
extends Object

An abstract base class useful for creating a plugin. This class performs standard plugin initialization work.

The editorInitialized method will be called on subclasses when the bean has been initialized. It will do this in the constructor if the bean is already initialized, or during the TextEvent.LOADING_COMPLETE event otherwise. Please note that if you have fields that are initialized inline, the Java Language Specification (section 12.5) states that fields are not initialized before a super call. Therefore these fields may be null when editorInitialized is called.

In addition, this class will also ensure that the version of EditLive! running is high enough to support the plugin. The performPreLoadingCompleteTasks method is called as soon as the version number is verified so that early-loading plugins can register custom document rendering.

In summary, if you are writing a plugin, you should consider extending from this class.

Since:
7.5

Constructor Summary
SafeLoadingPlugin(ELJBean bean, String requiredVersion, String pluginName)
          Standard constructor.
 
Method Summary
protected abstract  void editorInitialized()
          This is where you want to perform all initialization actions that require the editor to be loaded.
 ELJBean getBean()
          The current ELJBean instance set via the constructor
 EphoxEditorPane getEditorPane()
          Wrapper method to ELJBean.getEditorPane() that returns null if the bean isn't initialized.
 boolean isEnabled()
          Returns the current enabled state of the plugin.
protected  void performPreLoadingCompleteTasks()
          Method that will be called when the plugin is first loaded, before editorInitialized.
 void setEnabled(boolean enabled)
          Sets the current enabled state of the plugin
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SafeLoadingPlugin

public SafeLoadingPlugin(ELJBean bean,
                         String requiredVersion,
                         String pluginName)
Standard constructor. The requiredVersion parameter supports dot-notated detail up to the same level as EditLive!. For example:
Method Detail

performPreLoadingCompleteTasks

protected void performPreLoadingCompleteTasks()
Method that will be called when the plugin is first loaded, before editorInitialized. This method is called early enough for custom views, custom tags and view annotations to be registered successfully.

NOTE: If you use this method, your plugin must be early loading otherwise there is no guarantee that your customisations will be registered in time for the document to use them.


getBean

public ELJBean getBean()
The current ELJBean instance set via the constructor


editorInitialized

protected abstract void editorInitialized()
This is where you want to perform all initialization actions that require the editor to be loaded. It will only be called when the editor is ready for them.

NOTE: As detailed in the class documentation your class fields may be null when this is called.


getEditorPane

public EphoxEditorPane getEditorPane()
Wrapper method to ELJBean.getEditorPane() that returns null if the bean isn't initialized.


setEnabled

public void setEnabled(boolean enabled)
Sets the current enabled state of the plugin


isEnabled

public boolean isEnabled()
Returns the current enabled state of the plugin. This is automatically set to true before performPreLoadingCompleteTasks is called.


Copyright (c) 2005-2012 Ephox Pty Ltd. All rights reserved.