com.ephox.editlive.ephoxaction.filter
Class GenericEnabledFilter

java.lang.Object
  extended by com.ephox.editlive.ephoxaction.filter.GenericEnabledFilter
All Implemented Interfaces:
EventListener, EnabledFilter

public class GenericEnabledFilter
extends Object
implements EnabledFilter, EventListener

Automatically enables and disables based on listening for TextEvent events.

NOTE: Must be manually registered as a listener on EventBroadcaster.

Since:
7.5

Field Summary
 int _disableEvent
          The event that triggers this filter to be disabled.
 int _enableEvent
          The event that triggers this filter to be enabled.
 
Constructor Summary
GenericEnabledFilter(int enableEvent, int disableEvent, boolean initialState)
          Creates a new GenericEnabledFilter.
GenericEnabledFilter(int event, String enableValue, String disableValue, boolean initialState)
          Creates a new GenericEnabledFilter which only uses one event, instead looking at the extra object value to decide when to enable and disable.
 
Method Summary
 void addPropertyChangeListener(PropertyChangeListener listener)
          Add a property change listener which must be notified when the enabled state of this filter changes.
 boolean equals(Object obj)
           
 int hashCode()
           
 boolean isEnabled()
          The current state of the filter.
 void raiseEvent(TextEvent e)
          Method used to listen for events raised by EditLive!.
 void setEnabled(boolean isEnabled)
          Set whether or not the filter is enabled.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_enableEvent

public final int _enableEvent
The event that triggers this filter to be enabled.


_disableEvent

public final int _disableEvent
The event that triggers this filter to be disabled.

Constructor Detail

GenericEnabledFilter

public GenericEnabledFilter(int enableEvent,
                            int disableEvent,
                            boolean initialState)
Creates a new GenericEnabledFilter.

Parameters:
enableEvent - the TextEvent that indicates the filter should be enabled.
disableEvent - the TextEvent that indicates the filter should be disabled.
initialState - the initial state of this filter.

GenericEnabledFilter

public GenericEnabledFilter(int event,
                            String enableValue,
                            String disableValue,
                            boolean initialState)
Creates a new GenericEnabledFilter which only uses one event, instead looking at the extra object value to decide when to enable and disable.

Parameters:
event - the TextEvent that the filter should listen to.
enableValue - the event value required for the event to enable the filter.
disableValue - the event value required for the event to disable the filter.
initialState - the initial state of this filter.
Method Detail

isEnabled

public final boolean isEnabled()
The current state of the filter. Method is final; use setEnabled(boolean) to change the current state in order to notify property change listeners.

Specified by:
isEnabled in interface EnabledFilter
Returns:
true if this filter allows the action to be enabled, otherwise returns false.

setEnabled

public void setEnabled(boolean isEnabled)
Set whether or not the filter is enabled.


addPropertyChangeListener

public void addPropertyChangeListener(PropertyChangeListener listener)
Description copied from interface: EnabledFilter
Add a property change listener which must be notified when the enabled state of this filter changes.

Specified by:
addPropertyChangeListener in interface EnabledFilter
Parameters:
listener - the listener to add.

raiseEvent

public void raiseEvent(TextEvent e)
Description copied from interface: EventListener
Method used to listen for events raised by EditLive!.

Specified by:
raiseEvent in interface EventListener
Parameters:
e - TextEvent to be parsed.

hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

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