|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjavax.swing.table.AbstractTableModel
ikayaki.gui.MeasurementSequenceTableModel
public class MeasurementSequenceTableModel
Handles the showing and editing of a project's measurement sequence. The columns that are being shown can be selected on a per project basis, and the selections are remembered even after the project has been closed.
Field Summary | |
---|---|
private List<SequenceColumn> |
possibleColumns
|
private Project |
project
|
private static String |
VISIBLE_COLUMNS_PROPERTY
|
private List<SequenceColumn> |
visibleColumns
|
Fields inherited from class javax.swing.table.AbstractTableModel |
---|
listenerList |
Constructor Summary | |
---|---|
MeasurementSequenceTableModel()
Creates a new MeasurementSequenceTableModel with no active project. |
Method Summary | |
---|---|
Class<?> |
getColumnClass(int columnIndex)
Returns Object.class regardless of columnIndex . |
int |
getColumnCount()
Returns the number of columns in the model. |
String |
getColumnName(int column)
Returns a name for the column. |
String |
getColumnToolTip(int column)
Returns the tooltip text for the specified column. |
SequenceColumn[] |
getPossibleColumns()
Returns an array of columns that the current project can show. |
Project |
getProject()
Returns the active project, or null if no project is active. |
int |
getRowCount()
Returns the number of rows in the model. |
Object |
getValueAt(int rowIndex,
int columnIndex)
Returns the value for the cell at columnIndex and rowIndex . |
private void |
hideColumn(SequenceColumn column,
boolean save)
Hides the specified column. |
boolean |
isCellEditable(int rowIndex,
int columnIndex)
Returns false. |
boolean |
isColumnVisible(SequenceColumn column)
Tells if specified column is currently visible. |
void |
measurementUpdated(MeasurementEvent event)
Refreshes the table to reflect the changes in the measurement steps. |
void |
projectUpdated(ProjectEvent event)
Deprecated. The selected rows need to be saved before updating the table data, and that can only be done with access to the JTable. That's why it is on MeasurementSequencePanel's responsibility is to react to ProjectEvents and do the fireTableDataChanged(). |
private void |
saveColumn(SequenceColumn column,
boolean visible)
Saves to the project's properties, whether the specified column should be shown or not. |
void |
setColumnVisible(SequenceColumn column,
boolean visible)
Sets visibility of the specified column. |
void |
setProject(Project project)
Sets the project for this model. |
void |
setValueAt(Object data,
int rowIndex,
int columnIndex)
Sets the value for the cell at columnIndex and rowIndex . |
private void |
showColumn(SequenceColumn column,
boolean save)
Shows the specified column. |
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 |
Field Detail |
---|
private static final String VISIBLE_COLUMNS_PROPERTY
private Project project
private List<SequenceColumn> visibleColumns
private List<SequenceColumn> possibleColumns
Constructor Detail |
---|
public MeasurementSequenceTableModel()
Method Detail |
---|
public Project getProject()
public void setProject(Project project)
project
- new active project, or null to make no project active.public void projectUpdated(ProjectEvent event)
projectUpdated
in interface ProjectListener
event
- the event that happened.public void measurementUpdated(MeasurementEvent event)
measurementUpdated
in interface MeasurementListener
event
- the event that happened.public SequenceColumn[] getPossibleColumns()
private void showColumn(SequenceColumn column, boolean save)
column
- the column to be shown.save
- should this column change be saved to the project or not.private void hideColumn(SequenceColumn column, boolean save)
column
- the column to be hidden.save
- should this column change be saved to the project or not.public boolean isColumnVisible(SequenceColumn column)
column
- the column to be queried.
NullPointerException
- if column is null.public void setColumnVisible(SequenceColumn column, boolean visible)
column
- the column to be changed.visible
- true if the column should be visible, otherwise false.
NullPointerException
- if column is null.private void saveColumn(SequenceColumn column, boolean visible)
column
- the column whose property is changed.visible
- true to show the column, false to hide it.public int getRowCount()
JTable
uses this method to determine how many rows it
should display. This method should be quick, as it is called frequently during rendering.
getRowCount
in interface TableModel
getColumnCount()
public int getColumnCount()
JTable
uses this method to determine how many columns
it should create and display by default.
getColumnCount
in interface TableModel
getRowCount()
public Object getValueAt(int rowIndex, int columnIndex)
columnIndex
and rowIndex
.
getValueAt
in interface TableModel
rowIndex
- the row whose value is to be queriedcolumnIndex
- the column whose value is to be queried
public void setValueAt(Object data, int rowIndex, int columnIndex)
columnIndex
and rowIndex
.
setValueAt
in interface TableModel
setValueAt
in class AbstractTableModel
data
- new value of the cellrowIndex
- the row whose value is to be queriedcolumnIndex
- the column whose value is to be queriedpublic boolean isCellEditable(int rowIndex, int columnIndex)
isCellEditable
in interface TableModel
isCellEditable
in class AbstractTableModel
rowIndex
- the row being queriedcolumnIndex
- the column being queried
public String getColumnName(int column)
column
cannot be found, returns an empty string.
getColumnName
in interface TableModel
getColumnName
in class AbstractTableModel
column
- the column being queried.
public String getColumnToolTip(int column)
public Class<?> getColumnClass(int columnIndex)
Object.class
regardless of columnIndex
.
getColumnClass
in interface TableModel
getColumnClass
in class AbstractTableModel
columnIndex
- the column being queried
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |