edu.stanford.smi.protegex.owl.ui.conditions
Class ConditionsTableModel

java.lang.Object
  extended byjavax.swing.table.AbstractTableModel
      extended byedu.stanford.smi.protegex.owl.ui.conditions.ConditionsTableModel
All Implemented Interfaces:
ConditionsTableConstants, OWLTableModel, Serializable, SymbolTableModel, TableModel

public class ConditionsTableModel
extends AbstractTableModel
implements ConditionsTableConstants, OWLTableModel

The TableModel used by the AssertedConditionsWidget.

Author:
Holger Knublauch
See Also:
Serialized Form

Field Summary
private  ClassListener classListener
           
private  edu.stanford.smi.protege.event.FrameListener frameListener
           
private  OWLNamedClass hostClass
          The edited class
private  List items
          One Item object for each row
private  Collection listenedToClses
           
private  OWLModel owlModel
           
 edu.stanford.smi.protege.model.Cls previouslyEditedCls
          Needed to select the most recently edited row after closing the expression editor
private  edu.stanford.smi.protege.model.Slot superclassesSlot
           
 
Fields inherited from class javax.swing.table.AbstractTableModel
listenerList
 
Fields inherited from interface edu.stanford.smi.protegex.owl.ui.conditions.ConditionsTableConstants
COL_COUNT, COL_EXPRESSION, TYPE_DEFINITION_BASE, TYPE_INHERITED, TYPE_SUPERCLASS
 
Constructor Summary
ConditionsTableModel(OWLModel owlModel)
          Constructs a new ConditionsTableModel with default superslot.
ConditionsTableModel(OWLNamedClass hostCls, edu.stanford.smi.protege.model.Slot superclassesSlot)
          Constructs a new ConditionsTableModel for a given Cls.
ConditionsTableModel(edu.stanford.smi.protege.model.Slot superclassesSlot)
          Constructs a new ConditionsTableModel with customized superslot.
 
Method Summary
 int addEmptyDefinitionBlock()
           
 int addEmptyRow(int selectedRow)
           
private  void addInheritedSeparator()
           
private  void addItem(int index, ConditionsTableItem item)
           
private  void addItemUnlessOverloaded(RDFSClass aClass, OWLNamedClass originCls)
          Adds a given Item, unless it represents a restriction that has been overloaded in the existing entries.
 boolean addRow(RDFSClass aClass, int selectedRow)
          Adds a given Cls to the class conditions specified by a given row.
 boolean addRowAllowMove(RDFSClass aClass, int selectedRow)
           
private  boolean deleteDefinitionRow(int index)
           
 void deleteRow(int index)
           
 void deleteRow(int index, boolean forceDelete)
           
 void displaySemanticError(String message)
          Displays an illegal assignment error dialog, e.g. through a JOptionPane.
 void dispose()
           
 void dumpItems()
           
private  void fillDefinitionItems(Collection coveredClses)
           
private  void fillDirectSuperclassItems(Collection coveredClses)
           
private  void fillInheritedAnonymousClses(OWLNamedClass originCls, Collection coveredClses)
           
private  void fillInheritedItems(Collection coveredClses)
           
private  void fillInheritedItems(OWLNamedClass originCls, Collection coveredClses)
           
private  void fillItems()
           
 int getBlockSize(int blockStartRow)
           
 String getBlockText(int type)
          Gets a string of the form [& ] from all rows of a given block.
 RDFSClass getClass(int row)
          Gets the RDFSClass displayed at a given row.
 int getClassRow(RDFSClass cls)
           
 Class getColumnClass(int columnIndex)
           
 int getColumnCount()
           
 OWLIntersectionClass getDefinition(int rowIndex)
          If a given row displays an operand from an equivalent class intersection, then this method returns the OWLIntersectionClass hosting it.
 OWLNamedClass getEditedCls()
           
 Icon getIcon(int rowIndex, int rowHeight)
           
 Icon getIcon(RDFResource resource)
           
private  ConditionsTableItem getItem(int rowIndex)
           
private  Collection getNamedDefinitionClses(boolean allowDirectSuperclasses)
           
 OWLNamedClass getOriginClass(int rowIndex)
          Gets the class where the entry from a given row has been inherited from.
 RDFProperty getPredicate(int row)
           
 RDFResource getRDFResource(int row)
           
 int getRowCount()
           
 RDFResource getSubject()
           
 int getSymbolColumnIndex()
           
 int getType(int rowIndex)
          Gets the type of the entry at a certain row.
 Object getValueAt(int rowIndex, int columnIndex)
           
private  void handleDuplicateEntry(RDFSClass newClass)
           
 boolean isAddEnabledAt(int rowIndex)
          Checks whether the "add named class" function is enabled for a given row.
 boolean isCellEditable(int rowIndex, int columnIndex)
           
 boolean isCreateEnabledAt(int row)
          Checks whether an anonymous class could be added/created at a given row.
 boolean isDefinition(int rowIndex)
           
 boolean isDeleteEnabledFor(RDFSClass cls)
           
 boolean isEditable()
           
 boolean isRemoveEnabledFor(int rowIndex)
           
 boolean isSeparator(int rowIndex)
           
