ikayaki.gui
Class ProjectExplorerTable

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JTable
                  extended by ikayaki.gui.ProjectExplorerTable
All Implemented Interfaces:
ProjectListener, ImageObserver, MenuContainer, Serializable, EventListener, Accessible, CellEditorListener, ListSelectionListener, TableColumnModelListener, TableModelListener, Scrollable

public class ProjectExplorerTable
extends JTable
implements ProjectListener

Creates a list of project files in directory. Handles loading selected projects and showing export popup menu.

Author:
Samuli Kaipiainen
See Also:
Serialized Form

Nested Class Summary
private  class ProjectExplorerTable.ProjectExplorerPopupMenu
          Shows popup menu with export choices: AF (.dat), Thellier (.tdt) and Thermal (.tdt), and for each, "to current directory", "to disk drive A:" and "
private  class ProjectExplorerTable.ProjectExplorerTableComparator
          Comparator used for ProjectExplorerTable sorting.
private  class ProjectExplorerTable.ProjectExplorerTableModel
          TableModel which handles data from files (in upper-class ProjectExplorerTable).
 
Nested classes/interfaces inherited from class javax.swing.JTable
JTable.AccessibleJTable, JTable.PrintMode
 
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
static int[] calibration_columns
           
static int COLUMN_FILENAME
           
static int COLUMN_LASTMEASURE
           
static int COLUMN_LASTMOD
           
static String[] column_name
           
static int COLUMN_TYPE
           
private static int COLUMN_UNDEFINED
           
static int COLUMN_UNMEASURED
           
private  int[] columns
          Visible columns in this table (as in column translation table); can be set with setColumns(int[]).
static int[] default_columns
           
private  File directory
          Currently open directory.
private  Comparator<File> explorerTableComparator
           
private  ProjectExplorerTable.ProjectExplorerTableModel explorerTableModel
           
private  int explorerTableSortColumn
          Current sort column; must be set to an untranslated column index.
private  File[] files
          Project files to in current directory.
private  boolean isCalibration
          Tells whether this table is calibration project table or all-project table.
private  ProjectComponent parent
          The component (MainViewPanel) whose setProject() method will be called on opening a new project file.
private  Thread projectTypeCacher
          Builds the project type cache for each directory.
private  int selectedFile
          Selected project file index, or -1 if none selected in current directory.
 
Fields inherited from class javax.swing.JTable
AUTO_RESIZE_ALL_COLUMNS, AUTO_RESIZE_LAST_COLUMN, AUTO_RESIZE_NEXT_COLUMN, AUTO_RESIZE_OFF, AUTO_RESIZE_SUBSEQUENT_COLUMNS, autoCreateColumnsFromModel, autoResizeMode, cellEditor, cellSelectionEnabled, columnModel, dataModel, defaultEditorsByColumnClass, defaultRenderersByColumnClass, editingColumn, editingRow, editorComp, gridColor, preferredViewportSize, rowHeight, rowMargin, rowSelectionAllowed, selectionBackground, selectionForeground, selectionModel, showHorizontalLines, showVerticalLines, tableHeader
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
ProjectExplorerTable(ProjectComponent parent)
          Builds ProjectExplorerTable for displaying all project files.
ProjectExplorerTable(ProjectComponent parent, boolean isCalibration)
          Builds ProjectExplorerTable.
 
Method Summary
 void fitColumnWidths()
          Makes sure that all data fits in their columns (excluding the COLUMN_FILENAME column).
private  File[] getProjectFiles(File directory)
          Reads project file listing from given directory.
 void projectUpdated(ProjectEvent event)
          Forwards ProjectEvents to the table model.
private  void scrollToRow(int rowIndex)
          Scrolls the table to show the specified row.
 void setColumns(int[] columns)
          Sets the columns displayed in this table.
 void setDirectory(File directory)
          Updates table contents, sets selectedFile index and table selection to selected project file, or -1.
 
