ikayaki.gui
Class ProjectExplorerTable
java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JTable
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
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 |
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 |
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.
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.
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.