private  void refill()
           
 void refresh()
           
 void removeEmptyRow()
           
private  void removeListeners()
           
private  void replaceItemType(int oldType, int newType)
           
 void setCls(OWLNamedClass cls)
           
 void setValueAt(int rowIndex, OWLModel owlModel, String parsableText)
           
 void setValueAt(Object value, int rowIndex, int columnIndex)
           
private  void sortItems()
          Sorts the items according to their compareTo method.
private  void sortSufficientBlocks(List separators)
          Assumes that the items list contains nothing but at least two non- empty definition blocks.
private  void swapBlocks(ConditionsTableItem separatorA, ConditionsTableItem separatorB)
           
private  void updateLocalIndices()
           
private  void updateLocalIndices(int startRow)
           
 
Methods inherited from class javax.swing.table.AbstractTableModel
addTableModelListener, findColumn, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getColumnName, getListeners, getTableModelListeners, removeTableModelListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface javax.swing.table.TableModel
addTableModelListener, getColumnName, removeTableModelListener
 

Field Detail

classListener

private ClassListener classListener

frameListener

private edu.stanford.smi.protege.event.FrameListener frameListener

hostClass

private OWLNamedClass hostClass
The edited class


items

private List items
One Item object for each row


listenedToClses

private Collection listenedToClses

owlModel

private OWLModel owlModel

previouslyEditedCls

public edu.stanford.smi.protege.model.Cls previouslyEditedCls
Needed to select the most recently edited row after closing the expression editor


superclassesSlot

private edu.stanford.smi.protege.model.Slot superclassesSlot
Constructor Detail

ConditionsTableModel

public ConditionsTableModel(OWLModel owlModel)
Constructs a new ConditionsTableModel with default superslot.

Parameters:
owlModel - the OWLModel

ConditionsTableModel

public ConditionsTableModel(edu.stanford.smi.protege.model.Slot superclassesSlot)
Constructs a new ConditionsTableModel with customized superslot.

Parameters:
superclassesSlot - the Slot (either inferred or asserted superclasses)

ConditionsTableModel

public ConditionsTableModel(OWLNamedClass hostCls,
                            edu.stanford.smi.protege.model.Slot superclassesSlot)
Constructs a new ConditionsTableModel for a given Cls.

Parameters:
hostCls - the initially displayed class
superclassesSlot - the Slot (either inferred or asserted superclasses)
Method Detail

addEmptyDefinitionBlock

public int addEmptyDefinitionBlock()

addEmptyRow

public int addEmptyRow(int selectedRow)
Specified by:
addEmptyRow in interface OWLTableModel

addItem

private void addItem(int index,
                     ConditionsTableItem item)

addItemUnlessOverloaded

private void addItemUnlessOverloaded(RDFSClass aClass,
                                     OWLNamedClass originCls)
Adds a given Item, unless it represents a restriction that has been overloaded in the existing entries. A restriction is overloaded iff a restriction of the same type (OWLAllValuesFrom, or a cardinality restriction), and restricted slot already exists in the items list. With AllRestrictions the filler must be a subclass of the filler above.

Parameters:
aClass - the aClassass to add as an item
originCls - the class where aClassass has been defined

addInheritedSeparator

private void addInheritedSeparator()

addRow

public boolean addRow(RDFSClass aClass,
                      int selectedRow)
Adds a given Cls to the class conditions specified by a given row.

Specified by:
addRow in interface OWLTableModel
Parameters:
aClass - the aClassass to add
selectedRow - the row to add to
Returns:
true if the row has been added

addRowAllowMove

public boolean addRowAllowMove(RDFSClass aClass,
                               int selectedRow)

deleteDefinitionRow

private boolean deleteDefinitionRow(int index)

deleteRow

public void deleteRow(int index)
Specified by:
deleteRow in interface OWLTableModel

deleteRow

public void deleteRow(int index,
                      boolean forceDelete)

displaySemanticError

public void displaySemanticError(String message)
Description copied from interface: OWLTableModel
Displays an illegal assignment error dialog, e.g. through a JOptionPane. This can be used if someone tries to assign an illegal superclass to the model.

Specified by:
displaySemanticError in interface OWLTableModel
Parameters:
message - the message text

dispose

public void dispose()
Specified by:
dispose in interface OWLTableModel

dumpItems

public void dumpItems()

fillItems

private void fillItems()

fillDefinitionItems

private void fillDefinitionItems(Collection coveredClses)

fillDirectSuperclassItems

private void fillDirectSuperclassItems(Collection coveredClses)

fillInheritedItems

private void fillInheritedItems(Collection coveredClses)

fillInheritedItems

private void fillInheritedItems(OWLNamedClass originCls,
                                Collection coveredClses)

fillInheritedAnonymousClses

private void fillInheritedAnonymousClses(OWLNamedClass originCls,
                                         Collection coveredClses)

getBlockSize

public int getBlockSize(int blockStartRow)

getBlockText

