jigcell.compare.data
Class EditableDataGenerator

java.lang.Object
  extended by javax.swing.TransferHandler
      extended by jigcell.compare.impl.Transferer
          extended by jigcell.compare.impl.DataSource
              extended by jigcell.compare.data.DataGenerator
                  extended by jigcell.compare.data.EditableDataGenerator
All Implemented Interfaces:
java.awt.datatransfer.Transferable, java.beans.PropertyChangeListener, java.io.Serializable, java.lang.Cloneable, java.util.EventListener, IDataGenerator, IDataSource, IEditableDataGenerator, IReadableDataSource, IWriteableDataSource
Direct Known Subclasses:
ProgrammableDataGenerator

public class EditableDataGenerator
extends DataGenerator
implements IEditableDataGenerator

Implementation of DataGenerator that supports editing the generator fields. The default element type of an EditableDataGenerator is a SparseTreeDataElement.

This code is licensed under the DARPA BioCOMP Open Source License. See LICENSE for more details.

Author:
Nicholas Allen
See Also:
Serialized Form

Nested Class Summary
protected static class EditableDataGenerator.EditableDataGeneratorDelegate
          Persist the generator using the setElement method with a flat string rather than trying to expand the element.
 
Nested classes/interfaces inherited from interface jigcell.compare.IDataSource
IDataSource.Option
 
Field Summary
private  IDataElement element
          Cached version of the associated element
 
Fields inherited from class jigcell.compare.data.DataGenerator
COMPARATOR_NAME, DESCRIPTION_READ, SEPARATOR_ESCAPE, SPECIAL_CHARS
 
Fields inherited from class jigcell.compare.impl.DataSource
OPTIONS_LOCK, SEPARATOR_PAIR, SEPARATOR_PART, SEPARATORS
 
Fields inherited from class jigcell.compare.impl.Transferer
CSV_FOOTER, CSV_LINEPOSTPEND, CSV_LINEPREPEND, CSV_LINESEPARATOR, HTML_FOOTER, HTML_HEADPOSTPEND, HTML_HEADPREPEND, HTML_HEADSEPARATOR, HTML_LINEPOSTPEND, HTML_LINEPREPEND, HTML_LINESEPARATOR
 
Fields inherited from class javax.swing.TransferHandler
COPY, COPY_OR_MOVE, MOVE, NONE
 
Fields inherited from interface jigcell.compare.IDataGenerator
ATTRIBUTE_COMMENT, ATTRIBUTE_GUID, PROPERTY_GENERATOR_EDIT, RESOURCE_GENERATORS
 
Fields inherited from interface jigcell.compare.IReadableDataSource
OPTION_READDESCRIPTION, OPTION_READICON
 
Fields inherited from interface jigcell.compare.IDataSource
OPTION_NAME
 
Fields inherited from interface jigcell.compare.IWriteableDataSource
OPTION_WRITEDESCRIPTION, OPTION_WRITEICON
 
Constructor Summary
EditableDataGenerator()
          Creates a new data generator that supports editing.
EditableDataGenerator(IDataElement element)
          Creates a new data generator that supports editing.
 
Method Summary
 void clear()
          Nulls out the stored element.
 IDataElement getElement()
          A DataElement corresponding to this object. This may be a potentially expensive operation if isCached is false.
 boolean getPredictedCompatibility(java.lang.Class clazz)
          A prediction on whether this data source can hold a particular type.
 boolean getPredictedCompatibility(java.lang.Object instance)
          A prediction on whether this data source can hold a particular type.
 boolean isCached()
          Whether a cached value of the corresponding DataElement exists.
 boolean isSet()
          Whether this generator has a set value.
 boolean setAttribute(java.lang.String key, java.lang.String value)
          Sets a permanent attribute of this generator.
 void setComment(java.lang.String displayableComment)
          Sets the displayable description.
 void setElement(IDataElement element)
          Sets the associated data element.
 void setElement(java.lang.String text)
          Creates a new associated data element and initializes it with the given text.
 boolean setOption(java.lang.String key, java.lang.Object value)
          Sets a configuration optoin. Returns whether the configuration was changed.
 void setState(java.lang.String state)
          Completely replaces the previous configuration of this data source.
 void write(java.lang.Object data)
          Writes data to the source destroying the previous contents if multiple objects are not supported.
 
Methods inherited from class jigcell.compare.data.DataGenerator
clone, compareByName, copy, copy, generateGUID, getAttribute, getComment, getCopiedFrom, getName, getPredictedContents, getTransferData, initializeSource, isCopy, isCopyRelated, read, setCopyName, setName, toString
 
