Class AbstractEntry<G>

java.lang.Object
org.proto4j.swing.AbstractEntry<G>
Type Parameters:
G - the GUI's type
All Implemented Interfaces:
Entry<G>

public abstract class AbstractEntry<G>
extends java.lang.Object
implements Entry<G>
This class provides basic operations for the Entry.

It comes with two important methods: linkAction(Object) and start(Object...). Their implementation is standardized, so there is no need for external implementation.

  • Constructor Summary

    Constructors 
    Modifier Constructor Description
    protected AbstractEntry​(java.lang.Class<G> type)
    Create a new AbstractEntry object.
  • Method Summary

    Modifier and Type Method Description
    protected void addListener​(java.lang.Object listener, AnnotationContext<ActionHandler> ctx)  
    abstract <E extends java.util.EventListener>
    E
    createListener​(java.lang.Class<E> cls, java.lang.Object ls, java.lang.Object parent)
    A simple delegation method to provide the EventListener object.
    java.lang.Class<G> getType()  
    void linkAction​(java.lang.Object src)
    Searches for the ActionHandler annotation and tries to link the given EventListener to the specified target.
    <T extends java.util.EventListener>
    boolean
    linkAction​(java.lang.String fieldName, java.lang.Class<T> cls, T listener)
    Tries to link the given EventListener to the specified target.
    void start​(java.lang.Object... args)
    Searches for the EntryPoint annotation and executes the method with it.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • AbstractEntry

      protected AbstractEntry​(java.lang.Class<G> type)
      Create a new AbstractEntry object.
      Parameters:
      type - the GUI's type
  • Method Details

    • createListener

      public abstract <E extends java.util.EventListener> E createListener​(java.lang.Class<E> cls, java.lang.Object ls, java.lang.Object parent)
      A simple delegation method to provide the EventListener object.
      Type Parameters:
      E - the event listener type
      Parameters:
      cls - the EventListener class
      ls - the listener object - currently either directly the EventListener or a Method that should be casted to the EventListener.
      parent - the declaring object
      Returns:
      the EventListener instance
    • getType

      public java.lang.Class<G> getType()
      Specified by:
      getType in interface Entry<G>
      Returns:
      The GUI's type
    • start

      public void start​(java.lang.Object... args) throws java.lang.NullPointerException
      Searches for the EntryPoint annotation and executes the method with it.
      Specified by:
      start in interface Entry<G>
      Parameters:
      args - the method's arguments
      Throws:
      java.lang.NullPointerException - if no method was found
    • linkAction

      public void linkAction​(java.lang.Object src)
      Searches for the ActionHandler annotation and tries to link the given EventListener to the specified target.
      Specified by:
      linkAction in interface Entry<G>
      Parameters:
      src - the event listener object
    • linkAction

      public <T extends java.util.EventListener> boolean linkAction​(java.lang.String fieldName, java.lang.Class<T> cls, T listener)
      Description copied from interface: Entry
      Tries to link the given EventListener to the specified target.
      Specified by:
      linkAction in interface Entry<G>
      Type Parameters:
      T - the listener type
      Parameters:
      fieldName - the target field name
      cls - the listener base class
      listener - the event listener object
      Returns:
      true if the listener has been added successfully
    • addListener

      protected void addListener​(java.lang.Object listener, AnnotationContext<ActionHandler> ctx)