org.tbee.swing.jpa
Class JpaEntityTableCellEditor<T>

java.lang.Object
  extended by javax.swing.AbstractCellEditor
      extended by org.tbee.swing.jpa.JpaEntityTableCellEditor<T>
All Implemented Interfaces:
Serializable, CellEditor, TableCellEditor, UseTableCellEditorAsTableCellRenderer.UseAsRenderer

public abstract class JpaEntityTableCellEditor<T>
extends AbstractCellEditor
implements TableCellEditor, UseTableCellEditorAsTableCellRenderer.UseAsRenderer

The class edits a boolean value using a checkbox (improves visualisation)

Version:
$Revision: 1.9 $
Author:
$Author: toeukpap $
See Also:
, Serialized Form

Nested Class Summary
static interface JpaEntityTableCellEditor.PopupCellRenderer<T>
           
 
Field Summary
protected  JTextField iDescriptionTextfield
           
protected  JPanel iJPanel
           
protected  JTextField iKeyTextfield
           
protected  ImageButton iLinkButton
           
protected  ImageButton iSearchButton
           
static org.apache.log4j.Logger log4j
           
static String SOURCECODE_VERSION
          Standard variable for determining version of a class file.
 
Fields inherited from class javax.swing.AbstractCellEditor
changeEvent, listenerList
 
Constructor Summary
JpaEntityTableCellEditor()
          Initialize the editor
JpaEntityTableCellEditor(boolean showDescription)
          Initialize the editor
JpaEntityTableCellEditor(boolean showDescription, int keyfieldLength)
          Initialize the editor
 
Method Summary
protected  List<T> findAllPossibleEntities()
          optionally, will show a popup.
protected abstract  T findEntity()
           
 Object getCellEditorValue()
          Return the value after the editor is done
 boolean getEditable()
          disable the contents
protected abstract  Class getEntityClass()
           
protected abstract  String getEntityName()
           
 boolean getErrorWhenNothingFound()
          ErrorWhenNothingFound
 ListCellRenderer getListCellRenderer()
          ListCellRenderer Example: setListCellRenderer(new DefaultListCellRenderer() { public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { javax.swing.JLabel lJLabel = (javax.swing.JLabel)super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); Employee lEmployee = (Employee)value; lJLabel.setText( lEmployee == null ? "-" : lEmployee.getName() ); return lJLabel; } });
 boolean getShowDescription()
          ShowDescription
 boolean getShowLink()
          ShowLink
 boolean getShowSearch()
          ShowSearch
 Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column)
          Return the component that is shown in the cell in the table.
protected  T popupSelectionWindow(List<T> entities, JpaEntityTableCellEditor.PopupCellRenderer<T> renderer)
          remember to also set the list cell renderer (setListCellRenderer)
protected  void search()
           
 void setEditable(boolean value)
           
 void setErrorWhenNothingFound(boolean value)
           
 void setListCellRenderer(ListCellRenderer value)
           
 void setShowDescription(boolean value)
           
 void setShowLink(boolean value)
           
 void setShowSearch(boolean value)
           
 boolean stopCellEditing()
          validate and return false if it failed
protected abstract  void updateFields(T entity)
           
 JpaEntityTableCellEditor useAsRenderer()
          Makes the textfields transparent so the alternating coloring of the rows becomes visible (when used as renderer by UseTableCellEditorAsTableCellRenderer)
 JpaEntityTableCellEditor<T> withEditable(boolean value)
           
 JpaEntityTableCellEditor<T> withErrorWhenNothingFound(boolean value)
           
 JpaEntityTableCellEditor<T> withListCellRenderer(ListCellRenderer value)
           
 JpaEntityTableCellEditor<T> withShowDescription(boolean value)
           
 JpaEntityTableCellEditor<T> withShowLink(boolean value)
           
 JpaEntityTableCellEditor<T> withShowSearch(boolean value)
           
 
Methods inherited from class javax.swing.AbstractCellEditor
addCellEditorListener, cancelCellEditing, fireEditingCanceled, fireEditingStopped, getCellEditorListeners, isCellEditable, removeCellEditorListener, shouldSelectCell
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface javax.swing.CellEditor
addCellEditorListener, cancelCellEditing, isCellEditable, removeCellEditorListener, shouldSelectCell
 

Field Detail

SOURCECODE_VERSION

