Class ALcyModelCustomizerPanel

All Implemented Interfaces:
ILcdUndoableSource, ILcyCustomizerPanel, ILcdPropertyChangeSource, ImageObserver, MenuContainer, Serializable, Accessible

public abstract class ALcyModelCustomizerPanel extends ALcyCustomizerPanel

Abstract class that facilitates the implementation of ILcyCustomizerPanel for ILcdModel objects. This class by can be used to edit instances of TLcyModelContext objects.

This class adds listeners to the layer so that when the editable property of a layer changes the updateCustomizerPanelFromObject(boolean) method is called with the correct parameter.

See Also:
  • Constructor Details

    • ALcyModelCustomizerPanel

      protected ALcyModelCustomizerPanel(ILcdFilter aModelContextFilter, String aName)
  • Method Details

    • getView

      protected ILcdView getView()
      Convenience method to return the ILcdView that was set by setting a TLcyModelContext using setObject.
      Returns:
      Null if no TLcyModelContext is set, the ILcdView related to that context object otherwise.
    • getLayer

      protected ILcdLayer getLayer()
      Convenience method to return the ILcdLayer that was set by setting a TLcyModelContext using setObject.
      Returns:
      Null if no TLcyModelContext is set, the ILcdLayer related to that context object otherwise.
    • getModel

      protected ILcdModel getModel()
      Convenience method to return the ILcdModel that was set by setting a TLcyModelContext using setObject.
      Returns:
      Null if no TLcyModelContext is set, the ILcdModel related to that context object otherwise.
    • getModelContext

      protected final TLcyModelContext getModelContext()

      Returns the TLcyModelContext object that was set on this customizer. This context object can be used to retrieve the model and the layer and the view in which it is contained.

      Returns:
      The set TLcyModelContext. This object can be null when this customizer was deinitialized (with setObject(null)).
    • canSetObject

      public boolean canSetObject(Object aObject)
      Description copied from class: ALcyCustomizerPanel
      Returns true if and only if setObject would not throw an IllegalArgumentException.

      Only accepts null or objects that pass the object filter. If the filter itself is null, all objects are accepted.

      Specified by:
      canSetObject in interface ILcyCustomizerPanel
      Overrides:
      canSetObject in class ALcyCustomizerPanel
      Parameters:
      aObject - The object to check.
      Returns:
      true if setObject would accept the object, false if it would throw an exception.
    • setObject

      public void setObject(Object aObject)
      Set the object to be edited. This method should be called before the ILcyCustomizerPanel has been added to any parent AWT container. It can be called afterwards as well however. In this case the user interface should update itself to represent the newly set object.

      A value of null is set to inform this ILcyCustomizerPanel to (temporarily) deinitialize itself, it allows to perform cleanup tasks, such as removing listeners. Invokes ALcyCustomizerPanel.updateCustomizerPanelFromObject() to update the user interface.

      Also adds a listener to the layer of the TLcyModelContext object that calls updateCustomizerPanelFromObject when the "editable" property of that layer changes.

      Specified by:
      setObject in interface ILcyCustomizerPanel
      Overrides:
      setObject in class ALcyCustomizerPanel
      Parameters:
      aObject - The object to be customized, or null to inform that editing is temporarily disabled.
    • updateCustomizerPanelFromObject

      protected void updateCustomizerPanelFromObject()
      Specified by:
      updateCustomizerPanelFromObject in class ALcyCustomizerPanel
    • updateCustomizerPanelFromObject

      protected abstract void updateCustomizerPanelFromObject(boolean aPanelEditable)
      This means updating the user interface state according to the current state of the set Object. This method is called whenever a new object is set using setObject, or when the changes are canceled using cancelChanges.

      It does not need to take care of "changesPending".

      Consider for example that a TLcyLayerContext is set and a new label text is entered in a text field. When this method is called, the new label text should be cleared and the original label of the ILcdLayer (getLabel()) should be put in the text field.

      Parameters:
      aPanelEditable - True if the panel should be editable, false otherwise. See isPanelEditable() for more information.
    • isPanelEditable

      protected boolean isPanelEditable()
      Returns whether the panel is editable or not. Editable means the values it displays can be modified; for example, the content of a text field can be adapted. Not editable means the values it displays cannot be adapted; for example, a text field should be disabled.

      The default implementation returns

      
         getLayer().isEditableSupported() && getLayer().isEditable()
       
      or true if getLayer() is null.

      Override this method redefine when the panel is editable or not.

      Returns:
      True if the panel should be editable, false otherwise.