Methods inherited from class javax.swing.JTable
addColumn, addColumnSelectionInterval, addNotify, addRowSelectionInterval, changeSelection, clearSelection, columnAdded, columnAtPoint, columnMarginChanged, columnMoved, columnRemoved, columnSelectionChanged, configureEnclosingScrollPane, convertColumnIndexToModel, convertColumnIndexToView, createDefaultColumnModel, createDefaultColumnsFromModel, createDefaultDataModel, createDefaultEditors, createDefaultRenderers, createDefaultSelectionModel, createDefaultTableHeader, createScrollPaneForTable, doLayout, editCellAt, editCellAt, editingCanceled, editingStopped, getAccessibleContext, getAutoCreateColumnsFromModel, getAutoResizeMode, getCellEditor, getCellEditor, getCellRect, getCellRenderer, getCellSelectionEnabled, getColumn, getColumnClass, getColumnCount, getColumnModel, getColumnName, getColumnSelectionAllowed, getDefaultEditor, getDefaultRenderer, getDragEnabled, getEditingColumn, getEditingRow, getEditorComponent, getGridColor, getIntercellSpacing, getModel, getPreferredScrollableViewportSize, getPrintable, getRowCount, getRowHeight, getRowHeight, getRowMargin, getRowSelectionAllowed, getScrollableBlockIncrement, getScrollableTracksViewportHeight, getScrollableTracksViewportWidth, getScrollableUnitIncrement, getSelectedColumn, getSelectedColumnCount, getSelectedColumns, getSelectedRow, getSelectedRowCount, getSelectedRows, getSelectionBackground, getSelectionForeground, getSelectionModel, getShowHorizontalLines, getShowVerticalLines, getSurrendersFocusOnKeystroke, getTableHeader, getToolTipText, getUI, getUIClassID, getValueAt, initializeLocalVars, isCellEditable, isCellSelected, isColumnSelected, isEditing, isRowSelected, moveColumn, paramString, prepareEditor, prepareRenderer, print, print, print, print, processKeyBinding, removeColumn, removeColumnSelectionInterval, removeEditor, removeNotify, removeRowSelectionInterval, resizeAndRepaint, rowAtPoint, selectAll, setAutoCreateColumnsFromModel, setAutoResizeMode, setCellEditor, setCellSelectionEnabled, setColumnModel, setColumnSelectionAllowed, setColumnSelectionInterval, setDefaultEditor, setDefaultRenderer, setDragEnabled, setEditingColumn, setEditingRow, setGridColor, setIntercellSpacing, setModel, setPreferredScrollableViewportSize, setRowHeight, setRowHeight, setRowMargin, setRowSelectionAllowed, setRowSelectionInterval, setSelectionBackground, setSelectionForeground, setSelectionMode, setSelectionModel, setShowGrid, setShowHorizontalLines, setShowVerticalLines, setSurrendersFocusOnKeystroke, setTableHeader, setUI, setValueAt, sizeColumnsToFit, sizeColumnsToFit, tableChanged, unconfigureEnclosingScrollPane, updateUI, valueChanged
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getWidth, getVisibleRect, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

parent

private final ProjectComponent parent
The component (MainViewPanel) whose setProject() method will be called on opening a new project file.


isCalibration

private boolean isCalibration
Tells whether this table is calibration project table or all-project table.


explorerTableModel

private final ProjectExplorerTable.ProjectExplorerTableModel explorerTableModel

explorerTableComparator

private final Comparator<File> explorerTableComparator

projectTypeCacher

private Thread projectTypeCacher
Builds the project type cache for each directory. If the thread is still working when a new request arrives, the old thread should be interrupted.


directory

private File directory
Currently open directory.


files

private File[] files
Project files to in current directory. Set to new File[0] so that ProjectExplorerTableModel can be created.


selectedFile

private int selectedFile
Selected project file index, or -1 if none selected in current directory.


explorerTableSortColumn

private int explorerTableSortColumn
Current sort column; must be set to an untranslated column index.


COLUMN_UNDEFINED

private static final int COLUMN_UNDEFINED
See Also:
Constant Field Values

COLUMN_FILENAME

public static final int COLUMN_FILENAME
See Also:
Constant Field Values

COLUMN_TYPE

public static final int COLUMN_TYPE
See Also:
Constant Field Values

COLUMN_LASTMOD

public static final int COLUMN_LASTMOD
See Also:
Constant Field Values

COLUMN_LASTMEASURE

public static final int COLUMN_LASTMEASURE
See Also:
Constant Field Values

COLUMN_UNMEASURED

public static final int COLUMN_UNMEASURED
See Also:
Constant Field Values

column_name

public static final String[] column_name

default_columns

public static final int[] default_columns

calibration_columns

public static final int[] calibration_columns

columns

private int[] columns
Visible columns in this table (as in column translation table); can be set with setColumns(int[]). Initialized to new int[0] so that ProjectExplorerTableModel can be created.

Constructor Detail

ProjectExplorerTable

public ProjectExplorerTable(ProjectComponent parent)
Builds ProjectExplorerTable for displaying all project files.

Parameters:
parent - the component whose setProject() method will be called on opening a new project file.

ProjectExplorerTable

public ProjectExplorerTable(ProjectComponent parent,
                            boolean isCalibration)
Builds ProjectExplorerTable.

Parameters:
parent - the component whose setProject() method will be called on opening a new project file.
isCalibration - if true, this table will display only calibration projects and related columns.
Method Detail

setColumns

public void setColumns(int[] columns)
Sets the columns displayed in this table.

Parameters:
columns - int-table with COLUMN_xxx values, or null to just update table.

fitColumnWidths

public void fitColumnWidths()
Makes sure that all data fits in their columns (excluding the COLUMN_FILENAME column). Renders every cell of the table to find out their preferred width, and makes the column wider if the contents does not fit the column.

This method must be run in the event thread. It is recommendable to cache the project type column's data before calling this method, since this method needs to render every cell of the table.


setDirectory

public void setDirectory(File directory)
Updates table contents, sets selectedFile index and table selection to selected project file, or -1.

Parameters:
directory - directory whose project files to display, or null to just update the table.

scrollToRow

private void scrollToRow(int rowIndex)
Scrolls the table to show the specified row.

Parameters:
rowIndex - row to scroll to.

getProjectFiles

private File[] getProjectFiles(File directory)
Reads project file listing from given directory.

Parameters:
directory - directory whose project file listing to read.
Returns:
project files in that directory; new File[0] if directory is null or invalid.

projectUpdated

public void projectUpdated(ProjectEvent event)
Forwards ProjectEvents to the table model.

Specified by:
projectUpdated in interface ProjectListener
Parameters:
event - ProjectEvent received.