edu.stanford.smi.protegex.owl.ui.owltable
Class AbstractOWLTableModel

java.lang.Object
  extended byjavax.swing.table.AbstractTableModel
      extended byedu.stanford.smi.protegex.owl.ui.owltable.AbstractOWLTableModel
All Implemented Interfaces:
OWLTableModel, Serializable, SymbolTableModel, TableModel
Direct Known Subclasses:
PropertiesDefinitionTableModel, PropertiesSuperclassesTableModel

public abstract class AbstractOWLTableModel
extends AbstractTableModel
implements OWLTableModel

An AbstractTableModel that represents superclasses/equivalent classes with one row. Its contents is automatically synchronized with the given Cls. This is the common base class for three types of TableModels:

Author:
Holger Knublauch
See Also:
Serialized Form

Field Summary
private  ClassListener classListener
          The ClsListener that detects changes in the superclasses of the edited cls.
private  OWLNamedClass cls
          The currently edited class
private  int expressionColumn
          The index of the column that represents the expression
private  List rows
          The List of RDFSClass instances in the table, sorted by rows
 
Fields inherited from class javax.swing.table.AbstractTableModel
listenerList
 
Constructor Summary
protected AbstractOWLTableModel(int expressionColumn)
           
 
Method Summary
 int addEmptyRow(int rowIndex)
          Called to allow for editing.
protected  void addRows()
          This method completely fills the whole table and assumes that the rows list is empty.
(package private)  void clearRows()
          Removes all rows from the table.
 void deleteRow(int index)
          Deletes the superclass in a given row.
 void displaySemanticError(String message)
          Displays an illegal assignment error dialog, e.g. through a JOptionPane.
 void dispose()
          Clears any dangling listeners.
 RDFSClass getClass(int rowIndex)
           
 int getClassRow(RDFSClass superCls)
           
(package private)  edu.stanford.smi.protege.model.Cls getCls()
           
 Class getColumnClass(int columnIndex)
           
 int getColumnCount()
           
 String getColumnName(int column)
           
 OWLNamedClass getEditedCls()
           
 Icon getIcon(RDFResource resource)
           
protected abstract  int getInsertRowIndex(edu.stanford.smi.protege.model.Cls cls)
           
 RDFResource getRDFResource(int row)
           
 int getRowCount()
           
 RDFResource getSubject()
           
 int getSymbolColumnIndex()
           
 Object getValueAt(int rowIndex, int columnIndex)
           
protected  void insertRow(edu.stanford.smi.protege.model.Cls cls)
           
 boolean isAddEnabledAt(int rowIndex)
           
 boolean isCellEditable(int rowIndex, int columnIndex)
           
 boolean isEditable()
           
protected abstract  boolean isSuitable(edu.stanford.smi.protege.model.Cls cls)
          Checks whether a given superclass shall be displayed or not.
 void refill()
           
 void removeEmptyRow()
           
private  void removeListeners()
           
 void setCls(OWLNamedClass newCls)
           
protected abstract  void setValueAt(int rowIndex, OWLModel owlModel, String parsableText)
           
 void setValueAt(Object value, int rowIndex, int columnIndex)
           
 
Methods inherited from class javax.swing.table.AbstractTableModel
addTableModelListener, findColumn, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, 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 edu.stanford.smi.protegex.owl.ui.owltable.OWLTableModel
addRow, isDeleteEnabledFor
 
Methods inherited from interface edu.stanford.smi.protegex.owl.ui.owltable.SymbolTableModel
getPredicate
 
Methods inherited from interface javax.swing.table.TableModel
addTableModelListener, removeTableModelListener
 

Field Detail

cls

private OWLNamedClass cls
The currently edited class


expressionColumn

private int expressionColumn
The index of the column that represents the expression


rows

private List rows
The List of RDFSClass instances in the table, sorted by rows


classListener

private ClassListener classListener
The ClsListener that detects changes in the superclasses of the edited cls.

Constructor Detail

AbstractOWLTableModel

protected AbstractOWLTableModel(int expressionColumn)
Method Detail

addEmptyRow

public int addEmptyRow(int rowIndex)
Called to allow for editing.

Specified by:
addEmptyRow in interface OWLTableModel

addRows

protected void addRows()
This method completely fills the whole table and assumes that the rows list is empty.


clearRows

void clearRows()
Removes all rows from the table.


deleteRow

public void deleteRow(int index)
Deletes the superclass in a given row. This method does not only change the table contents but also modifies the underlying ontology. The method completely removes the superclass from the ontology if it was an anonymous class.

Specified by:
deleteRow in interface OWLTableModel
Parameters:
index - the index of the row to delete

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()
Clears any dangling listeners.

Specified by:
dispose in interface OWLTableModel

getCls

edu.stanford.smi.protege.model.Cls getCls()

getColumnClass

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

getColumnCount

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

getColumnName

public String getColumnName(int column)
Specified by:
getColumnName in interface TableModel

getClass

public RDFSClass getClass(int rowIndex)
Specified by:
getClass in interface OWLTableModel

getClassRow

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

getEditedCls

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

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

getIcon

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

isAddEnabledAt

public boolean isAddEnabledAt(int rowIndex)
Specified by:
isAddEnabledAt in interface OWLTableModel

isEditable

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

getInsertRowIndex

protected abstract int getInsertRowIndex(edu.stanford.smi.protege.model.Cls cls)

getRowCount

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

getValueAt

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

insertRow

protected void insertRow(edu.stanford.smi.protege.model.Cls cls)

isCellEditable

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

isSuitable

protected abstract boolean isSuitable(edu.stanford.smi.protege.model.Cls cls)
Checks whether a given superclass shall be displayed or not.

Parameters:
cls - the superclass to test
Returns:
true if the cls shall be listed in this table

refill

public void refill()

removeEmptyRow

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

removeListeners

private void removeListeners()

setCls

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

setValueAt

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

setValueAt

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