private class ALDNativeArray2DDataIOSwing.ArrayConfigWindow extends ALDSwingValueChangeReporter implements ActionListener, TableModelListener
DefaultTableModel
.Modifier and Type | Class and Description |
---|---|
protected class |
ALDNativeArray2DDataIOSwing.ArrayConfigWindow.DataTabFileFilter
Internal class that realizes a FileFilter for text
files where MiToBo table data is stored.
|
protected class |
ALDNativeArray2DDataIOSwing.ArrayConfigWindow.TableFocusListener
Focus listener to commit edits if table looses the focus.
|
Modifier and Type | Field and Description |
---|---|
private JButton |
addCol
Button for adding a column.
|
private JButton |
addRow
Button for adding a row.
|
protected JTable |
dataTab
Data table (swing tables are nicer than imageJ tables).
|
private DefaultTableModel |
dataTabModel
Reference object to the data.
|
private JButton |
delCol
Button for deleting a column.
|
private JButton |
delRow
Button for deleting a row.
|
protected ALDParameterDescriptor |
descriptor
Optional descriptor for additional information on parameter.
|
private Class<?> |
entryClass
Class of objects to be filled in the table.
|
private Object[][] |
entryRefList
List of currently specified values (to restore entry if check
fails).
|
private File |
lastDir
For convenience: always open last directory for saving.
|
private JButton |
tabClear
Button to clear the table.
|
private JScrollPane |
tableScroller
Scrollpane for table panel;
|
private JButton |
tabLoad
Button to load a table.
|
private JPanel |
tabPanel
Table component in window.
|
private JButton |
tabSave
Button to save the table.
|
private JFrame |
window
Main window.
|
protected boolean |
windowHasFocus
Flag to indicate the table window has the focus.
|
listenerList
Constructor and Description |
---|
ArrayConfigWindow(Field field,
Class<?> cl,
Object obj,
ALDParameterDescriptor descr)
Default constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
actionPerformed(ActionEvent e) |
void |
disableComponent()
Disable table and buttons to prohibit value changes.
|
void |
dispose()
Disposes all resources of this window.
|
void |
enableComponent()
Enable table and buttons to allow for value changes.
|
private void |
errorListToMessage(LinkedList<int[]> errorList)
Error function displaying an error message box.
|
protected void |
loadTable()
Loads contents of the table from a user-specified file.
|
Object |
readData(Field field,
Class<?> cl)
Read parameter value from graphical user interface.
|
protected void |
resizeTableEntries(int newRows,
int newCols)
Method to resize the reference entry list.
|
protected void |
saveTable()
Saves the contents of the table to a user-specified file.
|
protected void |
setTabEntryToDefault(int row,
int col,
Class<?> cl)
Sets the specified table entry to the class default.
|
private void |
setupTable()
Initializes the data table window.
|
void |
setValue(Field field,
Class<?> cl,
Object value)
Set value of parameter in GUI element.
|
void |
setVisible(boolean b)
Show or hide the configuration window.
|
void |
tableChanged(TableModelEvent e) |
protected boolean |
validateEntry(Class<?> cl,
String entry)
Checks if a string can be cast to the desired class.
|
addValueChangeEventListener, fireALDSwingValueChangeEvent, removeValueChangeEventListener
private JFrame window
protected JTable dataTab
private DefaultTableModel dataTabModel
private JPanel tabPanel
private JButton addCol
private JButton addRow
private JButton delCol
private JButton delRow
private JButton tabSave
private JButton tabLoad
private JButton tabClear
private JScrollPane tableScroller
private File lastDir
private Class<?> entryClass
protected ALDParameterDescriptor descriptor
private Object[][] entryRefList
protected boolean windowHasFocus
By this multiple warnings on the same issue should be avoided. They might happen due to table change events and focus change events being triggered at the same time.
public ArrayConfigWindow(Field field, Class<?> cl, Object obj, ALDParameterDescriptor descr)
field
- Field of array.cl
- Class of array elements.obj
- Default object value.descr
- Descriptor associated with parameter.public void setVisible(boolean b)
b
- If true, window is displayed, otherwise it is hidden.public void disableComponent()
public void enableComponent()
public void dispose()
protected void setTabEntryToDefault(int row, int col, Class<?> cl)
row
- Row index.col
- Column index.cl
- Class of table elements.public void setValue(Field field, Class<?> cl, Object value)
field
- Field of parameter.cl
- Class of parameter.value
- Value to be set in GUI.public Object readData(Field field, Class<?> cl) throws ALDDataIOProviderException
field
- Field of parameter to be read.cl
- Class of parameter to be read.ALDDataIOProviderException
- Thrown in case of read failures.protected void resizeTableEntries(int newRows, int newCols)
Existing entries are preserved as far as possible.
newRows
- New number of rows for the table.newCols
- New number of cols for the table.protected boolean validateEntry(Class<?> cl, String entry)
cl
- Target class.entry
- String under consideration.protected void saveTable()
The file format is TSV, i.e. tabulator-separated values. The default ending is '.txt'. The user can select the file name through a file open dialog which pops-up on call of the function.
protected void loadTable()
The file format is TSV, i.e. tabulator-separated values. The default ending is '.txt'. The user can select the file name through a file open dialog which pops-up on call of the function.
private void setupTable()
private void errorListToMessage(LinkedList<int[]> errorList) throws ALDDataIOProviderException
errorList
- List of errors.ALDDataIOProviderException
- Thrown in case of processing errors.public void actionPerformed(ActionEvent e)
actionPerformed
in interface ActionListener
public void tableChanged(TableModelEvent e)
tableChanged
in interface TableModelListener
Copyright © 2010–2021 Martin Luther University Halle-Wittenberg, Institute of Computer Science, Pattern Recognition and Bioinformatics. All rights reserved.