private class ALDNativeArray1DDataIOSwing.ArrayConfigWindow extends ALDSwingValueChangeReporter implements ActionListener, TableModelListener
Modifier and Type | Class and Description |
---|---|
protected class |
ALDNativeArray1DDataIOSwing.ArrayConfigWindow.DataTabFileFilter
Internal class that implements a
FileFilter
for text files where MiToBo table data is stored. |
protected class |
ALDNativeArray1DDataIOSwing.ArrayConfigWindow.TableFocusListener
Focus listener to commit edits if table looses the focus.
|
Modifier and Type | Field and Description |
---|---|
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 |
delRow
Button for deleting a row.
|
protected ALDParameterDescriptor |
descriptor
Optional descriptor for additional information on parameter.
|
private boolean |
disableValueChecks
Flag to disable entry validation checks.
|
private Class<?> |
elementClass
Class that table entries should represent.
|
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 |
tabReset
Button to reset the table.
|
private JButton |
tabSave
Button to save the table.
|
private JFrame |
window
Main frame.
|
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<Integer> 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 data from graphical component.
|
protected void |
resizeTableEntries(int newSize)
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,
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)
Fills the table with specified values.
|
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 JScrollPane tableScroller
private JButton addRow
private JButton delRow
private JButton tabSave
private JButton tabLoad
private JButton tabClear
private JButton tabReset
private File lastDir
private Class<?> elementClass
protected ALDParameterDescriptor descriptor
private Object[] entryRefList
private boolean disableValueChecks
Note that this flag is only valid for next event appearing. While processing the event the flag is reset to false.
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 values.descr
- Descriptor associated with operator 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, Class<?> cl)
row
- Row to set.cl
- Class of table elements.public void setValue(Field field, Class<?> cl, Object value)
field
- Field specifying type of data.cl
- Class of array entries.value
- Value to set.public Object readData(Field field, Class<?> cl) throws ALDDataIOProviderException
field
- Field of underlying parameter.cl
- Class of underlying parameter.ALDDataIOProviderException
- Thrown on read failures.protected void resizeTableEntries(int newSize)
Existing entries are preserved as far as possible.
newSize
- New size 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<Integer> errorList) throws ALDDataIOProviderException
errorList
- List of errors to format into message.ALDDataIOProviderException
- Thrown on processing failures.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.