edu.northwestern.at.wordhoard.swing.find
Class CriterionComponent

java.lang.Object
  extended by edu.northwestern.at.wordhoard.swing.find.CriterionComponent
Direct Known Subclasses:
AuthorCriterion, CollFreqCriterion, CorpusCriterion, DocFreqCriterion, GenderCriterion, LemmaCriterion, MajorWordClassCriterion, MetricalShapeCriterion, MortalityCriterion, NarrativeCriterion, PhraseSetCriterion, PosCriterion, ProsodicCriterion, PubYearCriterion, SpeakerCriterion, SpellingCriterion, TestCriterion, WordClassCriterion, WordSetCriterion, WorkCriterion, WorkPartCriterion, WorkSetCriterion

abstract class CriterionComponent
extends java.lang.Object

An abstract base class for search criterion components.


Constructor Summary
CriterionComponent()
           
 
Method Summary
(package private)  java.lang.String checkTaggingData(Corpus corpus, Work work, WorkPart workPart, long tag)
          Checks tagging data.
(package private)  SearchCriterion getOtherRowValue(java.lang.Class cls)
          Gets the value of another row.
(package private)  javax.swing.JComponent getSwingComponent()
          Gets the Swing component.
(package private) abstract  SearchCriterion getValue()
          Gets the value of the component.
(package private)  FindWindow getWindow()
          Gets the parent find window.
(package private)  void handleValueChanged(java.lang.Class cls, SearchCriterion oldVal, SearchCriterion newVal)
          Handles a value changed event in some other criterion.
(package private)  javax.swing.JComponent init(FindWindow window, Row row, SearchCriterion val)
          Initializes the component.
(package private) abstract  javax.swing.JComponent init(SearchCriterion val)
          Initializes the component.
(package private)  void notifyWindow(SearchCriterion oldVal, SearchCriterion newVal)
          Notifies the parent window that the value has changed.
(package private)  void rebuildSelf()
          Rebuilds ourself.
(package private) abstract  java.lang.String setCriteria(SearchCriteria searchCriteria)
          Sets the criteria value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CriterionComponent

CriterionComponent()
Method Detail

init

javax.swing.JComponent init(FindWindow window,
                            Row row,
                            SearchCriterion val)
                      throws java.lang.Exception
Initializes the component.

Parameters:
window - Parent find window.
row - Parent row.
val - Initial value, or null.
Returns:
The Swing component.
Throws:
java.lang.Exception

init

abstract javax.swing.JComponent init(SearchCriterion val)
                              throws java.lang.Exception
Initializes the component.

Subclasses must implement this method.

Parameters:
val - Initial value, or null.
Returns:
The component.
Throws:
java.lang.Exception

getValue

abstract SearchCriterion getValue()
Gets the value of the component.

Subclasses must implement this method.

Returns:
Value.

setCriteria

abstract java.lang.String setCriteria(SearchCriteria searchCriteria)
Sets the criteria value.

Subclasses must implement this method.

Parameters:
searchCriteria - Search criteria.
Returns:
Validation error message, or null if none.

notifyWindow

void notifyWindow(SearchCriterion oldVal,
                  SearchCriterion newVal)
Notifies the parent window that the value has changed.

This method must be called by subclasses whenever a criteria value changes.

Parameters:
oldVal - Old value.
newVal - New value.

rebuildSelf

void rebuildSelf()
Rebuilds ourself.

Subclasses must call this method if they want to rebuild themselves in any context other than responding to value change events. The method sends a value changed event back to the calling object with all three arguments null (for the class and old and new values). The object should respond to this special event by rebuilding itself using its current state. This ugly mechanism guarantees that the Swing component is properly sized, positioned, revalidated, and repainted.


handleValueChanged

void handleValueChanged(java.lang.Class cls,
                        SearchCriterion oldVal,
                        SearchCriterion newVal)
                  throws java.lang.Exception
Handles a value changed event in some other criterion.

Subclasses may override this method if they need to react to changes in other criteria. The default implementation does nothing.

On entry, oldVal != newVal is guaranteed.

Parameters:
cls - The class of the criterion that changed.
oldVal - Old value. Null if the row has just been created.
newVal - New value. Null if the row has just been deleted.
Throws:
java.lang.Exception

getOtherRowValue

SearchCriterion getOtherRowValue(java.lang.Class cls)
Gets the value of another row.

Parameters:
cls - Criterion class of the other row.
Returns:
Value, or null if none.

getWindow

FindWindow getWindow()
Gets the parent find window.

Returns:
The parent find window.

getSwingComponent

javax.swing.JComponent getSwingComponent()
Gets the Swing component.

Returns:
The Swing component.

checkTaggingData

java.lang.String checkTaggingData(Corpus corpus,
                                  Work work,
                                  WorkPart workPart,
                                  long tag)
Checks tagging data.

Parameters:
corpus - Corpus or null.
work - Work or null.
workPart - Work part or null.
tag - Tag mask to check.
Returns:
"Corpus" if corpus does not have tagging data, "Work" if work does not have tagging data, "Work part" if work part does not have tagging data, or null if all of them have tagging data.