Methods inherited from class jigcell.compare.impl.DataSource
addOption, addPropertyChangeListener, addPropertyChangeListener, configure, getOption, getOptions, getOptionType, getPropertyChangeListeners, getPropertyChangeListeners, getReadDescriptionOption, getReadIconOption, getState, getWriteDescriptionOption, getWriteIconOption, persistSource, propertyChange, removePropertyChangeListener, removePropertyChangeListener, setOptions, setOptionType, setReadDescriptionOption, setReadIconOption, setWriteDescriptionOption, setWriteIconOption, unpersistSource
 
Methods inherited from class jigcell.compare.impl.Transferer
addExtension, addFlavor, createCSVTable, createFormattedTable, createHTMLTable, getExceptionRecorder, getExpectedClasses, getExpectedClasses, getExpectedClasses, getFlavors, getFlavors, getPreferredExtensions, getPreferredExtensions, getTransferClass, getTransferDataFlavors, getTransferFlavor, isDataFlavorSupported, transfer
 
Methods inherited from class javax.swing.TransferHandler
canImport, createTransferable, exportAsDrag, exportDone, exportToClipboard, getCopyAction, getCutAction, getPasteAction, getSourceActions, getVisualRepresentation, importData
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface jigcell.compare.IEditableDataGenerator
setCopyName, setName
 
Methods inherited from interface jigcell.compare.IDataGenerator
copy, getAttribute, getComment, getCopiedFrom, isCopy, isCopyRelated
 
Methods inherited from interface jigcell.compare.IReadableDataSource
getPredictedContents, getReadDescriptionOption, getReadIconOption, read, setReadDescriptionOption, setReadIconOption
 
Methods inherited from interface jigcell.compare.IDataSource
addOption, clone, configure, getName, getOption, getState
 
Methods inherited from interface java.awt.datatransfer.Transferable
getTransferData, getTransferDataFlavors, isDataFlavorSupported
 
Methods inherited from interface jigcell.compare.IWriteableDataSource
getWriteDescriptionOption, getWriteIconOption, setWriteDescriptionOption, setWriteIconOption
 

Field Detail

element

private transient IDataElement element
Cached version of the associated element

Constructor Detail

EditableDataGenerator

public EditableDataGenerator()
Creates a new data generator that supports editing.


EditableDataGenerator

public EditableDataGenerator(IDataElement element)
Creates a new data generator that supports editing.

Parameters:
element - Element to link to
Method Detail

clear

public void clear()
Nulls out the stored element.

Specified by:
clear in interface IEditableDataGenerator

getElement

public IDataElement getElement()
A DataElement corresponding to this object. This may be a potentially expensive operation if isCached is false.

Specified by:
getElement in interface IDataGenerator
Overrides:
getElement in class DataGenerator

getPredictedCompatibility

public boolean getPredictedCompatibility(java.lang.Class clazz)
A prediction on whether this data source can hold a particular type.

Specified by:
getPredictedCompatibility in interface IWriteableDataSource
Parameters:
clazz - Type

getPredictedCompatibility

public boolean getPredictedCompatibility(java.lang.Object instance)
A prediction on whether this data source can hold a particular type.

Specified by:
getPredictedCompatibility in interface IWriteableDataSource
Parameters:
instance - Type

isCached

public boolean isCached()
Whether a cached value of the corresponding DataElement exists.

Specified by:
isCached in interface IDataGenerator

isSet

public boolean isSet()
Whether this generator has a set value.


setAttribute

public boolean setAttribute(java.lang.String key,
                            java.lang.String value)
Sets a permanent attribute of this generator. Returns whether the attribute was changed.

Specified by:
setAttribute in interface IDataGenerator
Parameters:
key - Attribute name
value - New attribute value

setComment

public void setComment(java.lang.String displayableComment)
Sets the displayable description.

Specified by:
setComment in interface IEditableDataGenerator
Parameters:
displayableComment - Description

setElement

public void setElement(IDataElement element)
Sets the associated data element.

Specified by:
setElement in interface IEditableDataGenerator
Parameters:
element - Element

setElement

public void setElement(java.lang.String text)
Creates a new associated data element and initializes it with the given text.

Parameters:
text - Textual representation of an element

setOption

public boolean setOption(java.lang.String key,
                         java.lang.Object value)
Sets a configuration optoin. Returns whether the configuration was changed.

Specified by:
setOption in interface IDataSource
Overrides:
setOption in class DataSource
Parameters:
key - Option name
value - Option value

setState

public void setState(java.lang.String state)
Completely replaces the previous configuration of this data source.

Specified by:
setState in interface IDataSource
Overrides:
setState in class DataSource
Parameters:
state - State

write

public void write(java.lang.Object data)
           throws java.lang.Exception
Writes data to the source destroying the previous contents if multiple objects are not supported.

Specified by:
write in interface IWriteableDataSource
Parameters:
data - Data
Throws:
java.lang.Exception