public static final String SOURCECODE_VERSION
Standard variable for determining version of a class file.

See Also:
Constant Field Values

log4j

public static org.apache.log4j.Logger log4j

iJPanel

protected JPanel iJPanel

iKeyTextfield

protected JTextField iKeyTextfield

iDescriptionTextfield

protected JTextField iDescriptionTextfield

iSearchButton

protected ImageButton iSearchButton

iLinkButton

protected ImageButton iLinkButton
Constructor Detail

JpaEntityTableCellEditor

public JpaEntityTableCellEditor()
Initialize the editor


JpaEntityTableCellEditor

public JpaEntityTableCellEditor(boolean showDescription)
Initialize the editor


JpaEntityTableCellEditor

public JpaEntityTableCellEditor(boolean showDescription,
                                int keyfieldLength)
Initialize the editor

Method Detail

stopCellEditing

public boolean stopCellEditing()
validate and return false if it failed

Specified by:
stopCellEditing in interface CellEditor
Overrides:
stopCellEditing in class AbstractCellEditor

getCellEditorValue

public Object getCellEditorValue()
Return the value after the editor is done

Specified by:
getCellEditorValue in interface CellEditor

getTableCellEditorComponent

public Component getTableCellEditorComponent(JTable table,
                                             Object value,
                                             boolean isSelected,
                                             int row,
                                             int column)
Return the component that is shown in the cell in the table.

Specified by:
getTableCellEditorComponent in interface TableCellEditor

useAsRenderer

public JpaEntityTableCellEditor useAsRenderer()
Makes the textfields transparent so the alternating coloring of the rows becomes visible (when used as renderer by UseTableCellEditorAsTableCellRenderer)

Specified by:
useAsRenderer in interface UseTableCellEditorAsTableCellRenderer.UseAsRenderer

search

protected void search()

getListCellRenderer

public ListCellRenderer getListCellRenderer()
ListCellRenderer Example: setListCellRenderer(new DefaultListCellRenderer() { public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { javax.swing.JLabel lJLabel = (javax.swing.JLabel)super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); Employee lEmployee = (Employee)value; lJLabel.setText( lEmployee == null ? "-" : lEmployee.getName() ); return lJLabel; } });


setListCellRenderer

public void setListCellRenderer(ListCellRenderer value)

withListCellRenderer

public JpaEntityTableCellEditor<T> withListCellRenderer(ListCellRenderer value)

getShowDescription

public boolean getShowDescription()
ShowDescription


setShowDescription

public void setShowDescription(boolean value)

withShowDescription

public JpaEntityTableCellEditor<T> withShowDescription(boolean value)

getShowLink

public boolean getShowLink()
ShowLink


setShowLink

public void setShowLink(boolean value)

withShowLink

public JpaEntityTableCellEditor<T> withShowLink(boolean value)

getShowSearch

public boolean getShowSearch()
ShowSearch


setShowSearch

public void setShowSearch(boolean value)

withShowSearch

public JpaEntityTableCellEditor<T> withShowSearch(boolean value)

getErrorWhenNothingFound

public boolean getErrorWhenNothingFound()
ErrorWhenNothingFound


setErrorWhenNothingFound

public void setErrorWhenNothingFound(boolean value)

withErrorWhenNothingFound

public JpaEntityTableCellEditor<T> withErrorWhenNothingFound(boolean value)

getEditable

public boolean getEditable()
disable the contents


setEditable

public void setEditable(boolean value)

withEditable

public JpaEntityTableCellEditor<T> withEditable(boolean value)

getEntityName

protected abstract String getEntityName()

getEntityClass

protected abstract Class getEntityClass()

findEntity

protected abstract T findEntity()

updateFields

protected abstract void updateFields(T entity)

findAllPossibleEntities

protected List<T> findAllPossibleEntities()
optionally, will show a popup. Remember to also set the list cell renderer (setListCellRenderer)

Returns:
null if no popup, list (size 0-N!) to process the result (0 means nothing selected)

popupSelectionWindow

protected T popupSelectionWindow(List<T> entities,
                                 JpaEntityTableCellEditor.PopupCellRenderer<T> renderer)
remember to also set the list cell renderer (setListCellRenderer)

Parameters:
entities -
renderer -
Returns:


Copyright © 2012 KnowledgePlaza. All Rights Reserved.