public String getBlockText(int type)
Gets a string of the form [& ] from all rows of a given block.

Parameters:
type - the type
Returns:
the string

getClassRow

public int getClassRow(RDFSClass cls)
Specified by:
getClassRow in interface OWLTableModel

getClass

public RDFSClass getClass(int row)
Gets the RDFSClass displayed at a given row.

Specified by:
getClass in interface OWLTableModel
Parameters:
row - the row to get the Class from
Returns:
the RDFSClass there

getColumnCount

public int getColumnCount()
Specified by:
getColumnCount in interface TableModel

getColumnClass

public Class getColumnClass(int columnIndex)
Specified by:
getColumnClass in interface TableModel

getDefinition

public OWLIntersectionClass getDefinition(int rowIndex)
If a given row displays an operand from an equivalent class intersection, then this method returns the OWLIntersectionClass hosting it.

Parameters:
rowIndex - the index of the row to get the OWLIntersectionClass from
Returns:
an OWLIntersectionClass or null

getEditedCls

public OWLNamedClass getEditedCls()
Specified by:
getEditedCls in interface OWLTableModel

getIcon

public Icon getIcon(RDFResource resource)
Specified by:
getIcon in interface SymbolTableModel

getIcon

public Icon getIcon(int rowIndex,
                    int rowHeight)

getItem

private ConditionsTableItem getItem(int rowIndex)

getNamedDefinitionClses

private Collection getNamedDefinitionClses(boolean allowDirectSuperclasses)

getOriginClass

public OWLNamedClass getOriginClass(int rowIndex)
Gets the class where the entry from a given row has been inherited from. This only makes sense for rows which have the type TYPE_INHERITED.

Parameters:
rowIndex - the index of the row to query
Returns:
the origin class

getPredicate

public RDFProperty getPredicate(int row)
Specified by:
getPredicate in interface SymbolTableModel

getRDFResource

public RDFResource getRDFResource(int row)
Specified by:
getRDFResource in interface SymbolTableModel

getSubject

public RDFResource getSubject()
Specified by:
getSubject in interface SymbolTableModel

getSymbolColumnIndex

public int getSymbolColumnIndex()
Specified by:
getSymbolColumnIndex in interface SymbolTableModel

getRowCount

public int getRowCount()
Specified by:
getRowCount in interface TableModel

getType

public int getType(int rowIndex)
Gets the type of the entry at a certain row.

Parameters:
rowIndex - the index of the row to get the type of
Returns:
one of ConditionsTableColumns.TYPE_xxx

getValueAt

public Object getValueAt(int rowIndex,
                         int columnIndex)
Specified by:
getValueAt in interface TableModel

handleDuplicateEntry

private void handleDuplicateEntry(RDFSClass newClass)

isAddEnabledAt

public boolean isAddEnabledAt(int rowIndex)
Checks whether the "add named class" function is enabled for a given row.

Specified by:
isAddEnabledAt in interface OWLTableModel
Parameters:
rowIndex - the index of the row where a named class shall be added
Returns:
true if a named class could be added

isCellEditable

public boolean isCellEditable(int rowIndex,
                              int columnIndex)
Specified by:
isCellEditable in interface TableModel

isCreateEnabledAt

public boolean isCreateEnabledAt(int row)
Checks whether an anonymous class could be added/created at a given row.

Parameters:
row - the index of the row to add a new anonymous class
Returns:
true if yes

isDeleteEnabledFor

public boolean isDeleteEnabledFor(RDFSClass cls)
Specified by:
isDeleteEnabledFor in interface OWLTableModel

isDefinition

public boolean isDefinition(int rowIndex)

isEditable

public boolean isEditable()
Specified by:
isEditable in interface OWLTableModel

isRemoveEnabledFor

public boolean isRemoveEnabledFor(int rowIndex)

isSeparator

public boolean isSeparator(int rowIndex)

refill

private void refill()

refresh

public void refresh()

removeEmptyRow

public void removeEmptyRow()
Specified by:
removeEmptyRow in interface OWLTableModel

removeListeners

private void removeListeners()

replaceItemType

private void replaceItemType(int oldType,
                             int newType)

setCls

public void setCls(OWLNamedClass cls)
Specified by:
setCls in interface OWLTableModel

setValueAt

public void setValueAt(Object value,
                       int rowIndex,
                       int columnIndex)
Specified by:
setValueAt in interface TableModel

setValueAt

public void setValueAt(int rowIndex,
                       OWLModel owlModel,
                       String parsableText)
                throws Exception
Throws:
Exception

sortItems

private void sortItems()
Sorts the items according to their compareTo method.

See Also:
ConditionsTableItem.compareTo(java.lang.Object)

sortSufficientBlocks

private void sortSufficientBlocks(List separators)
Assumes that the items list contains nothing but at least two non- empty definition blocks.


swapBlocks

private void swapBlocks(ConditionsTableItem separatorA,
                        ConditionsTableItem separatorB)

updateLocalIndices

private void updateLocalIndices()

updateLocalIndices

private void updateLocalIndices(int startRow)