Package adams.gui.dialog
Class SpreadSheetPanel
- java.lang.Object
-
- java.awt.Component
-
- java.awt.Container
-
- javax.swing.JComponent
-
- javax.swing.JPanel
-
- adams.gui.core.BasePanel
-
- adams.gui.dialog.SpreadSheetPanel
-
- All Implemented Interfaces:
JTableSupporter<SpreadSheetTable>,MenuBarProvider,SendToActionSupporter,ImageObserver,MenuContainer,Serializable,Accessible
public class SpreadSheetPanel extends BasePanel implements MenuBarProvider, SendToActionSupporter, JTableSupporter<SpreadSheetTable>
Displays a spreadsheet in a table.- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class javax.swing.JPanel
JPanel.AccessibleJPanel
-
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.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
-
-
Field Summary
Fields Modifier and Type Field Description protected SpreadSheetColumnComboBoxm_ColumnComboBoxthe combobox for jumping to columns.protected SpreadSheetFileChooserm_FileChooserthe filedialog for saving the spreadsheet.protected JMenuBarm_MenuBarthe menu bar, if used.protected JMenuItemm_MenuItemFileExitthe "exit" menu item.protected JMenuItemm_MenuItemFileSaveAsthe "save as" menu item.protected JMenuItemm_MenuItemViewDisplayedDecimalsthe "displayed decimals" menu item.protected JMenuItemm_MenuItemViewPositiveBackgroundthe "positive background" menu item.protected JMenuItemm_MenuItemViewRenderingthe "negative background" menu item.protected JMenuItemm_MenuItemViewShowFormulasthe "show formulas" menu item.protected JPanelm_PanelColumnComboBoxthe panel for the column combobox.protected SearchPanelm_PanelSearchthe search panel.protected SpreadSheetTablem_Tablethe table for displaying the spreadsheet.protected SpreadSheetTableModelm_TableModelthe table model.-
Fields inherited from class javax.swing.JComponent
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
accessibleContext, 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
Constructors Constructor Description SpreadSheetPanel()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidclose()Closes the dialog or frame.protected voidenterNumDecimals()Alows the user to enter the number of decimals to display.PopupMenuCustomizergetCellPopupMenuCustomizer()Returns the current popup menu customizer for the cells.CellRenderingCustomizergetCellRenderingCustomizer()Returns the renderer.PopupMenuCustomizergetHeadePopupMenuCustomizer()Returns the current popup menu customizer for the header.JMenuBargetMenuBar()Creates a menu bar (singleton per panel object).intgetNumDecimals()Returns the currently set number of decimals. -1 if displaying all.Class[]getSendToClasses()Returns the classes that the supporter generates.ObjectgetSendToItem(Class[] cls)Returns the object to send.booleangetShowColumnComboBox()Returns whether the column combobox is visible.booleangetShowFormulas()Returns whether to display the formulas or their calculated values.booleangetShowRowColumn()Returns whether the column with the row numbers is displayed.booleangetShowSearch()Returns whether the search is visible.SpreadSheetgetSpreadSheet()Returns the spreadsheet currently displayed.SpreadSheetTablegetTable()Returns the underlying table.booleangetUseSimpleHeader()Returns whether to display a simple header or an HTML one with the column indices.booleanhasSendToItem(Class[] cls)Checks whether something to send is available.protected voidinitGUI()Initializes the widgets.protected voidinitialize()Initializes the members.protected voidsaveAs()Saves the current sheet.protected voidselectRendering()Allows the user to select a different cell rendering customizer.voidsetCellPopupMenuCustomizer(PopupMenuCustomizer value)Sets the popup menu customizer to use for the cells.voidsetCellRenderingCustomizer(CellRenderingCustomizer value)Sets the renderer.voidsetHeaderPopupMenuCustomizer(PopupMenuCustomizer value)Sets the popup menu customizer to use for the header.voidsetNumDecimals(int value)Sets the number of decimals to display.voidsetShowColumnComboBox(boolean value)Sets whether the column combobox is visible.voidsetShowFormulas(boolean value)Sets whether to display the formulas or their calculated values.voidsetShowRowColumn(boolean value)Whether to display the column with the row numbers.voidsetShowSearch(boolean value)Sets whether the search is visible.voidsetSpreadSheet(SpreadSheet value)Sets the spreadsheet to display.voidsetUseSimpleHeader(boolean value)Whether to display a simple header or an HTML one with the column indices.voidsort(RowComparator comparator)Sorts the spreadsheet with the given comparator.protected voidupdateMenu()updates the enabled state of the menu items.voidwrite(SpreadSheetWriter writer, File file)Saves the specified file.-
Methods inherited from class adams.gui.core.BasePanel
afterHide, afterShow, beforeHide, beforeShow, closeParent, finishInit, getParentChild, getParentDialog, getParentFrame, getParentInternalFrame, getParentTitle, initFileChooser, main, printErrorMessage, printException, saveComponent, setEnabledCascade, setEnabledCascade, setParentTitle, setVisible
-
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
-
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, 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, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, 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, unregisterKeyboardAction, update
-
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, 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, 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, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, 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, requestFocus, requestFocus, requestFocusInWindow, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
-
-
-
-
Field Detail
-
m_Table
protected SpreadSheetTable m_Table
the table for displaying the spreadsheet.
-
m_TableModel
protected SpreadSheetTableModel m_TableModel
the table model.
-
m_FileChooser
protected SpreadSheetFileChooser m_FileChooser
the filedialog for saving the spreadsheet.
-
m_MenuBar
protected JMenuBar m_MenuBar
the menu bar, if used.
-
m_MenuItemFileSaveAs
protected JMenuItem m_MenuItemFileSaveAs
the "save as" menu item.
-
m_MenuItemFileExit
protected JMenuItem m_MenuItemFileExit
the "exit" menu item.
-
m_MenuItemViewDisplayedDecimals
protected JMenuItem m_MenuItemViewDisplayedDecimals
the "displayed decimals" menu item.
-
m_MenuItemViewRendering
protected JMenuItem m_MenuItemViewRendering
the "negative background" menu item.
-
m_MenuItemViewPositiveBackground
protected JMenuItem m_MenuItemViewPositiveBackground
the "positive background" menu item.
-
m_MenuItemViewShowFormulas
protected JMenuItem m_MenuItemViewShowFormulas
the "show formulas" menu item.
-
m_PanelSearch
protected SearchPanel m_PanelSearch
the search panel.
-
m_PanelColumnComboBox
protected JPanel m_PanelColumnComboBox
the panel for the column combobox.
-
m_ColumnComboBox
protected SpreadSheetColumnComboBox m_ColumnComboBox
the combobox for jumping to columns.
-
-
Method Detail
-
initialize
protected void initialize()
Initializes the members.- Overrides:
initializein classBasePanel
-
setSpreadSheet
public void setSpreadSheet(SpreadSheet value)
Sets the spreadsheet to display.- Parameters:
value- the spreadsheet to display
-
getSpreadSheet
public SpreadSheet getSpreadSheet()
Returns the spreadsheet currently displayed.- Returns:
- the spreadsheet on display
-
getMenuBar
public JMenuBar getMenuBar()
Creates a menu bar (singleton per panel object). Can be used in frames.- Specified by:
getMenuBarin interfaceMenuBarProvider- Returns:
- the menu bar
-
updateMenu
protected void updateMenu()
updates the enabled state of the menu items.
-
close
protected void close()
Closes the dialog or frame.
-
saveAs
protected void saveAs()
Saves the current sheet.
-
write
public void write(SpreadSheetWriter writer, File file)
Saves the specified file.- Parameters:
writer- the writer to use for saving the filefile- the file to save
-
enterNumDecimals
protected void enterNumDecimals()
Alows the user to enter the number of decimals to display.
-
selectRendering
protected void selectRendering()
Allows the user to select a different cell rendering customizer.
-
getSendToClasses
public Class[] getSendToClasses()
Returns the classes that the supporter generates.- Specified by:
getSendToClassesin interfaceSendToActionSupporter- Returns:
- the classes
-
hasSendToItem
public boolean hasSendToItem(Class[] cls)
Checks whether something to send is available.- Specified by:
hasSendToItemin interfaceSendToActionSupporter- Parameters:
cls- the classes to retrieve the item for- Returns:
- true if an object is available for sending
-
getSendToItem
public Object getSendToItem(Class[] cls)
Returns the object to send.- Specified by:
getSendToItemin interfaceSendToActionSupporter- Parameters:
cls- the classes to retrieve the item for- Returns:
- the item to send
-
setHeaderPopupMenuCustomizer
public void setHeaderPopupMenuCustomizer(PopupMenuCustomizer value)
Sets the popup menu customizer to use for the header.- Parameters:
value- the customizer, null to remove it
-
getHeadePopupMenuCustomizer
public PopupMenuCustomizer getHeadePopupMenuCustomizer()
Returns the current popup menu customizer for the header.- Returns:
- the customizer, null if none set
-
setCellPopupMenuCustomizer
public void setCellPopupMenuCustomizer(PopupMenuCustomizer value)
Sets the popup menu customizer to use for the cells.- Parameters:
value- the customizer, null to remove it
-
getCellPopupMenuCustomizer
public PopupMenuCustomizer getCellPopupMenuCustomizer()
Returns the current popup menu customizer for the cells.- Returns:
- the customizer, null if none set
-
setCellRenderingCustomizer
public void setCellRenderingCustomizer(CellRenderingCustomizer value)
Sets the renderer.- Parameters:
value- the renderer
-
getCellRenderingCustomizer
public CellRenderingCustomizer getCellRenderingCustomizer()
Returns the renderer.- Returns:
- the renderer
-
setShowFormulas
public void setShowFormulas(boolean value)
Sets whether to display the formulas or their calculated values.- Parameters:
value- true if to display the formulas rather than the calculated values
-
getShowFormulas
public boolean getShowFormulas()
Returns whether to display the formulas or their calculated values.- Returns:
- true if to display the formulas rather than the calculated values
-
sort
public void sort(RowComparator comparator)
Sorts the spreadsheet with the given comparator.- Parameters:
comparator- the row comparator to use
-
setNumDecimals
public void setNumDecimals(int value)
Sets the number of decimals to display. Use -1 to display all.- Parameters:
value- the number of decimals
-
getNumDecimals
public int getNumDecimals()
Returns the currently set number of decimals. -1 if displaying all.- Returns:
- the number of decimals
-
setShowSearch
public void setShowSearch(boolean value)
Sets whether the search is visible.- Parameters:
value- true if to show search
-
getShowSearch
public boolean getShowSearch()
Returns whether the search is visible.- Returns:
- true if search is shown
-
setShowColumnComboBox
public void setShowColumnComboBox(boolean value)
Sets whether the column combobox is visible.- Parameters:
value- true if to show column combobox
-
getShowColumnComboBox
public boolean getShowColumnComboBox()
Returns whether the column combobox is visible.- Returns:
- true if column combobox is shown
-
setUseSimpleHeader
public void setUseSimpleHeader(boolean value)
Whether to display a simple header or an HTML one with the column indices.- Parameters:
value- true if to display simple header
-
getUseSimpleHeader
public boolean getUseSimpleHeader()
Returns whether to display a simple header or an HTML one with the column indices.- Returns:
- true if simple header displayed
-
setShowRowColumn
public void setShowRowColumn(boolean value)
Whether to display the column with the row numbers.- Parameters:
value- true if to display column
-
getShowRowColumn
public boolean getShowRowColumn()
Returns whether the column with the row numbers is displayed.- Returns:
- true if column displayed
-
getTable
public SpreadSheetTable getTable()
Returns the underlying table.- Specified by:
getTablein interfaceJTableSupporter<SpreadSheetTable>- Returns:
- the table
-
-